2012-09-07 22:20:05 +10: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:21 +01:00
|
|
|
*
|
2012-09-07 22:20:05 +10: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:21 +01:00
|
|
|
*
|
2012-09-07 22:20:05 +10: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-02-15 22:20:24 +01:00
|
|
|
#include "hopkins/hopkins.h"
|
2012-09-07 22:20:05 +10:00
|
|
|
|
2013-02-15 22:20:24 +01:00
|
|
|
#include "base/plugins.h"
|
2012-09-07 22:20:05 +10:00
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/str-array.h"
|
|
|
|
#include "common/memstream.h"
|
|
|
|
#include "engines/advancedDetector.h"
|
|
|
|
#include "common/system.h"
|
2014-02-02 16:20:17 +01:00
|
|
|
#include "common/translation.h"
|
2012-09-07 22:20:05 +10:00
|
|
|
#include "graphics/surface.h"
|
|
|
|
|
2012-10-28 14:51:17 +11:00
|
|
|
#define MAX_SAVES 99
|
|
|
|
|
2012-09-07 22:20:05 +10:00
|
|
|
namespace Hopkins {
|
|
|
|
|
|
|
|
struct HopkinsGameDescription {
|
|
|
|
ADGameDescription desc;
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32 HopkinsEngine::getFeatures() const {
|
|
|
|
return _gameDescription->desc.flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Language HopkinsEngine::getLanguage() const {
|
|
|
|
return _gameDescription->desc.language;
|
|
|
|
}
|
|
|
|
|
2012-10-27 19:08:53 +02:00
|
|
|
Common::Platform HopkinsEngine::getPlatform() const {
|
|
|
|
return _gameDescription->desc.platform;
|
|
|
|
}
|
|
|
|
|
2012-09-07 22:20:05 +10:00
|
|
|
bool HopkinsEngine::getIsDemo() const {
|
|
|
|
return _gameDescription->desc.flags & ADGF_DEMO;
|
|
|
|
}
|
|
|
|
|
2013-08-01 03:28:27 +02:00
|
|
|
const Common::String &HopkinsEngine::getTargetName() const {
|
2013-07-31 21:01:04 -04:00
|
|
|
return _targetName;
|
|
|
|
}
|
|
|
|
|
2012-09-07 22:20:05 +10:00
|
|
|
} // End of namespace Hopkins
|
|
|
|
|
2012-09-08 09:08:24 +10:00
|
|
|
static const PlainGameDescriptor hopkinsGames[] = {
|
2012-09-07 22:20:05 +10:00
|
|
|
{"hopkins", "Hopkins FBI"},
|
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
#include "hopkins/detection_tables.h"
|
|
|
|
|
2014-02-02 16:20:17 +01:00
|
|
|
static const ADExtraGuiOptionsMap optionsList[] = {
|
|
|
|
{
|
|
|
|
GAMEOPTION_GORE_DEFAULT_OFF,
|
|
|
|
{
|
|
|
|
_s("Gore Mode"),
|
|
|
|
_s("Enable Gore Mode when available"),
|
|
|
|
"enable_gore",
|
|
|
|
false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
GAMEOPTION_GORE_DEFAULT_ON,
|
|
|
|
{
|
|
|
|
_s("Gore Mode"),
|
|
|
|
_s("Enable Gore Mode when available"),
|
|
|
|
"enable_gore",
|
|
|
|
true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
AD_EXTRA_GUI_OPTIONS_TERMINATOR
|
|
|
|
};
|
|
|
|
|
2012-11-17 00:43:05 +01:00
|
|
|
const static char *directoryGlobs[] = {
|
|
|
|
"voice",
|
2013-05-22 23:16:38 +02:00
|
|
|
"link",
|
2012-11-17 00:43:05 +01:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2012-09-07 22:20:05 +10:00
|
|
|
class HopkinsMetaEngine : public AdvancedMetaEngine {
|
|
|
|
public:
|
2014-02-02 16:20:17 +01:00
|
|
|
HopkinsMetaEngine() : AdvancedMetaEngine(Hopkins::gameDescriptions, sizeof(Hopkins::HopkinsGameDescription), hopkinsGames, optionsList) {
|
2012-11-17 00:43:05 +01:00
|
|
|
_maxScanDepth = 3;
|
|
|
|
_directoryGlobs = directoryGlobs;
|
2012-09-07 22:20:05 +10:00
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:29 +01:00
|
|
|
const char *getEngineId() const override {
|
2016-09-15 18:23:35 +02:00
|
|
|
return "hopkins";
|
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:29 +01:00
|
|
|
const char *getName() const override {
|
2016-09-15 20:04:14 +02:00
|
|
|
return "Hopkins FBI";
|
2012-09-07 22:20:05 +10:00
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:29 +01:00
|
|
|
const char *getOriginalCopyright() const override {
|
2018-12-10 18:39:26 +01:00
|
|
|
return "Hopkins FBI (C) 1997-2003 MP Entertainment";
|
2012-09-07 22:20:05 +10:00
|
|
|
}
|
|
|
|
|
2020-02-09 12:05:29 +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:28:36 +01:00
|
|
|
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
|
2012-09-07 22:20:05 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
bool HopkinsMetaEngine::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);
|
2012-09-07 22:20:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Hopkins::HopkinsEngine::hasFeature(EngineFeature f) const {
|
|
|
|
return
|
2020-05-11 08:42:53 -04:00
|
|
|
(f == kSupportsReturnToLauncher) ||
|
2012-09-07 22:20:05 +10:00
|
|
|
(f == kSupportsLoadingDuringRuntime) ||
|
|
|
|
(f == kSupportsSavingDuringRuntime);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HopkinsMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
|
|
|
const Hopkins::HopkinsGameDescription *gd = (const Hopkins::HopkinsGameDescription *)desc;
|
|
|
|
if (gd) {
|
|
|
|
*engine = new Hopkins::HopkinsEngine(syst, gd);
|
|
|
|
}
|
|
|
|
return gd != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveStateList HopkinsMetaEngine::listSaves(const char *target) const {
|
|
|
|
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
|
|
|
Common::StringArray filenames;
|
|
|
|
Common::String saveDesc;
|
2016-01-26 02:41:22 +01:00
|
|
|
Common::String pattern = Common::String::format("%s.0##", target);
|
2012-09-07 22:20:05 +10:00
|
|
|
|
|
|
|
filenames = saveFileMan->listSavefiles(pattern);
|
2012-10-28 14:51:17 +11:00
|
|
|
|
|
|
|
Hopkins::hopkinsSavegameHeader header;
|
2012-09-07 22:20:05 +10:00
|
|
|
|
|
|
|
SaveStateList saveList;
|
2012-10-28 14:51:17 +11: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) {
|
|
|
|
if (Hopkins::SaveLoadManager::readSavegameHeader(in, header)) {
|
2012-12-20 00:30:01 +01:00
|
|
|
saveList.push_back(SaveStateDescriptor(slot, header._saveName));
|
2012-10-28 14:51:17 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
delete in;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-09-07 22:20:05 +10:00
|
|
|
|
2016-02-25 19:55:13 +01:00
|
|
|
// Sort saves based on slot number.
|
|
|
|
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
|
2012-09-07 22:20:05 +10:00
|
|
|
return saveList;
|
|
|
|
}
|
|
|
|
|
|
|
|
int HopkinsMetaEngine::getMaximumSaveSlot() const {
|
2012-10-28 14:51:17 +11:00
|
|
|
return MAX_SAVES;
|
2012-09-07 22:20:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void HopkinsMetaEngine::removeSaveState(const char *target, int slot) const {
|
2012-10-28 14:51:17 +11:00
|
|
|
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
2012-09-07 22:20:05 +10:00
|
|
|
g_system->getSavefileManager()->removeSavefile(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveStateDescriptor HopkinsMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
|
2012-10-28 14:51:17 +11:00
|
|
|
Common::String filename = Common::String::format("%s.%03d", target, slot);
|
|
|
|
Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename);
|
|
|
|
|
|
|
|
if (f) {
|
|
|
|
Hopkins::hopkinsSavegameHeader 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 (!Hopkins::SaveLoadManager::readSavegameHeader(f, header, false)) {
|
|
|
|
delete f;
|
|
|
|
return SaveStateDescriptor();
|
|
|
|
}
|
|
|
|
|
2012-10-28 14:51:17 +11:00
|
|
|
delete f;
|
|
|
|
|
|
|
|
// Create the return descriptor
|
2012-12-20 00:30:01 +01: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);
|
2012-10-28 14:51:17 +11:00
|
|
|
|
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
2012-09-07 22:20:05 +10:00
|
|
|
return SaveStateDescriptor();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if PLUGIN_ENABLED_DYNAMIC(HOPKINS)
|
2014-02-17 23:02:07 +01:00
|
|
|
REGISTER_PLUGIN_DYNAMIC(HOPKINS, PLUGIN_TYPE_ENGINE, HopkinsMetaEngine);
|
2012-09-07 22:20:05 +10:00
|
|
|
#else
|
2014-02-17 23:02:07 +01:00
|
|
|
REGISTER_PLUGIN_STATIC(HOPKINS, PLUGIN_TYPE_ENGINE, HopkinsMetaEngine);
|
2012-09-07 22:20:05 +10:00
|
|
|
#endif
|