2018-10-14 13:02:24 -07:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-11-13 20:05:59 -08:00
|
|
|
#include "glk/glk.h"
|
2018-12-31 19:15:07 -08:00
|
|
|
#include "glk/detection.h"
|
2019-06-16 09:32:56 -07:00
|
|
|
#include "glk/quetzal.h"
|
2019-09-04 21:21:14 -07:00
|
|
|
#include "glk/adrift/detection.h"
|
|
|
|
#include "glk/adrift/adrift.h"
|
2019-06-03 19:18:40 -07:00
|
|
|
#include "glk/advsys/detection.h"
|
|
|
|
#include "glk/advsys/advsys.h"
|
2019-11-22 19:27:02 -08:00
|
|
|
#include "glk/agt/detection.h"
|
|
|
|
#include "glk/agt/agt.h"
|
2018-12-27 13:20:53 +02:00
|
|
|
#include "glk/alan2/detection.h"
|
|
|
|
#include "glk/alan2/alan2.h"
|
2019-06-26 21:42:47 -07:00
|
|
|
#include "glk/alan3/detection.h"
|
|
|
|
#include "glk/alan3/alan3.h"
|
2019-10-19 21:26:04 -07:00
|
|
|
#include "glk/archetype/archetype.h"
|
|
|
|
#include "glk/archetype/detection.h"
|
2020-05-26 20:02:45 -07:00
|
|
|
#include "glk/comprehend/comprehend.h"
|
|
|
|
#include "glk/comprehend/detection.h"
|
2020-06-22 20:06:26 -07:00
|
|
|
#include "glk/zcode/detection.h"
|
|
|
|
#include "glk/zcode/zcode.h"
|
2020-08-22 14:08:41 -07:00
|
|
|
#include "glk/glulx/detection.h"
|
|
|
|
#include "glk/glulx/glulx.h"
|
2019-05-07 18:57:09 +10:00
|
|
|
#include "glk/hugo/detection.h"
|
|
|
|
#include "glk/hugo/hugo.h"
|
2019-09-30 20:33:24 -07:00
|
|
|
#include "glk/jacl/detection.h"
|
|
|
|
#include "glk/jacl/jacl.h"
|
2019-10-13 11:31:07 -07:00
|
|
|
#include "glk/level9/detection.h"
|
|
|
|
#include "glk/level9/level9.h"
|
2019-05-07 15:27:14 +10:00
|
|
|
#include "glk/magnetic/detection.h"
|
|
|
|
#include "glk/magnetic/magnetic.h"
|
2019-07-20 14:58:39 -07:00
|
|
|
#include "glk/quest/detection.h"
|
|
|
|
#include "glk/quest/quest.h"
|
2018-11-14 18:01:42 -08:00
|
|
|
#include "glk/scott/detection.h"
|
|
|
|
#include "glk/scott/scott.h"
|
2018-11-27 19:48:17 -08:00
|
|
|
#include "glk/tads/detection.h"
|
2018-11-27 21:02:49 -08:00
|
|
|
#include "glk/tads/tads2/tads2.h"
|
|
|
|
#include "glk/tads/tads3/tads3.h"
|
2018-10-14 13:02:24 -07:00
|
|
|
|
|
|
|
#include "base/plugins.h"
|
2018-11-03 20:41:59 -07:00
|
|
|
#include "common/md5.h"
|
|
|
|
#include "common/memstream.h"
|
2018-10-14 13:02:24 -07:00
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/str-array.h"
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "graphics/surface.h"
|
2018-10-17 22:45:25 -07:00
|
|
|
#include "common/config-manager.h"
|
2018-10-18 07:34:39 -07:00
|
|
|
#include "common/file.h"
|
2020-06-21 21:48:22 +01:00
|
|
|
#include "common/translation.h"
|
2018-10-14 13:02:24 -07:00
|
|
|
|
2019-07-06 10:13:58 -07:00
|
|
|
namespace Glk {
|
|
|
|
|
2020-06-21 22:48:53 +01:00
|
|
|
Common::String GlkDetectedGame::getGlkGUIOptions() {
|
|
|
|
#if defined (USE_TTS)
|
|
|
|
return GUIO2(GUIO_NOMUSIC, GUIO_NOSUBTITLES);
|
|
|
|
#else
|
|
|
|
return GUIO3(GUIO_NOSPEECH, GUIO_NOMUSIC, GUIO_NOSUBTITLES);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-06-21 18:12:29 -07:00
|
|
|
GlkDetectedGame::GlkDetectedGame(const char *id, const char *desc, const Common::String &filename,
|
|
|
|
GameSupportLevel supportLevel) :
|
2016-09-15 18:39:45 +02:00
|
|
|
DetectedGame("glk", id, desc, Common::EN_ANY, Common::kPlatformUnknown) {
|
2020-06-21 22:48:53 +01:00
|
|
|
setGUIOptions(getGlkGUIOptions());
|
2020-06-21 18:12:29 -07:00
|
|
|
gameSupportLevel = supportLevel;
|
2019-07-06 10:13:58 -07:00
|
|
|
addExtraEntry("filename", filename);
|
|
|
|
}
|
|
|
|
|
2019-07-06 17:24:37 -07:00
|
|
|
GlkDetectedGame::GlkDetectedGame(const char *id, const char *desc, const Common::String &filename,
|
2020-06-21 18:12:29 -07:00
|
|
|
Common::Language lang, GameSupportLevel supportLevel) : DetectedGame("glk", id, desc, lang, Common::kPlatformUnknown) {
|
2020-06-21 22:48:53 +01:00
|
|
|
setGUIOptions(getGlkGUIOptions());
|
2020-06-21 18:12:29 -07:00
|
|
|
gameSupportLevel = supportLevel;
|
2019-07-06 10:13:58 -07:00
|
|
|
addExtraEntry("filename", filename);
|
|
|
|
}
|
|
|
|
|
2019-09-25 20:11:12 -07:00
|
|
|
GlkDetectedGame::GlkDetectedGame(const char *id, const char *desc, const char *xtra,
|
2020-06-21 18:12:29 -07:00
|
|
|
const Common::String &filename, Common::Language lang,
|
|
|
|
GameSupportLevel supportLevel) :
|
2016-09-15 18:39:45 +02:00
|
|
|
DetectedGame("glk", id, desc, lang, Common::kPlatformUnknown, xtra) {
|
2020-06-21 22:48:53 +01:00
|
|
|
setGUIOptions(getGlkGUIOptions());
|
2020-06-21 18:12:29 -07:00
|
|
|
gameSupportLevel = supportLevel;
|
2019-09-04 22:36:03 -07:00
|
|
|
addExtraEntry("filename", filename);
|
|
|
|
}
|
|
|
|
|
2019-07-06 17:24:37 -07:00
|
|
|
GlkDetectedGame::GlkDetectedGame(const char *id, const char *desc, const Common::String &filename,
|
2020-06-21 18:12:29 -07:00
|
|
|
const Common::String &md5, size_t filesize, GameSupportLevel supportLevel) :
|
2016-09-15 18:39:45 +02:00
|
|
|
DetectedGame("glk", id, desc, Common::UNK_LANG, Common::kPlatformUnknown) {
|
2020-06-21 22:48:53 +01:00
|
|
|
setGUIOptions(getGlkGUIOptions());
|
2020-06-21 18:12:29 -07:00
|
|
|
gameSupportLevel = supportLevel;
|
2019-07-06 10:13:58 -07:00
|
|
|
addExtraEntry("filename", filename);
|
|
|
|
|
|
|
|
canBeAdded = true;
|
|
|
|
hasUnknownFiles = true;
|
|
|
|
|
|
|
|
FileProperties fp;
|
|
|
|
fp.md5 = md5;
|
|
|
|
fp.size = filesize;
|
|
|
|
matchedFiles[filename] = fp;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Glk
|
|
|
|
|
2018-11-13 20:05:59 -08:00
|
|
|
bool GlkMetaEngine::hasFeature(MetaEngineFeature f) const {
|
2018-10-14 13:02:24 -07:00
|
|
|
return
|
2018-11-10 05:42:22 +00:00
|
|
|
(f == kSupportsListSaves) ||
|
|
|
|
(f == kSupportsLoadingDuringStartup) ||
|
|
|
|
(f == kSupportsDeleteSave) ||
|
|
|
|
(f == kSavesSupportMetaInfo) ||
|
|
|
|
(f == kSavesSupportCreationDate) ||
|
|
|
|
(f == kSavesSupportPlayTime) ||
|
|
|
|
(f == kSimpleSavesNames);
|
2018-10-14 13:02:24 -07:00
|
|
|
}
|
|
|
|
|
2018-11-13 20:05:59 -08:00
|
|
|
bool Glk::GlkEngine::hasFeature(EngineFeature f) const {
|
2018-10-14 13:02:24 -07:00
|
|
|
return
|
2020-05-11 08:42:53 -04:00
|
|
|
(f == kSupportsReturnToLauncher) ||
|
2018-11-10 05:42:22 +00:00
|
|
|
(f == kSupportsLoadingDuringRuntime) ||
|
|
|
|
(f == kSupportsSavingDuringRuntime);
|
2018-10-14 13:02:24 -07:00
|
|
|
}
|
|
|
|
|
2020-06-21 18:12:29 -07:00
|
|
|
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) {
|
|
|
|
|
2018-12-31 22:32:07 -08:00
|
|
|
Glk::GameDescriptor gd = META::findGame(gameDesc._gameId.c_str());
|
|
|
|
if (gd._description) {
|
2020-06-21 18:12:29 -07:00
|
|
|
if (!isGameAllowed(gd._supportLevel))
|
|
|
|
return true;
|
|
|
|
|
2018-12-31 22:32:07 -08:00
|
|
|
gameDesc._options = gd._options;
|
2020-06-21 18:12:29 -07:00
|
|
|
engine = new ENG(syst, gameDesc);
|
|
|
|
return true;
|
2018-12-31 22:32:07 -08:00
|
|
|
} else {
|
2020-06-21 18:12:29 -07:00
|
|
|
return false;
|
2018-12-31 22:32:07 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-14 18:01:42 -08:00
|
|
|
Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
|
2018-12-31 19:47:14 -08:00
|
|
|
Glk::GameDescriptor td = Glk::GameDescriptor::empty();
|
2018-11-14 18:01:42 -08:00
|
|
|
assert(engine);
|
2018-10-14 13:02:24 -07:00
|
|
|
|
2018-11-14 18:38:56 -08:00
|
|
|
// Populate the game description
|
2018-11-14 18:01:42 -08:00
|
|
|
Glk::GlkGameDescription gameDesc;
|
|
|
|
gameDesc._gameId = ConfMan.get("gameid");
|
|
|
|
gameDesc._filename = ConfMan.get("filename");
|
|
|
|
|
2018-11-14 18:38:56 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-11-17 19:04:06 -08:00
|
|
|
// 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();
|
|
|
|
|
2018-12-08 16:54:31 -08:00
|
|
|
// Create the correct engine
|
2019-01-01 00:38:49 -08:00
|
|
|
*engine = nullptr;
|
2020-06-21 18:12:29 -07:00
|
|
|
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::Comprehend::ComprehendMetaEngine, Glk::Comprehend::Comprehend>(syst, gameDesc, *engine))) {}
|
2020-08-22 14:08:41 -07:00
|
|
|
else if ((create<Glk::Glulx::GlulxMetaEngine, Glk::Glulx::Glulx>(syst, gameDesc, *engine))) {}
|
2020-06-21 18:12:29 -07:00
|
|
|
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))) {}
|
2020-05-17 18:20:13 -07:00
|
|
|
else if ((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str()))._description) {
|
2020-06-21 18:12:29 -07:00
|
|
|
if (!isGameAllowed(td._supportLevel))
|
|
|
|
return Common::kUserCanceled;
|
|
|
|
else if (td._options & Glk::TADS::OPTION_TADS3)
|
|
|
|
new Glk::TADS::TADS3::TADS3(syst, gameDesc);
|
2018-11-27 21:02:49 -08:00
|
|
|
else
|
2020-06-21 18:12:29 -07:00
|
|
|
new Glk::TADS::TADS2::TADS2(syst, gameDesc);
|
2020-06-22 20:06:26 -07:00
|
|
|
} else if ((create<Glk::ZCode::ZCodeMetaEngine, Glk::ZCode::ZCode>(syst, gameDesc, *engine))) {
|
2020-05-17 18:20:13 -07:00
|
|
|
} else {
|
2018-11-14 18:01:42 -08:00
|
|
|
return Common::kNoGameDataFoundError;
|
2018-11-17 19:04:06 -08:00
|
|
|
}
|
2018-11-14 18:01:42 -08:00
|
|
|
|
2020-06-21 18:12:29 -07:00
|
|
|
return *engine ? Common::kNoError : Common::kUserCanceled;
|
2018-11-14 18:01:42 -08:00
|
|
|
}
|
|
|
|
|
2018-11-14 18:38:56 -08:00
|
|
|
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);
|
2020-05-11 08:42:53 -04:00
|
|
|
|
2018-11-14 18:38:56 -08:00
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
|
2018-11-14 18:01:42 -08:00
|
|
|
PlainGameList GlkMetaEngine::getSupportedGames() const {
|
|
|
|
PlainGameList list;
|
2019-09-26 18:18:38 -07:00
|
|
|
Glk::Adrift::AdriftMetaEngine::getSupportedGames(list);
|
2019-06-16 19:23:30 -07:00
|
|
|
Glk::AdvSys::AdvSysMetaEngine::getSupportedGames(list);
|
2019-11-22 19:27:02 -08:00
|
|
|
Glk::AGT::AGTMetaEngine::getSupportedGames(list);
|
2019-06-23 16:55:34 -07:00
|
|
|
Glk::Alan2::Alan2MetaEngine::getSupportedGames(list);
|
2019-07-06 19:40:04 -07:00
|
|
|
Glk::Alan3::Alan3MetaEngine::getSupportedGames(list);
|
2019-10-19 21:26:04 -07:00
|
|
|
Glk::Archetype::ArchetypeMetaEngine::getSupportedGames(list);
|
2020-05-26 20:02:45 -07:00
|
|
|
Glk::Comprehend::ComprehendMetaEngine::getSupportedGames(list);
|
2020-08-22 14:08:41 -07:00
|
|
|
Glk::Glulx::GlulxMetaEngine::getSupportedGames(list);
|
2019-05-16 11:27:55 -10:00
|
|
|
Glk::Hugo::HugoMetaEngine::getSupportedGames(list);
|
2019-10-10 20:38:56 -07:00
|
|
|
Glk::JACL::JACLMetaEngine::getSupportedGames(list);
|
2019-10-13 11:31:07 -07:00
|
|
|
Glk::Level9::Level9MetaEngine::getSupportedGames(list);
|
2019-10-22 19:24:19 -07:00
|
|
|
Glk::Magnetic::MagneticMetaEngine::getSupportedGames(list);
|
2019-07-20 14:58:39 -07:00
|
|
|
Glk::Quest::QuestMetaEngine::getSupportedGames(list);
|
2018-11-14 18:01:42 -08:00
|
|
|
Glk::Scott::ScottMetaEngine::getSupportedGames(list);
|
2018-11-27 19:48:17 -08:00
|
|
|
Glk::TADS::TADSMetaEngine::getSupportedGames(list);
|
2020-06-22 20:06:26 -07:00
|
|
|
Glk::ZCode::ZCodeMetaEngine::getSupportedGames(list);
|
2018-11-14 18:01:42 -08:00
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2019-10-22 19:24:19 -07:00
|
|
|
#define FIND_GAME(SUBENGINE) \
|
|
|
|
Glk::GameDescriptor gd##SUBENGINE = Glk::SUBENGINE::SUBENGINE##MetaEngine::findGame(gameId); \
|
|
|
|
if (gd##SUBENGINE._description) return gd##SUBENGINE
|
2019-06-16 19:23:30 -07:00
|
|
|
|
2019-10-22 19:24:19 -07:00
|
|
|
PlainGameDescriptor GlkMetaEngine::findGame(const char *gameId) const {
|
|
|
|
FIND_GAME(Adrift);
|
|
|
|
FIND_GAME(AdvSys);
|
|
|
|
FIND_GAME(Alan2);
|
2019-11-22 19:27:02 -08:00
|
|
|
FIND_GAME(AGT);
|
2019-10-22 19:24:19 -07:00
|
|
|
FIND_GAME(Alan3);
|
2019-10-19 21:26:04 -07:00
|
|
|
FIND_GAME(Archetype);
|
2020-05-26 20:02:45 -07:00
|
|
|
FIND_GAME(Comprehend);
|
2020-08-22 14:08:41 -07:00
|
|
|
FIND_GAME(Glulx);
|
2019-10-22 19:24:19 -07:00
|
|
|
FIND_GAME(Hugo);
|
|
|
|
FIND_GAME(JACL);
|
2019-10-13 11:31:07 -07:00
|
|
|
FIND_GAME(Level9);
|
2019-10-22 19:24:19 -07:00
|
|
|
FIND_GAME(Magnetic);
|
|
|
|
FIND_GAME(Quest);
|
|
|
|
FIND_GAME(Scott);
|
|
|
|
FIND_GAME(TADS);
|
2020-06-22 20:06:26 -07:00
|
|
|
FIND_GAME(ZCode);
|
2019-10-22 19:24:19 -07:00
|
|
|
|
2018-11-14 18:01:42 -08:00
|
|
|
return PlainGameDescriptor();
|
|
|
|
}
|
|
|
|
|
2019-10-22 19:24:19 -07:00
|
|
|
#undef FIND_GAME
|
|
|
|
|
2018-11-14 18:01:42 -08:00
|
|
|
DetectedGames GlkMetaEngine::detectGames(const Common::FSList &fslist) const {
|
2018-12-14 18:25:20 -08:00
|
|
|
// This is as good a place as any to detect multiple sub-engines using the same Ids
|
|
|
|
detectClashes();
|
|
|
|
|
2018-11-14 18:01:42 -08:00
|
|
|
DetectedGames detectedGames;
|
2019-09-26 18:18:38 -07:00
|
|
|
Glk::Adrift::AdriftMetaEngine::detectGames(fslist, detectedGames);
|
2019-06-16 19:23:30 -07:00
|
|
|
Glk::AdvSys::AdvSysMetaEngine::detectGames(fslist, detectedGames);
|
2019-11-22 19:27:02 -08:00
|
|
|
Glk::AGT::AGTMetaEngine::detectGames(fslist, detectedGames);
|
2019-06-23 16:55:34 -07:00
|
|
|
Glk::Alan2::Alan2MetaEngine::detectGames(fslist, detectedGames);
|
2019-07-06 19:40:04 -07:00
|
|
|
Glk::Alan3::Alan3MetaEngine::detectGames(fslist, detectedGames);
|
2019-10-19 21:26:04 -07:00
|
|
|
Glk::Archetype::ArchetypeMetaEngine::detectGames(fslist, detectedGames);
|
2020-05-26 20:02:45 -07:00
|
|
|
Glk::Comprehend::ComprehendMetaEngine::detectGames(fslist, detectedGames);
|
2020-08-22 14:08:41 -07:00
|
|
|
Glk::Glulx::GlulxMetaEngine::detectGames(fslist, detectedGames);
|
2019-05-16 11:27:55 -10:00
|
|
|
Glk::Hugo::HugoMetaEngine::detectGames(fslist, detectedGames);
|
2019-10-10 20:38:56 -07:00
|
|
|
Glk::JACL::JACLMetaEngine::detectGames(fslist, detectedGames);
|
2019-10-13 11:31:07 -07:00
|
|
|
Glk::Level9::Level9MetaEngine::detectGames(fslist, detectedGames);
|
2019-10-22 19:24:19 -07:00
|
|
|
Glk::Magnetic::MagneticMetaEngine::detectGames(fslist, detectedGames);
|
2019-07-20 14:58:39 -07:00
|
|
|
Glk::Quest::QuestMetaEngine::detectGames(fslist, detectedGames);
|
2018-11-14 18:01:42 -08:00
|
|
|
Glk::Scott::ScottMetaEngine::detectGames(fslist, detectedGames);
|
2018-11-27 19:48:17 -08:00
|
|
|
Glk::TADS::TADSMetaEngine::detectGames(fslist, detectedGames);
|
2020-06-22 20:06:26 -07:00
|
|
|
Glk::ZCode::ZCodeMetaEngine::detectGames(fslist, detectedGames);
|
2018-11-14 18:01:42 -08:00
|
|
|
|
|
|
|
return detectedGames;
|
2018-10-14 13:02:24 -07:00
|
|
|
}
|
|
|
|
|
2018-12-14 18:25:20 -08:00
|
|
|
void GlkMetaEngine::detectClashes() const {
|
|
|
|
Common::StringMap map;
|
2019-09-26 18:18:38 -07:00
|
|
|
Glk::Adrift::AdriftMetaEngine::detectClashes(map);
|
2019-06-16 19:23:30 -07:00
|
|
|
Glk::AdvSys::AdvSysMetaEngine::detectClashes(map);
|
2019-11-22 19:27:02 -08:00
|
|
|
Glk::AGT::AGTMetaEngine::detectClashes(map);
|
2019-06-23 16:55:34 -07:00
|
|
|
Glk::Alan2::Alan2MetaEngine::detectClashes(map);
|
2019-07-06 19:40:04 -07:00
|
|
|
Glk::Alan3::Alan3MetaEngine::detectClashes(map);
|
2019-10-19 21:26:04 -07:00
|
|
|
Glk::Archetype::ArchetypeMetaEngine::detectClashes(map);
|
2020-05-26 20:02:45 -07:00
|
|
|
Glk::Comprehend::ComprehendMetaEngine::detectClashes(map);
|
2020-08-22 14:08:41 -07:00
|
|
|
Glk::Glulx::GlulxMetaEngine::detectClashes(map);
|
2019-05-16 11:27:55 -10:00
|
|
|
Glk::Hugo::HugoMetaEngine::detectClashes(map);
|
2019-10-10 20:38:56 -07:00
|
|
|
Glk::JACL::JACLMetaEngine::detectClashes(map);
|
2019-10-13 11:31:07 -07:00
|
|
|
Glk::Level9::Level9MetaEngine::detectClashes(map);
|
2019-10-22 19:24:19 -07:00
|
|
|
Glk::Magnetic::MagneticMetaEngine::detectClashes(map);
|
2019-07-20 14:58:39 -07:00
|
|
|
Glk::Quest::QuestMetaEngine::detectClashes(map);
|
2018-12-14 18:25:20 -08:00
|
|
|
Glk::Scott::ScottMetaEngine::detectClashes(map);
|
|
|
|
Glk::TADS::TADSMetaEngine::detectClashes(map);
|
2020-06-22 20:06:26 -07:00
|
|
|
Glk::ZCode::ZCodeMetaEngine::detectClashes(map);
|
2018-12-14 18:25:20 -08:00
|
|
|
}
|
|
|
|
|
2020-06-21 21:48:22 +01:00
|
|
|
const ExtraGuiOptions GlkMetaEngine::getExtraGuiOptions(const Common::String &) const {
|
|
|
|
ExtraGuiOptions options;
|
|
|
|
#if defined(USE_TTS)
|
|
|
|
static const ExtraGuiOption ttsSpeakOptions = {
|
|
|
|
_s("Enable Text to Speech"),
|
|
|
|
_s("Use TTS to read the text"),
|
|
|
|
"speak",
|
|
|
|
false
|
|
|
|
};
|
|
|
|
static const ExtraGuiOption ttsSpeakInputOptions = {
|
|
|
|
_s("Also read input text"),
|
|
|
|
_s("Use TTS to read the input text"),
|
|
|
|
"speak_input",
|
|
|
|
false
|
|
|
|
};
|
|
|
|
options.push_back(ttsSpeakOptions);
|
|
|
|
options.push_back(ttsSpeakInputOptions);
|
|
|
|
#endif
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
2018-11-13 20:05:59 -08:00
|
|
|
SaveStateList GlkMetaEngine::listSaves(const char *target) const {
|
2018-11-04 15:11:11 -08:00
|
|
|
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);
|
|
|
|
|
2018-10-14 13:02:24 -07:00
|
|
|
SaveStateList saveList;
|
2018-11-04 15:11:11 -08:00
|
|
|
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) {
|
2019-06-16 09:32:56 -07:00
|
|
|
Common::String saveName;
|
|
|
|
if (Glk::QuetzalReader::getSavegameDescription(in, saveName))
|
|
|
|
saveList.push_back(SaveStateDescriptor(slot, saveName));
|
2018-11-04 15:11:11 -08:00
|
|
|
|
|
|
|
delete in;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sort saves based on slot number.
|
|
|
|
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
|
2018-10-14 13:02:24 -07:00
|
|
|
return saveList;
|
|
|
|
}
|
|
|
|
|
2018-11-13 20:05:59 -08:00
|
|
|
int GlkMetaEngine::getMaximumSaveSlot() const {
|
2018-10-14 13:02:24 -07:00
|
|
|
return MAX_SAVES;
|
|
|
|
}
|
|
|
|
|
2018-11-13 20:05:59 -08:00
|
|
|
void GlkMetaEngine::removeSaveState(const char *target, int slot) const {
|
2018-11-11 09:35:28 -08:00
|
|
|
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
|
|
|
g_system->getSavefileManager()->removeSavefile(filename);
|
2018-10-14 13:02:24 -07:00
|
|
|
}
|
|
|
|
|
2018-11-13 20:05:59 -08:00
|
|
|
SaveStateDescriptor GlkMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
|
2018-11-04 18:02:36 -08:00
|
|
|
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
|
|
|
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename);
|
2019-06-16 09:32:56 -07:00
|
|
|
SaveStateDescriptor ssd;
|
|
|
|
bool result = false;
|
2018-11-04 18:02:36 -08:00
|
|
|
|
|
|
|
if (in) {
|
2019-06-16 09:32:56 -07:00
|
|
|
result = Glk::QuetzalReader::getSavegameMetaInfo(in, ssd);
|
|
|
|
ssd.setSaveSlot(slot);
|
|
|
|
delete in;
|
2018-11-04 18:02:36 -08:00
|
|
|
}
|
|
|
|
|
2019-06-16 09:32:56 -07:00
|
|
|
if (result)
|
|
|
|
return ssd;
|
|
|
|
|
2018-10-14 13:02:24 -07:00
|
|
|
return SaveStateDescriptor();
|
|
|
|
}
|
|
|
|
|
2018-11-13 19:47:07 -08:00
|
|
|
#if PLUGIN_ENABLED_DYNAMIC(GLK)
|
2018-11-13 20:05:59 -08:00
|
|
|
REGISTER_PLUGIN_DYNAMIC(GLK, PLUGIN_TYPE_ENGINE, GlkMetaEngine);
|
2018-10-14 13:02:24 -07:00
|
|
|
#else
|
2018-11-13 20:05:59 -08:00
|
|
|
REGISTER_PLUGIN_STATIC(GLK, PLUGIN_TYPE_ENGINE, GlkMetaEngine);
|
2018-10-14 13:02:24 -07:00
|
|
|
#endif
|