SCI: Refactor to use Engine debugger

This commit is contained in:
Paul Gilbert 2020-02-13 18:41:39 -08:00 committed by Filippos Karapetis
parent 818d9bab27
commit ba147f5ad5
5 changed files with 20 additions and 15 deletions

View File

@ -261,6 +261,15 @@ Console::Console(SciEngine *engine) : GUI::Debugger(),
Console::~Console() {
}
void Console::attach(const char *entry) {
if (entry) {
// Attaching to display a severe error, let the engine know
_engine->severeError();
}
GUI::Debugger::attach(entry);
}
void Console::preEnter() {
_engine->pauseEngine(true);
}

View File

@ -41,6 +41,12 @@ public:
Console(SciEngine *engine);
~Console() override;
/**
* 'Attach' the debugger. This ensures that the next time onFrame()
* is invoked, the debugger will activate and accept user input.
*/
void attach(const char *entry = nullptr) override;
private:
void preEnter() override;
void postEnter() override;

View File

@ -303,14 +303,6 @@ SciEvent EventManager::getScummVMEvent() {
return noEvent;
}
// Check for Control-Shift-D (debug console)
if (ev.type == Common::EVENT_KEYDOWN && ev.kbd.hasFlags(Common::KBD_CTRL | Common::KBD_SHIFT) && ev.kbd.keycode == Common::KEYCODE_d) {
// Open debug console
Console *con = g_sci->getSciDebugger();
con->attach();
return noEvent;
}
// The IBM keyboard driver prior to SCI1.1 only sent keydown events to the
// interpreter
if (ev.type != Common::EVENT_KEYDOWN && getSciVersion() < SCI_VERSION_1_1) {

View File

@ -240,7 +240,7 @@ SciEngine::~SciEngine() {
delete _soundCmd;
delete _kernel;
delete _vocabulary;
delete _console;
//_console deleted by Engine
delete _guestAdditions;
delete _features;
delete _gfxMacIconBar;
@ -331,6 +331,7 @@ Common::Error SciEngine::run() {
// Create debugger console. It requires GFX and _gamestate to be initialized
_console = new Console(this);
setDebugger(_console);
// The game needs to be initialized before the graphics system is initialized, as
// the graphics code checks parts of the seg manager upon initialization (e.g. for
@ -757,8 +758,8 @@ void SciEngine::exitGame() {
_gamestate->_fileHandles.resize(5);
}
// Invoked by error() when a severe error occurs
GUI::Debugger *SciEngine::getDebugger() {
// Invoked by debugger when a severe error occurs
void SciEngine::severeError() {
if (_gamestate) {
ExecStack *xs = &(_gamestate->_executionStack.back());
if (xs) {
@ -769,11 +770,8 @@ GUI::Debugger *SciEngine::getDebugger() {
_debugState.runningStep = 0; // Stop multiple execution
_debugState.seeking = kDebugSeekNothing; // Stop special seeks
return _console;
}
// Used to obtain the engine's console in order to print messages to it
Console *SciEngine::getSciDebugger() {
return _console;
}

View File

@ -257,7 +257,7 @@ public:
Common::Error run() override;
bool hasFeature(EngineFeature f) const override;
void pauseEngineIntern(bool pause) override;
GUI::Debugger *getDebugger() override;
void severeError();
Console *getSciDebugger();
Common::Error loadGameState(int slot) override;
Common::Error saveGameState(int slot, const Common::String &desc) override;