Hotkeys: Add hotkey to open cheat settings
This commit is contained in:
parent
7d2216c289
commit
903213c818
|
@ -285,9 +285,9 @@ static void DoToggleAnalogMode();
|
|||
static constexpr double INPUT_BINDING_TIMEOUT_SECONDS = 5.0;
|
||||
|
||||
static void SwitchToSettings();
|
||||
static void SwitchToGameSettings();
|
||||
static bool SwitchToGameSettings();
|
||||
static void SwitchToGameSettings(const GameList::Entry* entry);
|
||||
static void SwitchToGameSettingsForPath(const std::string& path);
|
||||
static bool SwitchToGameSettingsForPath(const std::string& path);
|
||||
static void SwitchToGameSettingsForSerial(std::string_view serial);
|
||||
static void DrawSettingsWindow();
|
||||
static void DrawSummarySettingsPage();
|
||||
|
@ -710,6 +710,20 @@ void FullscreenUI::OpenPauseMenu()
|
|||
FixStateIfPaused();
|
||||
}
|
||||
|
||||
void FullscreenUI::OpenCheatsMenu()
|
||||
{
|
||||
if (!System::IsValid())
|
||||
return;
|
||||
|
||||
if (!Initialize() || s_current_main_window != MainWindowType::None || !SwitchToGameSettings())
|
||||
return;
|
||||
|
||||
s_settings_page = SettingsPage::Cheats;
|
||||
PauseForMenuOpen(true);
|
||||
ForceKeyNavEnabled();
|
||||
FixStateIfPaused();
|
||||
}
|
||||
|
||||
void FullscreenUI::FixStateIfPaused()
|
||||
{
|
||||
if (!System::IsValid() || System::IsRunning())
|
||||
|
@ -2715,28 +2729,34 @@ void FullscreenUI::SwitchToGameSettingsForSerial(std::string_view serial)
|
|||
QueueResetFocus(FocusResetType::ViewChanged);
|
||||
}
|
||||
|
||||
void FullscreenUI::SwitchToGameSettings()
|
||||
bool FullscreenUI::SwitchToGameSettings()
|
||||
{
|
||||
if (System::GetGameSerial().empty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
auto lock = GameList::GetLock();
|
||||
const GameList::Entry* entry = GameList::GetEntryForPath(System::GetDiscPath());
|
||||
if (!entry)
|
||||
{
|
||||
SwitchToGameSettingsForSerial(System::GetGameSerial());
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SwitchToGameSettings(entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
SwitchToGameSettings(entry);
|
||||
}
|
||||
|
||||
void FullscreenUI::SwitchToGameSettingsForPath(const std::string& path)
|
||||
bool FullscreenUI::SwitchToGameSettingsForPath(const std::string& path)
|
||||
{
|
||||
auto lock = GameList::GetLock();
|
||||
const GameList::Entry* entry = GameList::GetEntryForPath(path);
|
||||
if (entry)
|
||||
SwitchToGameSettings(entry);
|
||||
if (!entry)
|
||||
return false;
|
||||
|
||||
SwitchToGameSettings(entry);
|
||||
return true;
|
||||
}
|
||||
|
||||
void FullscreenUI::SwitchToGameSettings(const GameList::Entry* entry)
|
||||
|
|
|
@ -28,6 +28,7 @@ void OnRunningGameChanged();
|
|||
|
||||
#ifndef __ANDROID__
|
||||
void OpenPauseMenu();
|
||||
void OpenCheatsMenu();
|
||||
void OpenAchievementsWindow();
|
||||
bool IsAchievementsWindowOpen();
|
||||
void OpenLeaderboardsWindow();
|
||||
|
|
|
@ -165,13 +165,6 @@ static bool CanPause()
|
|||
#endif
|
||||
|
||||
BEGIN_HOTKEY_LIST(g_common_hotkeys)
|
||||
#ifndef __ANDROID__
|
||||
DEFINE_HOTKEY("OpenPauseMenu", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("Hotkeys", "Open Pause Menu"),
|
||||
[](s32 pressed) {
|
||||
if (!pressed && CanPause())
|
||||
FullscreenUI::OpenPauseMenu();
|
||||
})
|
||||
#endif
|
||||
|
||||
DEFINE_HOTKEY("FastForward", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("Hotkeys", "Fast Forward"),
|
||||
[](s32 pressed) {
|
||||
|
@ -216,6 +209,18 @@ DEFINE_HOTKEY("PowerOff", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("
|
|||
if (!pressed && CanPause())
|
||||
Host::RequestSystemShutdown(true, g_settings.save_state_on_exit);
|
||||
})
|
||||
|
||||
DEFINE_HOTKEY("OpenPauseMenu", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("Hotkeys", "Open Pause Menu"),
|
||||
[](s32 pressed) {
|
||||
if (!pressed && CanPause())
|
||||
FullscreenUI::OpenPauseMenu();
|
||||
})
|
||||
|
||||
DEFINE_HOTKEY("OpenCheatsMenu", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("Hotkeys", "Open Cheat Settings"),
|
||||
[](s32 pressed) {
|
||||
if (!pressed && CanPause())
|
||||
FullscreenUI::OpenCheatsMenu();
|
||||
})
|
||||
#endif
|
||||
|
||||
DEFINE_HOTKEY("Screenshot", TRANSLATE_NOOP("Hotkeys", "General"), TRANSLATE_NOOP("Hotkeys", "Save Screenshot"),
|
||||
|
|
Loading…
Reference in New Issue