mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:50:05 +00:00
Save settings changes functionality
This commit is contained in:
parent
f7cc902eef
commit
6b90c5471d
3 changed files with 21 additions and 5 deletions
|
|
@ -24,6 +24,9 @@ static boost::json::value ConvertSettingsToJson();
|
|||
static void GenerateDefaultSettings();
|
||||
static bool LoadSettings(const boost::json::object& settingsJson);
|
||||
|
||||
static bool initialized_ {false};
|
||||
static std::string settingsPath_ {};
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
std::string appDataPath {
|
||||
|
|
@ -39,9 +42,10 @@ void Initialize()
|
|||
}
|
||||
}
|
||||
|
||||
std::string settingsPath {appDataPath + "/settings.json"};
|
||||
settingsPath_ = appDataPath + "/settings.json";
|
||||
initialized_ = true;
|
||||
|
||||
ReadSettings(settingsPath);
|
||||
ReadSettings(settingsPath_);
|
||||
}
|
||||
|
||||
void ReadSettings(const std::string& settingsPath)
|
||||
|
|
@ -71,6 +75,17 @@ void ReadSettings(const std::string& settingsPath)
|
|||
};
|
||||
}
|
||||
|
||||
void SaveSettings()
|
||||
{
|
||||
if (initialized_)
|
||||
{
|
||||
logger_->info("Saving settings");
|
||||
|
||||
boost::json::value settingsJson = ConvertSettingsToJson();
|
||||
util::json::WriteJsonFile(settingsPath_, settingsJson);
|
||||
}
|
||||
}
|
||||
|
||||
settings::GeneralSettings& general_settings()
|
||||
{
|
||||
static settings::GeneralSettings generalSettings_;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace SettingsManager
|
|||
|
||||
void Initialize();
|
||||
void ReadSettings(const std::string& settingsPath);
|
||||
void SaveSettings();
|
||||
|
||||
settings::GeneralSettings& general_settings();
|
||||
settings::MapSettings& map_settings();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue