diff options
author | Eugene Sandulenko | 2006-04-26 00:59:13 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2006-04-26 00:59:13 +0000 |
commit | 35098dbd9fac1c5bc70c9711c8779b439ec6d294 (patch) | |
tree | f993191126832324c8204ebc01697d58009765a9 | |
parent | d53348797fe32ce9685a97ebca374bd08e37ea7d (diff) | |
download | scummvm-rg350-35098dbd9fac1c5bc70c9711c8779b439ec6d294.tar.gz scummvm-rg350-35098dbd9fac1c5bc70c9711c8779b439ec6d294.tar.bz2 scummvm-rg350-35098dbd9fac1c5bc70c9711c8779b439ec6d294.zip |
Introduce and use Engine_Empty() and Engine::GUIErrorMessage()
svn-id: r22165
-rw-r--r-- | base/engine.cpp | 15 | ||||
-rw-r--r-- | base/engine.h | 24 | ||||
-rw-r--r-- | engines/saga/saga.cpp | 10 | ||||
-rw-r--r-- | engines/scumm/plugin.cpp | 2 | ||||
-rw-r--r-- | engines/simon/simon.cpp | 9 |
5 files changed, 42 insertions, 18 deletions
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 diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp index cec8e3a939..322b013a68 100644 --- a/engines/saga/saga.cpp +++ b/engines/saga/saga.cpp @@ -53,8 +53,6 @@ #include "saga/objectmap.h" #include "saga/resnames.h" -#include "gui/message.h" - namespace Saga { #define MAX_TIME_DELTA 100 @@ -162,13 +160,7 @@ int SagaEngine::init() { // Detect game and open resource files if (!initGame()) { - _system->beginGFXTransaction(); - initCommonGFX(false); - _system->initSize(320, 200, 2); - _system->endGFXTransaction(); - GUI::MessageDialog dialog("No valid games were found in the specified directory."); - dialog.runModal(); - + GUIErrorMessage("No valid games were found in the specified directory."); return FAILURE; } diff --git a/engines/scumm/plugin.cpp b/engines/scumm/plugin.cpp index 4703bf2ab0..e3000cb4fe 100644 --- a/engines/scumm/plugin.cpp +++ b/engines/scumm/plugin.cpp @@ -1314,7 +1314,7 @@ Engine *Engine_SCUMM_create(OSystem *syst) { // Unable to locate game data if (results.empty()) { warning("ScummEngine: unable to locate game data"); - return 0; + return new Engine_Empty(syst); } DetectorResult res(*(results.begin())); diff --git a/engines/simon/simon.cpp b/engines/simon/simon.cpp index 26fa3f8025..ec2127645c 100644 --- a/engines/simon/simon.cpp +++ b/engines/simon/simon.cpp @@ -31,7 +31,6 @@ #include "common/system.h" #include "gui/about.h" -#include "gui/message.h" #include "simon/simon.h" #include "simon/intern.h" @@ -404,13 +403,7 @@ int SimonEngine::init() { // Detect game if (!initGame()) { - _system->beginGFXTransaction(); - initCommonGFX(false); - _system->initSize(320, 200, 2); - _system->endGFXTransaction(); - GUI::MessageDialog dialog("No valid games were found in the specified directory."); - dialog.runModal(); - + GUIErrorMessage("No valid games were found in the specified directory."); return -1; } |