add new StartPause event (e.g. useful for combos)

fix some code
This commit is contained in:
thrust26 2019-05-30 08:59:33 +02:00
parent a225003ed9
commit 996517eefb
5 changed files with 28 additions and 21 deletions

View File

@ -19,7 +19,6 @@
#define KEYMAP_HXX
#include <unordered_map>
#include "Event.hxx"
#include "EventHandlerConstants.hxx"

View File

@ -142,7 +142,7 @@ void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mod
setDefaultKey(Event::LoadState , KBDK_F11);
setDefaultKey(Event::TakeSnapshot , KBDK_F12);
setDefaultKey(Event::Fry , KBDK_BACKSPACE);
setDefaultKey(Event::PauseMode , KBDK_PAUSE);
setDefaultKey(Event::TogglePauseMode , KBDK_PAUSE);
setDefaultKey(Event::OptionsMenuMode , KBDK_TAB);
setDefaultKey(Event::CmdMenuMode , KBDK_BACKSLASH);
setDefaultKey(Event::TimeMachineMode , KBDK_T);

View File

@ -74,7 +74,7 @@ class Event
MouseButtonLeftValue, MouseButtonRightValue,
ChangeState, LoadState, SaveState, TakeSnapshot, Quit,
PauseMode, OptionsMenuMode, CmdMenuMode, TimeMachineMode, DebuggerMode, ExitMode,
TogglePauseMode, OptionsMenuMode, CmdMenuMode, TimeMachineMode, DebuggerMode, ExitMode,
Fry, VolumeDecrease, VolumeIncrease, SoundToggle, VidmodeDecrease, VidmodeIncrease,
Rewind, Unwind,
@ -103,6 +103,8 @@ class Event
Rewind1Menu, Rewind10Menu, RewindAllMenu,
Unwind1Menu, Unwind10Menu, UnwindAllMenu,
StartPauseMode,
LastType
};

View File

