mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 17:29:11 +00:00
GLK: Split detection features & adapt to new plugins.
- Additionally, adapt to renaming glulxe -> glulx
This commit is contained in:
parent
27d16ba9c5
commit
92839dce1c
2
configure
vendored
2
configure
vendored
@ -6170,7 +6170,7 @@ declare -a static_detect_engines=("PLUMBERS" "AGI" "SCUMM" "SKY" "DREAMWEB" "DRA
|
||||
"TEENAGENT" "TESTBED" "TINSEL" "TITANIC" "TOLTECS" "TONY" "TOON"
|
||||
"TOUCHE" "TSAGE" "TUCKER" "VOYEUR" "WAGE" "AVALANCHE" "BBVS"
|
||||
"BLADERUNNER" "CHEWY" "CINE" "CRUISE" "CRYO" "CRYOMNI3D" "DIRECTOR"
|
||||
"FULLPIPE" "SAGA" "XEEN" "WINTERMUTE" "SCI" "MOHAWK" "ULTIMA")
|
||||
"FULLPIPE" "SAGA" "XEEN" "WINTERMUTE" "SCI" "MOHAWK" "ULTIMA" "GLK")
|
||||
detectId="_DETECTION"
|
||||
|
||||
echo "Creating engines/plugins_table.h"
|
||||
|
@ -20,44 +20,35 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "glk/glk.h"
|
||||
#include "base/plugins.h"
|
||||
#include "common/md5.h"
|
||||
#include "common/memstream.h"
|
||||
#include "common/str-array.h"
|
||||
#include "common/file.h"
|
||||
#include "common/translation.h"
|
||||
#include "common/config-manager.h"
|
||||
|
||||
#include "glk/detection.h"
|
||||
#include "glk/quetzal.h"
|
||||
#include "glk/game_description.h"
|
||||
|
||||
#include "glk/adrift/detection.h"
|
||||
#include "glk/adrift/adrift.h"
|
||||
#include "glk/advsys/detection.h"
|
||||
#include "glk/advsys/advsys.h"
|
||||
#include "glk/agt/detection.h"
|
||||
#include "glk/agt/agt.h"
|
||||
#include "glk/alan2/detection.h"
|
||||
#include "glk/alan2/alan2.h"
|
||||
#include "glk/alan3/detection.h"
|
||||
#include "glk/alan3/alan3.h"
|
||||
#include "glk/archetype/archetype.h"
|
||||
#include "glk/archetype/detection.h"
|
||||
#include "glk/zcode/detection.h"
|
||||
#include "glk/zcode/zcode.h"
|
||||
#include "glk/hugo/detection.h"
|
||||
#include "glk/hugo/hugo.h"
|
||||
#include "glk/jacl/detection.h"
|
||||
#include "glk/jacl/jacl.h"
|
||||
#include "glk/level9/detection.h"
|
||||
#include "glk/level9/level9.h"
|
||||
#include "glk/magnetic/detection.h"
|
||||
#include "glk/magnetic/magnetic.h"
|
||||
#include "glk/quest/detection.h"
|
||||
#include "glk/quest/quest.h"
|
||||
#include "glk/scott/detection.h"
|
||||
#include "glk/scott/scott.h"
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
#include "glk/comprehend/comprehend.h"
|
||||
#include "glk/comprehend/detection.h"
|
||||
#include "glk/glulx/detection.h"
|
||||
#include "glk/glulx/glulx.h"
|
||||
#include "glk/tads/detection.h"
|
||||
#include "glk/tads/tads2/tads2.h"
|
||||
#include "glk/tads/tads3/tads3.h"
|
||||
#endif
|
||||
|
||||
#include "base/plugins.h"
|
||||
@ -123,144 +114,6 @@ GlkDetectedGame::GlkDetectedGame(const char *id, const char *desc, const Common:
|
||||
|
||||
} // End of namespace Glk
|
||||
|
||||
bool GlkMetaEngine::hasFeature(MetaEngineFeature f) const {
|
||||
return
|
||||
(f == kSupportsListSaves) ||
|
||||
(f == kSupportsLoadingDuringStartup) ||
|
||||
(f == kSupportsDeleteSave) ||
|
||||
(f == kSavesSupportMetaInfo) ||
|
||||
(f == kSavesSupportCreationDate) ||
|
||||
(f == kSavesSupportPlayTime) ||
|
||||
(f == kSimpleSavesNames);
|
||||
}
|
||||
|
||||
bool Glk::GlkEngine::hasFeature(EngineFeature f) const {
|
||||
return
|
||||
(f == kSupportsReturnToLauncher) ||
|
||||
(f == kSupportsLoadingDuringRuntime) ||
|
||||
(f == kSupportsSavingDuringRuntime);
|
||||
}
|
||||
|
||||
bool isGameAllowed(GameSupportLevel supportLevel) {
|
||||
bool showTestingWarning = false;
|
||||
#ifdef RELEASE_BUILD
|
||||
showTestingWarning = true;
|
||||
#endif
|
||||
|
||||
if (((supportLevel == kUnstableGame
|
||||
|| (supportLevel == kTestingGame && showTestingWarning)))
|
||||
&& !Engine::warnUserAboutUnsupportedGame())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class META, class ENG>bool create(OSystem *syst,
|
||||
Glk::GlkGameDescription &gameDesc, Engine *&engine) {
|
||||
|
||||
Glk::GameDescriptor gd = META::findGame(gameDesc._gameId.c_str());
|
||||
if (gd._description) {
|
||||
if (!isGameAllowed(gd._supportLevel))
|
||||
return true;
|
||||
|
||||
gameDesc._options = gd._options;
|
||||
engine = new ENG(syst, gameDesc);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
|
||||
#ifndef RELEASE_BUILD
|
||||
Glk::GameDescriptor td = Glk::GameDescriptor::empty();
|
||||
#endif
|
||||
assert(engine);
|
||||
|
||||
// Populate the game description
|
||||
Glk::GlkGameDescription gameDesc;
|
||||
gameDesc._gameId = ConfMan.get("gameid");
|
||||
gameDesc._filename = ConfMan.get("filename");
|
||||
|
||||
gameDesc._language = Common::UNK_LANG;
|
||||
gameDesc._platform = Common::kPlatformUnknown;
|
||||
if (ConfMan.hasKey("language"))
|
||||
gameDesc._language = Common::parseLanguage(ConfMan.get("language"));
|
||||
if (ConfMan.hasKey("platform"))
|
||||
gameDesc._platform = Common::parsePlatform(ConfMan.get("platform"));
|
||||
|
||||
// If the game description has no filename, the engine has been launched directly from
|
||||
// the command line. Do a scan for supported games for that Id in the game folder
|
||||
if (gameDesc._filename.empty()) {
|
||||
gameDesc._filename = findFileByGameId(gameDesc._gameId);
|
||||
if (gameDesc._filename.empty())
|
||||
return Common::kNoGameDataFoundError;
|
||||
}
|
||||
|
||||
// Get the MD5
|
||||
Common::File f;
|
||||
if (!f.open(Common::FSNode(ConfMan.get("path")).getChild(gameDesc._filename)))
|
||||
return Common::kNoGameDataFoundError;
|
||||
|
||||
gameDesc._md5 = Common::computeStreamMD5AsString(f, 5000);
|
||||
f.close();
|
||||
|
||||
// Create the correct engine
|
||||
*engine = nullptr;
|
||||
if ((create<Glk::Adrift::AdriftMetaEngine, Glk::Adrift::Adrift>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::AdvSys::AdvSysMetaEngine, Glk::AdvSys::AdvSys>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::AGT::AGTMetaEngine, Glk::AGT::AGT>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Alan2::Alan2MetaEngine, Glk::Alan2::Alan2>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Alan3::Alan3MetaEngine, Glk::Alan3::Alan3>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Archetype::ArchetypeMetaEngine, Glk::Archetype::Archetype>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Hugo::HugoMetaEngine, Glk::Hugo::Hugo>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::JACL::JACLMetaEngine, Glk::JACL::JACL>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Level9::Level9MetaEngine, Glk::Level9::Level9>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Magnetic::MagneticMetaEngine, Glk::Magnetic::Magnetic>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Quest::QuestMetaEngine, Glk::Quest::Quest>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Scott::ScottMetaEngine, Glk::Scott::Scott>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::ZCode::ZCodeMetaEngine, Glk::ZCode::ZCode>(syst, gameDesc, *engine))) {}
|
||||
#ifndef RELEASE_BUILD
|
||||
else if ((create<Glk::Comprehend::ComprehendMetaEngine, Glk::Comprehend::Comprehend>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Glulx::GlulxMetaEngine, Glk::Glulx::Glulx>(syst, gameDesc, *engine))) {}
|
||||
else if ((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str()))._description) {
|
||||
if (!isGameAllowed(td._supportLevel))
|
||||
return Common::kUserCanceled;
|
||||
else if (td._options & Glk::TADS::OPTION_TADS3)
|
||||
new Glk::TADS::TADS3::TADS3(syst, gameDesc);
|
||||
else
|
||||
new Glk::TADS::TADS2::TADS2(syst, gameDesc);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
return Common::kNoGameDataFoundError;
|
||||
}
|
||||
|
||||
return *engine ? Common::kNoError : Common::kUserCanceled;
|
||||
}
|
||||
|
||||
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"));
|
||||
Common::FSList fslist;
|
||||
folder.getChildren(fslist, Common::FSNode::kListFilesOnly);
|
||||
|
||||
// Iterate over the files
|
||||
for (Common::FSList::iterator i = fslist.begin(); i != fslist.end(); ++i) {
|
||||
// Run a detection on each file in the folder individually
|
||||
Common::FSList singleList;
|
||||
singleList.push_back(*i);
|
||||
DetectedGames games = detectGames(singleList);
|
||||
|
||||
// If a detection was found with the correct game Id, we have a winner
|
||||
if (!games.empty() && games.front().gameId == gameId)
|
||||
return (*i).getName();
|
||||
}
|
||||
|
||||
// No match found
|
||||
return Common::String();
|
||||
}
|
||||
|
||||
PlainGameList GlkMetaEngine::getSupportedGames() const {
|
||||
PlainGameList list;
|
||||
Glk::Adrift::AdriftMetaEngine::getSupportedGames(list);
|
||||
@ -384,66 +237,4 @@ const ExtraGuiOptions GlkMetaEngine::getExtraGuiOptions(const Common::String &)
|
||||
return options;
|
||||
}
|
||||
|
||||
SaveStateList GlkMetaEngine::listSaves(const char *target) const {
|
||||
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
||||
Common::StringArray filenames;
|
||||
Common::String saveDesc;
|
||||
Common::String pattern = Common::String::format("%s.0##", target);
|
||||
|
||||
filenames = saveFileMan->listSavefiles(pattern);
|
||||
|
||||
SaveStateList saveList;
|
||||
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
|
||||
const char *ext = strrchr(file->c_str(), '.');
|
||||
int slot = ext ? atoi(ext + 1) : -1;
|
||||
|
||||
if (slot >= 0 && slot <= MAX_SAVES) {
|
||||
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
|
||||
|
||||
if (in) {
|
||||
Common::String saveName;
|
||||
if (Glk::QuetzalReader::getSavegameDescription(in, saveName))
|
||||
saveList.push_back(SaveStateDescriptor(slot, saveName));
|
||||
|
||||
delete in;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort saves based on slot number.
|
||||
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
|
||||
return saveList;
|
||||
}
|
||||
|
||||
int GlkMetaEngine::getMaximumSaveSlot() const {
|
||||
return MAX_SAVES;
|
||||
}
|
||||
|
||||
void GlkMetaEngine::removeSaveState(const char *target, int slot) const {
|
||||
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
||||
g_system->getSavefileManager()->removeSavefile(filename);
|
||||
}
|
||||
|
||||
SaveStateDescriptor GlkMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
|
||||
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
||||
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename);
|
||||
SaveStateDescriptor ssd;
|
||||
bool result = false;
|
||||
|
||||
if (in) {
|
||||
result = Glk::QuetzalReader::getSavegameMetaInfo(in, ssd);
|
||||
ssd.setSaveSlot(slot);
|
||||
delete in;
|
||||
}
|
||||
|
||||
if (result)
|
||||
return ssd;
|
||||
|
||||
return SaveStateDescriptor();
|
||||
}
|
||||
|
||||
#if PLUGIN_ENABLED_DYNAMIC(GLK)
|
||||
REGISTER_PLUGIN_DYNAMIC(GLK, PLUGIN_TYPE_ENGINE, GlkMetaEngine);
|
||||
#else
|
||||
REGISTER_PLUGIN_STATIC(GLK, PLUGIN_TYPE_ENGINE, GlkMetaEngine);
|
||||
#endif
|
||||
REGISTER_PLUGIN_STATIC(GLK_DETECTION, PLUGIN_TYPE_METAENGINE, GlkMetaEngine);
|
||||
|
@ -26,14 +26,10 @@
|
||||
#include "engines/advancedDetector.h"
|
||||
#include "engines/game.h"
|
||||
|
||||
#define MAX_SAVES 99
|
||||
|
||||
/**
|
||||
* ScummVM Meta Engine interface
|
||||
*/
|
||||
class GlkMetaEngine : public MetaEngine {
|
||||
private:
|
||||
Common::String findFileByGameId(const Common::String &gameId) const;
|
||||
public:
|
||||
GlkMetaEngine() : MetaEngine() {}
|
||||
|
||||
@ -49,13 +45,6 @@ public:
|
||||
return "Infocom games (C) Infocom\nScott Adams games (C) Scott Adams";
|
||||
}
|
||||
|
||||
bool hasFeature(MetaEngineFeature f) const override;
|
||||
Common::Error createInstance(OSystem *syst, Engine **engine) const override;
|
||||
SaveStateList listSaves(const char *target) const override;
|
||||
int getMaximumSaveSlot() const override;
|
||||
void removeSaveState(const char *target, int slot) const override;
|
||||
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
|
||||
|
||||
/**
|
||||
* Returns a list of games supported by this engine.
|
||||
*/
|
||||
|
293
engines/glk/metaengine.cpp
Normal file
293
engines/glk/metaengine.cpp
Normal file
@ -0,0 +1,293 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "base/plugins.h"
|
||||
#include "common/md5.h"
|
||||
#include "common/memstream.h"
|
||||
#include "common/str-array.h"
|
||||
#include "common/file.h"
|
||||
#include "common/translation.h"
|
||||
#include "common/config-manager.h"
|
||||
|
||||
#include "glk/detection.h"
|
||||
#include "glk/game_description.h"
|
||||
|
||||
#include "glk/adrift/detection.h"
|
||||
#include "glk/advsys/detection.h"
|
||||
#include "glk/agt/detection.h"
|
||||
#include "glk/alan2/detection.h"
|
||||
#include "glk/alan3/detection.h"
|
||||
#include "glk/archetype/detection.h"
|
||||
#include "glk/zcode/detection.h"
|
||||
#include "glk/zcode/zcode.h"
|
||||
#include "glk/hugo/detection.h"
|
||||
#include "glk/jacl/detection.h"
|
||||
#include "glk/level9/detection.h"
|
||||
#include "glk/magnetic/detection.h"
|
||||
#include "glk/quest/detection.h"
|
||||
#include "glk/scott/detection.h"
|
||||
#include "glk/scott/scott.h"
|
||||
|
||||
#ifndef RELEASE_BUILD
|
||||
#include "glk/comprehend/comprehend.h"
|
||||
#include "glk/comprehend/detection.h"
|
||||
#include "glk/glulx/detection.h"
|
||||
#include "glk/glulx/glulx.h"
|
||||
#include "glk/tads/detection.h"
|
||||
#include "glk/tads/tads2/tads2.h"
|
||||
#include "glk/tads/tads3/tads3.h"
|
||||
#endif
|
||||
|
||||
#include "base/plugins.h"
|
||||
#include "common/md5.h"
|
||||
#include "common/memstream.h"
|
||||
#include "common/savefile.h"
|
||||
#include "common/str-array.h"
|
||||
#include "common/system.h"
|
||||
#include "graphics/surface.h"
|
||||
#include "common/config-manager.h"
|
||||
#include "common/file.h"
|
||||
#include "common/translation.h"
|
||||
|
||||
#define MAX_SAVES 99
|
||||
|
||||
class GlkMetaEngineConnect : public MetaEngineConnect {
|
||||
private:
|
||||
Common::String findFileByGameId(const Common::String &gameId) const;
|
||||
public:
|
||||
const char* getName() const override {
|
||||
return "glk";
|
||||
}
|
||||
|
||||
bool hasFeature(MetaEngineFeature f) const override;
|
||||
Common::Error createInstance(OSystem *syst, Engine **engine) const override;
|
||||
|
||||
SaveStateList listSaves(const char *target) const override;
|
||||
int getMaximumSaveSlot() const override;
|
||||
void removeSaveState(const char *target, int slot) const override;
|
||||
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
|
||||
};
|
||||
|
||||
bool GlkMetaEngineConnect::hasFeature(MetaEngineFeature f) const {
|
||||
return
|
||||
(f == kSupportsListSaves) ||
|
||||
(f == kSupportsLoadingDuringStartup) ||
|
||||
(f == kSupportsDeleteSave) ||
|
||||
(f == kSavesSupportMetaInfo) ||
|
||||
(f == kSavesSupportCreationDate) ||
|
||||
(f == kSavesSupportPlayTime) ||
|
||||
(f == kSimpleSavesNames);
|
||||
}
|
||||
|
||||
bool Glk::GlkEngine::hasFeature(EngineFeature f) const {
|
||||
return
|
||||
(f == kSupportsReturnToLauncher) ||
|
||||
(f == kSupportsLoadingDuringRuntime) ||
|
||||
(f == kSupportsSavingDuringRuntime);
|
||||
}
|
||||
|
||||
bool isGameAllowed(GameSupportLevel supportLevel) {
|
||||
bool showTestingWarning = false;
|
||||
#ifdef RELEASE_BUILD
|
||||
showTestingWarning = true;
|
||||
#endif
|
||||
|
||||
if (((supportLevel == kUnstableGame
|
||||
|| (supportLevel == kTestingGame && showTestingWarning)))
|
||||
&& !Engine::warnUserAboutUnsupportedGame())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class META, class ENG>bool create(OSystem *syst,
|
||||
Glk::GlkGameDescription &gameDesc, Engine *&engine) {
|
||||
|
||||
Glk::GameDescriptor gd = META::findGame(gameDesc._gameId.c_str());
|
||||
if (gd._description) {
|
||||
if (!isGameAllowed(gd._supportLevel))
|
||||
return true;
|
||||
|
||||
gameDesc._options = gd._options;
|
||||
engine = new ENG(syst, gameDesc);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Common::String GlkMetaEngineConnect::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"));
|
||||
Common::FSList fslist;
|
||||
folder.getChildren(fslist, Common::FSNode::kListFilesOnly);
|
||||
|
||||
// Get the matching MetaEngine for this Engine.
|
||||
const MetaEngine &metaEngine = g_engine->getMetaEngine();
|
||||
|
||||
// Iterate over the files
|
||||
for (Common::FSList::iterator i = fslist.begin(); i != fslist.end(); ++i) {
|
||||
// Run a detection on each file in the folder individually
|
||||
Common::FSList singleList;
|
||||
singleList.push_back(*i);
|
||||
DetectedGames games = metaEngine.detectGames(singleList);
|
||||
|
||||
// If a detection was found with the correct game Id, we have a winner
|
||||
if (!games.empty() && games.front().gameId == gameId)
|
||||
return (*i).getName();
|
||||
}
|
||||
|
||||
// No match found
|
||||
return Common::String();
|
||||
}
|
||||
|
||||
Common::Error GlkMetaEngineConnect::createInstance(OSystem *syst, Engine **engine) const {
|
||||
#ifndef RELEASE_BUILD
|
||||
Glk::GameDescriptor td = Glk::GameDescriptor::empty();
|
||||
#endif
|
||||
assert(engine);
|
||||
|
||||
// Populate the game description
|
||||
Glk::GlkGameDescription gameDesc;
|
||||
gameDesc._gameId = ConfMan.get("gameid");
|
||||
gameDesc._filename = ConfMan.get("filename");
|
||||
|
||||
gameDesc._language = Common::UNK_LANG;
|
||||
gameDesc._platform = Common::kPlatformUnknown;
|
||||
if (ConfMan.hasKey("language"))
|
||||
gameDesc._language = Common::parseLanguage(ConfMan.get("language"));
|
||||
if (ConfMan.hasKey("platform"))
|
||||
gameDesc._platform = Common::parsePlatform(ConfMan.get("platform"));
|
||||
|
||||
// If the game description has no filename, the engine has been launched directly from
|
||||
// the command line. Do a scan for supported games for that Id in the game folder
|
||||
if (gameDesc._filename.empty()) {
|
||||
gameDesc._filename = findFileByGameId(gameDesc._gameId);
|
||||
if (gameDesc._filename.empty())
|
||||
return Common::kNoGameDataFoundError;
|
||||
}
|
||||
|
||||
// Get the MD5
|
||||
Common::File f;
|
||||
if (!f.open(Common::FSNode(ConfMan.get("path")).getChild(gameDesc._filename)))
|
||||
return Common::kNoGameDataFoundError;
|
||||
|
||||
gameDesc._md5 = Common::computeStreamMD5AsString(f, 5000);
|
||||
f.close();
|
||||
|
||||
// Create the correct engine
|
||||
*engine = nullptr;
|
||||
if ((create<Glk::Adrift::AdriftMetaEngine, Glk::Adrift::Adrift>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::AdvSys::AdvSysMetaEngine, Glk::AdvSys::AdvSys>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::AGT::AGTMetaEngine, Glk::AGT::AGT>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Alan2::Alan2MetaEngine, Glk::Alan2::Alan2>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Alan3::Alan3MetaEngine, Glk::Alan3::Alan3>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Archetype::ArchetypeMetaEngine, Glk::Archetype::Archetype>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Hugo::HugoMetaEngine, Glk::Hugo::Hugo>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::JACL::JACLMetaEngine, Glk::JACL::JACL>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Level9::Level9MetaEngine, Glk::Level9::Level9>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Magnetic::MagneticMetaEngine, Glk::Magnetic::Magnetic>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Quest::QuestMetaEngine, Glk::Quest::Quest>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Scott::ScottMetaEngine, Glk::Scott::Scott>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::ZCode::ZCodeMetaEngine, Glk::ZCode::ZCode>(syst, gameDesc, *engine))) {}
|
||||
#ifndef RELEASE_BUILD
|
||||
else if ((create<Glk::Comprehend::ComprehendMetaEngine, Glk::Comprehend::Comprehend>(syst, gameDesc, *engine))) {}
|
||||
else if ((create<Glk::Glulx::GlulxMetaEngine, Glk::Glulx::Glulx>(syst, gameDesc, *engine))) {}
|
||||
else if ((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str()))._description) {
|
||||
if (!isGameAllowed(td._supportLevel))
|
||||
return Common::kUserCanceled;
|
||||
else if (td._options & Glk::TADS::OPTION_TADS3)
|
||||
new Glk::TADS::TADS3::TADS3(syst, gameDesc);
|
||||
else
|
||||
new Glk::TADS::TADS2::TADS2(syst, gameDesc);
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
return Common::kNoGameDataFoundError;
|
||||
}
|
||||
|
||||
return *engine ? Common::kNoError : Common::kUserCanceled;
|
||||
}
|
||||
|
||||
SaveStateList GlkMetaEngineConnect::listSaves(const char *target) const {
|
||||
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
||||
Common::StringArray filenames;
|
||||
Common::String saveDesc;
|
||||
Common::String pattern = Common::String::format("%s.0##", target);
|
||||
|
||||
filenames = saveFileMan->listSavefiles(pattern);
|
||||
|
||||
SaveStateList saveList;
|
||||
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
|
||||
const char *ext = strrchr(file->c_str(), '.');
|
||||
int slot = ext ? atoi(ext + 1) : -1;
|
||||
|
||||
if (slot >= 0 && slot <= MAX_SAVES) {
|
||||
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
|
||||
|
||||
if (in) {
|
||||
Common::String saveName;
|
||||
if (Glk::QuetzalReader::getSavegameDescription(in, saveName))
|
||||
saveList.push_back(SaveStateDescriptor(slot, saveName));
|
||||
|
||||
delete in;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort saves based on slot number.
|
||||
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
|
||||
return saveList;
|
||||
}
|
||||
|
||||
int GlkMetaEngineConnect::getMaximumSaveSlot() const {
|
||||
return MAX_SAVES;
|
||||
}
|
||||
|
||||
void GlkMetaEngineConnect::removeSaveState(const char *target, int slot) const {
|
||||
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
||||
g_system->getSavefileManager()->removeSavefile(filename);
|
||||
}
|
||||
|
||||
SaveStateDescriptor GlkMetaEngineConnect::querySaveMetaInfos(const char *target, int slot) const {
|
||||
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
||||
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename);
|
||||
SaveStateDescriptor ssd;
|
||||
bool result = false;
|
||||
|
||||
if (in) {
|
||||
result = Glk::QuetzalReader::getSavegameMetaInfo(in, ssd);
|
||||
ssd.setSaveSlot(slot);
|
||||
delete in;
|
||||
}
|
||||
|
||||
if (result)
|
||||
return ssd;
|
||||
|
||||
return SaveStateDescriptor();
|
||||
}
|
||||
|
||||
#if PLUGIN_ENABLED_DYNAMIC(GLK)
|
||||
REGISTER_PLUGIN_DYNAMIC(GLK, PLUGIN_TYPE_ENGINE, GlkMetaEngineConnect);
|
||||
#else
|
||||
REGISTER_PLUGIN_STATIC(GLK, PLUGIN_TYPE_ENGINE, GlkMetaEngineConnect);
|
||||
#endif
|
@ -4,12 +4,12 @@ MODULE_OBJS := \
|
||||
blorb.o \
|
||||
conf.o \
|
||||
debugger.o \
|
||||
detection.o \
|
||||
events.o \
|
||||
fonts.o \
|
||||
glk.o \
|
||||
glk_api.o \
|
||||
glk_dispa.o \
|
||||
metaengine.o \
|
||||
pc_speaker.o \
|
||||
picture.o \
|
||||
quetzal.o \
|
||||
@ -321,3 +321,33 @@ endif
|
||||
|
||||
# Include common rules
|
||||
include $(srcdir)/rules.mk
|
||||
|
||||
# Detection objects
|
||||
DETECT_OBJS += $(MODULE)/detection.o
|
||||
|
||||
# If building as static, skip the below, as
|
||||
# they're already in the executable.
|
||||
|
||||
ifeq ($(ENABLE_GLK), DYNAMIC_PLUGIN)
|
||||
# Sub-engine detection objects
|
||||
DETECT_OBJS += $(MODULE)/adrift/detection.o
|
||||
DETECT_OBJS += $(MODULE)/advsys/detection.o
|
||||
DETECT_OBJS += $(MODULE)/agt/detection.o
|
||||
DETECT_OBJS += $(MODULE)/alan2/detection.o
|
||||
DETECT_OBJS += $(MODULE)/alan3/detection.o
|
||||
DETECT_OBJS += $(MODULE)/archetype/detection.o
|
||||
DETECT_OBJS += $(MODULE)/comprehend/detection.o
|
||||
DETECT_OBJS += $(MODULE)/glulx/detection.o
|
||||
DETECT_OBJS += $(MODULE)/hugo/detection.o
|
||||
DETECT_OBJS += $(MODULE)/jacl/detection.o
|
||||
DETECT_OBJS += $(MODULE)/level9/detection.o
|
||||
DETECT_OBJS += $(MODULE)/magnetic/detection.o
|
||||
DETECT_OBJS += $(MODULE)/quest/detection.o
|
||||
DETECT_OBJS += $(MODULE)/scott/detection.o
|
||||
DETECT_OBJS += $(MODULE)/tads/detection.o
|
||||
DETECT_OBJS += $(MODULE)/zcode/detection.o
|
||||
|
||||
# Dependencies of detection objects
|
||||
DETECT_OBJS += $(MODULE)/blorb.o
|
||||
DETECT_OBJS += $(MODULE)/advsys/game.o
|
||||
endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user