From 6f83052b403b2ddcb51f7e732564bd53c240e1a9 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 15 Aug 2011 22:03:58 -0400 Subject: AGI: Cleanup PreAGI console code --- engines/agi/console.cpp | 28 ++++++++++++---------------- engines/agi/console.h | 24 +++++++----------------- engines/agi/preagi.cpp | 7 ++++--- engines/agi/preagi.h | 2 -- engines/agi/preagi_mickey.cpp | 3 ++- engines/agi/preagi_mickey.h | 4 ++++ engines/agi/preagi_winnie.cpp | 2 +- engines/agi/preagi_winnie.h | 4 ++++ 8 files changed, 34 insertions(+), 40 deletions(-) (limited to 'engines') diff --git a/engines/agi/console.cpp b/engines/agi/console.cpp index a2daf1493f..dd06736290 100644 --- a/engines/agi/console.cpp +++ b/engines/agi/console.cpp @@ -275,25 +275,21 @@ bool Console::Cmd_BT(int argc, const char **argv) { return true; } -PreAGI_Console::PreAGI_Console(PreAgiEngine *vm) { - _vm = vm; -} - -Mickey_Console::Mickey_Console(MickeyEngine *mickey) : PreAGI_Console(mickey) { +MickeyConsole::MickeyConsole(MickeyEngine *mickey) : GUI::Debugger() { _mickey = mickey; - DCmd_Register("curRoom", WRAP_METHOD(Mickey_Console, Cmd_CurRoom)); - DCmd_Register("gotoRoom", WRAP_METHOD(Mickey_Console, Cmd_GotoRoom)); - DCmd_Register("drawPic", WRAP_METHOD(Mickey_Console, Cmd_DrawPic)); - DCmd_Register("drawObj", WRAP_METHOD(Mickey_Console, Cmd_DrawObj)); + DCmd_Register("curRoom", WRAP_METHOD(MickeyConsole, Cmd_CurRoom)); + DCmd_Register("gotoRoom", WRAP_METHOD(MickeyConsole, Cmd_GotoRoom)); + DCmd_Register("drawPic", WRAP_METHOD(MickeyConsole, Cmd_DrawPic)); + DCmd_Register("drawObj", WRAP_METHOD(MickeyConsole, Cmd_DrawObj)); } -bool Mickey_Console::Cmd_CurRoom(int argc, const char **argv) { +bool MickeyConsole::Cmd_CurRoom(int argc, const char **argv) { _mickey->debugCurRoom(); return true; } -bool Mickey_Console::Cmd_GotoRoom(int argc, const char **argv) { +bool MickeyConsole::Cmd_GotoRoom(int argc, const char **argv) { if (argc != 2) DebugPrintf("Usage: %s \n", argv[0]); else @@ -301,7 +297,7 @@ bool Mickey_Console::Cmd_GotoRoom(int argc, const char **argv) { return true; } -bool Mickey_Console::Cmd_DrawPic(int argc, const char **argv) { +bool MickeyConsole::Cmd_DrawPic(int argc, const char **argv) { if (argc != 2) DebugPrintf("Usage: %s \n", argv[0]); else @@ -309,7 +305,7 @@ bool Mickey_Console::Cmd_DrawPic(int argc, const char **argv) { return true; } -bool Mickey_Console::Cmd_DrawObj(int argc, const char **argv) { +bool MickeyConsole::Cmd_DrawObj(int argc, const char **argv) { if (argc != 2) DebugPrintf("Usage: %s \n", argv[0]); else @@ -317,13 +313,13 @@ bool Mickey_Console::Cmd_DrawObj(int argc, const char **argv) { return true; } -Winnie_Console::Winnie_Console(WinnieEngine *winnie) : PreAGI_Console(winnie) { +WinnieConsole::WinnieConsole(WinnieEngine *winnie) : GUI::Debugger() { _winnie = winnie; - DCmd_Register("curRoom", WRAP_METHOD(Winnie_Console, Cmd_CurRoom)); + DCmd_Register("curRoom", WRAP_METHOD(WinnieConsole, Cmd_CurRoom)); } -bool Winnie_Console::Cmd_CurRoom(int argc, const char **argv) { +bool WinnieConsole::Cmd_CurRoom(int argc, const char **argv) { _winnie->debugCurRoom(); return true; diff --git a/engines/agi/console.h b/engines/agi/console.h index 78f0e79280..5f69460907 100644 --- a/engines/agi/console.h +++ b/engines/agi/console.h @@ -67,20 +67,10 @@ private: AgiEngine *_vm; }; -class PreAGI_Console : public GUI::Debugger { +class MickeyConsole : public GUI::Debugger { public: - PreAGI_Console(PreAgiEngine *vm); - virtual ~PreAGI_Console() {} - -private: - PreAgiEngine *_vm; -}; - - -class Mickey_Console : public PreAGI_Console { -public: - Mickey_Console(MickeyEngine *mickey); - virtual ~Mickey_Console() {} + MickeyConsole(MickeyEngine *mickey); + virtual ~MickeyConsole() {} private: MickeyEngine *_mickey; @@ -91,10 +81,10 @@ private: bool Cmd_DrawObj(int argc, const char **argv); }; -class Winnie_Console : public PreAGI_Console { +class WinnieConsole : public GUI::Debugger { public: - Winnie_Console(WinnieEngine *winnie); - virtual ~Winnie_Console() {} + WinnieConsole(WinnieEngine *winnie); + virtual ~WinnieConsole() {} private: WinnieEngine *_winnie; @@ -102,6 +92,6 @@ private: bool Cmd_CurRoom(int argc, const char **argv); }; -} // End of namespace Agi +} // End of namespace Agi #endif /* AGI_CONSOLE_H */ diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp index 065b93e5f9..34180b543f 100644 --- a/engines/agi/preagi.cpp +++ b/engines/agi/preagi.cpp @@ -203,6 +203,7 @@ void PreAgiEngine::printStrXOR(char *szMsg) { int PreAgiEngine::getSelection(SelectionTypes type) { Common::Event event; + GUI::Debugger *console = getDebugger(); while (!shouldQuit()) { while (_eventMan->pollEvent(event)) { @@ -216,9 +217,9 @@ int PreAgiEngine::getSelection(SelectionTypes type) { if (type == kSelYesNo || type == kSelAnyKey) return 1; case Common::EVENT_KEYDOWN: - if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL) && _console) { - _console->attach(); - _console->onFrame(); + if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL) && console) { + console->attach(); + console->onFrame(); //FIXME: If not cleared, clicking again will start the console event.kbd.keycode = Common::KEYCODE_INVALID; event.kbd.flags = 0; diff --git a/engines/agi/preagi.h b/engines/agi/preagi.h index d0aea0e77a..14ff483d9f 100644 --- a/engines/agi/preagi.h +++ b/engines/agi/preagi.h @@ -66,8 +66,6 @@ protected: } PictureMgr *_picture; - PreAGI_Console *_console; - GUI::Debugger *getDebugger() { return _console; } void clearImageStack() {} void recordImageStackCall(uint8 type, int16 p1, int16 p2, int16 p3, diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp index 3164011edb..6d1eb445a2 100644 --- a/engines/agi/preagi_mickey.cpp +++ b/engines/agi/preagi_mickey.cpp @@ -2247,10 +2247,11 @@ void MickeyEngine::debugGotoRoom(int room) { } MickeyEngine::MickeyEngine(OSystem *syst, const AGIGameDescription *gameDesc) : PreAgiEngine(syst, gameDesc) { - _console = new Mickey_Console(this); + _console = new MickeyConsole(this); } MickeyEngine::~MickeyEngine() { + delete _console; } void MickeyEngine::init() { diff --git a/engines/agi/preagi_mickey.h b/engines/agi/preagi_mickey.h index 788cfab144..673839a592 100644 --- a/engines/agi/preagi_mickey.h +++ b/engines/agi/preagi_mickey.h @@ -689,7 +689,11 @@ public: void drawPic(int); void drawObj(ENUM_MSA_OBJECT, int, int); + GUI::Debugger *getDebugger() { return _console; } + protected: + MickeyConsole *_console; + MSA_GAME _gameStateMickey; bool _clickToMove; diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp index 2c7f50ce0d..fee8fde2b3 100644 --- a/engines/agi/preagi_winnie.cpp +++ b/engines/agi/preagi_winnie.cpp @@ -1306,7 +1306,7 @@ void WinnieEngine::debugCurRoom() { } WinnieEngine::WinnieEngine(OSystem *syst, const AGIGameDescription *gameDesc) : PreAgiEngine(syst, gameDesc) { - _console = new Winnie_Console(this); + _console = new WinnieConsole(this); } WinnieEngine::~WinnieEngine() { diff --git a/engines/agi/preagi_winnie.h b/engines/agi/preagi_winnie.h index 34efcfa50d..96ae65997e 100644 --- a/engines/agi/preagi_winnie.h +++ b/engines/agi/preagi_winnie.h @@ -291,7 +291,11 @@ public: void debugCurRoom(); + GUI::Debugger *getDebugger() { return _console; } + private: + WinnieConsole *_console; + WTP_SAVE_GAME _gameStateWinnie; int _room; int _mist; -- cgit v1.2.3