diff options
author | Paul Gilbert | 2018-12-31 22:32:07 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-31 22:32:07 -0800 |
commit | 4938ac9ea1b207f100a73e2ecbf617b7569fb4b0 (patch) | |
tree | 1268a49b90a5c7b8744ff266b5d5daef006c141a /engines | |
parent | fa51ea2138831f4f87f0d66a7f32f32c2942b8e6 (diff) | |
download | scummvm-rg350-4938ac9ea1b207f100a73e2ecbf617b7569fb4b0.tar.gz scummvm-rg350-4938ac9ea1b207f100a73e2ecbf617b7569fb4b0.tar.bz2 scummvm-rg350-4938ac9ea1b207f100a73e2ecbf617b7569fb4b0.zip |
GLK: Implement passing detection options to the engines
Diffstat (limited to 'engines')
-rw-r--r-- | engines/glk/detection.cpp | 28 | ||||
-rw-r--r-- | engines/glk/frotz/config.cpp | 6 | ||||
-rw-r--r-- | engines/glk/frotz/config.h | 5 | ||||
-rw-r--r-- | engines/glk/frotz/detection.cpp | 7 | ||||
-rw-r--r-- | engines/glk/frotz/detection.h | 7 | ||||
-rw-r--r-- | engines/glk/frotz/frotz.cpp | 2 | ||||
-rw-r--r-- | engines/glk/glk.h | 6 |
7 files changed, 50 insertions, 11 deletions
diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp index a1786d047c..4c0932a561 100644 --- a/engines/glk/detection.cpp +++ b/engines/glk/detection.cpp @@ -63,6 +63,18 @@ bool Glk::GlkEngine::hasFeature(EngineFeature f) const { (f == kSupportsSavingDuringRuntime); } +template<class META, class ENG>Engine *create(OSystem *syst, Glk::GlkGameDescription &gameDesc) { + Glk::GameDescriptor gd = META::findGame(gameDesc._gameId.c_str()); + if (gd._description) { + gameDesc._options = gd._options; + return new ENG(syst, gameDesc); + } else { + return nullptr; + } +} + +#define CREATE(META, ENG) if (!(*engine = create<META, ENG>(syst, gameDesc))) + Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) const { Glk::GameDescriptor td = Glk::GameDescriptor::empty(); assert(engine); @@ -96,15 +108,11 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons f.close(); // Create the correct engine - if (Glk::Alan2::Alan2MetaEngine::findGame(gameDesc._gameId.c_str())._description) { - *engine = new Glk::Alan2::Alan2(syst, gameDesc); - } else if (Glk::Frotz::FrotzMetaEngine::findGame(gameDesc._gameId.c_str())._description) { - *engine = new Glk::Frotz::Frotz(syst, gameDesc); - } else if (Glk::Glulxe::GlulxeMetaEngine::findGame(gameDesc._gameId.c_str())._description) { - *engine = new Glk::Glulxe::Glulxe(syst, gameDesc); - } else if (Glk::Scott::ScottMetaEngine::findGame(gameDesc._gameId.c_str())._description) { - *engine = new Glk::Scott::Scott(syst, gameDesc); - } else if ((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str()))._description) { + CREATE(Glk::Alan2::Alan2MetaEngine, Glk::Alan2::Alan2) + CREATE(Glk::Frotz::FrotzMetaEngine, Glk::Frotz::Frotz) + CREATE(Glk::Glulxe::GlulxeMetaEngine, Glk::Glulxe::Glulxe) + CREATE(Glk::Scott::ScottMetaEngine, Glk::Scott::Scott) + if (!((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str()))._description)) { if (td._options & Glk::TADS::OPTION_TADS3) *engine = new Glk::TADS::TADS3::TADS3(syst, gameDesc); else @@ -116,6 +124,8 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons return Common::kNoError; } +#undef CREATE + Common::String GlkMetaEngine::findFileByGameId(const Common::String &gameId) const { // Get the list of files in the folder and return detection against them Common::FSNode folder = Common::FSNode(ConfMan.get("path")); diff --git a/engines/glk/frotz/config.cpp b/engines/glk/frotz/config.cpp index 1d0264bc8e..aff46792d3 100644 --- a/engines/glk/frotz/config.cpp +++ b/engines/glk/frotz/config.cpp @@ -21,6 +21,8 @@ */ #include "glk/frotz/config.h" +#include "glk/frotz/detection.h" +#include "glk/glk.h" #include "common/config-manager.h" #include "common/textconsole.h" @@ -162,5 +164,9 @@ UserOptions::UserOptions() : _undo_slots(MAX_UNDO_SLOTS), _sound(true), _quetzal _defaultBackground = getConfigInt("background", 0x000080, 0xffffff); } +bool UserOptions::isInfocom() const { + return g_vm->getOptions() & OPTION_INFOCOM; +} + } // End of namespace Scott } // End of namespace Glk diff --git a/engines/glk/frotz/config.h b/engines/glk/frotz/config.h index 17e787de3b..1086d7e51f 100644 --- a/engines/glk/frotz/config.h +++ b/engines/glk/frotz/config.h @@ -155,6 +155,11 @@ struct UserOptions { * Constructor */ UserOptions(); + + /** + * Returns true if the game being played is one of the original Infocom releases + */ + bool isInfocom() const; }; /** diff --git a/engines/glk/frotz/detection.cpp b/engines/glk/frotz/detection.cpp index 57e2961fd7..273ca37342 100644 --- a/engines/glk/frotz/detection.cpp +++ b/engines/glk/frotz/detection.cpp @@ -41,8 +41,11 @@ void FrotzMetaEngine::getSupportedGames(PlainGameList &games) { GameDescriptor FrotzMetaEngine::findGame(const char *gameId) { for (const PlainGameDescriptor *pd = INFOCOM_GAME_LIST; pd->gameId; ++pd) { - if (!strcmp(gameId, pd->gameId)) - return *pd; + if (!strcmp(gameId, pd->gameId)) { + GameDescriptor gd(*pd); + gd._options |= OPTION_INFOCOM; + return gd; + } } for (const PlainGameDescriptor *pd = ZCODE_GAME_LIST; pd->gameId; ++pd) { if (!strcmp(gameId, pd->gameId)) diff --git a/engines/glk/frotz/detection.h b/engines/glk/frotz/detection.h index e0163bc9f7..7943385aa9 100644 --- a/engines/glk/frotz/detection.h +++ b/engines/glk/frotz/detection.h @@ -32,6 +32,13 @@ namespace Glk { namespace Frotz { +/** + * Game descriptor detection options + */ +enum DetectionOption { + OPTION_INFOCOM = 1 +}; + class FrotzMetaEngine { public: /** diff --git a/engines/glk/frotz/frotz.cpp b/engines/glk/frotz/frotz.cpp index c2341d4026..3d6bf6c9f9 100644 --- a/engines/glk/frotz/frotz.cpp +++ b/engines/glk/frotz/frotz.cpp @@ -48,6 +48,8 @@ void Frotz::runGame(Common::SeekableReadStream *gameFile) { story_fp = gameFile; initialize(); + debug("Game %s an Infocom original", isInfocom() ? "is" : "isn't"); + // If save was selected from the launcher, handle loading it int saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; if (saveSlot != -1) { diff --git a/engines/glk/glk.h b/engines/glk/glk.h index 55066e2cde..91a6371e98 100644 --- a/engines/glk/glk.h +++ b/engines/glk/glk.h @@ -60,6 +60,7 @@ struct GlkGameDescription { Common::Platform _platform; Common::String _filename; Common::String _md5; + uint _options; }; /** @@ -164,6 +165,11 @@ public: const Common::String &getFilename() const { return _gameDescription._filename; } /** + * Returns any options returned with the game's detection entry + */ + const uint getOptions() const { return _gameDescription._options; } + + /** * Return the game engine's target name */ const Common::String &getTargetName() const { |