@ -662,7 +662,7 @@ void EventHandler::handleEvent(Event::Type event, bool pressed)
switch (myState)
{
case EventHandlerState::PAUSE:
if (pressed) changeStateByEvent(Event::PauseMode);
if (pressed) changeStateByEvent(Event::TogglePauseMode);
return;
case EventHandlerState::CMDMENU:
@ -704,6 +704,11 @@ void EventHandler::handleEvent(Event::Type event, bool pressed)
}
return;
case Event::StartPauseMode:
if (pressed && myState == EventHandlerState::EMULATION)
setState(EventHandlerState::PAUSE);
return;
////////////////////////////////////////////////////////////////////////
// A combo event is simply multiple calls to handleEvent, once for
// each event it contains
@ -772,7 +777,7 @@ void EventHandler::handleEvent(Event::Type event, bool pressed)
if (myIs7800)
myOSystem.frameBuffer().showMessage("Pause pressed");
}
break;
return;
case Event::ConsoleLeftDiffA:
if(pressed)
@ -780,14 +785,14 @@ void EventHandler::handleEvent(Event::Type event, bool pressed)
myEvent.set(Event::ConsoleLeftDiffB, 0);
myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " A");
}
break;
return;
case Event::ConsoleLeftDiffB:
if(pressed)
{
myEvent.set(Event::ConsoleLeftDiffA, 0);
myOSystem.frameBuffer().showMessage(GUI::LEFT_DIFFICULTY + " B");
}
break;
return;
case Event::ConsoleLeftDiffToggle:
if(pressed)
{
@ -813,14 +818,14 @@ void EventHandler::handleEvent(Event::Type event, bool pressed)
myEvent.set(Event::ConsoleRightDiffB, 0);
myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " A");
}
break;
return;
case Event::ConsoleRightDiffB:
if(pressed)
{
myEvent.set(Event::ConsoleRightDiffA, 0);
myOSystem.frameBuffer().showMessage(GUI::RIGHT_DIFFICULTY + " B");
}
break;
return;
case Event::ConsoleRightDiffToggle:
if(pressed)
{
@ -909,7 +914,7 @@ bool EventHandler::changeStateByEvent(Event::Type type)
switch(type)
{
case Event::PauseMode:
case Event::TogglePauseMode:
if(myState == EventHandlerState::EMULATION)
setState(EventHandlerState::PAUSE);
else if(myState == EventHandlerState::PAUSE)
@ -1528,10 +1533,10 @@ void EventHandler::setState(EventHandlerState state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] = {
{ Event::Quit, "Quit", "", false },
{ Event::ExitMode, "Exit current Stella mode", "", false },
{ Event::OptionsMenuMode, "Enter options menu UI", "", false },
{ Event::CmdMenuMode, "Toggle command menu UI", "", false },
{ Event::DebuggerMode, "Toggle debugger mode", "", false },
{ Event::ExitMode, "Exit current Stella menu/mode", "", false },
{ Event::OptionsMenuMode, "Enter Options menu UI", "", false },
{ Event::CmdMenuMode, "Toggle Commands menu UI", "", false },
{ Event::DebuggerMode, "Toggle Debugger mode", "", false },
{ Event::ConsoleSelect, "Select", "", true },
{ Event::ConsoleReset, "Reset", "", true },
@ -1541,15 +1546,16 @@ EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] =
{ Event::Console7800Pause, "7800 Pause Key", "", true },
{ Event::ConsoleLeftDiffA, "P0 Difficulty A", "", true },
{ Event::ConsoleLeftDiffB, "P0 Difficulty B", "", true },
{ Event::ConsoleLeftDiffToggle, "P0 swap Difficulty", "", true },
{ Event::ConsoleLeftDiffToggle, "P0 Swap Difficulty", "", true },
{ Event::ConsoleRightDiffA, "P1 Difficulty A", "", true },
{ Event::ConsoleRightDiffB, "P1 Difficulty B", "", true },
{ Event::ConsoleRightDiffToggle, "P1 swap Difficulty", "", true },
{ Event::ConsoleRightDiffToggle, "P1 Swap Difficulty", "", true },
{ Event::SaveState, "Save state", "", false },
{ Event::ChangeState, "Change state", "", false },
{ Event::LoadState, "Load state", "", false },
{ Event::TakeSnapshot, "Snapshot", "", false },
{ Event::PauseMode, "Pause", "", false },
{ Event::TogglePauseMode, "Toggle pause mode", "", true },
{ Event::StartPauseMode, "Start pause mode", "", true },
{ Event::JoystickZeroUp, "P0 Joystick Up", "", true },
{ Event::JoystickZeroDown, "P0 Joystick Down", "", true },
@ -1670,11 +1676,11 @@ EventHandler::ActionList EventHandler::ourEmulActionList[EMUL_ACTIONLIST_SIZE] =
#endif
{ Event::ToggleTimeMachine, "Toggle 'Time Machine' mode", "", false },
{ Event::TimeMachineMode, "Toggle 'Time Machine' UI", "", false },
{ Event::Rewind, "Rewind game one state", "", false },
{ Event::Rewind, "Rewind game one state", "", true },
{ Event::Rewind1Menu, "Rewind one state & enter TM UI", "", false },
{ Event::Rewind10Menu, "Rewind 10 states & enter TM UI", "", false },
{ Event::RewindAllMenu, "Rewind all states & enter TM UI", "", false },
{ Event::Unwind, "Unwind game one state", "", false },
{ Event::Unwind, "Unwind game one state", "", true },
{ Event::Unwind1Menu, "Unwind one state & enter TM UI", "", false },
{ Event::Unwind10Menu, "Unwind 10 states & enter TM UI", "", false },
{ Event::UnwindAllMenu, "Unwind all states & enter TM UI", "", false },

View File

@ -368,9 +368,9 @@ class EventHandler
COMBO_SIZE = 16,
EVENTS_PER_COMBO = 8,
#ifdef PNG_SUPPORT
EMUL_ACTIONLIST_SIZE = 135 + COMBO_SIZE,
EMUL_ACTIONLIST_SIZE = 136 + COMBO_SIZE,
#else
EMUL_ACTIONLIST_SIZE = 135 - 2 + COMBO_SIZE,
EMUL_ACTIONLIST_SIZE = 136 - 2 + COMBO_SIZE,
#endif
MENU_ACTIONLIST_SIZE = 18
;