mirror of https://github.com/stella-emu/stella.git
refactored ESC key handling
prevent exiting debugger from within Options Dialog (hack)
This commit is contained in:
parent
df119ba505
commit
9263e7c62f
|
@ -64,7 +64,8 @@ Debugger::Debugger(OSystem& osystem, Console& console)
|
||||||
mySystem(console.system()),
|
mySystem(console.system()),
|
||||||
myDialog(nullptr),
|
myDialog(nullptr),
|
||||||
myWidth(DebuggerDialog::kSmallFontMinW),
|
myWidth(DebuggerDialog::kSmallFontMinW),
|
||||||
myHeight(DebuggerDialog::kSmallFontMinH)
|
myHeight(DebuggerDialog::kSmallFontMinH),
|
||||||
|
myMenuMode(false)
|
||||||
{
|
{
|
||||||
// Init parser
|
// Init parser
|
||||||
myParser = make_unique<DebuggerParser>(*this, osystem.settings());
|
myParser = make_unique<DebuggerParser>(*this, osystem.settings());
|
||||||
|
|
|
@ -240,6 +240,13 @@ class Debugger : public DialogContainer
|
||||||
void lockBankswitchState();
|
void lockBankswitchState();
|
||||||
void unlockBankswitchState();
|
void unlockBankswitchState();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Used to make sure that debugger cannot be exited while Options dialog is open.
|
||||||
|
(ugly hack!)
|
||||||
|
*/
|
||||||
|
void setMenuMode(bool enable) { myMenuMode = enable; };
|
||||||
|
bool inMenuMode() { return myMenuMode; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
Save state of each debugger subsystem and, by default, mark all
|
Save state of each debugger subsystem and, by default, mark all
|
||||||
|
@ -323,6 +330,8 @@ class Debugger : public DialogContainer
|
||||||
static BuiltinFunction ourBuiltinFunctions[NUM_BUILTIN_FUNCS];
|
static BuiltinFunction ourBuiltinFunctions[NUM_BUILTIN_FUNCS];
|
||||||
static PseudoRegister ourPseudoRegisters[NUM_PSEUDO_REGS];
|
static PseudoRegister ourPseudoRegisters[NUM_PSEUDO_REGS];
|
||||||
|
|
||||||
|
bool myMenuMode;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// rewind/unwind n states
|
// rewind/unwind n states
|
||||||
uInt16 windStates(uInt16 numStates, bool unwind, string& message);
|
uInt16 windStates(uInt16 numStates, bool unwind, string& message);
|
||||||
|
|
|
@ -174,6 +174,7 @@ void DebuggerDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kDDOptionsCmd:
|
case kDDOptionsCmd:
|
||||||
|
instance().debugger().setMenuMode(true);
|
||||||
myOptions->open();
|
myOptions->open();
|
||||||
loadConfig();
|
loadConfig();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -614,11 +614,36 @@ void EventHandler::handleKeyEvent(StellaKey key, StellaMod mod, bool state)
|
||||||
// Don't pass the key on if we've already taken care of it
|
// Don't pass the key on if we've already taken care of it
|
||||||
if(handled) return;
|
if(handled) return;
|
||||||
|
|
||||||
// Handle keys which switch eventhandler state
|
|
||||||
// Arrange the logic to take advantage of short-circuit evaluation
|
// Arrange the logic to take advantage of short-circuit evaluation
|
||||||
if(!(StellaModTest::isControl(mod) || StellaModTest::isShift(mod) || StellaModTest::isAlt(mod)) &&
|
if(!(StellaModTest::isControl(mod) || StellaModTest::isShift(mod) || StellaModTest::isAlt(mod)))
|
||||||
!state && eventStateChange(myKeyTable[key][kEmulationMode]))
|
{
|
||||||
return;
|
// special handling for Escape key
|
||||||
|
if(state && key == KBDK_ESCAPE)
|
||||||
|
{
|
||||||
|
if(myState == EventHandlerState::PAUSE)
|
||||||
|
{
|
||||||
|
setEventState(EventHandlerState::EMULATION);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(myState == EventHandlerState::CMDMENU ||
|
||||||
|
myState == EventHandlerState::TIMEMACHINE)
|
||||||
|
{
|
||||||
|
leaveMenuMode();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: this currently does not work, because it exits the search dialog too
|
||||||
|
// How can we identify if the focus is in a different dialog?
|
||||||
|
/*else if(myState == EventHandlerState::DEBUGGER && !myOSystem.debugger().inMenuMode())
|
||||||
|
{
|
||||||
|
leaveDebugMode();
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle keys which switch eventhandler state
|
||||||
|
if(!state && eventStateChange(myKeyTable[key][kEmulationMode]))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Otherwise, let the event handler deal with it
|
// Otherwise, let the event handler deal with it
|
||||||
switch(myState)
|
switch(myState)
|
||||||
|
@ -1250,25 +1275,12 @@ bool EventHandler::eventStateChange(Event::Type type)
|
||||||
case Event::DebuggerMode:
|
case Event::DebuggerMode:
|
||||||
if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE)
|
if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE)
|
||||||
enterDebugMode();
|
enterDebugMode();
|
||||||
else if(myState == EventHandlerState::DEBUGGER)
|
else if(myState == EventHandlerState::DEBUGGER && !myOSystem.debugger().inMenuMode())
|
||||||
leaveDebugMode();
|
leaveDebugMode();
|
||||||
else
|
else
|
||||||
handled = false;
|
handled = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Event::LauncherMode:
|
|
||||||
if (myState == EventHandlerState::PAUSE ||
|
|
||||||
myState == EventHandlerState::TIMEMACHINE)
|
|
||||||
setEventState(EventHandlerState::EMULATION);
|
|
||||||
else if(myState == EventHandlerState::CMDMENU)
|
|
||||||
leaveMenuMode();
|
|
||||||
// TODO: this currently does not work, because it exits all open dialogs too
|
|
||||||
/*else if(myState == EventHandlerState::DEBUGGER)
|
|
||||||
leaveDebugMode();*/
|
|
||||||
else
|
|
||||||
handled = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
handled = false;
|
handled = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,7 +216,6 @@ void InputTextDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
Dialog::handleCommand(sender, GuiObject::kCloseCmd, data, id);
|
Dialog::handleCommand(sender, GuiObject::kCloseCmd, data, id);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Dialog::handleCommand(sender, cmd, data, id);
|
Dialog::handleCommand(sender, cmd, data, id);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "HelpDialog.hxx"
|
#include "HelpDialog.hxx"
|
||||||
#include "AboutDialog.hxx"
|
#include "AboutDialog.hxx"
|
||||||
#include "OptionsDialog.hxx"
|
#include "OptionsDialog.hxx"
|
||||||
|
#include "Debugger.hxx"
|
||||||
#include "Launcher.hxx"
|
#include "Launcher.hxx"
|
||||||
|
|
||||||
#ifdef CHEATCODE_SUPPORT
|
#ifdef CHEATCODE_SUPPORT
|
||||||
|
@ -251,7 +252,10 @@ void OptionsDialog::handleCommand(CommandSender* sender, int cmd,
|
||||||
|
|
||||||
case kExitCmd:
|
case kExitCmd:
|
||||||
if(myMode != emulator)
|
if(myMode != emulator)
|
||||||
|
{
|
||||||
|
instance().debugger().setMenuMode(false);
|
||||||
close();
|
close();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
instance().eventHandler().leaveMenuMode();
|
instance().eventHandler().leaveMenuMode();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue