]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/settings.h
Translated using Weblate (Spanish)
[dragonfireclient.git] / src / settings.h
index 89f7589dfddc1bd40932133009ba1c52d6be25e1..80d41fd790f18b5c66a387a577c5ea0e2702f04f 100644 (file)
@@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "irrlichttypes_bloated.h"
 #include "util/string.h"
-#include "jthread/jmutex.h"
+#include "threading/mutex.h"
 #include <string>
 #include <map>
 #include <list>
@@ -31,8 +31,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 class Settings;
 struct NoiseParams;
 
+// Global objects
+extern Settings *g_settings;
+extern std::string g_settings_path;
+
 /** function type to register a changed callback */
-typedef void (*setting_changed_callback)(const std::string);
+typedef void (*setting_changed_callback)(const std::string &name, void *data);
 
 enum ValueType {
        VALUETYPE_STRING,
@@ -202,22 +206,28 @@ class Settings {
        // remove a setting
        bool remove(const std::string &name);
        void clear();
+       void clearDefaults();
        void updateValue(const Settings &other, const std::string &name);
        void update(const Settings &other);
-       void registerChangedCallback(std::string name, setting_changed_callback cbf);
+       void registerChangedCallback(std::string name, setting_changed_callback cbf, void *userdata = NULL);
+       void deregisterChangedCallback(std::string name, setting_changed_callback cbf, void *userdata = NULL);
 
 private:
 
        void updateNoLock(const Settings &other);
        void clearNoLock();
+       void clearDefaultsNoLock();
 
        void doCallbacks(std::string name);
 
        std::map<std::string, SettingsEntry> m_settings;
        std::map<std::string, SettingsEntry> m_defaults;
-       std::map<std::string, std::vector<setting_changed_callback> > m_callbacks;
-       // All methods that access m_settings/m_defaults directly should lock this.
-       mutable JMutex m_mutex;
+
+       std::map<std::string, std::vector<std::pair<setting_changed_callback,void*> > > m_callbacks;
+
+       mutable Mutex m_callbackMutex;
+       mutable Mutex m_mutex; // All methods that access m_settings/m_defaults directly should lock this.
+
 };
 
 #endif