From 5f626f7a6abbcc2ec18cc50df1ce5ba705f967cd Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 17 Oct 2018 22:45:25 -0700 Subject: GLK: Add detection logic needed for engine startup --- engines/gargoyle/detection.cpp | 29 ++++++++++++++++++++++++++++- engines/gargoyle/gargoyle.cpp | 7 +++++-- engines/gargoyle/gargoyle.h | 24 ++++++++++++++++++++++++ engines/gargoyle/scott/detection.cpp | 2 ++ 4 files changed, 59 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/gargoyle/detection.cpp b/engines/gargoyle/detection.cpp index f86e34cd21..b7a32a780a 100644 --- a/engines/gargoyle/detection.cpp +++ b/engines/gargoyle/detection.cpp @@ -37,9 +37,13 @@ namespace Gargoyle { struct GargoyleGameDescription { ADGameDescription desc; + Common::String filename; InterpreterType interpType; }; +const Common::String &GargoyleEngine::getFilename() const { + return _gameDescription->filename; +} uint32 GargoyleEngine::getFeatures() const { return _gameDescription->desc.flags; } @@ -63,6 +67,7 @@ static const PlainGameDescriptor gargoyleGames[] = { {0, 0} }; +#include "common/config-manager.h" #include "gargoyle/detection_tables.h" #include "gargoyle/scott/detection.h" #include "gargoyle/scott/scott.h" @@ -89,6 +94,8 @@ public: SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const; virtual DetectedGames detectGames(const Common::FSList &fslist) const override; + + virtual ADDetectedGames detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const override; }; bool GargoyleMetaEngine::hasFeature(MetaEngineFeature f) const { @@ -108,7 +115,9 @@ bool Gargoyle::GargoyleEngine::hasFeature(EngineFeature f) const { } bool GargoyleMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { - const Gargoyle::GargoyleGameDescription *gd = (const Gargoyle::GargoyleGameDescription *)desc; + Gargoyle::GargoyleGameDescription *gd = (Gargoyle::GargoyleGameDescription *)desc; + gd->filename = ConfMan.get("filename"); + switch (gd->interpType) { case Gargoyle::INTERPRETER_SCOTT: *engine = new Gargoyle::Scott::Scott(syst, gd); @@ -143,6 +152,24 @@ DetectedGames GargoyleMetaEngine::detectGames(const Common::FSList &fslist) cons return detectedGames; } +static Gargoyle::GargoyleGameDescription gameDescription; + +ADDetectedGames GargoyleMetaEngine::detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const { + ADDetectedGames detectedGames; + static char gameId[100]; + strcpy(gameId, ConfMan.get("gameid").c_str()); + + gameDescription.desc.gameId = gameId; + gameDescription.desc.language = language; + gameDescription.desc.platform = platform; + gameDescription.desc.extra = extra.c_str(); + gameDescription.filename = ConfMan.get("filename"); + + ADDetectedGame dg((ADGameDescription *)&gameDescription); + detectedGames.push_back(dg); + return detectedGames; +} + #if PLUGIN_ENABLED_DYNAMIC(GARGOYLE) REGISTER_PLUGIN_DYNAMIC(Gargoyle, PLUGIN_TYPE_ENGINE, GargoyleMetaEngine); #else diff --git a/engines/gargoyle/gargoyle.cpp b/engines/gargoyle/gargoyle.cpp index 7953c684f8..561f14ae01 100644 --- a/engines/gargoyle/gargoyle.cpp +++ b/engines/gargoyle/gargoyle.cpp @@ -24,6 +24,7 @@ #include "common/config-manager.h" #include "common/debug-channels.h" #include "common/events.h" +#include "common/file.h" #include "engines/util.h" #include "graphics/scaler.h" #include "graphics/thumbnail.h" @@ -54,8 +55,10 @@ void GargoyleEngine::initialize() { Common::Error GargoyleEngine::run() { initialize(); - // TODO: Pass proper gamefile - runGame(nullptr); + Common::File f; + if (!f.open(getFilename())) + error("Could not open game file"); + runGame(&f); return Common::kNoError; } diff --git a/engines/gargoyle/gargoyle.h b/engines/gargoyle/gargoyle.h index 37c1a22196..3cfee29c87 100644 --- a/engines/gargoyle/gargoyle.h +++ b/engines/gargoyle/gargoyle.h @@ -75,6 +75,10 @@ protected: // Engine APIs virtual Common::Error run(); + + /** + * Returns true whether a given feature is supported by the engine + */ virtual bool hasFeature(EngineFeature f) const; /** @@ -85,10 +89,30 @@ public: GargoyleEngine(OSystem *syst, const GargoyleGameDescription *gameDesc); virtual ~GargoyleEngine(); + /** + * Returns the bitset of game features + */ uint32 getFeatures() const; + + /** + * Returns whether the game is a demo + */ bool isDemo() const; + + /** + * Returns the language + */ Common::Language getLanguage() const; + + /** + * Returns the running interpreter type + */ InterpreterType getInterpreterType() const; + + /** + * Returns the primary filename for the game + */ + const Common::String &GargoyleEngine::getFilename() const; }; } // End of namespace Gargoyle diff --git a/engines/gargoyle/scott/detection.cpp b/engines/gargoyle/scott/detection.cpp index fdf659e7b7..d2ed4391d0 100644 --- a/engines/gargoyle/scott/detection.cpp +++ b/engines/gargoyle/scott/detection.cpp @@ -58,6 +58,8 @@ void ScottMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &g if (p->_filesize) { // Found a match DetectedGame gd("scott", p->_desc, Common::EN_ANY, Common::kPlatformUnknown, "Scott"); + gd.addExtraEntry("filename", file->getName()); + gameList.push_back(gd); } -- cgit v1.2.3