mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-20 23:25:46 +00:00
configuration: Simplify applying per-game settings
Originally, every time we add a per-game setting, we'd have to guard for it when setting it on the global config, and use a specific function to do it for the per-game config. This moves the global check into the ApplyPerGameSetting function so that we can use it for changing both the global and per-game states. Less work for the programmer.
This commit is contained in:
parent
11b43840a9
commit
4158f88b49
6 changed files with 69 additions and 112 deletions
|
@ -50,6 +50,9 @@ void ConfigureGeneral::SetConfiguration() {
|
|||
}
|
||||
|
||||
void ConfigureGeneral::ApplyConfiguration() {
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_multi_core,
|
||||
ui->use_multi_core, use_multi_core);
|
||||
|
||||
if (Settings::IsConfiguringGlobal()) {
|
||||
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
|
||||
UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked();
|
||||
|
@ -62,13 +65,7 @@ void ConfigureGeneral::ApplyConfiguration() {
|
|||
Qt::Checked);
|
||||
Settings::values.frame_limit.SetValue(ui->frame_limit->value());
|
||||
}
|
||||
if (Settings::values.use_multi_core.UsingGlobal()) {
|
||||
Settings::values.use_multi_core.SetValue(ui->use_multi_core->isChecked());
|
||||
}
|
||||
} else {
|
||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_multi_core,
|
||||
ui->use_multi_core, use_multi_core);
|
||||
|
||||
bool global_frame_limit = use_frame_limit == ConfigurationShared::CheckState::Global;
|
||||
Settings::values.use_frame_limit.SetGlobal(global_frame_limit);
|
||||
Settings::values.frame_limit.SetGlobal(global_frame_limit);
|
||||
|
@ -94,6 +91,9 @@ void ConfigureGeneral::RetranslateUI() {
|
|||
|
||||
void ConfigureGeneral::SetupPerGameUI() {
|
||||
if (Settings::IsConfiguringGlobal()) {
|
||||
// Disables each setting if:
|
||||
// - A game is running (thus settings in use), and
|
||||
// - A non-global setting is applied.
|
||||
ui->toggle_frame_limit->setEnabled(Settings::values.use_frame_limit.UsingGlobal());
|
||||
ui->frame_limit->setEnabled(Settings::values.frame_limit.UsingGlobal());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue