1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 11:53:53 +00:00

Merge pull request #2365 from akortunov/guifixes

Refactor Settings::Manager::apply()
This commit is contained in:
Alexei Dobrohotov 2019-05-04 21:01:15 +03:00 committed by GitHub
commit acae586765
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 9 deletions

View file

@ -478,12 +478,13 @@ namespace MWGui
void SettingsWindow::apply() 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().getWorld()->processChangedSettings(changed);
MWBase::Environment::get().getSoundManager()->processChangedSettings(changed); MWBase::Environment::get().getSoundManager()->processChangedSettings(changed);
MWBase::Environment::get().getWindowManager()->processChangedSettings(changed); MWBase::Environment::get().getWindowManager()->processChangedSettings(changed);
MWBase::Environment::get().getInputManager()->processChangedSettings(changed); MWBase::Environment::get().getInputManager()->processChangedSettings(changed);
MWBase::Environment::get().getMechanicsManager()->processChangedSettings(changed); MWBase::Environment::get().getMechanicsManager()->processChangedSettings(changed);
Settings::Manager::resetPendingChanges();
} }
void SettingsWindow::onKeyboardSwitchClicked(MyGUI::Widget* _sender) void SettingsWindow::onKeyboardSwitchClicked(MyGUI::Widget* _sender)

View file

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

View file

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

View file

@ -35,9 +35,11 @@ namespace Settings
void saveUser (const std::string& file); void saveUser (const std::string& file);
///< save user settings to 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 ///< returns the list of changed settings and then clears it
static int getInt (const std::string& setting, const std::string& category); static int getInt (const std::string& setting, const std::string& category);