Qt: Fix live changing game settings not applying

This commit is contained in:
Connor McLaughlin 2022-03-07 19:37:23 +10:00 committed by lightningterror
parent ddd5fc7bf3
commit a8ee746c39
5 changed files with 32 additions and 12 deletions

View File

@ -374,6 +374,22 @@ void EmuThread::applySettings()
VMManager::ApplySettings(); VMManager::ApplySettings();
} }
void EmuThread::reloadGameSettings()
{
if (!isOnEmuThread())
{
QMetaObject::invokeMethod(this, &EmuThread::reloadGameSettings, Qt::QueuedConnection);
return;
}
// this will skip applying settings when they're not active
if (VMManager::ReloadGameSettings())
{
// none of these settings below are per-game.. for now. but in case they are in the future.
checkForSettingChanges();
}
}
void EmuThread::checkForSettingChanges() void EmuThread::checkForSettingChanges()
{ {
if (VMManager::HasValidVM()) if (VMManager::HasValidVM())

View File

@ -65,6 +65,7 @@ public Q_SLOTS:
void toggleFullscreen(); void toggleFullscreen();
void setFullscreen(bool fullscreen); void setFullscreen(bool fullscreen);
void applySettings(); void applySettings();
void reloadGameSettings();
void toggleSoftwareRendering(); void toggleSoftwareRendering();
void switchRenderer(GSRendererType renderer); void switchRenderer(GSRendererType renderer);
void changeDisc(const QString& path); void changeDisc(const QString& path);

View File

@ -406,7 +406,7 @@ namespace SettingWidgetBinder
sif->DeleteValue(section.c_str(), key.c_str()); sif->DeleteValue(section.c_str(), key.c_str());
sif->Save(); sif->Save();
g_emu_thread->applySettings(); g_emu_thread->reloadGameSettings();
}); });
} }
else else
@ -446,7 +446,7 @@ namespace SettingWidgetBinder
sif->DeleteValue(section.c_str(), key.c_str()); sif->DeleteValue(section.c_str(), key.c_str());
sif->Save(); sif->Save();
g_emu_thread->applySettings(); g_emu_thread->reloadGameSettings();
}); });
} }
else else
@ -485,7 +485,7 @@ namespace SettingWidgetBinder
sif->DeleteValue(section.c_str(), key.c_str()); sif->DeleteValue(section.c_str(), key.c_str());
sif->Save(); sif->Save();
g_emu_thread->applySettings(); g_emu_thread->reloadGameSettings();
}); });
} }
else else
@ -525,7 +525,7 @@ namespace SettingWidgetBinder
sif->DeleteValue(section.c_str(), key.c_str()); sif->DeleteValue(section.c_str(), key.c_str());
sif->Save(); sif->Save();
g_emu_thread->applySettings(); g_emu_thread->reloadGameSettings();
}); });
} }
else else
@ -565,7 +565,7 @@ namespace SettingWidgetBinder
sif->DeleteValue(section.c_str(), key.c_str()); sif->DeleteValue(section.c_str(), key.c_str());
sif->Save(); sif->Save();
g_emu_thread->applySettings(); g_emu_thread->reloadGameSettings();
}); });
} }
else else
@ -624,7 +624,7 @@ namespace SettingWidgetBinder
} }
sif->Save(); sif->Save();
g_emu_thread->applySettings(); g_emu_thread->reloadGameSettings();
}); });
} }
else else
@ -689,7 +689,7 @@ namespace SettingWidgetBinder
sif->DeleteValue(section.c_str(), key.c_str()); sif->DeleteValue(section.c_str(), key.c_str());
sif->Save(); sif->Save();
g_emu_thread->applySettings(); g_emu_thread->reloadGameSettings();
}); });
} }
else else
@ -751,7 +751,7 @@ namespace SettingWidgetBinder
sif->DeleteValue(section.c_str(), key.c_str()); sif->DeleteValue(section.c_str(), key.c_str());
sif->Save(); sif->Save();
g_emu_thread->applySettings(); g_emu_thread->reloadGameSettings();
}); });
} }
else else

View File

@ -1158,10 +1158,13 @@ void VMManager::ApplySettings()
} }
} }
void VMManager::ReloadGameSettings() bool VMManager::ReloadGameSettings()
{ {
if (UpdateGameSettingsLayer()) if (!UpdateGameSettingsLayer())
ApplySettings(); return false;
ApplySettings();
return true;
} }
static void HotkeyAdjustTargetSpeed(double delta) static void HotkeyAdjustTargetSpeed(double delta)

View File

@ -96,7 +96,7 @@ namespace VMManager
void ApplySettings(); void ApplySettings();
/// Reloads game specific settings, and applys any changes present. /// Reloads game specific settings, and applys any changes present.
void ReloadGameSettings(); bool ReloadGameSettings();
/// Reloads cheats/patches. If verbose is set, the number of patches loaded will be shown in the OSD. /// Reloads cheats/patches. If verbose is set, the number of patches loaded will be shown in the OSD.
void ReloadPatches(bool verbose); void ReloadPatches(bool verbose);