2011-07-14 20:08:06 +02: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.
|
2014-02-18 02:34:18 +01:00
|
|
|
*
|
2011-07-14 20:08:06 +02:00
|
|
|
* 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.
|
2014-02-18 02:34:18 +01:00
|
|
|
*
|
2011-07-14 20:08:06 +02:00
|
|
|
* 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"
|
2012-05-22 14:22:57 -07:00
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/serializer.h"
|
|
|
|
#include "common/str-array.h"
|
2011-07-14 20:08:06 +02:00
|
|
|
#include "engines/advancedDetector.h"
|
|
|
|
|
|
|
|
#include "composer/composer.h"
|
|
|
|
|
|
|
|
namespace Composer {
|
|
|
|
|
|
|
|
struct ComposerGameDescription {
|
|
|
|
ADGameDescription desc;
|
|
|
|
|
|
|
|
int gameType;
|
|
|
|
};
|
|
|
|
|
|
|
|
int ComposerEngine::getGameType() const {
|
|
|
|
return _gameDescription->gameType;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *ComposerEngine::getGameId() const {
|
2016-03-08 18:53:55 +01:00
|
|
|
return _gameDescription->desc.gameId;
|
2011-07-14 20:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32 ComposerEngine::getFeatures() const {
|
|
|
|
return _gameDescription->desc.flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Language ComposerEngine::getLanguage() const {
|
|
|
|
return _gameDescription->desc.language;
|
|
|
|
}
|
|
|
|
|
2019-11-24 00:41:49 +02:00
|
|
|
Common::Platform ComposerEngine::getPlatform() const {
|
|
|
|
return _gameDescription->desc.platform;
|
|
|
|
}
|
|
|
|
|
2019-11-27 07:37:21 +02:00
|
|
|
bool ComposerEngine::loadDetectedConfigFile(Common::INIFile &configFile) const {
|
2019-11-25 22:20:30 +02:00
|
|
|
const ADGameFileDescription *res = _gameDescription->desc.filesDescriptions;
|
|
|
|
while (res->fileName != NULL) {
|
|
|
|
if (res->fileType == GAME_CONFIGFILE) {
|
2019-11-27 07:37:21 +02:00
|
|
|
return configFile.loadFromFile(res->fileName);
|
2019-11-25 22:20:30 +02:00
|
|
|
}
|
2019-11-25 22:46:05 +02:00
|
|
|
res++;
|
2019-11-25 22:20:30 +02:00
|
|
|
}
|
|
|
|
// default config file name
|
2019-11-27 07:37:21 +02:00
|
|
|
return configFile.loadFromFile("book.ini") || configFile.loadFromFile("book.mac");
|
2019-11-25 22:20:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-14 20:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const PlainGameDescriptor composerGames[] = {
|
2012-02-15 14:17:09 +00:00
|
|
|
{"babayaga", "Magic Tales: Baba Yaga and the Magic Geese"},
|
2011-07-14 20:08:06 +02:00
|
|
|
{"darby", "Darby the Dragon"},
|
2011-07-15 00:02:28 +02:00
|
|
|
{"gregory", "Gregory and the Hot Air Balloon"},
|
2012-02-15 14:17:09 +00:00
|
|
|
{"imoking", "Magic Tales: Imo and the King"},
|
2011-07-20 11:35:01 +02:00
|
|
|
{"liam", "Magic Tales: Liam Finds a Story"},
|
2012-02-15 14:17:09 +00:00
|
|
|
{"littlesamurai", "Magic Tales: The Little Samurai"},
|
2019-11-25 22:20:30 +02:00
|
|
|
{"magictales", "Magic Tales"},
|
2017-06-17 22:52:42 +01:00
|
|
|
{"princess", "Magic Tales: The Princess and the Crab"},
|
|
|
|
{"sleepingcub", "Magic Tales: Sleeping Cub's Test of Courage"},
|
2011-07-14 20:08:06 +02:00
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
|
2020-02-05 15:01:24 +01:00
|
|
|
#include "composer/detection_tables.h"
|
2011-07-14 20:08:06 +02:00
|
|
|
|
|
|
|
using namespace Composer;
|
|
|
|
|
2011-08-23 23:11:41 +02:00
|
|
|
// we match from data too, to stop detection from a non-top-level directory
|
2012-11-23 20:44:17 +00:00
|
|
|
static const char *directoryGlobs[] = {
|
2011-08-23 23:11:41 +02:00
|
|
|
"data",
|
2012-02-15 16:29:03 +00:00
|
|
|
"liam",
|
2011-08-23 23:11:41 +02:00
|
|
|
"programs",
|
2011-08-25 16:44:43 +01:00
|
|
|
"princess",
|
|
|
|
"sleepcub",
|
2011-08-23 23:11:41 +02:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2011-07-14 20:08:06 +02:00
|
|
|
class ComposerMetaEngine : public AdvancedMetaEngine {
|
|
|
|
public:
|
2011-07-20 11:35:01 +02:00
|
|
|
ComposerMetaEngine() : AdvancedMetaEngine(Composer::gameDescriptions, sizeof(Composer::ComposerGameDescription), composerGames) {
|
2011-08-23 23:11:41 +02:00
|
|
|
_maxScanDepth = 2;
|
|
|
|
_directoryGlobs = directoryGlobs;
|
2011-07-20 11:35:01 +02:00
|
|
|
}
|
2011-07-14 20:08:06 +02:00
|
|
|
|
2020-02-05 14:59:35 +01:00
|
|
|
const char *getEngineId() const override {
|
2016-09-15 18:23:35 +02:00
|
|
|
return "composer";
|
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:27 +01:00
|
|
|
const char *getName() const override {
|
2016-09-15 20:04:14 +02:00
|
|
|
return "Magic Composer";
|
2011-07-14 20:08:06 +02:00
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:27 +01:00
|
|
|
const char *getOriginalCopyright() const override {
|
2011-07-20 17:31:42 +02:00
|
|
|
return "Copyright (C) 1995-1999 Animation Magic";
|
2011-07-14 20:08:06 +02:00
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:27 +01:00
|
|
|
bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
|
|
|
|
bool hasFeature(MetaEngineFeature f) const override;
|
|
|
|
int getMaximumSaveSlot() const override;
|
|
|
|
SaveStateList listSaves(const char* target) const override;
|
2011-07-14 20:08:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
bool ComposerMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
|
|
|
const Composer::ComposerGameDescription *gd = (const Composer::ComposerGameDescription *)desc;
|
|
|
|
if (gd) {
|
|
|
|
*engine = new Composer::ComposerEngine(syst, gd);
|
|
|
|
}
|
|
|
|
return gd != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ComposerMetaEngine::hasFeature(MetaEngineFeature f) const {
|
2012-06-23 03:03:52 -07:00
|
|
|
return ((f == kSupportsListSaves) || (f == kSupportsLoadingDuringStartup));
|
2012-05-22 14:22:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
Common::String getSaveName(Common::InSaveFile *in) {
|
2012-05-24 09:42:03 -07:00
|
|
|
Common::Serializer ser(in, NULL);
|
2012-05-22 14:22:57 -07:00
|
|
|
Common::String name;
|
|
|
|
uint32 tmp;
|
|
|
|
ser.syncAsUint32LE(tmp);
|
|
|
|
ser.syncAsUint32LE(tmp);
|
|
|
|
ser.syncString(name);
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
int ComposerMetaEngine::getMaximumSaveSlot() const {
|
|
|
|
return 99;
|
|
|
|
}
|
|
|
|
SaveStateList ComposerMetaEngine::listSaves(const char *target) const {
|
|
|
|
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
|
|
|
Common::StringArray filenames;
|
|
|
|
Common::String saveDesc;
|
2018-03-26 01:26:15 +02:00
|
|
|
Common::String pattern = Common::String::format("%s.##", target);
|
2012-05-22 14:22:57 -07:00
|
|
|
|
|
|
|
filenames = saveFileMan->listSavefiles(pattern);
|
|
|
|
|
|
|
|
SaveStateList saveList;
|
|
|
|
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
|
|
|
|
// Obtain the last 3 digits of the filename, since they correspond to the save slot
|
|
|
|
int slotNum = atoi(file->c_str() + file->size() - 2);
|
|
|
|
|
|
|
|
if (slotNum >= 0 && slotNum <= 99) {
|
|
|
|
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
|
|
|
|
if (in) {
|
|
|
|
saveDesc = getSaveName(in);
|
|
|
|
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
|
|
|
|
delete in;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-26 00:49:33 +02:00
|
|
|
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
|
2012-05-22 14:22:57 -07:00
|
|
|
return saveList;
|
2011-07-14 20:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Composer::ComposerEngine::hasFeature(EngineFeature f) const {
|
2020-05-11 08:42:53 -04:00
|
|
|
return (f == kSupportsReturnToLauncher
|
2017-09-01 13:46:25 +02:00
|
|
|
|| f == kSupportsSavingDuringRuntime
|
2012-06-12 15:19:25 -07:00
|
|
|
|| f == kSupportsLoadingDuringRuntime);
|
2011-07-14 20:08:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if PLUGIN_ENABLED_DYNAMIC(COMPOSER)
|
2014-02-17 23:01:36 +01:00
|
|
|
REGISTER_PLUGIN_DYNAMIC(COMPOSER, PLUGIN_TYPE_ENGINE, ComposerMetaEngine);
|
2011-07-14 20:08:06 +02:00
|
|
|
#else
|
2014-02-17 23:01:36 +01:00
|
|
|
REGISTER_PLUGIN_STATIC(COMPOSER, PLUGIN_TYPE_ENGINE, ComposerMetaEngine);
|
2011-07-14 20:08:06 +02:00
|
|
|
#endif
|