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();
}
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()
{
if (VMManager::HasValidVM())

View File

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

View File

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

View File

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

View File

@ -96,7 +96,7 @@ namespace VMManager
void ApplySettings();
/// 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.
void ReloadPatches(bool verbose);