Several large infrastructure changes for upcoming Time Machine stuff:

- renamed Rewinder and associated dialog to TimeMachine and friends
 - changed EventHandler state enum to stronger 'enum class' type (and associated changes to the codebase)
 - moved EventHandlerState into separate class, allowing a few files to not need to include EventHandler.hxx (reduce compile dependency)
 - plumbed EventHandlerState::TIMEMACHINE into the codebase; still TODO is activate it and add a usable dialog)
This commit is contained in:
Stephen Anthony 2017-12-20 21:56:22 -03:30
parent 6313c98fdc
commit 7890a94144
31 changed files with 200 additions and 167 deletions

View File

@ -227,7 +227,7 @@ uInt32 RewindManager::unwindState(uInt32 numStates)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RewindManager::compressStates()
{
uInt64 currentCycles = myOSystem.console().tia().cycles();
// uInt64 currentCycles = myOSystem.console().tia().cycles();
double expectedCycles = myInterval * myFactor * (1 + myFactor);
double maxError = 1;
uInt32 idx = myStateList.size() - 2;
@ -302,7 +302,7 @@ string RewindManager::getUnitString(Int64 cycles)
stringstream result;
Int32 i;
cycles = abs(cycles);
cycles = std::abs(cycles);
for(i = 0; i < NUM_UNITS - 1; ++i)
{

View File

@ -22,6 +22,7 @@
#include "Version.hxx"
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "EventHandler.hxx"
#include "FSNode.hxx"
#include "Settings.hxx"
#include "DebuggerDialog.hxx"

View File

@ -20,6 +20,7 @@
class OSystem;
class Console;
class EventHandler;
class TiaInfoWidget;
class TiaOutputWidget;
class TiaZoomWidget;

View File

@ -19,6 +19,7 @@
#include "Dialog.hxx"
#include "Font.hxx"
#include "Debugger.hxx"
#include "EventHandler.hxx"
#include "FrameBuffer.hxx"
#include "FBSurface.hxx"
#include "DataGridWidget.hxx"

View File

@ -19,6 +19,7 @@
#include "Widget.hxx"
#include "Dialog.hxx"
#include "Settings.hxx"
#include "EventHandler.hxx"
#include "TabWidget.hxx"
#include "TiaInfoWidget.hxx"
#include "TiaOutputWidget.hxx"

View File

@ -20,6 +20,7 @@
#include "DiStella.hxx"
#include "PackedBitArray.hxx"
#include "Widget.hxx"
#include "EventHandler.hxx"
#include "FBSurface.hxx"
#include "Font.hxx"
#include "ScrollBarWidget.hxx"

View File

@ -16,6 +16,7 @@
//============================================================================
#include "OSystem.hxx"
#include "EventHandler.hxx"
#include "Widget.hxx"
#include "ToggleWidget.hxx"

View File

@ -1008,11 +1008,11 @@ void Console::attachDebugger(Debugger& dbg)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Console::stateChanged(EventHandler::State state)
void Console::stateChanged(EventHandlerState state)
{
// For now, only the CompuMate cares about state changes
if(myCMHandler)
myCMHandler->enableKeyHandling(state == EventHandler::S_EMULATE);
myCMHandler->enableKeyHandling(state == EventHandlerState::EMULATION);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -34,6 +34,7 @@ class Debugger;
#include "TIATypes.hxx"
#include "FrameBuffer.hxx"
#include "Serializable.hxx"
#include "EventHandlerConstants.hxx"
#include "NTSCFilter.hxx"
#include "frame-manager/AbstractFrameManager.hxx"
@ -184,7 +185,7 @@ class Console : public Serializable
/**
Informs the Console of a change in EventHandler state.
*/
void stateChanged(EventHandler::State state);
void stateChanged(EventHandlerState state);
public:
/**

View File

@ -29,6 +29,7 @@
#include "TIASurface.hxx"
#include "FSNode.hxx"
#include "Launcher.hxx"
#include "TimeMachine.hxx"
#include "Menu.hxx"
#include "OSystem.hxx"
#include "Joystick.hxx"
@ -60,7 +61,7 @@
EventHandler::EventHandler(OSystem& osystem)
: myOSystem(osystem),
myOverlay(nullptr),
myState(S_NONE),
myState(EventHandlerState::NONE),
myAllowAllDirectionsFlag(false),
myFryingFlag(false),
myUseCtrlKeyFlag(true),
@ -124,7 +125,7 @@ void EventHandler::initialize()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::reset(State state)
void EventHandler::reset(EventHandlerState state)
{
setEventState(state);
myOSystem.state().reset();
@ -213,7 +214,7 @@ void EventHandler::poll(uInt64 time)
// Update controllers and console switches, and in general all other things
// related to emulation
if(myState == S_EMULATE)
if(myState == EventHandlerState::EMULATION)
{
myOSystem.console().riot().update();
@ -294,31 +295,31 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
myOSystem.frameBuffer().toggleFullscreen();
}
// state rewinding must work in pause mode too
else if(myState == S_EMULATE || myState == S_PAUSE)
else if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE)
{
switch(key)
{
case KBDK_LEFT: // Alt-left(-shift) rewinds 1(10) states
myOSystem.frameBuffer().setPauseDelay();
setEventState(S_PAUSE);
setEventState(EventHandlerState::PAUSE);
myOSystem.state().rewindState((kbdShift(mod) && state) ? 10 : 1);
break;
case KBDK_RIGHT: // Alt-right(-shift) unwinds 1(10) states
myOSystem.frameBuffer().setPauseDelay();
setEventState(S_PAUSE);
setEventState(EventHandlerState::PAUSE);
myOSystem.state().unwindState((kbdShift(mod) && state) ? 10 : 1);
break;
case KBDK_DOWN: // Alt-down rewinds to start of list
myOSystem.frameBuffer().setPauseDelay();
setEventState(S_PAUSE);
setEventState(EventHandlerState::PAUSE);
myOSystem.state().rewindState(1000);
break;
case KBDK_UP: // Alt-up rewinds to end of list
myOSystem.frameBuffer().setPauseDelay();
setEventState(S_PAUSE);
setEventState(EventHandlerState::PAUSE);
myOSystem.state().unwindState(1000);
break;
@ -328,7 +329,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
}
}
// These only work when in emulation mode
if(!handled && myState == S_EMULATE)
if(!handled && myState == EventHandlerState::EMULATION)
{
handled = true;
switch(key)
@ -538,7 +539,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
handleEvent(Event::Quit, 1);
}
// These only work when in emulation mode
else if(myState == S_EMULATE)
else if(myState == EventHandlerState::EMULATION)
{
switch(key)
{
@ -622,11 +623,11 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
// Otherwise, let the event handler deal with it
switch(myState)
{
case S_EMULATE:
case EventHandlerState::EMULATION:
handleEvent(myKeyTable[key][kEmulationMode], state);
break;
case S_PAUSE:
case EventHandlerState::PAUSE:
switch(myKeyTable[key][kEmulationMode])
{
case Event::TakeSnapshot:
@ -650,7 +651,7 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
void EventHandler::handleMouseMotionEvent(int x, int y, int xrel, int yrel, int button)
{
// Determine which mode we're in, then send the event to the appropriate place
if(myState == S_EMULATE)
if(myState == EventHandlerState::EMULATION)
{
if(!mySkipMouseMotion)
{
@ -667,7 +668,7 @@ void EventHandler::handleMouseMotionEvent(int x, int y, int xrel, int yrel, int
void EventHandler::handleMouseButtonEvent(MouseButton b, int x, int y)
{
// Determine which mode we're in, then send the event to the appropriate place
if(myState == S_EMULATE)
if(myState == EventHandlerState::EMULATION)
{
switch(b)
{
@ -706,7 +707,7 @@ void EventHandler::handleJoyEvent(int stick, int button, uInt8 state)
return;
// Determine which mode we're in, then send the event to the appropriate place
if(myState == S_EMULATE)
if(myState == EventHandlerState::EMULATION)
handleEvent(joy->btnTable[button][kEmulationMode], state);
else if(myOverlay)
myOverlay->handleJoyEvent(stick, button, state);
@ -726,7 +727,7 @@ void EventHandler::handleJoyEvent(int stick, int button, uInt8 state)
// The 'type-4' here refers to the fact that 'StellaJoystick::JT_2600DAPTOR_LEFT'
// and 'StellaJoystick::JT_2600DAPTOR_RIGHT' are at index 4 and 5 in the JoyType
// enum; subtracting four gives us Controller 0 and 1
if(myState == S_EMULATE)
if(myState == EventHandlerState::EMULATION)
{
switch(myOSystem.console().leftController().type())
{
@ -761,7 +762,7 @@ void EventHandler::handleJoyAxisEvent(int stick, int axis, int value)
switch(joy->type)
{
case StellaJoystick::JT_REGULAR:
if(myState == S_EMULATE)
if(myState == EventHandlerState::EMULATION)
{
// Every axis event has two associated values, negative and positive
Event::Type eventAxisNeg = joy->axisTable[axis][0][kEmulationMode];
@ -867,7 +868,7 @@ void EventHandler::handleJoyHatEvent(int stick, int hat, int value)
// Preprocess all hat events, converting to Stella JoyHat type
// Generate multiple equivalent hat events representing combined direction
// when we get a diagonal hat event
if(myState == S_EMULATE)
if(myState == EventHandlerState::EMULATION)
{
handleEvent(joy->hatTable[hat][int(JoyHat::UP)][kEmulationMode],
value & EVENT_HATUP_M);
@ -913,7 +914,7 @@ void EventHandler::handleSystemEvent(SystemEvent e, int, int)
break;
#if 0
case EVENT_WINDOW_MINIMIZED:
if(myState == S_EMULATE) enterMenuMode(S_MENU);
if(myState == EventHandlerState::EMULATION) enterMenuMode(EventHandlerState::OPTIONSMENU);
break;
#endif
default: // handle other events as testing requires
@ -1001,8 +1002,8 @@ void EventHandler::handleEvent(Event::Type event, int state)
return;
case Event::LauncherMode:
if((myState == S_EMULATE || myState == S_CMDMENU ||
myState == S_DEBUGGER) && state)
if((myState == EventHandlerState::EMULATION || myState == EventHandlerState::CMDMENU ||
myState == EventHandlerState::DEBUGGER) && state)
{
// Go back to the launcher, or immediately quit
if(myOSystem.settings().getBool("exitlauncher") ||
@ -1218,34 +1219,34 @@ bool EventHandler::eventStateChange(Event::Type type)
switch(type)
{
case Event::PauseMode:
if(myState == S_EMULATE)
setEventState(S_PAUSE);
else if(myState == S_PAUSE)
setEventState(S_EMULATE);
if(myState == EventHandlerState::EMULATION)
setEventState(EventHandlerState::PAUSE);
else if(myState == EventHandlerState::PAUSE)
setEventState(EventHandlerState::EMULATION);
else
handled = false;
break;
case Event::MenuMode:
if(myState == S_EMULATE)
enterMenuMode(S_MENU);
if(myState == EventHandlerState::EMULATION)
enterMenuMode(EventHandlerState::OPTIONSMENU);
else
handled = false;
break;
case Event::CmdMenuMode:
if(myState == S_EMULATE)
enterMenuMode(S_CMDMENU);
else if(myState == S_CMDMENU)
if(myState == EventHandlerState::EMULATION)
enterMenuMode(EventHandlerState::CMDMENU);
else if(myState == EventHandlerState::CMDMENU)
leaveMenuMode();
else
handled = false;
break;
case Event::DebuggerMode:
if(myState == S_EMULATE || myState == S_PAUSE)
if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE)
enterDebugMode();
else if(myState == S_DEBUGGER)
else if(myState == EventHandlerState::DEBUGGER)
leaveDebugMode();
else
handled = false;
@ -2068,7 +2069,7 @@ void EventHandler::setContinuousSnapshots(uInt32 interval)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::enterMenuMode(State state)
void EventHandler::enterMenuMode(EventHandlerState state)
{
setEventState(state);
myOverlay->reStack();
@ -2078,7 +2079,7 @@ void EventHandler::enterMenuMode(State state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::leaveMenuMode()
{
setEventState(S_EMULATE);
setEventState(EventHandlerState::EMULATION);
myOSystem.sound().mute(false);
}
@ -2086,7 +2087,7 @@ void EventHandler::leaveMenuMode()
bool EventHandler::enterDebugMode()
{
#ifdef DEBUGGER_SUPPORT
if(myState == S_DEBUGGER || !myOSystem.hasConsole())
if(myState == EventHandlerState::DEBUGGER || !myOSystem.hasConsole())
return false;
// Make sure debugger starts in a consistent state
@ -2094,13 +2095,13 @@ bool EventHandler::enterDebugMode()
// mode, since it takes care of locking the debugger state, which will
// probably be modified below
myOSystem.debugger().setStartState();
setEventState(S_DEBUGGER);
setEventState(EventHandlerState::DEBUGGER);
FBInitStatus fbstatus = myOSystem.createFrameBuffer();
if(fbstatus != FBInitStatus::Success)
{
myOSystem.debugger().setQuitState();
setEventState(S_EMULATE);
setEventState(EventHandlerState::EMULATION);
if(fbstatus == FBInitStatus::FailTooLarge)
myOSystem.frameBuffer().showMessage("Debugger window too large for screen",
MessagePosition::BottomCenter, true);
@ -2121,20 +2122,20 @@ void EventHandler::leaveDebugMode()
{
#ifdef DEBUGGER_SUPPORT
// paranoia: this should never happen:
if(myState != S_DEBUGGER)
if(myState != EventHandlerState::DEBUGGER)
return;
// Make sure debugger quits in a consistent state
myOSystem.debugger().setQuitState();
setEventState(S_EMULATE);
setEventState(EventHandlerState::EMULATION);
myOSystem.createFrameBuffer();
myOSystem.sound().mute(false);
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::setEventState(State state)
void EventHandler::setEventState(EventHandlerState state)
{
myState = state;
@ -2146,7 +2147,7 @@ void EventHandler::setEventState(State state)
// keyboard acts as one large joystick with many (single) buttons
switch(myState)
{
case S_EMULATE:
case EventHandlerState::EMULATION:
myOverlay = nullptr;
myOSystem.sound().mute(false);
enableTextEvents(false);
@ -2154,36 +2155,41 @@ void EventHandler::setEventState(State state)
myUseCtrlKeyFlag = false;
break;
case S_PAUSE:
case EventHandlerState::PAUSE:
myOverlay = nullptr;
myOSystem.sound().mute(true);
enableTextEvents(false);
break;
case S_MENU:
case EventHandlerState::OPTIONSMENU:
myOverlay = &myOSystem.menu();
enableTextEvents(true);
break;
case S_CMDMENU:
case EventHandlerState::CMDMENU:
myOverlay = &myOSystem.commandMenu();
enableTextEvents(true);
break;
case S_LAUNCHER:
case EventHandlerState::TIMEMACHINE:
myOverlay = &myOSystem.timeMachine();
enableTextEvents(true);
break;
case EventHandlerState::LAUNCHER:
myOverlay = &myOSystem.launcher();
enableTextEvents(true);
myEvent.clear();
break;
#ifdef DEBUGGER_SUPPORT
case S_DEBUGGER:
case EventHandlerState::DEBUGGER:
myOverlay = &myOSystem.debugger();
enableTextEvents(true);
break;
#endif
default:
case EventHandlerState::NONE:
myOverlay = nullptr;
break;
}

View File

@ -56,17 +56,6 @@ class EventHandler
EventHandler(OSystem& osystem);
virtual ~EventHandler();
// Enumeration representing the different states of operation
enum State {
S_NONE,
S_EMULATE,
S_PAUSE,
S_LAUNCHER,
S_MENU,
S_CMDMENU,
S_DEBUGGER
};
/**
Returns the event object associated with this handler class.
@ -109,16 +98,16 @@ class EventHandler
/**
Returns the current state of the EventHandler
@return The State type
@return The EventHandlerState type
*/
State state() const { return myState; }
EventHandlerState state() const { return myState; }
/**
Resets the state machine of the EventHandler to the defaults
@param state The current state to set
*/
void reset(State state);
void reset(EventHandlerState state);
/**
This method indicates that the system should terminate.
@ -131,7 +120,7 @@ class EventHandler
@param enable Whether to use the mouse to emulate controllers
Currently, this will be one of the following values:
'always', 'analog', 'never'
'always', 'analog', 'never'
*/
void setMouseControllerMode(const string& enable);
@ -163,7 +152,7 @@ class EventHandler
return (mod & KBDM_SHIFT);
}
void enterMenuMode(State state);
void enterMenuMode(EventHandlerState state);
void leaveMenuMode();
bool enterDebugMode();
void leaveDebugMode();
@ -519,7 +508,7 @@ class EventHandler
*/
bool eventIsAnalog(Event::Type event) const;
void setEventState(State state);
void setEventState(EventHandlerState state);
private:
// Structure used for action menu items
@ -547,7 +536,7 @@ class EventHandler
Event::Type myComboTable[kComboSize][kEventsPerCombo];
// Indicates the current state of the system (ie, which mode is current)
State myState;
EventHandlerState myState;
// Indicates whether the joystick emulates 'impossible' directions
bool myAllowAllDirectionsFlag;

View File

@ -18,6 +18,18 @@
#ifndef EVENTHANDLER_CONSTANTS_HXX
#define EVENTHANDLER_CONSTANTS_HXX
// Enumeration representing the different states of operation
enum class EventHandlerState {
NONE,
EMULATION,
TIMEMACHINE,
PAUSE,
LAUNCHER,
OPTIONSMENU,
CMDMENU,
DEBUGGER
};
enum class MouseButton {
LBUTTONDOWN,
LBUTTONUP,

View File

@ -17,7 +17,6 @@
#include "bspf.hxx"
#include "CommandMenu.hxx"
#include "Console.hxx"
#include "EventHandler.hxx"
#include "Event.hxx"
@ -28,6 +27,8 @@
#include "ConsoleFont.hxx"
#include "Launcher.hxx"
#include "Menu.hxx"
#include "CommandMenu.hxx"
#include "TimeMachine.hxx"
#include "OSystem.hxx"
#include "Settings.hxx"
#include "TIA.hxx"
@ -205,8 +206,8 @@ FBInitStatus FrameBuffer::createDisplay(const string& title,
myScreenSize = mode.screen;
// Inform TIA surface about new mode
if(myOSystem.eventHandler().state() != EventHandler::S_LAUNCHER &&
myOSystem.eventHandler().state() != EventHandler::S_DEBUGGER)
if(myOSystem.eventHandler().state() != EventHandlerState::LAUNCHER &&
myOSystem.eventHandler().state() != EventHandlerState::DEBUGGER)
myTIASurface->initialize(myOSystem.console(), mode);
// Did we get the requested fullscreen state?
@ -262,14 +263,14 @@ void FrameBuffer::update()
invalidate();
switch(myOSystem.eventHandler().state())
{
case EventHandler::S_EMULATE:
case EventHandlerState::EMULATION:
{
// Run the console for one frame
// Note that the debugger can cause a breakpoint to occur, which changes
// the EventHandler state 'behind our back' - we need to check for that
myOSystem.console().tia().update();
#ifdef DEBUGGER_SUPPORT
if(myOSystem.eventHandler().state() != EventHandler::S_EMULATE) break;
if(myOSystem.eventHandler().state() != EventHandlerState::EMULATION) break;
#endif
if(myOSystem.eventHandler().frying())
myOSystem.console().fry();
@ -295,10 +296,10 @@ void FrameBuffer::update()
myStatsMsg.surface->render();
}
myPausedCount = 0;
break; // S_EMULATE
break; // EventHandlerState::EMULATION
}
case EventHandler::S_PAUSE:
case EventHandlerState::PAUSE:
{
myTIASurface->render();
@ -308,38 +309,45 @@ void FrameBuffer::update()
myPausedCount = uInt32(7 * myOSystem.frameRate());
showMessage("Paused", MessagePosition::MiddleCenter);
}
break; // S_PAUSE
break; // EventHandlerState::PAUSE
}
case EventHandler::S_MENU:
case EventHandlerState::OPTIONSMENU:
{
myTIASurface->render();
myOSystem.menu().draw(true);
break; // S_MENU
break; // EventHandlerState::OPTIONSMENU
}
case EventHandler::S_CMDMENU:
case EventHandlerState::CMDMENU:
{
myTIASurface->render();
myOSystem.commandMenu().draw(true);
break; // S_CMDMENU
break; // EventHandlerState::CMDMENU
}
case EventHandler::S_LAUNCHER:
case EventHandlerState::TIMEMACHINE:
{
myTIASurface->render();
myOSystem.timeMachine().draw(true);
break; // EventHandlerState::TIMEMACHINE
}
case EventHandlerState::LAUNCHER:
{
myOSystem.launcher().draw(true);
break; // S_LAUNCHER
break; // EventHandlerState::LAUNCHER
}
#ifdef DEBUGGER_SUPPORT
case EventHandler::S_DEBUGGER:
case EventHandlerState::DEBUGGER:
{
myOSystem.debugger().draw(true);
break; // S_DEBUGGER
break; // EventHandlerState::DEBUGGER
}
#endif
default:
case EventHandlerState::NONE:
return;
}
@ -528,7 +536,7 @@ void FrameBuffer::setPalette(const uInt32* raw_palette)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::stateChanged(EventHandler::State state)
void FrameBuffer::stateChanged(EventHandlerState state)
{
// Make sure any onscreen messages are removed
myMsg.enabled = false;
@ -545,8 +553,8 @@ void FrameBuffer::setFullscreen(bool enable)
myScreenSize = mode.screen;
// Inform TIA surface about new mode
if(myOSystem.eventHandler().state() != EventHandler::S_LAUNCHER &&
myOSystem.eventHandler().state() != EventHandler::S_DEBUGGER)
if(myOSystem.eventHandler().state() != EventHandlerState::LAUNCHER &&
myOSystem.eventHandler().state() != EventHandlerState::DEBUGGER)
myTIASurface->initialize(myOSystem.console(), mode);
// Did we get the requested fullscreen state?
@ -566,9 +574,9 @@ void FrameBuffer::toggleFullscreen()
bool FrameBuffer::changeWindowedVidMode(int direction)
{
#ifdef WINDOWED_SUPPORT
EventHandler::State state = myOSystem.eventHandler().state();
bool tiaMode = (state != EventHandler::S_DEBUGGER &&
state != EventHandler::S_LAUNCHER);
EventHandlerState state = myOSystem.eventHandler().state();
bool tiaMode = (state != EventHandlerState::DEBUGGER &&
state != EventHandlerState::LAUNCHER);
// Ignore any attempts to change video size while in invalid modes
if(!tiaMode || fullScreen())
@ -605,7 +613,7 @@ void FrameBuffer::setCursorState()
// Always grab mouse in emulation (if enabled) and emulating a controller
// that always uses the mouse
bool emulation =
myOSystem.eventHandler().state() == EventHandler::S_EMULATE;
myOSystem.eventHandler().state() == EventHandlerState::EMULATION;
bool analog = myOSystem.hasConsole() ?
(myOSystem.eventHandler().controllerIsAnalog(Controller::Left) ||
myOSystem.eventHandler().controllerIsAnalog(Controller::Right)) : false;
@ -669,9 +677,9 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
// Check if zooming is allowed for this state (currently only allowed
// for TIA screens)
EventHandler::State state = myOSystem.eventHandler().state();
bool tiaMode = (state != EventHandler::S_DEBUGGER &&
state != EventHandler::S_LAUNCHER);
EventHandlerState state = myOSystem.eventHandler().state();
bool tiaMode = (state != EventHandlerState::DEBUGGER &&
state != EventHandlerState::LAUNCHER);
// TIA mode allows zooming at integral factors in windowed modes,
// and also non-integral factors in fullscreen mode
@ -730,7 +738,7 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const VideoMode& FrameBuffer::getSavedVidMode(bool fullscreen)
{
EventHandler::State state = myOSystem.eventHandler().state();
EventHandlerState state = myOSystem.eventHandler().state();
if(fullscreen)
{
@ -748,7 +756,7 @@ const VideoMode& FrameBuffer::getSavedVidMode(bool fullscreen)
// Now select the best resolution depending on the state
// UI modes (launcher and debugger) have only one supported resolution
// so the 'current' one is the only valid one
if(state == EventHandler::S_DEBUGGER || state == EventHandler::S_LAUNCHER)
if(state == EventHandlerState::DEBUGGER || state == EventHandlerState::LAUNCHER)
myCurrentModeList->setZoom(1);
else
myCurrentModeList->setZoom(myZoomMode);

View File

@ -30,11 +30,11 @@ namespace GUI {
class Font;
}
#include "EventHandler.hxx"
#include "Rect.hxx"
#include "Variant.hxx"
#include "TIAConstants.hxx"
#include "FrameBufferConstants.hxx"
#include "EventHandlerConstants.hxx"
#include "bspf.hxx"
// Contains all relevant info for the dimensions of a video screen
@ -261,7 +261,7 @@ class FrameBuffer
/**
Informs the Framebuffer of a change in EventHandler state.
*/
void stateChanged(EventHandler::State state);
void stateChanged(EventHandlerState state);
//////////////////////////////////////////////////////////////////////
// The following methods are system-specific and can/must be

View File

@ -47,7 +47,7 @@
#include "Menu.hxx"
#include "CommandMenu.hxx"
#include "Launcher.hxx"
#include "Rewinder.hxx"
#include "TimeMachine.hxx"
#include "PNGLibrary.hxx"
#include "Widget.hxx"
#include "Console.hxx"
@ -140,8 +140,8 @@ bool OSystem::create()
// Create menu and launcher GUI objects
myMenu = make_unique<Menu>(*this);
myCommandMenu = make_unique<CommandMenu>(*this);
myTimeMachine = make_unique<TimeMachine>(*this);
myLauncher = make_unique<Launcher>(*this);
myRewinder = make_unique<Rewinder>(*this);
myStateManager = make_unique<StateManager>(*this);
// Create the sound object; the sound subsystem isn't actually
@ -250,27 +250,28 @@ FBInitStatus OSystem::createFrameBuffer()
FBInitStatus fbstatus = FBInitStatus::FailComplete;
switch(myEventHandler->state())
{
case EventHandler::S_EMULATE:
case EventHandler::S_PAUSE:
case EventHandler::S_MENU:
case EventHandler::S_CMDMENU:
case EventHandlerState::EMULATION:
case EventHandlerState::PAUSE:
case EventHandlerState::OPTIONSMENU:
case EventHandlerState::CMDMENU:
case EventHandlerState::TIMEMACHINE:
if((fbstatus = myConsole->initializeVideo()) != FBInitStatus::Success)
return fbstatus;
break; // S_EMULATE, S_PAUSE, S_MENU, S_CMDMENU
break;
case EventHandler::S_LAUNCHER:
case EventHandlerState::LAUNCHER:
if((fbstatus = myLauncher->initializeVideo()) != FBInitStatus::Success)
return fbstatus;
break; // S_LAUNCHER
break;
#ifdef DEBUGGER_SUPPORT
case EventHandler::S_DEBUGGER:
case EventHandlerState::DEBUGGER:
if((fbstatus = myDebugger->initializeVideo()) != FBInitStatus::Success)
return fbstatus;
break; // S_DEBUGGER
break;
#endif
default: // Should never happen
case EventHandlerState::NONE: // Should never happen
logMessage("ERROR: Unknown emulation state in createFrameBuffer()", 0);
break;
}
@ -333,12 +334,12 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
#ifdef CHEATCODE_SUPPORT
myCheatManager->loadCheats(myRomMD5);
#endif
myEventHandler->reset(EventHandler::S_EMULATE);
myEventHandler->reset(EventHandlerState::EMULATION);
myEventHandler->setMouseControllerMode(mySettings->getString("usemouse"));
if(createFrameBuffer() != FBInitStatus::Success) // Takes care of initializeVideo()
{
logMessage("ERROR: Couldn't create framebuffer for console", 0);
myEventHandler->reset(EventHandler::S_LAUNCHER);
myEventHandler->reset(EventHandlerState::LAUNCHER);
return "ERROR: Couldn't create framebuffer for console";
}
myConsole->initializeAudio();
@ -379,7 +380,7 @@ bool OSystem::reloadConsole()
bool OSystem::hasConsole() const
{
return myConsole != nullptr &&
myEventHandler->state() != EventHandler::S_LAUNCHER;
myEventHandler->state() != EventHandlerState::LAUNCHER;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -393,7 +394,7 @@ bool OSystem::createLauncher(const string& startdir)
mySettings->setValue("tmpromdir", startdir);
bool status = false;
myEventHandler->reset(EventHandler::S_LAUNCHER);
myEventHandler->reset(EventHandlerState::LAUNCHER);
if(createFrameBuffer() == FBInitStatus::Success)
{
myLauncher->reStack();

View File

@ -26,8 +26,9 @@ class Console;
class Debugger;
class Launcher;
class Menu;
class Rewinder;
class TimeMachine;
class FrameBuffer;
class EventHandler;
class PNGLibrary;
class Properties;
class PropertiesSet;
@ -38,9 +39,9 @@ class Sound;
class StateManager;
class VideoDialog;
#include "EventHandler.hxx"
#include "FSNode.hxx"
#include "FrameBufferConstants.hxx"
#include "EventHandlerConstants.hxx"
#include "bspf.hxx"
struct TimingInfo {
@ -154,11 +155,11 @@ class OSystem
Launcher& launcher() const { return *myLauncher; }
/**
Get the state rewinder of the system.
Get the time machine of the system (manages state files).
@return The rewinder object
@return The time machine object
*/
Rewinder& rewinder() const { return *myRewinder; }
TimeMachine& timeMachine() const { return *myTimeMachine; }
/**
Get the state manager of the system.
@ -410,7 +411,7 @@ class OSystem
/**
Informs the OSystem of a change in EventHandler state.
*/
virtual void stateChanged(EventHandler::State state) { }
virtual void stateChanged(EventHandlerState state) { }
/**
Returns the default save and load paths for various files
@ -469,8 +470,8 @@ class OSystem
unique_ptr<Launcher> myLauncher;
bool myLauncherUsed;
// Pointer to the Rewinder object
unique_ptr<Rewinder> myRewinder;
// Pointer to the TimeMachine object
unique_ptr<TimeMachine> myTimeMachine;
#ifdef DEBUGGER_SUPPORT
// Pointer to the Debugger object

View File

@ -16,6 +16,7 @@
//============================================================================
#include "OSystem.hxx"
#include "EventHandler.hxx"
#include "FrameBuffer.hxx"
#include "FBSurface.hxx"
#include "Font.hxx"

View File

@ -19,6 +19,7 @@
//============================================================================
#include "OSystem.hxx"
#include "EventHandler.hxx"
#include "FrameBuffer.hxx"
#include "FBSurface.hxx"
#include "Font.hxx"

View File

@ -16,6 +16,7 @@
//============================================================================
#include "Dialog.hxx"
#include "EventHandler.hxx"
#include "FBSurface.hxx"
#include "Font.hxx"
#include "EditableWidget.hxx"

View File

@ -18,6 +18,7 @@
#include "bspf.hxx"
#include "OSystem.hxx"
#include "Console.hxx"
#include "EventHandler.hxx"
#include "Joystick.hxx"
#include "Paddles.hxx"
#include "PointingDevice.hxx"
@ -348,7 +349,7 @@ void InputDialog::saveConfig()
const string& cursor = myCursorState->getSelectedTag().toString();
instance().settings().setValue("cursor", cursor);
instance().settings().setValue("grabmouse", myGrabMouse->getState());
instance().frameBuffer().enableGrabMouse(myGrabMouse->getState());
instance().frameBuffer().enableGrabMouse(myGrabMouse->getState());
// Enable/disable control key-combos
instance().settings().setValue("ctrlcombo", myCtrlCombo->getState());

View File

@ -16,6 +16,7 @@
//============================================================================
#include "OSystem.hxx"
#include "EventHandler.hxx"
#include "Widget.hxx"
#include "Font.hxx"
#include "EditTextWidget.hxx"

View File

@ -30,6 +30,7 @@
#include "MessageBox.hxx"
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "EventHandler.hxx"
#include "Props.hxx"
#include "PropsSet.hxx"
#include "RomInfoWidget.hxx"

View File

@ -23,6 +23,7 @@
#include "ScrollBarWidget.hxx"
#include "Dialog.hxx"
#include "FrameBuffer.hxx"
#include "EventHandler.hxx"
#include "ListWidget.hxx"
#include "bspf.hxx"

View File

@ -17,6 +17,7 @@
#include "OSystem.hxx"
#include "FrameBuffer.hxx"
#include "EventHandler.hxx"
#include "Dialog.hxx"
#include "DialogContainer.hxx"
#include "Widget.hxx"
@ -164,10 +165,10 @@ void OptionsDialog::loadConfig()
// in launcher mode
switch(instance().eventHandler().state())
{
case EventHandler::S_EMULATE:
case EventHandlerState::EMULATION:
myGameInfoButton->setFlags(WIDGET_ENABLED);
break;
case EventHandler::S_LAUNCHER:
case EventHandlerState::LAUNCHER:
if(instance().launcher().selectedRomMD5() != "")
myGameInfoButton->setFlags(WIDGET_ENABLED);
else

View File

@ -22,6 +22,7 @@ class GUIObject;
class ContextMenu;
#include "bspf.hxx"
#include "Variant.hxx"
#include "Command.hxx"
#include "Widget.hxx"

View File

@ -15,6 +15,7 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#include "EventHandler.hxx"
#include "FrameBuffer.hxx"
#include "Dialog.hxx"
#include "FBSurface.hxx"
@ -26,7 +27,6 @@
#include "Rect.hxx"
#include "Widget.hxx"
#include "TIAConstants.hxx"
#include "RomInfoWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -59,7 +59,7 @@ void RomInfoWidget::setProperties(const Properties& props)
myProperties = props;
// Decide whether the information should be shown immediately
if(instance().eventHandler().state() == EventHandler::S_LAUNCHER)
if(instance().eventHandler().state() == EventHandlerState::LAUNCHER)
parseProperties();
}
@ -71,7 +71,7 @@ void RomInfoWidget::clearProperties()
mySurface->setVisible(mySurfaceIsValid);
// Decide whether the information should be shown immediately
if(instance().eventHandler().state() == EventHandler::S_LAUNCHER)
if(instance().eventHandler().state() == EventHandlerState::LAUNCHER)
setDirty();
}

View File

@ -17,13 +17,13 @@
#include "Dialog.hxx"
#include "FrameBuffer.hxx"
#include "RewindDialog.hxx"
#include "Rewinder.hxx"
#include "TimeMachineDialog.hxx"
#include "TimeMachine.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Rewinder::Rewinder(OSystem& osystem)
TimeMachine::TimeMachine(OSystem& osystem)
: DialogContainer(osystem)
{
myBaseDialog = new RewindDialog(myOSystem, *this,
myBaseDialog = new TimeMachineDialog(myOSystem, *this,
FrameBuffer::kFBMinW, FrameBuffer::kFBMinH);
}

View File

@ -15,31 +15,31 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef REWINDER_HXX
#define REWINDER_HXX
#ifndef TIME_MACHINE_HXX
#define TIME_MACHINE_HXX
class OSystem;
#include "DialogContainer.hxx"
/**
The base dialog for all rewind-related UI items in Stella.
The base dialog for all time machine related UI items in Stella.
@author Stephen Anthony
*/
class Rewinder : public DialogContainer
class TimeMachine : public DialogContainer
{
public:
Rewinder(OSystem& osystem);
virtual ~Rewinder() = default;
TimeMachine(OSystem& osystem);
virtual ~TimeMachine() = default;
private:
// Following constructors and assignment operators not supported
Rewinder() = delete;
Rewinder(const Rewinder&) = delete;
Rewinder(Rewinder&&) = delete;
Rewinder& operator=(const Rewinder&) = delete;
Rewinder& operator=(Rewinder&&) = delete;
TimeMachine() = delete;
TimeMachine(const TimeMachine&) = delete;
TimeMachine(TimeMachine&&) = delete;
TimeMachine& operator=(const TimeMachine&) = delete;
TimeMachine& operator=(TimeMachine&&) = delete;
};
#endif

View File

@ -21,11 +21,11 @@
#include "FrameBuffer.hxx"
#include "OSystem.hxx"
#include "Widget.hxx"
#include "RewindDialog.hxx"
#include "TimeMachineDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RewindDialog::RewindDialog(OSystem& osystem, DialogContainer& parent,
int max_w, int max_h)
TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
int max_w, int max_h)
: Dialog(osystem, parent)
{
const GUI::Font& font = instance().frameBuffer().font();

View File

@ -15,8 +15,8 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================
#ifndef REWIND_DIALOG_HXX
#define REWIND_DIALOG_HXX
#ifndef TIME_MACHINE_DIALOG_HXX
#define TIME_MACHINE_DIALOG_HXX
class CommandSender;
class DialogContainer;
@ -24,19 +24,19 @@ class OSystem;
#include "Dialog.hxx"
class RewindDialog : public Dialog
class TimeMachineDialog : public Dialog
{
public:
RewindDialog(OSystem& osystem, DialogContainer& parent, int max_w, int max_h);
virtual ~RewindDialog() = default;
TimeMachineDialog(OSystem& osystem, DialogContainer& parent, int max_w, int max_h);
virtual ~TimeMachineDialog() = default;
private:
// Following constructors and assignment operators not supported
RewindDialog() = delete;
RewindDialog(const RewindDialog&) = delete;
RewindDialog(RewindDialog&&) = delete;
RewindDialog& operator=(const RewindDialog&) = delete;
RewindDialog& operator=(RewindDialog&&) = delete;
TimeMachineDialog() = delete;
TimeMachineDialog(const TimeMachineDialog&) = delete;
TimeMachineDialog(TimeMachineDialog&&) = delete;
TimeMachineDialog& operator=(const TimeMachineDialog&) = delete;
TimeMachineDialog& operator=(TimeMachineDialog&&) = delete;
};
#endif

View File

@ -4,20 +4,20 @@ MODULE_OBJS := \
src/gui/AboutDialog.o \
src/gui/AudioDialog.o \
src/gui/BrowserDialog.o \
src/gui/CheckListWidget.o \
src/gui/ColorWidget.o \
src/gui/ComboDialog.o \
src/gui/CommandDialog.o \
src/gui/CommandMenu.o \
src/gui/ConfigPathDialog.o \
src/gui/ContextMenu.o \
src/gui/DialogContainer.o \
src/gui/DeveloperDialog.o \
src/gui/DialogContainer.o \
src/gui/Dialog.o \
src/gui/EditableWidget.o \
src/gui/EditTextWidget.o \
src/gui/EventMappingWidget.o \
src/gui/FileListWidget.o \
src/gui/ConfigPathDialog.o \
src/gui/SnapshotDialog.o \
src/gui/Font.o \
src/gui/GameInfoDialog.o \
src/gui/GameList.o \
@ -26,25 +26,25 @@ MODULE_OBJS := \
src/gui/InputDialog.o \
src/gui/InputTextDialog.o \
src/gui/JoystickDialog.o \
src/gui/Launcher.o \
src/gui/LauncherDialog.o \
src/gui/LauncherFilterDialog.o \
src/gui/LoggerDialog.o \
src/gui/Launcher.o \
src/gui/ListWidget.o \
src/gui/LoggerDialog.o \
src/gui/Menu.o \
src/gui/MessageBox.o \
src/gui/OptionsDialog.o \
src/gui/PopUpWidget.o \
src/gui/ProgressDialog.o \
src/gui/RadioButtonWidget.o \
src/gui/Rewinder.o \
src/gui/RewindDialog.o \
src/gui/RomAuditDialog.o \
src/gui/RomInfoWidget.o \
src/gui/ScrollBarWidget.o \
src/gui/CheckListWidget.o \
src/gui/SnapshotDialog.o \
src/gui/StringListWidget.o \
src/gui/TabWidget.o \
src/gui/TimeMachineDialog.o \
src/gui/TimeMachine.o \
src/gui/UIDialog.o \
src/gui/VideoDialog.o \
src/gui/Widget.o