2009-09-03 20:59:17 +00: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.
|
|
|
|
*/
|
|
|
|
|
2009-09-04 20:08:33 +00:00
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/savefile.h"
|
2009-10-18 12:13:58 +00:00
|
|
|
#include "common/algorithm.h"
|
2009-09-03 20:59:17 +00:00
|
|
|
|
|
|
|
#include "base/plugins.h"
|
2009-09-04 20:08:33 +00:00
|
|
|
|
|
|
|
#include "engines/advancedDetector.h"
|
2012-07-16 14:09:34 +00:00
|
|
|
#include "teenagent/resources.h"
|
2009-09-03 20:59:17 +00:00
|
|
|
#include "teenagent/teenagent.h"
|
2009-10-18 12:13:58 +00:00
|
|
|
#include "graphics/thumbnail.h"
|
2009-09-03 20:59:17 +00:00
|
|
|
|
|
|
|
static const PlainGameDescriptor teenAgentGames[] = {
|
2009-09-15 10:36:50 +00:00
|
|
|
{ "teenagent", "Teen Agent" },
|
2009-09-03 20:59:17 +00:00
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
2009-09-05 08:16:35 +00:00
|
|
|
static const ADGameDescription teenAgentGameDescriptions[] = {
|
2009-09-03 20:59:17 +00:00
|
|
|
{
|
2009-09-05 08:16:35 +00:00
|
|
|
"teenagent",
|
|
|
|
"",
|
2009-09-03 22:42:12 +00:00
|
|
|
{
|
2009-09-05 08:16:35 +00:00
|
|
|
{"off.res", 0, NULL, -1},
|
|
|
|
{"on.res", 0, NULL, -1},
|
|
|
|
{"ons.res", 0, NULL, -1},
|
|
|
|
{"varia.res", 0, NULL, -1},
|
|
|
|
{"lan_000.res", 0, NULL, -1},
|
|
|
|
{"lan_500.res", 0, NULL, -1},
|
|
|
|
{"mmm.res", 0, NULL, -1},
|
|
|
|
{"sam_mmm.res", 0, NULL, -1},
|
|
|
|
{"sam_sam.res", 0, NULL, -1},
|
2010-04-28 19:50:28 +00:00
|
|
|
//{"unlogic.res", 0, NULL, -1}, //skipped if not present
|
2009-09-05 08:16:35 +00:00
|
|
|
{NULL, 0, NULL, 0}
|
2009-09-15 08:54:06 +00:00
|
|
|
},
|
2009-09-05 08:16:35 +00:00
|
|
|
Common::EN_ANY,
|
|
|
|
Common::kPlatformPC,
|
|
|
|
ADGF_NO_FLAGS,
|
2011-10-23 16:52:43 +00:00
|
|
|
GUIO1(GUIO_NOSPEECH)
|
2010-04-28 19:50:28 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"teenagent",
|
|
|
|
"",
|
|
|
|
{
|
|
|
|
{"off.res", 0, NULL, -1},
|
|
|
|
{"on.res", 0, NULL, -1},
|
|
|
|
{"ons.res", 0, NULL, -1},
|
|
|
|
{"varia.res", 0, NULL, -1},
|
|
|
|
{"lan_000.res", 0, NULL, -1},
|
|
|
|
{"lan_500.res", 0, NULL, -1},
|
|
|
|
{"sam_sam.res", 0, NULL, -1},
|
|
|
|
{"voices.res", 0, NULL, -1},
|
|
|
|
{"cdlogo.res", 0, NULL, -1},
|
|
|
|
{NULL, 0, NULL, 0}
|
|
|
|
},
|
|
|
|
Common::CZ_CZE,
|
|
|
|
Common::kPlatformPC,
|
|
|
|
ADGF_CD,
|
2011-11-16 21:38:58 +00:00
|
|
|
GUIO0()
|
2009-09-15 08:54:06 +00:00
|
|
|
},
|
|
|
|
AD_TABLE_END_MARKER,
|
2009-09-03 20:59:17 +00:00
|
|
|
};
|
|
|
|
|
2011-06-10 13:53:56 +00:00
|
|
|
enum {
|
2012-07-04 01:13:40 +00:00
|
|
|
MAX_SAVES = 20
|
2009-09-03 20:59:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TeenAgentMetaEngine : public AdvancedMetaEngine {
|
|
|
|
public:
|
2011-06-10 13:53:56 +00:00
|
|
|
TeenAgentMetaEngine() : AdvancedMetaEngine(teenAgentGameDescriptions, sizeof(ADGameDescription), teenAgentGames) {
|
2011-06-11 15:52:32 +00:00
|
|
|
_singleid = "teenagent";
|
2009-09-03 20:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *getName() const {
|
2011-05-22 11:46:57 +00:00
|
|
|
return "TeenAgent";
|
2009-09-03 20:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *getOriginalCopyright() const {
|
2009-12-25 03:31:19 +00:00
|
|
|
return "TEENAGENT (C) 1994 Metropolis";
|
2009-09-03 20:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool hasFeature(MetaEngineFeature f) const {
|
|
|
|
switch (f) {
|
|
|
|
case kSupportsListSaves:
|
|
|
|
case kSupportsDeleteSave:
|
|
|
|
case kSupportsLoadingDuringStartup:
|
2009-10-18 12:13:58 +00:00
|
|
|
case kSavesSupportMetaInfo:
|
|
|
|
case kSavesSupportThumbnail:
|
2009-09-03 20:59:17 +00:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
|
|
|
if (desc) {
|
2009-09-05 08:16:35 +00:00
|
|
|
*engine = new TeenAgent::TeenAgentEngine(syst, desc);
|
2009-09-03 20:59:17 +00:00
|
|
|
}
|
|
|
|
return desc != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Common::String generateGameStateFileName(const char *target, int slot) {
|
2010-11-01 16:02:28 +00:00
|
|
|
return Common::String::format("%s.%02d", target, slot);
|
2009-09-03 20:59:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual SaveStateList listSaves(const char *target) const {
|
|
|
|
Common::String pattern = target;
|
2012-07-04 01:13:40 +00:00
|
|
|
pattern += ".??";
|
2009-09-15 08:54:06 +00:00
|
|
|
|
2010-03-18 15:54:40 +00:00
|
|
|
Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles(pattern);
|
2009-10-18 12:13:58 +00:00
|
|
|
Common::sort(filenames.begin(), filenames.end());
|
|
|
|
|
2009-09-03 20:59:17 +00:00
|
|
|
SaveStateList saveList;
|
2010-03-18 15:54:40 +00:00
|
|
|
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
|
2012-07-04 01:13:40 +00:00
|
|
|
int slot = atoi(file->c_str() + file->size() - 2);
|
|
|
|
if (slot >= 0 && slot < MAX_SAVES) {
|
2010-03-20 20:03:58 +00:00
|
|
|
Common::ScopedPtr<Common::InSaveFile> in(g_system->getSavefileManager()->openForLoading(*file));
|
2010-03-20 14:53:46 +00:00
|
|
|
if (!in)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
char buf[25];
|
|
|
|
in->seek(0);
|
|
|
|
in->read(buf, 24);
|
|
|
|
buf[24] = 0;
|
|
|
|
saveList.push_back(SaveStateDescriptor(slot, buf));
|
2009-09-03 20:59:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return saveList;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int getMaximumSaveSlot() const {
|
|
|
|
return MAX_SAVES - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void removeSaveState(const char *target, int slot) const {
|
|
|
|
Common::String filename = generateGameStateFileName(target, slot);
|
|
|
|
g_system->getSavefileManager()->removeSavefile(filename);
|
|
|
|
}
|
2009-10-18 12:13:58 +00:00
|
|
|
|
|
|
|
virtual SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const {
|
|
|
|
Common::String filename = generateGameStateFileName(target, slot);
|
2010-03-20 20:03:58 +00:00
|
|
|
Common::ScopedPtr<Common::InSaveFile> in(g_system->getSavefileManager()->openForLoading(filename));
|
2010-03-20 14:53:46 +00:00
|
|
|
if (!in)
|
2009-10-18 12:13:58 +00:00
|
|
|
return SaveStateDescriptor();
|
|
|
|
|
|
|
|
char buf[25];
|
|
|
|
in->seek(0);
|
|
|
|
in->read(buf, 24);
|
|
|
|
buf[24] = 0;
|
|
|
|
|
|
|
|
Common::String desc = buf;
|
|
|
|
|
2012-07-16 14:09:34 +00:00
|
|
|
in->seek(TeenAgent::saveStateSize);
|
2009-10-18 12:13:58 +00:00
|
|
|
if (!Graphics::checkThumbnailHeader(*in))
|
|
|
|
return SaveStateDescriptor(slot, desc);
|
|
|
|
|
|
|
|
SaveStateDescriptor ssd(slot, desc);
|
2010-03-20 14:53:46 +00:00
|
|
|
|
|
|
|
//checking for the thumbnail
|
2011-08-07 12:35:01 +00:00
|
|
|
if (Graphics::Surface *const thumb = Graphics::loadThumbnail(*in))
|
|
|
|
ssd.setThumbnail(thumb);
|
2009-10-18 12:13:58 +00:00
|
|
|
|
|
|
|
return ssd;
|
|
|
|
}
|
2009-09-03 20:59:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if PLUGIN_ENABLED_DYNAMIC(TEENAGENT)
|
2009-09-15 08:54:06 +00:00
|
|
|
REGISTER_PLUGIN_DYNAMIC(TEENAGENT, PLUGIN_TYPE_ENGINE, TeenAgentMetaEngine);
|
2009-09-03 20:59:17 +00:00
|
|
|
#else
|
2009-09-15 08:54:06 +00:00
|
|
|
REGISTER_PLUGIN_STATIC(TEENAGENT, PLUGIN_TYPE_ENGINE, TeenAgentMetaEngine);
|
2009-09-03 20:59:17 +00:00
|
|
|
#endif
|