mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 23:55:40 +00:00
CommonHostInterface: Add a hotkey to toggle all cheats
This commit is contained in:
parent
922e17f677
commit
737a87b483
|
@ -107,6 +107,9 @@ public:
|
||||||
ALWAYS_INLINE u32 GetCodeCount() const { return static_cast<u32>(m_codes.size()); }
|
ALWAYS_INLINE u32 GetCodeCount() const { return static_cast<u32>(m_codes.size()); }
|
||||||
ALWAYS_INLINE bool IsCodeEnabled(u32 index) const { return m_codes[index].enabled; }
|
ALWAYS_INLINE bool IsCodeEnabled(u32 index) const { return m_codes[index].enabled; }
|
||||||
|
|
||||||
|
ALWAYS_INLINE bool GetMasterEnable() const { return m_master_enable; }
|
||||||
|
ALWAYS_INLINE void SetMasterEnable(bool enable) { m_master_enable = enable; }
|
||||||
|
|
||||||
const CheatCode* FindCode(const char* name) const;
|
const CheatCode* FindCode(const char* name) const;
|
||||||
const CheatCode* FindCode(const char* group, const char* name) const;
|
const CheatCode* FindCode(const char* group, const char* name) const;
|
||||||
|
|
||||||
|
@ -144,6 +147,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<CheatCode> m_codes;
|
std::vector<CheatCode> m_codes;
|
||||||
|
bool m_master_enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MemoryScan
|
class MemoryScan
|
||||||
|
|
|
@ -964,6 +964,25 @@ void CommonHostInterface::DoFrameStep()
|
||||||
PauseSystem(false);
|
PauseSystem(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CommonHostInterface::DoToggleCheats()
|
||||||
|
{
|
||||||
|
if (System::IsShutdown())
|
||||||
|
return;
|
||||||
|
|
||||||
|
CheatList* cl = System::GetCheatList();
|
||||||
|
if (!cl)
|
||||||
|
{
|
||||||
|
AddOSDMessage(TranslateStdString("OSDMessage", "No cheats are loaded."), 10.0f);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cl->SetMasterEnable(!cl->GetMasterEnable());
|
||||||
|
AddFormattedOSDMessage(10.0f,
|
||||||
|
cl->GetMasterEnable() ? TranslateString("OSDMessage", "%u cheats are now active.") :
|
||||||
|
TranslateString("OSDMessage", "%u cheats are now inactive."),
|
||||||
|
cl->GetEnabledCodeCount());
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<CommonHostInterface::HostKeyCode>
|
std::optional<CommonHostInterface::HostKeyCode>
|
||||||
CommonHostInterface::GetHostKeyCode(const std::string_view key_code) const
|
CommonHostInterface::GetHostKeyCode(const std::string_view key_code) const
|
||||||
{
|
{
|
||||||
|
@ -1449,6 +1468,12 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
||||||
PauseSystem(!System::IsPaused());
|
PauseSystem(!System::IsPaused());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("ToggleCheats"),
|
||||||
|
StaticString(TRANSLATABLE("Hotkeys", "Toggle Cheats")), [this](bool pressed) {
|
||||||
|
if (pressed)
|
||||||
|
DoToggleCheats();
|
||||||
|
});
|
||||||
|
|
||||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("PowerOff"),
|
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("PowerOff"),
|
||||||
StaticString(TRANSLATABLE("Hotkeys", "Power Off System")), [this](bool pressed) {
|
StaticString(TRANSLATABLE("Hotkeys", "Power Off System")), [this](bool pressed) {
|
||||||
if (pressed && System::IsValid())
|
if (pressed && System::IsValid())
|
||||||
|
@ -1490,9 +1515,7 @@ void CommonHostInterface::RegisterGeneralHotkeys()
|
||||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("FrameStep"),
|
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "General")), StaticString("FrameStep"),
|
||||||
StaticString(TRANSLATABLE("Hotkeys", "Frame Step")), [this](bool pressed) {
|
StaticString(TRANSLATABLE("Hotkeys", "Frame Step")), [this](bool pressed) {
|
||||||
if (pressed)
|
if (pressed)
|
||||||
{
|
|
||||||
DoFrameStep();
|
DoFrameStep();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -331,6 +331,7 @@ protected:
|
||||||
void DrawOSDMessages();
|
void DrawOSDMessages();
|
||||||
void DrawDebugWindows();
|
void DrawDebugWindows();
|
||||||
void DoFrameStep();
|
void DoFrameStep();
|
||||||
|
void DoToggleCheats();
|
||||||
|
|
||||||
std::unique_ptr<GameList> m_game_list;
|
std::unique_ptr<GameList> m_game_list;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue