diff options
author | Max Horn | 2009-11-24 22:11:07 +0000 |
---|---|---|
committer | Max Horn | 2009-11-24 22:11:07 +0000 |
commit | 1a313a7eca87e9c135171d404ff10a90718f8c4c (patch) | |
tree | 418528e4834f748973f5c38ee48aaed583933f19 /engines | |
parent | 5e0f79a2edd388dd727ecf6377bc6b8f37c577ed (diff) | |
download | scummvm-rg350-1a313a7eca87e9c135171d404ff10a90718f8c4c.tar.gz scummvm-rg350-1a313a7eca87e9c135171d404ff10a90718f8c4c.tar.bz2 scummvm-rg350-1a313a7eca87e9c135171d404ff10a90718f8c4c.zip |
COMMON: Remove dependency on engines code (by using the inversion principle).
svn-id: r46130
Diffstat (limited to 'engines')
-rw-r--r-- | engines/engine.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/engines/engine.cpp b/engines/engine.cpp index 3c659a5d9e..d8aeb88278 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -31,11 +31,13 @@ #include "engines/engine.h" #include "common/config-manager.h" +#include "common/debug.h" #include "common/events.h" #include "common/file.h" #include "common/timer.h" #include "common/savefile.h" #include "common/system.h" +#include "gui/debugger.h" #include "gui/message.h" #include "gui/GuiManager.h" #include "sound/mixer.h" @@ -49,6 +51,32 @@ extern bool isSmartphone(); // FIXME: HACK for MidiEmu & error() Engine *g_engine = 0; +// Output formatter for debug() and error() which invokes +// the errorString method of the active engine, if any. +static void defaultOutputFormatter(char *dst, const char *src, size_t dstSize) { + if (g_engine) { + g_engine->errorString(src, dst, dstSize); + } else { + strncpy(dst, src, dstSize); + } +} + +static void defaultErrorHandler(const char *msg) { + // Unless this error -originated- within the debugger itself, we + // now invoke the debugger, if available / supported. + if (g_engine) { + GUI::Debugger *debugger = g_engine->getDebugger(); +#ifdef _WIN32_WCE + if (isSmartphone()) + debugger = 0; +#endif + if (debugger && !debugger->isAttached()) { + debugger->attach(msg); + debugger->onFrame(); + } + } +} + Engine::Engine(OSystem *syst) : _system(syst), @@ -62,6 +90,9 @@ Engine::Engine(OSystem *syst) _mainMenuDialog(NULL) { g_engine = this; + Common::setDebugOutputFormatter(defaultOutputFormatter); + Common::setErrorOutputFormatter(defaultOutputFormatter); + Common::setErrorHandler(defaultErrorHandler); // FIXME: Get rid of the following again. It is only here temporarily. // We really should never run with a non-working Mixer, so ought to handle |