HostInterface: Modify settings loading interface to support per-frontend settings

This commit is contained in:
Connor McLaughlin
2020-05-01 01:01:50 +10:00
parent 6e7c58de43
commit d8ab587153
8 changed files with 82 additions and 38 deletions

View File

@ -1003,7 +1003,17 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetBoolValue("Debug", "ShowMDECState", false);
}
void HostInterface::UpdateSettings(const std::function<void()>& apply_callback)
void HostInterface::ApplySettings(SettingsInterface& si)
{
m_settings.Load(si);
}
void HostInterface::ExportSettings(SettingsInterface& si)
{
m_settings.Save(si);
}
void HostInterface::UpdateSettings(SettingsInterface& si)
{
const bool old_increase_timer_resolution = m_settings.increase_timer_resolution;
const float old_emulation_speed = m_settings.emulation_speed;
@ -1038,7 +1048,7 @@ void HostInterface::UpdateSettings(const std::function<void()>& apply_callback)
const bool old_log_to_window = m_settings.log_to_window;
const bool old_log_to_file = m_settings.log_to_file;
apply_callback();
ApplySettings(si);
if (m_system)
{

View File

@ -192,7 +192,7 @@ protected:
/// Sets the user directory to the program directory, i.e. "portable mode".
void SetUserDirectoryToProgramDirectory();
/// Performs the initial load of settings. Should call CheckSettings() and m_settings.Load().
/// Performs the initial load of settings. Should call CheckSettings() and ApplySettings().
virtual void LoadSettings() = 0;
/// Updates logging settings.
@ -232,9 +232,14 @@ protected:
/// Restores all settings to defaults.
virtual void SetDefaultSettings(SettingsInterface& si);
/// Applies new settings, updating internal state as needed. apply_callback should call m_settings.Load() after
/// locking any required mutexes.
void UpdateSettings(const std::function<void()>& apply_callback);
/// Loads settings to m_settings and any frontend-specific parameters.
virtual void ApplySettings(SettingsInterface& si);
/// Saves current settings variables to ini.
virtual void ExportSettings(SettingsInterface& si);
/// Applies new settings, updating internal state as needed.
virtual void UpdateSettings(SettingsInterface& si);
/// Quick switch between software and hardware rendering.
void ToggleSoftwareRendering();