From 35098dbd9fac1c5bc70c9711c8779b439ec6d294 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 26 Apr 2006 00:59:13 +0000 Subject: Introduce and use Engine_Empty() and Engine::GUIErrorMessage() svn-id: r22165 --- base/engine.cpp | 15 +++++++++++++++ base/engine.h | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'base') diff --git a/base/engine.cpp b/base/engine.cpp index a01a7df533..55cbf2f65b 100644 --- a/base/engine.cpp +++ b/base/engine.cpp @@ -248,3 +248,18 @@ void checkHeap() { } #endif } + +void Engine::GUIErrorMessage(const Common::String msg) { + _system->setWindowCaption("Error"); + _system->beginGFXTransaction(); + initCommonGFX(false); + _system->initSize(320, 200, 2); + _system->endGFXTransaction(); + + GUI::MessageDialog dialog(msg); + dialog.runModal(); +} + +Engine_Empty::Engine_Empty(OSystem *syst, const Common::String msg) : Engine(syst), _message(msg) { +} + diff --git a/base/engine.h b/base/engine.h index 73d4264883..73d1a9cd3b 100644 --- a/base/engine.h +++ b/base/engine.h @@ -77,8 +77,32 @@ public: /* Indicate if an autosave should be performed */ bool shouldPerformAutoSave(int lastSaveTime); + + /** Initialized graphics and shows error message */ + void GUIErrorMessage(const Common::String msg); }; +// Used when no valid game was found in the directory +// Just pops up an error message and returns to launcher +class Engine_Empty : public Engine { +public: + Engine_Empty(OSystem *syst, const Common::String msg = "No valid games were found in specified directory."); + virtual ~Engine_Empty() {} + + // Displays error message + int init() { GUIErrorMessage(_message); return 0; } + + // Just indicate that we want return to launcher + int go() { return 1; } + + void errorString(char *buf_input, char *buf_output) {} + +private: + Common::String _message; +}; + + + extern Engine *g_engine; #endif -- cgit v1.2.3