add autoslot event and default mapping

fix autoslot message
This commit is contained in:
thrust26 2019-06-12 23:58:44 +02:00
parent dfc1f852cf
commit 43537c868b
6 changed files with 30 additions and 4 deletions

View File

@ -475,6 +475,7 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultEmuMa
{Event::SaveState, KBDK_F9},
{Event::SaveAllStates, KBDK_F9, MOD3},
{Event::ChangeState, KBDK_F10},
{Event::ToggleAutoSlot, KBDK_F10, MOD3},
{Event::LoadState, KBDK_F11},
{Event::LoadAllStates, KBDK_F11, MOD3},
{Event::TakeSnapshot, KBDK_F12},

View File

@ -288,7 +288,7 @@ void StateManager::saveState(int slot)
if(myOSystem.settings().getBool("autoslot"))
{
myCurrentSlot = (slot + 1) % 10;
buf << ", switching to slot " << slot;
buf << ", switching to slot " << myCurrentSlot;
}
}
else
@ -309,6 +309,19 @@ void StateManager::changeState()
myOSystem.frameBuffer().showMessage(buf.str());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StateManager::toggleAutoSlot()
{
bool autoSlot = !myOSystem.settings().getBool("autoslot");
// Print appropriate message
ostringstream buf;
buf << "Automatic slot change " << (autoSlot ? "enabled" : "disabled");
myOSystem.frameBuffer().showMessage(buf.str());
myOSystem.settings().setValue("autoslot", autoSlot);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool StateManager::loadState(Serializer& in)
{

View File

@ -118,6 +118,11 @@ class StateManager
*/
void changeState();
/**
Toggles auto slot mode.
*/
void toggleAutoSlot();
/**
Load a state into the current system from the given Serializer.
No messages are printed to the screen.

View File

@ -106,11 +106,13 @@ class Event
StartPauseMode, SaveAllStates, LoadAllStates,
DecreaseOverscan, IncreaseOverScan,
ToggleAutoSlot,
LastType
};
// Event list version, update if the id of existing event types changed
static constexpr Int32 VERSION = 2;
static constexpr Int32 VERSION = 3;
class KeyTable {
public:

View File

@ -630,6 +630,10 @@ void EventHandler::handleEvent(Event::Type event, bool pressed, bool repeated)
if(pressed) myOSystem.state().changeState();
return;
case Event::ToggleAutoSlot:
if (pressed) myOSystem.state().toggleAutoSlot();
return;
case Event::LoadState:
if(pressed && !repeated) myOSystem.state().loadState();
return;
@ -1606,7 +1610,8 @@ EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] =
{ Event::ConsoleRightDiffB, "P1 Difficulty B", "" },
{ Event::ConsoleRightDiffToggle, "P1 Swap Difficulty", "" },
{ Event::SaveState, "Save state", "" },
{ Event::ChangeState, "Change state", "" },
{ Event::ChangeState, "Change state slot", "" },
{ Event::ToggleAutoSlot, "Toggle automatic state slot change", "" },
{ Event::LoadState, "Load state", "" },
{ Event::TakeSnapshot, "Snapshot", "" },
{ Event::TogglePauseMode, "Toggle pause mode", "" },

View File

@ -382,7 +382,7 @@ class EventHandler
#else
PNG_SIZE = 0,
#endif
EMUL_ACTIONLIST_SIZE = 138 + PNG_SIZE + COMBO_SIZE,
EMUL_ACTIONLIST_SIZE = 139 + PNG_SIZE + COMBO_SIZE,
MENU_ACTIONLIST_SIZE = 18
;