|
1 | 1 | #include "module_settings.h" |
2 | 2 | #include "settings/settings.h" |
3 | 3 |
|
4 | | -std::string ModuleSettings::GetString(const char * setting) const |
| 4 | +const char * ModuleSettings::GetString(const char * setting) const |
5 | 5 | { |
6 | | - return Settings::GetInstance().GetString(setting); |
| 6 | + return SettingsStore::GetInstance().GetString(setting); |
7 | 7 | } |
8 | 8 |
|
9 | 9 | bool ModuleSettings::GetBool(const char * setting) const |
10 | 10 | { |
11 | | - return Settings::GetInstance().GetBool(setting); |
| 11 | + return SettingsStore::GetInstance().GetBool(setting); |
| 12 | +} |
| 13 | + |
| 14 | +int32_t ModuleSettings::GetInt(const char* setting) const |
| 15 | +{ |
| 16 | + return SettingsStore::GetInstance().GetInt(setting); |
12 | 17 | } |
13 | 18 |
|
14 | 19 | void ModuleSettings::SetString(const char * setting, const char * value) |
15 | 20 | { |
16 | | - Settings::GetInstance().SetString(setting, value); |
| 21 | + SettingsStore::GetInstance().SetString(setting, value); |
17 | 22 | } |
18 | 23 |
|
19 | 24 | void ModuleSettings::SetBool(const char * setting, bool value) |
20 | 25 | { |
21 | | - Settings::GetInstance().SetBool(setting, value); |
| 26 | + SettingsStore::GetInstance().SetBool(setting, value); |
| 27 | +} |
| 28 | + |
| 29 | +void ModuleSettings::SetInt(const char * setting, int32_t value) |
| 30 | +{ |
| 31 | + SettingsStore::GetInstance().SetInt(setting, value); |
| 32 | +} |
| 33 | + |
| 34 | +void ModuleSettings::SetDefaultBool(const char * setting, bool value) |
| 35 | +{ |
| 36 | + SettingsStore::GetInstance().SetDefaultBool(setting, value); |
| 37 | +} |
| 38 | + |
| 39 | +void ModuleSettings::SetDefaultInt(const char * setting, int32_t value) |
| 40 | +{ |
| 41 | + SettingsStore::GetInstance().SetDefaultInt(setting, value); |
| 42 | +} |
| 43 | + |
| 44 | +void ModuleSettings::SetDefaultString(const char * setting, const char * value) |
| 45 | +{ |
| 46 | + SettingsStore::GetInstance().SetDefaultString(setting, value); |
| 47 | +} |
| 48 | + |
| 49 | +const char * ModuleSettings::GetSectionSettings(const char * section) const |
| 50 | +{ |
| 51 | + JsonValue json = SettingsStore::GetInstance().GetSettings(section); |
| 52 | + m_sectionSetting = json.isNull() ? "" : JsonStyledWriter().write(json); |
| 53 | + return m_sectionSetting.c_str(); |
| 54 | +} |
| 55 | + |
| 56 | +void ModuleSettings::SetSectionSettings(const char * section, const std::string & json) |
| 57 | +{ |
| 58 | + JsonValue root; |
| 59 | + if (!json.empty()) |
| 60 | + { |
| 61 | + JsonReader reader; |
| 62 | + if (!reader.Parse(json.data(), json.data() + json.size(), root)) |
| 63 | + { |
| 64 | + return; |
| 65 | + } |
| 66 | + } |
| 67 | + SettingsStore& settings = SettingsStore::GetInstance(); |
| 68 | + settings.SetSettings(section, root); |
| 69 | + settings.Save(); |
| 70 | +} |
| 71 | + |
| 72 | +void ModuleSettings::RegisterCallback(const char* setting, SettingChangeCallback callback, void * userData) |
| 73 | +{ |
| 74 | + SettingsStore::GetInstance().RegisterCallback(setting, callback, userData); |
| 75 | +} |
| 76 | + |
| 77 | +void ModuleSettings::UnregisterCallback(const char* setting, SettingChangeCallback callback, void* userData) |
| 78 | +{ |
| 79 | + __debugbreak(); |
22 | 80 | } |
0 commit comments