diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/engine.cpp | 31 | ||||
-rw-r--r-- | engines/engine.h | 28 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 3 |
3 files changed, 61 insertions, 1 deletions
diff --git a/engines/engine.cpp b/engines/engine.cpp index c63437f800..24008dd073 100644 --- a/engines/engine.cpp +++ b/engines/engine.cpp @@ -45,6 +45,7 @@ #include "common/taskbar.h" #include "common/textconsole.h" #include "common/translation.h" +#include "common/singleton.h" #include "backends/keymapper/keymapper.h" @@ -101,6 +102,36 @@ static void defaultErrorHandler(const char *msg) { } } +// Chained games manager + +ChainedGamesManager::ChainedGamesManager() { + clear(); +} + +void ChainedGamesManager::clear() { + _chainedGames.clear(); +} + +void ChainedGamesManager::push(const Common::String target, const int slot) { + Game game; + game.target = target; + game.slot = slot; + _chainedGames.push(game); +} + +bool ChainedGamesManager::pop(Common::String &target, int &slot) { + if (_chainedGames.empty()) { + return false; + } + Game game = _chainedGames.pop(); + target = game.target; + slot = game.slot; + return true; +} + +namespace Common { +DECLARE_SINGLETON(ChainedGamesManager); +} Engine::Engine(OSystem *syst) : _system(syst), diff --git a/engines/engine.h b/engines/engine.h index e325cc1ba2..d3415d584c 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -27,6 +27,8 @@ #include "common/str.h" #include "common/language.h" #include "common/platform.h" +#include "common/queue.h" +#include "common/singleton.h" class OSystem; @@ -334,6 +336,32 @@ protected: }; +// Chained games + +/** + * Singleton class which manages chained games. A chained game is one that + * starts automatically, optionally loading a saved game, instead of returning + * to the launcher. + */ +class ChainedGamesManager : public Common::Singleton<ChainedGamesManager> { +private: + struct Game { + Common::String target; + int slot; + }; + + Common::Queue<Game> _chainedGames; + +public: + ChainedGamesManager(); + void clear(); + void push(const Common::String target, const int slot = -1); + bool pop(Common::String &target, int &slot); +}; + +/** Convenience shortcut for accessing the chained games manager. */ +#define ChainedGamesMan ChainedGamesManager::instance() + // FIXME: HACK for MidiEmu & error() extern Engine *g_engine; diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index 34ae957951..9518ed4e5c 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -2625,7 +2625,8 @@ bool ScummEngine::startManiac() { // Set up the chanined games to Maniac Mansion, and then back // to the current game again with that save slot. - ConfMan.set("chained_games", maniacTarget + "," + ConfMan.getActiveDomainName() + ":100", Common::ConfigManager::kTransientDomain); + ChainedGamesMan.push(maniacTarget); + ChainedGamesMan.push(ConfMan.getActiveDomainName(), 100); // Force a return to the launcher. This will start the first // chained game. |