2014-02-16 15:22:57 -05: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.
|
2015-05-09 15:56:27 +02:00
|
|
|
*
|
2014-02-16 15:22:57 -05: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.
|
2015-05-09 15:56:27 +02:00
|
|
|
*
|
2014-02-16 15:22:57 -05: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 "mads/mads.h"
|
|
|
|
|
|
|
|
#include "base/plugins.h"
|
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/str-array.h"
|
|
|
|
#include "common/memstream.h"
|
|
|
|
#include "engines/advancedDetector.h"
|
|
|
|
#include "common/system.h"
|
2015-03-15 04:05:06 +02:00
|
|
|
#include "common/translation.h"
|
2014-02-16 15:22:57 -05:00
|
|
|
#include "graphics/colormasks.h"
|
|
|
|
#include "graphics/surface.h"
|
2014-05-02 21:29:33 -04:00
|
|
|
#include "mads/events.h"
|
2014-04-26 09:08:46 -04:00
|
|
|
#include "mads/game.h"
|
2014-02-16 15:22:57 -05:00
|
|
|
|
|
|
|
#define MAX_SAVES 99
|
|
|
|
|
|
|
|
namespace MADS {
|
|
|
|
|
|
|
|
struct MADSGameDescription {
|
|
|
|
ADGameDescription desc;
|
2014-02-18 20:08:58 -05:00
|
|
|
|
|
|
|
int gameID;
|
|
|
|
uint32 features;
|
2014-02-16 15:22:57 -05:00
|
|
|
};
|
|
|
|
|
2014-02-18 20:08:58 -05:00
|
|
|
uint32 MADSEngine::getGameID() const {
|
|
|
|
return _gameDescription->gameID;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 MADSEngine::getGameFeatures() const {
|
2014-02-19 22:01:10 -05:00
|
|
|
return _gameDescription->features;
|
2014-02-18 20:08:58 -05:00
|
|
|
}
|
|
|
|
|
2014-02-16 15:22:57 -05:00
|
|
|
uint32 MADSEngine::getFeatures() const {
|
|
|
|
return _gameDescription->desc.flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Language MADSEngine::getLanguage() const {
|
|
|
|
return _gameDescription->desc.language;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Platform MADSEngine::getPlatform() const {
|
|
|
|
return _gameDescription->desc.platform;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace MADS
|
|
|
|
|
|
|
|
static const PlainGameDescriptor MADSGames[] = {
|
2014-04-27 20:56:53 +03:00
|
|
|
{"dragonsphere", "Dragonsphere"},
|
2014-02-16 15:22:57 -05:00
|
|
|
{"nebular", "Rex Nebular and the Cosmic Gender Bender"},
|
2014-04-27 20:56:53 +03:00
|
|
|
{"phantom", "Return of the Phantom"},
|
2014-02-16 15:22:57 -05:00
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
|
2015-03-15 04:05:06 +02:00
|
|
|
#define GAMEOPTION_EASY_MOUSE GUIO_GAMEOPTIONS1
|
|
|
|
#define GAMEOPTION_ANIMATED_INVENTORY GUIO_GAMEOPTIONS2
|
|
|
|
#define GAMEOPTION_ANIMATED_INTERFACE GUIO_GAMEOPTIONS3
|
|
|
|
#define GAMEOPTION_NAUGHTY_MODE GUIO_GAMEOPTIONS4
|
|
|
|
//#define GAMEOPTION_GRAPHICS_DITHERING GUIO_GAMEOPTIONS5
|
|
|
|
|
2019-12-20 22:51:20 -03:00
|
|
|
#ifdef USE_TTS
|
|
|
|
#define GAMEOPTION_TTS_NARRATOR GUIO_GAMEOPTIONS5
|
|
|
|
#endif
|
|
|
|
|
2014-02-16 15:22:57 -05:00
|
|
|
#include "mads/detection_tables.h"
|
|
|
|
|
2015-03-15 04:05:06 +02:00
|
|
|
static const ADExtraGuiOptionsMap optionsList[] = {
|
|
|
|
{
|
|
|
|
GAMEOPTION_EASY_MOUSE,
|
|
|
|
{
|
|
|
|
_s("Easy mouse interface"),
|
|
|
|
_s("Shows object names when hovering the mouse over them"),
|
|
|
|
"EasyMouse",
|
|
|
|
true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
GAMEOPTION_ANIMATED_INVENTORY,
|
|
|
|
{
|
|
|
|
_s("Animated inventory items"),
|
|
|
|
_s("Animated inventory items"),
|
|
|
|
"InvObjectsAnimated",
|
|
|
|
true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
GAMEOPTION_ANIMATED_INTERFACE,
|
|
|
|
{
|
|
|
|
_s("Animated game interface"),
|
|
|
|
_s("Animated game interface"),
|
|
|
|
"TextWindowAnimated",
|
|
|
|
true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
GAMEOPTION_NAUGHTY_MODE,
|
|
|
|
{
|
|
|
|
_s("Naughty game mode"),
|
|
|
|
_s("Naughty game mode"),
|
|
|
|
"NaughtyMode",
|
|
|
|
true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/*{
|
|
|
|
GAMEOPTION_GRAPHICS_DITHERING,
|
|
|
|
{
|
|
|
|
_s("Graphics dithering"),
|
|
|
|
_s("Graphics dithering"),
|
|
|
|
"GraphicsDithering",
|
|
|
|
true
|
|
|
|
}
|
|
|
|
},*/
|
|
|
|
|
2019-12-20 22:51:20 -03:00
|
|
|
#ifdef USE_TTS
|
|
|
|
{
|
|
|
|
GAMEOPTION_TTS_NARRATOR,
|
|
|
|
{
|
|
|
|
_s("TTS Narrator"),
|
|
|
|
_s("Use TTS to read the descriptions (if TTS is available)"),
|
|
|
|
"tts_narrator",
|
|
|
|
false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
#endif
|
|
|
|
|
2015-03-15 04:05:06 +02:00
|
|
|
AD_EXTRA_GUI_OPTIONS_TERMINATOR
|
|
|
|
};
|
|
|
|
|
2014-02-16 15:22:57 -05:00
|
|
|
class MADSMetaEngine : public AdvancedMetaEngine {
|
|
|
|
public:
|
2015-03-15 04:05:06 +02:00
|
|
|
MADSMetaEngine() : AdvancedMetaEngine(MADS::gameDescriptions, sizeof(MADS::MADSGameDescription), MADSGames, optionsList) {
|
2014-02-16 15:22:57 -05:00
|
|
|
_maxScanDepth = 3;
|
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:30 +01:00
|
|
|
const char *getEngineId() const override {
|
2016-09-15 18:23:35 +02:00
|
|
|
return "mads";
|
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:30 +01:00
|
|
|
const char *getName() const override {
|
2016-09-15 20:04:14 +02:00
|
|
|
return "MADS";
|
2014-02-16 15:22:57 -05:00
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:30 +01:00
|
|
|
const char *getOriginalCopyright() const override {
|
2018-12-10 18:39:26 +01:00
|
|
|
return "MADS (C) Microprose";
|
2014-02-16 15:22:57 -05:00
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:30 +01:00
|
|
|
bool hasFeature(MetaEngineFeature f) const override;
|
|
|
|
bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
|
|
|
|
SaveStateList listSaves(const char *target) const override;
|
|
|
|
int getMaximumSaveSlot() const override;
|
|
|
|
void removeSaveState(const char *target, int slot) const override;
|
2020-02-05 15:54:38 +01:00
|
|
|
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
|
2014-02-16 15:22:57 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
bool MADSMetaEngine::hasFeature(MetaEngineFeature f) const {
|
|
|
|
return
|
|
|
|
(f == kSupportsListSaves) ||
|
|
|
|
(f == kSupportsLoadingDuringStartup) ||
|
|
|
|
(f == kSupportsDeleteSave) ||
|
|
|
|
(f == kSavesSupportMetaInfo) ||
|
2016-07-25 14:32:04 +06:00
|
|
|
(f == kSavesSupportThumbnail) ||
|
|
|
|
(f == kSimpleSavesNames);
|
2014-02-16 15:22:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MADS::MADSEngine::hasFeature(EngineFeature f) const {
|
|
|
|
return
|
2020-05-11 08:42:53 -04:00
|
|
|
(f == kSupportsReturnToLauncher) ||
|
2014-02-16 15:22:57 -05:00
|
|
|
(f == kSupportsLoadingDuringRuntime) ||
|
|
|
|
(f == kSupportsSavingDuringRuntime);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MADSMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
|
|
|
const MADS::MADSGameDescription *gd = (const MADS::MADSGameDescription *)desc;
|
|
|
|
if (gd) {
|
|
|
|
*engine = new MADS::MADSEngine(syst, gd);
|
|
|
|
}
|
|
|
|
return gd != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveStateList MADSMetaEngine::listSaves(const char *target) const {
|
|
|
|
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
|
|
|
Common::StringArray filenames;
|
|
|
|
Common::String saveDesc;
|
2016-01-26 02:42:08 +01:00
|
|
|
Common::String pattern = Common::String::format("%s.0##", target);
|
2014-04-26 09:08:46 -04:00
|
|
|
MADS::MADSSavegameHeader header;
|
2014-02-16 15:22:57 -05:00
|
|
|
|
|
|
|
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) {
|
ALL: Load savegame thumbnail only when necessary
This commit introduces the following changes:
1. Graphics::loadThumbnail()
Now returns a boolean and takes a new argument skipThumbnail which
defaults to false. In case of true, loadThumbnail() reads past the
thumbnail data in the input stream instead of actually loading the
thumbnail. This simplifies savegame handling where, up until now,
many engines always read the whole savegame metadata (including
the thumbnail) and then threw away the thumbnail when not needed
(which is in almost all cases, the most common exception being
MetaEngine::querySaveMetaInfos() which is responsible for loading
savegame metadata for displaying it in the GUI launcher.
2. readSavegameHeader()
Engines which already implement such a method (name varies) now take
a new argument skipThumbnail (default: true) which is passed
through to loadThumbnail(). This means that the default case for
readSavegameHeader() is now _not_ loading the thumbnail from a
savegame and just reading past it. In those cases, e.g.
querySaveMetaInfos(), where we actually are interested in loading
the thumbnail readSavegameHeader() needs to explicitely be called
with skipThumbnail == false.
Engines whose readSavegameHeader() (name varies) already takes an
argument loadThumbnail have been adapted to have a similar
prototype and semantics.
I.e. readSaveHeader(in, loadThumbnail, header) now is
readSaveHeader(in, header, skipThumbnail).
3. Error handling
Engines which previously did not check the return value of
readSavegameHeader() (name varies) now do so ensuring that possibly
broken savegames (be it a broken thumbnail or something else) don't
make it into the GUI launcher list in the first place.
2018-04-06 00:06:38 +02:00
|
|
|
if (MADS::Game::readSavegameHeader(in, header))
|
|
|
|
saveList.push_back(SaveStateDescriptor(slot, header._saveName));
|
2014-02-16 15:22:57 -05:00
|
|
|
delete in;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-25 19:55:14 +01:00
|
|
|
// Sort saves based on slot number.
|
|
|
|
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
|
2014-02-16 15:22:57 -05:00
|
|
|
return saveList;
|
|
|
|
}
|
|
|
|
|
|
|
|
int MADSMetaEngine::getMaximumSaveSlot() const {
|
|
|
|
return MAX_SAVES;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MADSMetaEngine::removeSaveState(const char *target, int slot) const {
|
|
|
|
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
|
|
|
g_system->getSavefileManager()->removeSavefile(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveStateDescriptor MADSMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
|
|
|
|
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
|
|
|
Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename);
|
|
|
|
|
|
|
|
if (f) {
|
2014-05-02 21:29:33 -04:00
|
|
|
MADS::MADSSavegameHeader header;
|
ALL: Load savegame thumbnail only when necessary
This commit introduces the following changes:
1. Graphics::loadThumbnail()
Now returns a boolean and takes a new argument skipThumbnail which
defaults to false. In case of true, loadThumbnail() reads past the
thumbnail data in the input stream instead of actually loading the
thumbnail. This simplifies savegame handling where, up until now,
many engines always read the whole savegame metadata (including
the thumbnail) and then threw away the thumbnail when not needed
(which is in almost all cases, the most common exception being
MetaEngine::querySaveMetaInfos() which is responsible for loading
savegame metadata for displaying it in the GUI launcher.
2. readSavegameHeader()
Engines which already implement such a method (name varies) now take
a new argument skipThumbnail (default: true) which is passed
through to loadThumbnail(). This means that the default case for
readSavegameHeader() is now _not_ loading the thumbnail from a
savegame and just reading past it. In those cases, e.g.
querySaveMetaInfos(), where we actually are interested in loading
the thumbnail readSavegameHeader() needs to explicitely be called
with skipThumbnail == false.
Engines whose readSavegameHeader() (name varies) already takes an
argument loadThumbnail have been adapted to have a similar
prototype and semantics.
I.e. readSaveHeader(in, loadThumbnail, header) now is
readSaveHeader(in, header, skipThumbnail).
3. Error handling
Engines which previously did not check the return value of
readSavegameHeader() (name varies) now do so ensuring that possibly
broken savegames (be it a broken thumbnail or something else) don't
make it into the GUI launcher list in the first place.
2018-04-06 00:06:38 +02:00
|
|
|
if (!MADS::Game::readSavegameHeader(f, header, false)) {
|
|
|
|
delete f;
|
|
|
|
return SaveStateDescriptor();
|
|
|
|
}
|
2014-02-16 15:22:57 -05:00
|
|
|
delete f;
|
|
|
|
|
|
|
|
// Create the return descriptor
|
2014-05-02 21:29:33 -04:00
|
|
|
SaveStateDescriptor desc(slot, header._saveName);
|
|
|
|
desc.setThumbnail(header._thumbnail);
|
|
|
|
desc.setSaveDate(header._year, header._month, header._day);
|
|
|
|
desc.setSaveTime(header._hour, header._minute);
|
|
|
|
desc.setPlayTime(header._totalFrames * GAME_FRAME_TIME);
|
2014-02-16 15:22:57 -05:00
|
|
|
|
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SaveStateDescriptor();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if PLUGIN_ENABLED_DYNAMIC(MADS)
|
2014-02-18 20:08:58 -05:00
|
|
|
REGISTER_PLUGIN_DYNAMIC(MADS, PLUGIN_TYPE_ENGINE, MADSMetaEngine);
|
2014-02-16 15:22:57 -05:00
|
|
|
#else
|
2014-02-18 20:08:58 -05:00
|
|
|
REGISTER_PLUGIN_STATIC(MADS, PLUGIN_TYPE_ENGINE, MADSMetaEngine);
|
2014-02-16 15:22:57 -05:00
|
|
|
#endif
|