CommonHostInterface: Add post processing toggle hotkeys

This commit is contained in:
Connor McLaughlin 2020-09-13 22:31:31 +10:00
parent 441f26706e
commit 9c28b3e167
2 changed files with 31 additions and 2 deletions

View file

@ -1439,6 +1439,12 @@ void CommonHostInterface::RegisterGraphicsHotkeys()
ModifyResolutionScale(-1);
});
RegisterHotkey(StaticString("Graphics"), StaticString("TogglePostProcessing"),
StaticString(TRANSLATABLE("Hotkeys", "Toggle Post-Processing")), [this](bool pressed) {
if (!pressed)
TogglePostProcessing();
});
RegisterHotkey(StaticString("Graphics"), StaticString("ReloadPostProcessingShaders"),
StaticString(TRANSLATABLE("Hotkeys", "Reload Post Processing Shaders")), [this](bool pressed) {
if (!pressed)
@ -2279,15 +2285,35 @@ void CommonHostInterface::ApplyCheatCode(u32 index)
}
}
void CommonHostInterface::TogglePostProcessing()
{
if (!m_display)
return;
g_settings.display_post_processing = !g_settings.display_post_processing;
if (g_settings.display_post_processing)
{
AddOSDMessage(TranslateStdString("OSDMessage", "Post-processing is now enabled."), 10.0f);
if (!m_display->SetPostProcessingChain(g_settings.display_post_process_chain))
AddOSDMessage(TranslateStdString("OSDMessage", "Failed to load post processing shader chain."), 20.0f);
}
else
{
AddOSDMessage(TranslateStdString("OSDMessage", "Post-processing is now disabled."), 10.0f);
m_display->SetPostProcessingChain({});
}
}
void CommonHostInterface::ReloadPostProcessingShaders()
{
if (!m_display || !g_settings.display_post_processing)
return;
if (!m_display->SetPostProcessingChain(g_settings.display_post_process_chain))
AddOSDMessage(TranslateStdString("OSDMessage", "Failed to load post processing shader chain."), 20.0f);
AddOSDMessage(TranslateStdString("OSDMessage", "Failed to load post-processing shader chain."), 20.0f);
else
AddOSDMessage(TranslateStdString("OSDMessage", "Post processing shaders reloaded."), 10.0f);
AddOSDMessage(TranslateStdString("OSDMessage", "Post-processing shaders reloaded."), 10.0f);
}
#ifdef WITH_DISCORD_PRESENCE

View file

@ -166,6 +166,9 @@ public:
/// Immediately applies the specified cheat code.
void ApplyCheatCode(u32 index);
/// Temporarily toggles post-processing on/off.
void TogglePostProcessing();
/// Reloads post processing shaders with the current configuration.
void ReloadPostProcessingShaders();