From dd3a58d4aca3957c3eb19ad5d2ee7c4b5b2d1cdb Mon Sep 17 00:00:00 2001 From: thrust26 Date: Mon, 20 Jan 2020 12:11:26 +0100 Subject: [PATCH] add hotkey to decrease current state slot --- docs/index.html | 16 +++++++++++----- src/common/PKeyboardHandler.cxx | 3 ++- src/common/StateManager.cxx | 8 ++++++-- src/common/StateManager.hxx | 4 ++-- src/debugger/gui/DebuggerDialog.cxx | 3 ++- src/emucore/Event.hxx | 4 ++-- src/emucore/EventHandler.cxx | 20 +++++++++++++------- src/emucore/EventHandler.hxx | 2 +- src/emucore/Settings.cxx | 2 +- src/gui/CommandDialog.cxx | 2 +- src/gui/DeveloperDialog.cxx | 2 +- src/gui/MinUICommandDialog.cxx | 2 +- 12 files changed, 43 insertions(+), 25 deletions(-) diff --git a/docs/index.html b/docs/index.html index 506bd598c..6cfd49054 100644 --- a/docs/index.html +++ b/docs/index.html @@ -736,13 +736,19 @@ - Switch current state slot + Change to previous state slot + Shift + F10 + Shift + F10 + + + + Change to next state slot F10 F10 - Automatically switch state slot + Automatically change state slot Alt + F10 Cmd + F10 @@ -2243,7 +2249,7 @@
-autoslot <1|0>
- Automatically switch to the next available save state slot after + Automatically change to the next available save state slot after saving a ROM state file. @@ -3395,9 +3401,9 @@ -saveonexit - Automatically switch... + Automatically change... - Automatically switch to the next available save state slot after saving a ROM state file. + Automatically change to the next available save state slot after saving a ROM state file. -autoslot diff --git a/src/common/PKeyboardHandler.cxx b/src/common/PKeyboardHandler.cxx index fcd09acb3..22a8a7f8e 100644 --- a/src/common/PKeyboardHandler.cxx +++ b/src/common/PKeyboardHandler.cxx @@ -406,7 +406,8 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo {Event::ConsoleRightDiffB, KBDK_F8}, {Event::SaveState, KBDK_F9}, {Event::SaveAllStates, KBDK_F9, MOD3}, - {Event::ChangeState, KBDK_F10}, + {Event::PreviousState, KBDK_F10, KBDM_SHIFT}, + {Event::NextState, KBDK_F10}, {Event::ToggleAutoSlot, KBDK_F10, MOD3}, {Event::LoadState, KBDK_F11}, {Event::LoadAllStates, KBDK_F11, MOD3}, diff --git a/src/common/StateManager.cxx b/src/common/StateManager.cxx index ec69395e9..667665054 100644 --- a/src/common/StateManager.cxx +++ b/src/common/StateManager.cxx @@ -297,9 +297,13 @@ void StateManager::saveState(int slot) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void StateManager::changeState() +void StateManager::changeState(int direction) { - myCurrentSlot = (myCurrentSlot + 1) % 10; + myCurrentSlot += direction; + if (myCurrentSlot < 0) + myCurrentSlot = 9; + else + myCurrentSlot %= 10; // Print appropriate message ostringstream buf; diff --git a/src/common/StateManager.hxx b/src/common/StateManager.hxx index 21d87ff7f..d7fa25c16 100644 --- a/src/common/StateManager.hxx +++ b/src/common/StateManager.hxx @@ -114,9 +114,9 @@ class StateManager void saveState(int slot = -1); /** - Switches to the next higher state slot (circular queue style). + Switches to the next higher or lower state slot (circular queue style). */ - void changeState(); + void changeState(int direction); /** Toggles auto slot mode. diff --git a/src/debugger/gui/DebuggerDialog.cxx b/src/debugger/gui/DebuggerDialog.cxx index 69055b7ad..4c75e2be5 100644 --- a/src/debugger/gui/DebuggerDialog.cxx +++ b/src/debugger/gui/DebuggerDialog.cxx @@ -144,7 +144,8 @@ void DebuggerDialog::handleKeyDown(StellaKey key, StellaMod mod, bool repeated) case Event::SaveState: case Event::SaveAllStates: - case Event::ChangeState: + case Event::PreviousState : + case Event::NextState: case Event::LoadState: case Event::LoadAllStates: diff --git a/src/emucore/Event.hxx b/src/emucore/Event.hxx index 9653ebde4..0dfcb3895 100644 --- a/src/emucore/Event.hxx +++ b/src/emucore/Event.hxx @@ -93,7 +93,7 @@ class Event OptionsMenuMode, CmdMenuMode, DebuggerMode, ExitMode, TakeSnapshot, ToggleContSnapshots, ToggleContSnapshotsFrame, - ChangeState, LoadState, SaveState, + NextState, PreviousState, LoadState, SaveState, SaveAllStates, LoadAllStates, ToggleAutoSlot, ToggleTimeMachine, TimeMachineMode, Rewind1Menu, Rewind10Menu, RewindAllMenu, @@ -134,7 +134,7 @@ class Event }; // Event list version, update only if the id of existing(!) event types changed - static constexpr Int32 VERSION = 2; + static constexpr Int32 VERSION = 3; using EventSet = std::set; diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 87a8ac25a..10fdccb11 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -656,8 +656,12 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) myOSystem.frameBuffer().showMessage(myOSystem.state().rewindManager().saveAllStates()); return; - case Event::ChangeState: - if(pressed) myOSystem.state().changeState(); + case Event::NextState: + if(pressed) myOSystem.state().changeState(1); + return; + + case Event::PreviousState: + if (pressed) myOSystem.state().changeState(-1); return; case Event::ToggleAutoSlot: @@ -1810,9 +1814,13 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { { { Event::ConsoleRightDiffB, "P1 Difficulty B", "" }, { Event::ConsoleRightDiffToggle, "P1 Toggle Difficulty", "" }, { Event::SaveState, "Save state", "" }, - { Event::ChangeState, "Change state slot", "" }, + { Event::SaveAllStates, "Save all TM states of current game", "" }, + { Event::PreviousState, "Change to previous state slot", "" }, + { Event::NextState, "Change to next state slot", "" }, { Event::ToggleAutoSlot, "Toggle automatic state slot change", "" }, { Event::LoadState, "Load state", "" }, + { Event::LoadAllStates, "Load saved TM states for current game", "" }, + #ifdef PNG_SUPPORT { Event::TakeSnapshot, "Snapshot", "" }, { Event::ToggleContSnapshots, "Save continuous snapsh. (as defined)", "" }, @@ -1939,8 +1947,6 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { { { Event::ToggleGrabMouse, "Toggle grab mouse", "" }, { Event::ToggleSAPortOrder, "Swap Stelladaptor port ordering", "" }, - { Event::SaveAllStates, "Save all TM states of current game", "" }, - { Event::LoadAllStates, "Load saved TM states for current game", "" }, { Event::ToggleTimeMachine, "Toggle 'Time Machine' mode", "" }, { Event::TimeMachineMode, "Toggle 'Time Machine' UI", "" }, { Event::RewindPause, "Rewind one state & enter Pause mode", "" }, @@ -2026,8 +2032,8 @@ const Event::EventSet EventHandler::AudioVideoEvents = { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - const Event::EventSet EventHandler::StateEvents = { - Event::ChangeState, Event::LoadState, Event::SaveState, Event::TimeMachineMode, - Event::RewindPause, Event::UnwindPause, Event::ToggleTimeMachine, + Event::NextState, Event::PreviousState, Event::LoadState, Event::SaveState, + Event::TimeMachineMode, Event::RewindPause, Event::UnwindPause, Event::ToggleTimeMachine, Event::Rewind1Menu, Event::Rewind10Menu, Event::RewindAllMenu, Event::Unwind1Menu, Event::Unwind10Menu, Event::UnwindAllMenu, Event::SaveAllStates, Event::LoadAllStates, Event::ToggleAutoSlot, diff --git a/src/emucore/EventHandler.hxx b/src/emucore/EventHandler.hxx index 08b159ef7..7fa56d17d 100644 --- a/src/emucore/EventHandler.hxx +++ b/src/emucore/EventHandler.hxx @@ -468,7 +468,7 @@ class EventHandler #else PNG_SIZE = 0, #endif - EMUL_ACTIONLIST_SIZE = 143 + PNG_SIZE + COMBO_SIZE, + EMUL_ACTIONLIST_SIZE = 144 + PNG_SIZE + COMBO_SIZE, MENU_ACTIONLIST_SIZE = 18 ; diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index c8750ecc7..6fee4347a 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -469,7 +469,7 @@ void Settings::usage() const << endl << " -saveonexit \n" - << " -autoslot <1|0> Automatically switch to next save slot when\n" + << " -autoslot <1|0> Automatically change to next save slot when\n" << " state saving\n" << endl << " -rominfo Display detailed information for the given ROM\n" diff --git a/src/gui/CommandDialog.cxx b/src/gui/CommandDialog.cxx index 8007cebe8..b44ec06cb 100644 --- a/src/gui/CommandDialog.cxx +++ b/src/gui/CommandDialog.cxx @@ -168,7 +168,7 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd, case kStateSlotCmd: { - event = Event::ChangeState; + event = Event::NextState; stateCmd = true; int slot = (instance().state().currentSlot() + 1) % 10; updateSlot(slot); diff --git a/src/gui/DeveloperDialog.cxx b/src/gui/DeveloperDialog.cxx index 28ecf6e7b..1edfd3bcc 100644 --- a/src/gui/DeveloperDialog.cxx +++ b/src/gui/DeveloperDialog.cxx @@ -495,7 +495,7 @@ void DeveloperDialog::addTimeMachineTab(const GUI::Font& font) ypos += lineHeight + VGAP; - myAutoSlotWidget = new CheckboxWidget(myTab, font, HBORDER, ypos + 1, "Automatically switch save state slots"); + myAutoSlotWidget = new CheckboxWidget(myTab, font, HBORDER, ypos + 1, "Automatically change save state slots"); wid.push_back(myAutoSlotWidget); ypos += lineHeight + VGAP; diff --git a/src/gui/MinUICommandDialog.cxx b/src/gui/MinUICommandDialog.cxx index 448d7677e..45c8c45fd 100644 --- a/src/gui/MinUICommandDialog.cxx +++ b/src/gui/MinUICommandDialog.cxx @@ -191,7 +191,7 @@ void MinUICommandDialog::handleCommand(CommandSender* sender, int cmd, case kStateSlotCmd: { - event = Event::ChangeState; + event = Event::NextState; stateCmd = true; int slot = (instance().state().currentSlot() + 1) % 10; updateSlot(slot);