HostInterface: Add keys to a bunch of OSD messages

This commit is contained in:
Connor McLaughlin 2021-11-17 00:05:13 +10:00
parent 7522304360
commit 928e492963

View file

@ -1583,12 +1583,13 @@ void CommonHostInterface::DoToggleCheats()
CheatList* cl = System::GetCheatList(); CheatList* cl = System::GetCheatList();
if (!cl) if (!cl)
{ {
AddOSDMessage(TranslateStdString("OSDMessage", "No cheats are loaded."), 10.0f); AddKeyedOSDMessage("ToggleCheats", TranslateStdString("OSDMessage", "No cheats are loaded."), 10.0f);
return; return;
} }
cl->SetMasterEnable(!cl->GetMasterEnable()); cl->SetMasterEnable(!cl->GetMasterEnable());
AddOSDMessage(cl->GetMasterEnable() ? AddKeyedOSDMessage("ToggleCheats",
cl->GetMasterEnable() ?
TranslateStdString("OSDMessage", "%n cheats are now active.", "", cl->GetEnabledCodeCount()) : TranslateStdString("OSDMessage", "%n cheats are now active.", "", cl->GetEnabledCodeCount()) :
TranslateStdString("OSDMessage", "%n cheats are now inactive.", "", cl->GetEnabledCodeCount()), TranslateStdString("OSDMessage", "%n cheats are now inactive.", "", cl->GetEnabledCodeCount()),
10.0f); 10.0f);
@ -2233,14 +2234,15 @@ void CommonHostInterface::SetRewindState(bool enabled)
if (!g_settings.rewind_enable) if (!g_settings.rewind_enable)
{ {
if (enabled) if (enabled)
AddOSDMessage(TranslateStdString("OSDMessage", "Rewinding is not enabled."), 5.0f); AddKeyedOSDMessage("SetRewindState", TranslateStdString("OSDMessage", "Rewinding is not enabled."), 5.0f);
return; return;
} }
if (!m_fullscreen_ui_enabled) if (!m_fullscreen_ui_enabled)
{ {
AddOSDMessage(enabled ? TranslateStdString("OSDMessage", "Rewinding...") : AddKeyedOSDMessage("SetRewindState",
enabled ? TranslateStdString("OSDMessage", "Rewinding...") :
TranslateStdString("OSDMessage", "Stopped rewinding."), TranslateStdString("OSDMessage", "Stopped rewinding."),
5.0f); 5.0f);
} }
@ -2446,13 +2448,14 @@ void CommonHostInterface::RegisterSystemHotkeys()
const u32 percent = g_settings.GetCPUOverclockPercent(); const u32 percent = g_settings.GetCPUOverclockPercent();
const double clock_speed = const double clock_speed =
((static_cast<double>(System::MASTER_CLOCK) * static_cast<double>(percent)) / 100.0) / 1000000.0; ((static_cast<double>(System::MASTER_CLOCK) * static_cast<double>(percent)) / 100.0) / 1000000.0;
AddFormattedOSDMessage(5.0f, AddKeyedFormattedOSDMessage(
TranslateString("OSDMessage", "CPU clock speed control enabled (%u%% / %.3f MHz)."), "ToggleOverclocking", 5.0f,
percent, clock_speed); TranslateString("OSDMessage", "CPU clock speed control enabled (%u%% / %.3f MHz)."), percent, clock_speed);
} }
else else
{ {
AddFormattedOSDMessage(5.0f, TranslateString("OSDMessage", "CPU clock speed control disabled (%.3f MHz)."), AddKeyedFormattedOSDMessage("ToggleOverclocking", 5.0f,
TranslateString("OSDMessage", "CPU clock speed control disabled (%.3f MHz)."),
static_cast<double>(System::MASTER_CLOCK) / 1000000.0); static_cast<double>(System::MASTER_CLOCK) / 1000000.0);
} }
} }
@ -2476,7 +2479,8 @@ void CommonHostInterface::RegisterGraphicsHotkeys()
g_gpu->UpdateSettings(); g_gpu->UpdateSettings();
g_gpu->ResetGraphicsAPIState(); g_gpu->ResetGraphicsAPIState();
System::ClearMemorySaveStates(); System::ClearMemorySaveStates();
AddOSDMessage(g_settings.gpu_pgxp_enable ? AddKeyedOSDMessage("TogglePGXP",
g_settings.gpu_pgxp_enable ?
TranslateStdString("OSDMessage", "PGXP is now enabled.") : TranslateStdString("OSDMessage", "PGXP is now enabled.") :
TranslateStdString("OSDMessage", "PGXP is now disabled."), TranslateStdString("OSDMessage", "PGXP is now disabled."),
5.0f); 5.0f);
@ -2520,7 +2524,8 @@ void CommonHostInterface::RegisterGraphicsHotkeys()
StaticString(TRANSLATABLE("Hotkeys", "Reload Texture Replacements")), [this](bool pressed) { StaticString(TRANSLATABLE("Hotkeys", "Reload Texture Replacements")), [this](bool pressed) {
if (pressed && System::IsValid()) 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(); g_texture_replacements.Reload();
} }
}); });
@ -2545,7 +2550,8 @@ void CommonHostInterface::RegisterGraphicsHotkeys()
g_gpu->UpdateSettings(); g_gpu->UpdateSettings();
g_gpu->ResetGraphicsAPIState(); g_gpu->ResetGraphicsAPIState();
System::ClearMemorySaveStates(); System::ClearMemorySaveStates();
AddOSDMessage(g_settings.gpu_pgxp_depth_buffer ? AddKeyedOSDMessage("TogglePGXPDepth",
g_settings.gpu_pgxp_depth_buffer ?
TranslateStdString("OSDMessage", "PGXP Depth Buffer is now enabled.") : TranslateStdString("OSDMessage", "PGXP Depth Buffer is now enabled.") :
TranslateStdString("OSDMessage", "PGXP Depth Buffer is now disabled."), TranslateStdString("OSDMessage", "PGXP Depth Buffer is now disabled."),
5.0f); 5.0f);
@ -2708,9 +2714,15 @@ void CommonHostInterface::RegisterAudioHotkeys()
const s32 volume = GetAudioOutputVolume(); const s32 volume = GetAudioOutputVolume();
m_audio_stream->SetOutputVolume(volume); m_audio_stream->SetOutputVolume(volume);
if (g_settings.audio_output_muted) if (g_settings.audio_output_muted)
AddOSDMessage(TranslateStdString("OSDMessage", "Volume: Muted"), 2.0f); {
AddKeyedOSDMessage("AudioControlHotkey", TranslateStdString("OSDMessage", "Volume: Muted"),
2.0f);
}
else 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"), RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioCDAudioMute"),
@ -2718,7 +2730,8 @@ void CommonHostInterface::RegisterAudioHotkeys()
if (pressed && System::IsValid()) if (pressed && System::IsValid())
{ {
g_settings.cdrom_mute_cd_audio = !g_settings.cdrom_mute_cd_audio; g_settings.cdrom_mute_cd_audio = !g_settings.cdrom_mute_cd_audio;
AddOSDMessage(g_settings.cdrom_mute_cd_audio ? AddKeyedOSDMessage("AudioControlHotkey",
g_settings.cdrom_mute_cd_audio ?
TranslateStdString("OSDMessage", "CD Audio Muted.") : TranslateStdString("OSDMessage", "CD Audio Muted.") :
TranslateStdString("OSDMessage", "CD Audio Unmuted."), TranslateStdString("OSDMessage", "CD Audio Unmuted."),
2.0f); 2.0f);
@ -2734,7 +2747,8 @@ void CommonHostInterface::RegisterAudioHotkeys()
g_settings.audio_output_volume = volume; g_settings.audio_output_volume = volume;
g_settings.audio_fast_forward_volume = volume; g_settings.audio_fast_forward_volume = volume;
m_audio_stream->SetOutputVolume(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"), RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioVolumeDown"),
@ -2747,7 +2761,8 @@ void CommonHostInterface::RegisterAudioHotkeys()
g_settings.audio_output_volume = volume; g_settings.audio_output_volume = volume;
g_settings.audio_fast_forward_volume = volume; g_settings.audio_fast_forward_volume = volume;
m_audio_stream->SetOutputVolume(volume); m_audio_stream->SetOutputVolume(volume);
AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), volume); AddKeyedFormattedOSDMessage("AudioControlHotkey", 2.0f,
TranslateString("OSDMessage", "Volume: %d%%"), volume);
} }
}); });
} }