From 367cb511d153c6d4733a65b153506b7f0e8b01b3 Mon Sep 17 00:00:00 2001 From: Walter van Niftrik Date: Sat, 26 Mar 2016 23:26:22 +0100 Subject: ADL: Add Console --- engines/adl/adl.cpp | 11 ++++++++++- engines/adl/adl.h | 6 +++++- engines/adl/console.cpp | 31 +++++++++++++++++++++++++++++++ engines/adl/console.h | 42 ++++++++++++++++++++++++++++++++++++++++++ engines/adl/module.mk | 1 + 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 engines/adl/console.cpp create mode 100644 engines/adl/console.h diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp index db2d9d69c5..c9673bd1d5 100644 --- a/engines/adl/adl.cpp +++ b/engines/adl/adl.cpp @@ -47,6 +47,7 @@ AdlEngine::~AdlEngine() { delete _display; delete _graphics; delete _speaker; + delete _console; } AdlEngine::AdlEngine(OSystem *syst, const AdlGameDescription *gd) : @@ -64,7 +65,9 @@ AdlEngine::AdlEngine(OSystem *syst, const AdlGameDescription *gd) : _canRestoreNow(false) { } -bool AdlEngine::pollEvent(Common::Event &event) { +bool AdlEngine::pollEvent(Common::Event &event) const { + _console->onFrame(); + if (g_system->getEventManager()->pollEvent(event)) { if (event.type != Common::EVENT_KEYDOWN) return false; @@ -74,6 +77,11 @@ bool AdlEngine::pollEvent(Common::Event &event) { quitGame(); return false; } + + if (event.kbd.keycode == Common::KEYCODE_d) { + _console->attach(); + return false; + } } return true; @@ -493,6 +501,7 @@ void AdlEngine::dropItem(byte noun) { } Common::Error AdlEngine::run() { + _console = new Console(this); _speaker = new Speaker(); _display = new Display(); diff --git a/engines/adl/adl.h b/engines/adl/adl.h index 4751ed6e91..d9fc5908b4 100644 --- a/engines/adl/adl.h +++ b/engines/adl/adl.h @@ -35,6 +35,7 @@ #include "audio/mixer.h" #include "audio/softsynth/pcspk.h" +#include "adl/console.h" #include "adl/disk.h" namespace Common { @@ -46,6 +47,7 @@ struct Event; namespace Adl { +class Console; class Display; class GraphicsMan; class Speaker; @@ -172,7 +174,7 @@ class AdlEngine : public Engine { public: virtual ~AdlEngine(); - static bool pollEvent(Common::Event &event); + bool pollEvent(Common::Event &event) const; protected: AdlEngine(OSystem *syst, const AdlGameDescription *gd); @@ -320,6 +322,8 @@ private: Common::String getWord(const Common::String &line, uint &index) const; void getInput(uint &verb, uint &noun); + Console *_console; + GUI::Debugger *getDebugger() { return _console; } const AdlGameDescription *_gameDescription; byte _saveVerb, _saveNoun, _restoreVerb, _restoreNoun; bool _canSaveNow, _canRestoreNow; diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp new file mode 100644 index 0000000000..e051716a6c --- /dev/null +++ b/engines/adl/console.cpp @@ -0,0 +1,31 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "adl/console.h" + +namespace Adl { + +Console::Console(AdlEngine *engine) : GUI::Debugger() { + _engine = engine; +} + +} // End of namespace Adl diff --git a/engines/adl/console.h b/engines/adl/console.h new file mode 100644 index 0000000000..56c84f08fa --- /dev/null +++ b/engines/adl/console.h @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef ADL_CONSOLE_H +#define ADL_CONSOLE_H + +#include "gui/debugger.h" + +namespace Adl { + +class AdlEngine; + +class Console : public GUI::Debugger { +public: + Console(AdlEngine *engine); + +private: + AdlEngine *_engine; +}; + +} // End of namespace Adl + +#endif diff --git a/engines/adl/module.mk b/engines/adl/module.mk index 661d1b1991..7f097a42d5 100644 --- a/engines/adl/module.mk +++ b/engines/adl/module.mk @@ -3,6 +3,7 @@ MODULE := engines/adl MODULE_OBJS := \ adl.o \ adl_v2.o \ + console.o \ detection.o \ disk.o \ display.o \ -- cgit v1.2.3