Refactor Settings::Manager::apply()

pull/2365/head
Andrei Kortunov 6 years ago
parent 0cd8d4b842
commit 4f42fe5595

@ -451,12 +451,13 @@ namespace MWGui
void SettingsWindow::apply()
{
const Settings::CategorySettingVector changed = Settings::Manager::apply();
const Settings::CategorySettingVector changed = Settings::Manager::getPendingChanges();
MWBase::Environment::get().getWorld()->processChangedSettings(changed);
MWBase::Environment::get().getSoundManager()->processChangedSettings(changed);
MWBase::Environment::get().getWindowManager()->processChangedSettings(changed);
MWBase::Environment::get().getInputManager()->processChangedSettings(changed);
MWBase::Environment::get().getMechanicsManager()->processChangedSettings(changed);
Settings::Manager::resetPendingChanges();
}
void SettingsWindow::onKeyboardSwitchClicked(MyGUI::Widget* _sender)

@ -1130,8 +1130,8 @@ namespace MWInput
// There is no need to track these changes.
Settings::Manager::setInt("resolution x", "Video", x);
Settings::Manager::setInt("resolution y", "Video", y);
Settings::Manager::apply("resolution x", "Video");
Settings::Manager::apply("resolution y", "Video");
Settings::Manager::resetPendingChange("resolution x", "Video");
Settings::Manager::resetPendingChange("resolution y", "Video");
MWBase::Environment::get().getWindowManager()->windowResized(x, y);

@ -414,17 +414,20 @@ void Manager::setBool(const std::string &setting, const std::string &category, c
setString(setting, category, value ? "true" : "false");
}
void Manager::apply(const std::string &setting, const std::string &category)
void Manager::resetPendingChange(const std::string &setting, const std::string &category)
{
CategorySettingValueMap::key_type key = std::make_pair(category, setting);
mChangedSettings.erase(key);
}
const CategorySettingVector Manager::apply()
const CategorySettingVector Manager::getPendingChanges()
{
return mChangedSettings;
}
void Manager::resetPendingChanges()
{
CategorySettingVector vec = mChangedSettings;
mChangedSettings.clear();
return vec;
}
}

@ -35,9 +35,11 @@ namespace Settings
void saveUser (const std::string& file);
///< save user settings to file
static void apply(const std::string &setting, const std::string &category);
static void resetPendingChange(const std::string &setting, const std::string &category);
static const CategorySettingVector apply();
static void resetPendingChanges();
static const CategorySettingVector getPendingChanges();
///< returns the list of changed settings and then clears it
static int getInt (const std::string& setting, const std::string& category);

Loading…
Cancel
Save