From 928e49296349b7992a36982499767ef4563cae10 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 17 Nov 2021 00:05:13 +1000 Subject: [PATCH] HostInterface: Add keys to a bunch of OSD messages --- src/frontend-common/common_host_interface.cpp | 77 +++++++++++-------- 1 file changed, 46 insertions(+), 31 deletions(-) diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 3b420cb17..c27d659ff 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -1583,15 +1583,16 @@ void CommonHostInterface::DoToggleCheats() CheatList* cl = System::GetCheatList(); if (!cl) { - AddOSDMessage(TranslateStdString("OSDMessage", "No cheats are loaded."), 10.0f); + AddKeyedOSDMessage("ToggleCheats", TranslateStdString("OSDMessage", "No cheats are loaded."), 10.0f); return; } cl->SetMasterEnable(!cl->GetMasterEnable()); - AddOSDMessage(cl->GetMasterEnable() ? - TranslateStdString("OSDMessage", "%n cheats are now active.", "", cl->GetEnabledCodeCount()) : - TranslateStdString("OSDMessage", "%n cheats are now inactive.", "", cl->GetEnabledCodeCount()), - 10.0f); + AddKeyedOSDMessage("ToggleCheats", + cl->GetMasterEnable() ? + TranslateStdString("OSDMessage", "%n cheats are now active.", "", cl->GetEnabledCodeCount()) : + TranslateStdString("OSDMessage", "%n cheats are now inactive.", "", cl->GetEnabledCodeCount()), + 10.0f); } std::optional @@ -2233,16 +2234,17 @@ void CommonHostInterface::SetRewindState(bool enabled) if (!g_settings.rewind_enable) { if (enabled) - AddOSDMessage(TranslateStdString("OSDMessage", "Rewinding is not enabled."), 5.0f); + AddKeyedOSDMessage("SetRewindState", TranslateStdString("OSDMessage", "Rewinding is not enabled."), 5.0f); return; } if (!m_fullscreen_ui_enabled) { - AddOSDMessage(enabled ? TranslateStdString("OSDMessage", "Rewinding...") : - TranslateStdString("OSDMessage", "Stopped rewinding."), - 5.0f); + AddKeyedOSDMessage("SetRewindState", + enabled ? TranslateStdString("OSDMessage", "Rewinding...") : + TranslateStdString("OSDMessage", "Stopped rewinding."), + 5.0f); } System::SetRewinding(enabled); @@ -2446,14 +2448,15 @@ void CommonHostInterface::RegisterSystemHotkeys() const u32 percent = g_settings.GetCPUOverclockPercent(); const double clock_speed = ((static_cast(System::MASTER_CLOCK) * static_cast(percent)) / 100.0) / 1000000.0; - AddFormattedOSDMessage(5.0f, - TranslateString("OSDMessage", "CPU clock speed control enabled (%u%% / %.3f MHz)."), - percent, clock_speed); + AddKeyedFormattedOSDMessage( + "ToggleOverclocking", 5.0f, + TranslateString("OSDMessage", "CPU clock speed control enabled (%u%% / %.3f MHz)."), percent, clock_speed); } else { - AddFormattedOSDMessage(5.0f, TranslateString("OSDMessage", "CPU clock speed control disabled (%.3f MHz)."), - static_cast(System::MASTER_CLOCK) / 1000000.0); + AddKeyedFormattedOSDMessage("ToggleOverclocking", 5.0f, + TranslateString("OSDMessage", "CPU clock speed control disabled (%.3f MHz)."), + static_cast(System::MASTER_CLOCK) / 1000000.0); } } }); @@ -2476,10 +2479,11 @@ void CommonHostInterface::RegisterGraphicsHotkeys() g_gpu->UpdateSettings(); g_gpu->ResetGraphicsAPIState(); System::ClearMemorySaveStates(); - AddOSDMessage(g_settings.gpu_pgxp_enable ? - TranslateStdString("OSDMessage", "PGXP is now enabled.") : - TranslateStdString("OSDMessage", "PGXP is now disabled."), - 5.0f); + AddKeyedOSDMessage("TogglePGXP", + g_settings.gpu_pgxp_enable ? + TranslateStdString("OSDMessage", "PGXP is now enabled.") : + TranslateStdString("OSDMessage", "PGXP is now disabled."), + 5.0f); if (g_settings.gpu_pgxp_enable) PGXP::Initialize(); @@ -2520,7 +2524,8 @@ void CommonHostInterface::RegisterGraphicsHotkeys() StaticString(TRANSLATABLE("Hotkeys", "Reload Texture Replacements")), [this](bool pressed) { if (pressed && System::IsValid()) { - AddOSDMessage(TranslateStdString("OSDMessage", "Texture replacements reloaded."), 10.0f); + AddKeyedOSDMessage("ReloadTextureReplacements", + TranslateStdString("OSDMessage", "Texture replacements reloaded."), 10.0f); g_texture_replacements.Reload(); } }); @@ -2545,10 +2550,11 @@ void CommonHostInterface::RegisterGraphicsHotkeys() g_gpu->UpdateSettings(); g_gpu->ResetGraphicsAPIState(); System::ClearMemorySaveStates(); - AddOSDMessage(g_settings.gpu_pgxp_depth_buffer ? - TranslateStdString("OSDMessage", "PGXP Depth Buffer is now enabled.") : - TranslateStdString("OSDMessage", "PGXP Depth Buffer is now disabled."), - 5.0f); + AddKeyedOSDMessage("TogglePGXPDepth", + g_settings.gpu_pgxp_depth_buffer ? + TranslateStdString("OSDMessage", "PGXP Depth Buffer is now enabled.") : + TranslateStdString("OSDMessage", "PGXP Depth Buffer is now disabled."), + 5.0f); } }); @@ -2708,9 +2714,15 @@ void CommonHostInterface::RegisterAudioHotkeys() const s32 volume = GetAudioOutputVolume(); m_audio_stream->SetOutputVolume(volume); if (g_settings.audio_output_muted) - AddOSDMessage(TranslateStdString("OSDMessage", "Volume: Muted"), 2.0f); + { + AddKeyedOSDMessage("AudioControlHotkey", TranslateStdString("OSDMessage", "Volume: Muted"), + 2.0f); + } else - AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), volume); + { + AddKeyedFormattedOSDMessage("AudioControlHotkey", 2.0f, + TranslateString("OSDMessage", "Volume: %d%%"), volume); + } } }); RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioCDAudioMute"), @@ -2718,10 +2730,11 @@ void CommonHostInterface::RegisterAudioHotkeys() if (pressed && System::IsValid()) { g_settings.cdrom_mute_cd_audio = !g_settings.cdrom_mute_cd_audio; - AddOSDMessage(g_settings.cdrom_mute_cd_audio ? - TranslateStdString("OSDMessage", "CD Audio Muted.") : - TranslateStdString("OSDMessage", "CD Audio Unmuted."), - 2.0f); + AddKeyedOSDMessage("AudioControlHotkey", + g_settings.cdrom_mute_cd_audio ? + TranslateStdString("OSDMessage", "CD Audio Muted.") : + TranslateStdString("OSDMessage", "CD Audio Unmuted."), + 2.0f); } }); RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioVolumeUp"), @@ -2734,7 +2747,8 @@ void CommonHostInterface::RegisterAudioHotkeys() g_settings.audio_output_volume = volume; g_settings.audio_fast_forward_volume = volume; m_audio_stream->SetOutputVolume(volume); - AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), volume); + AddKeyedFormattedOSDMessage("AudioControlHotkey", 2.0f, + TranslateString("OSDMessage", "Volume: %d%%"), volume); } }); RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioVolumeDown"), @@ -2747,7 +2761,8 @@ void CommonHostInterface::RegisterAudioHotkeys() g_settings.audio_output_volume = volume; g_settings.audio_fast_forward_volume = volume; m_audio_stream->SetOutputVolume(volume); - AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), volume); + AddKeyedFormattedOSDMessage("AudioControlHotkey", 2.0f, + TranslateString("OSDMessage", "Volume: %d%%"), volume); } }); }