Add hotkeys for incrementing/decrementing selected state slot (like RetroArch)

This commit is contained in:
askew-etc 2022-08-07 12:20:09 -05:00
parent 7b2b559743
commit 914f38753a
6 changed files with 35 additions and 1 deletions

View File

@ -179,6 +179,8 @@ constexpr std::array<const char*, NUM_HOTKEYS> s_hotkey_labels{{
_trans("Undo Save State"), _trans("Undo Save State"),
_trans("Save State"), _trans("Save State"),
_trans("Load State"), _trans("Load State"),
_trans("Increase Selected State Slot"),
_trans("Decrease Selected State Slot"),
_trans("Load ROM"), _trans("Load ROM"),
_trans("Unload ROM"), _trans("Unload ROM"),
@ -349,7 +351,7 @@ constexpr std::array<HotkeyGroupInfo, NUM_HOTKEY_GROUPS> s_groups_info = {
{_trans("Save State"), HK_SAVE_STATE_SLOT_1, HK_SAVE_STATE_SLOT_SELECTED}, {_trans("Save State"), HK_SAVE_STATE_SLOT_1, HK_SAVE_STATE_SLOT_SELECTED},
{_trans("Select State"), HK_SELECT_STATE_SLOT_1, HK_SELECT_STATE_SLOT_10}, {_trans("Select State"), HK_SELECT_STATE_SLOT_1, HK_SELECT_STATE_SLOT_10},
{_trans("Load Last State"), HK_LOAD_LAST_STATE_1, HK_LOAD_LAST_STATE_10}, {_trans("Load Last State"), HK_LOAD_LAST_STATE_1, HK_LOAD_LAST_STATE_10},
{_trans("Other State Hotkeys"), HK_SAVE_FIRST_STATE, HK_LOAD_STATE_FILE}, {_trans("Other State Hotkeys"), HK_SAVE_FIRST_STATE, HK_DECREMENT_SELECTED_STATE_SLOT},
{_trans("GBA Core"), HK_GBA_LOAD, HK_GBA_RESET, true}, {_trans("GBA Core"), HK_GBA_LOAD, HK_GBA_RESET, true},
{_trans("GBA Volume"), HK_GBA_VOLUME_DOWN, HK_GBA_TOGGLE_MUTE, true}, {_trans("GBA Volume"), HK_GBA_VOLUME_DOWN, HK_GBA_TOGGLE_MUTE, true},
{_trans("GBA Window Size"), HK_GBA_1X, HK_GBA_4X, true}}}; {_trans("GBA Window Size"), HK_GBA_1X, HK_GBA_4X, true}}};

View File

@ -164,6 +164,8 @@ enum Hotkey
HK_UNDO_SAVE_STATE, HK_UNDO_SAVE_STATE,
HK_SAVE_STATE_FILE, HK_SAVE_STATE_FILE,
HK_LOAD_STATE_FILE, HK_LOAD_STATE_FILE,
HK_INCREMENT_SELECTED_STATE_SLOT,
HK_DECREMENT_SELECTED_STATE_SLOT,
HK_GBA_LOAD, HK_GBA_LOAD,
HK_GBA_UNLOAD, HK_GBA_UNLOAD,

View File

@ -490,6 +490,12 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_LOAD_STATE_SLOT_SELECTED)) if (IsHotkey(HK_LOAD_STATE_SLOT_SELECTED))
emit StateLoadSlotHotkey(); emit StateLoadSlotHotkey();
if (IsHotkey(HK_INCREMENT_SELECTED_STATE_SLOT))
emit IncrementSelectedStateSlotHotkey();
if (IsHotkey(HK_DECREMENT_SELECTED_STATE_SLOT))
emit DecrementSelectedStateSlotHotkey();
// Stereoscopy // Stereoscopy
if (IsHotkey(HK_TOGGLE_STEREO_SBS)) if (IsHotkey(HK_TOGGLE_STEREO_SBS))
{ {

View File

@ -36,6 +36,8 @@ signals:
void ScreenShotHotkey(); void ScreenShotHotkey();
void RefreshGameListHotkey(); void RefreshGameListHotkey();
void SetStateSlotHotkey(int slot); void SetStateSlotHotkey(int slot);
void IncrementSelectedStateSlotHotkey();
void DecrementSelectedStateSlotHotkey();
void StateLoadSlotHotkey(); void StateLoadSlotHotkey();
void StateSaveSlotHotkey(); void StateSaveSlotHotkey();
void StateLoadSlot(int state); void StateLoadSlot(int state);

View File

@ -595,6 +595,10 @@ void MainWindow::ConnectHotkeys()
&MainWindow::StateSaveSlot); &MainWindow::StateSaveSlot);
connect(m_hotkey_scheduler, &HotkeyScheduler::SetStateSlotHotkey, this, connect(m_hotkey_scheduler, &HotkeyScheduler::SetStateSlotHotkey, this,
&MainWindow::SetStateSlot); &MainWindow::SetStateSlot);
connect(m_hotkey_scheduler, &HotkeyScheduler::IncrementSelectedStateSlotHotkey, this,
&MainWindow::IncrementSelectedStateSlot);
connect(m_hotkey_scheduler, &HotkeyScheduler::DecrementSelectedStateSlotHotkey, this,
&MainWindow::DecrementSelectedStateSlot);
connect(m_hotkey_scheduler, &HotkeyScheduler::StartRecording, this, connect(m_hotkey_scheduler, &HotkeyScheduler::StartRecording, this,
&MainWindow::OnStartRecording); &MainWindow::OnStartRecording);
connect(m_hotkey_scheduler, &HotkeyScheduler::PlayRecording, this, &MainWindow::OnPlayRecording); connect(m_hotkey_scheduler, &HotkeyScheduler::PlayRecording, this, &MainWindow::OnPlayRecording);
@ -1358,6 +1362,22 @@ void MainWindow::SetStateSlot(int slot)
2500); 2500);
} }
void MainWindow::IncrementSelectedStateSlot()
{
int state_slot = m_state_slot + 1;
if (state_slot > State::NUM_STATES)
state_slot = 1;
m_menu_bar->SetStateSlot(state_slot);
}
void MainWindow::DecrementSelectedStateSlot()
{
int state_slot = m_state_slot - 1;
if (state_slot < 1)
state_slot = State::NUM_STATES;
m_menu_bar->SetStateSlot(state_slot);
}
void MainWindow::PerformOnlineUpdate(const std::string& region) void MainWindow::PerformOnlineUpdate(const std::string& region)
{ {
WiiUpdate::PerformOnlineUpdate(region, this); WiiUpdate::PerformOnlineUpdate(region, this);

View File

@ -102,6 +102,8 @@ private:
void StateSaveUndo(); void StateSaveUndo();
void StateSaveOldest(); void StateSaveOldest();
void SetStateSlot(int slot); void SetStateSlot(int slot);
void IncrementSelectedStateSlot();
void DecrementSelectedStateSlot();
void BootWiiSystemMenu(); void BootWiiSystemMenu();
void PerformOnlineUpdate(const std::string& region); void PerformOnlineUpdate(const std::string& region);