CommonHostInterface: Add hotkeys for opening leaderboards/achievements
This commit is contained in:
parent
1644a0762d
commit
a072455903
|
@ -1925,6 +1925,7 @@ void CommonHostInterface::SetTurboEnabled(bool enabled)
|
|||
void CommonHostInterface::RegisterHotkeys()
|
||||
{
|
||||
RegisterGeneralHotkeys();
|
||||
RegisterSystemHotkeys();
|
||||
RegisterGraphicsHotkeys();
|
||||
RegisterSaveStateHotkeys();
|
||||
RegisterAudioHotkeys();
|
||||
|
@ -2005,19 +2006,50 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
|||
|
||||
#endif
|
||||
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("Reset"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Reset System")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
ResetSystem();
|
||||
});
|
||||
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("Screenshot"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Save Screenshot")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
SaveScreenshot();
|
||||
});
|
||||
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ChangeDisc"),
|
||||
#ifdef WITH_CHEEVOS
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("OpenAchievements"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Open Achievement List")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
{
|
||||
if (!m_fullscreen_ui_enabled || !FullscreenUI::OpenAchievementsWindow())
|
||||
{
|
||||
AddOSDMessage(
|
||||
TranslateStdString("OSDMessage", "Achievements are disabled or unavailable for this game."),
|
||||
10.0f);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("OpenLeaderboards"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Open Leaderboard List")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
{
|
||||
if (!m_fullscreen_ui_enabled || !FullscreenUI::OpenLeaderboardsWindow())
|
||||
{
|
||||
AddOSDMessage(
|
||||
TranslateStdString("OSDMessage", "Leaderboards are disabled or unavailable for this game."),
|
||||
10.0f);
|
||||
}
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void CommonHostInterface::RegisterSystemHotkeys()
|
||||
{
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "System")), StaticString("Reset"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Reset System")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
ResetSystem();
|
||||
});
|
||||
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "System")), StaticString("ChangeDisc"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Change Disc")), [](bool pressed) {
|
||||
if (pressed && System::IsValid() && System::HasMediaSubImages())
|
||||
{
|
||||
|
@ -2028,14 +2060,14 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
|||
}
|
||||
});
|
||||
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("SwapMemoryCards"),
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "System")), StaticString("SwapMemoryCards"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Swap Memory Card Slots")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
SwapMemoryCards();
|
||||
});
|
||||
|
||||
#ifndef __ANDROID__
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("FrameStep"),
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "System")), StaticString("FrameStep"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Frame Step")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
{
|
||||
|
@ -2046,7 +2078,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
|||
}
|
||||
});
|
||||
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("Rewind"),
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "System")), StaticString("Rewind"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Rewind")), [this](bool pressed) {
|
||||
if (System::IsValid())
|
||||
{
|
||||
|
@ -2064,7 +2096,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
|||
}
|
||||
});
|
||||
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ToggleCheats"),
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "System")), StaticString("ToggleCheats"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Toggle Cheats")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
{
|
||||
|
@ -2075,7 +2107,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
|||
}
|
||||
});
|
||||
#else
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("TogglePatchCodes"),
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "System")), StaticString("TogglePatchCodes"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Toggle Patch Codes")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
{
|
||||
|
@ -2088,7 +2120,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
|||
#endif
|
||||
|
||||
RegisterHotkey(
|
||||
StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ToggleOverclocking"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "System")), StaticString("ToggleOverclocking"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Toggle Clock Speed Control (Overclocking)")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
{
|
||||
|
|
|
@ -488,6 +488,7 @@ private:
|
|||
void LoadSettings();
|
||||
void InitializeUserDirectory();
|
||||
void RegisterGeneralHotkeys();
|
||||
void RegisterSystemHotkeys();
|
||||
void RegisterGraphicsHotkeys();
|
||||
void RegisterSaveStateHotkeys();
|
||||
void RegisterAudioHotkeys();
|
||||
|
|
|
@ -299,6 +299,29 @@ void CloseQuickMenu()
|
|||
ClearImGuiFocus();
|
||||
}
|
||||
|
||||
bool OpenAchievementsWindow()
|
||||
{
|
||||
const bool achievements_enabled = Cheevos::HasActiveGame() && (Cheevos::GetAchievementCount() > 0);
|
||||
if (!achievements_enabled)
|
||||
return false;
|
||||
|
||||
s_current_main_window = MainWindowType::Achievements;
|
||||
s_quick_menu_was_open = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OpenLeaderboardsWindow()
|
||||
{
|
||||
const bool leaderboards_enabled = Cheevos::HasActiveGame() && (Cheevos::GetLeaderboardCount() > 0);
|
||||
if (!leaderboards_enabled)
|
||||
return false;
|
||||
|
||||
s_current_main_window = MainWindowType::Leaderboards;
|
||||
s_open_leaderboard_id.reset();
|
||||
s_quick_menu_was_open = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
if (s_game_list_load_thread.joinable())
|
||||
|
@ -2553,14 +2576,11 @@ void DrawQuickMenu(MainWindowType type)
|
|||
#ifdef WITH_CHEEVOS
|
||||
const bool achievements_enabled = Cheevos::HasActiveGame() && (Cheevos::GetAchievementCount() > 0);
|
||||
if (ActiveButton(ICON_FA_TROPHY " Achievements", false, achievements_enabled))
|
||||
s_current_main_window = MainWindowType::Achievements;
|
||||
OpenAchievementsWindow();
|
||||
|
||||
const bool leaderboards_enabled = Cheevos::HasActiveGame() && (Cheevos::GetLeaderboardCount() > 0);
|
||||
if (ActiveButton(ICON_FA_STOPWATCH " Leaderboards", false, leaderboards_enabled))
|
||||
{
|
||||
s_current_main_window = MainWindowType::Leaderboards;
|
||||
s_open_leaderboard_id.reset();
|
||||
}
|
||||
OpenLeaderboardsWindow();
|
||||
|
||||
#else
|
||||
ActiveButton(ICON_FA_TROPHY " Achievements", false, false);
|
||||
|
|
|
@ -49,6 +49,8 @@ void SystemDestroyed();
|
|||
void SystemPaused(bool paused);
|
||||
void OpenQuickMenu();
|
||||
void CloseQuickMenu();
|
||||
bool OpenAchievementsWindow();
|
||||
bool OpenLeaderboardsWindow();
|
||||
void Shutdown();
|
||||
void Render();
|
||||
|
||||
|
|
Loading…
Reference in New Issue