2007-05-30 21:56:52 +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.
|
2007-01-21 00:25:04 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-09-17 17:31:29 +00:00
|
|
|
#include "engines/game.h"
|
2007-01-21 00:25:04 +00:00
|
|
|
#include "base/plugins.h"
|
2008-02-04 10:15:21 +00:00
|
|
|
#include "graphics/surface.h"
|
|
|
|
|
2007-01-21 00:25:04 +00:00
|
|
|
|
2007-06-15 17:13:13 +00:00
|
|
|
const PlainGameDescriptor *findPlainGameDescriptor(const char *gameid, const PlainGameDescriptor *list) {
|
|
|
|
const PlainGameDescriptor *g = list;
|
|
|
|
while (g->gameid) {
|
|
|
|
if (0 == scumm_stricmp(gameid, g->gameid))
|
2008-07-20 16:28:06 +00:00
|
|
|
return g;
|
2007-06-15 17:13:13 +00:00
|
|
|
g++;
|
|
|
|
}
|
2008-07-20 16:28:06 +00:00
|
|
|
return 0;
|
2007-06-15 17:13:13 +00:00
|
|
|
}
|
|
|
|
|
2008-10-06 12:48:52 +00:00
|
|
|
GameDescriptor::GameDescriptor() {
|
|
|
|
setVal("gameid", "");
|
|
|
|
setVal("description", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
GameDescriptor::GameDescriptor(const PlainGameDescriptor &pgd) {
|
|
|
|
setVal("gameid", pgd.gameid);
|
|
|
|
setVal("description", pgd.description);
|
|
|
|
}
|
|
|
|
|
2009-06-06 17:57:39 +00:00
|
|
|
GameDescriptor::GameDescriptor(const PlainGameDescriptorGUIOpts &pgd) {
|
|
|
|
setVal("gameid", pgd.gameid);
|
|
|
|
setVal("description", pgd.description);
|
|
|
|
|
|
|
|
if (pgd.guioptions != 0)
|
|
|
|
setVal("guioptions", Common::getGameGUIOptionsDescription(pgd.guioptions));
|
|
|
|
}
|
|
|
|
|
|
|
|
GameDescriptor::GameDescriptor(const Common::String &g, const Common::String &d, Common::Language l, Common::Platform p, uint32 guioptions) {
|
2008-10-06 12:48:52 +00:00
|
|
|
setVal("gameid", g);
|
|
|
|
setVal("description", d);
|
|
|
|
if (l != Common::UNK_LANG)
|
|
|
|
setVal("language", Common::getLanguageCode(l));
|
|
|
|
if (p != Common::kPlatformUnknown)
|
|
|
|
setVal("platform", Common::getPlatformCode(p));
|
2009-06-06 17:57:39 +00:00
|
|
|
if (guioptions != 0)
|
|
|
|
setVal("guioptions", Common::getGameGUIOptionsDescription(guioptions));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameDescriptor::setGUIOptions(uint32 guioptions) {
|
|
|
|
if (guioptions != 0)
|
|
|
|
setVal("guioptions", Common::getGameGUIOptionsDescription(guioptions));
|
|
|
|
else
|
|
|
|
erase("guioptions");
|
2008-10-06 12:48:52 +00:00
|
|
|
}
|
|
|
|
|
2007-01-21 00:25:04 +00:00
|
|
|
void GameDescriptor::updateDesc(const char *extra) {
|
|
|
|
// TODO: The format used here (LANG/PLATFORM/EXTRA) is not set in stone.
|
|
|
|
// We may want to change the order (PLATFORM/EXTRA/LANG, anybody?), or
|
|
|
|
// the seperator (instead of '/' use ', ' or ' ').
|
2007-01-21 00:29:03 +00:00
|
|
|
const bool hasCustomLanguage = (language() != Common::UNK_LANG);
|
|
|
|
const bool hasCustomPlatform = (platform() != Common::kPlatformUnknown);
|
2007-01-21 00:25:04 +00:00
|
|
|
const bool hasExtraDesc = (extra && extra[0]);
|
|
|
|
|
|
|
|
// Adapt the description string if custom platform/language is set.
|
|
|
|
if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
|
2007-01-21 00:29:03 +00:00
|
|
|
Common::String descr = description();
|
2007-01-21 00:25:04 +00:00
|
|
|
|
|
|
|
descr += " (";
|
2007-02-06 12:01:34 +00:00
|
|
|
if (hasExtraDesc)
|
|
|
|
descr += extra;
|
2007-01-21 00:25:04 +00:00
|
|
|
if (hasCustomPlatform) {
|
2007-02-06 12:01:34 +00:00
|
|
|
if (hasExtraDesc)
|
2007-01-21 00:25:04 +00:00
|
|
|
descr += "/";
|
2007-01-21 00:29:03 +00:00
|
|
|
descr += Common::getPlatformDescription(platform());
|
2007-01-21 00:25:04 +00:00
|
|
|
}
|
2007-02-06 12:01:34 +00:00
|
|
|
if (hasCustomLanguage) {
|
|
|
|
if (hasExtraDesc || hasCustomPlatform)
|
2007-01-21 00:25:04 +00:00
|
|
|
descr += "/";
|
2007-02-06 12:01:34 +00:00
|
|
|
descr += Common::getLanguageDescription(language());
|
2007-01-21 00:25:04 +00:00
|
|
|
}
|
|
|
|
descr += ")";
|
2007-01-21 00:29:03 +00:00
|
|
|
setVal("description", descr);
|
2007-01-21 00:25:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-04 10:15:21 +00:00
|
|
|
void SaveStateDescriptor::setThumbnail(Graphics::Surface *t) {
|
2008-09-16 14:10:55 +00:00
|
|
|
if (_thumbnail.get() == t)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_thumbnail = Common::SharedPtr<Graphics::Surface>(t, Graphics::SharedPtrSurfaceDeleter());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SaveStateDescriptor::getBool(const Common::String &key) const {
|
|
|
|
if (contains(key)) {
|
|
|
|
Common::String value = getVal(key);
|
|
|
|
if (value.equalsIgnoreCase("true") ||
|
2009-01-01 15:06:43 +00:00
|
|
|
value.equalsIgnoreCase("yes") ||
|
2008-09-16 14:10:55 +00:00
|
|
|
value.equals("1"))
|
|
|
|
return true;
|
|
|
|
if (value.equalsIgnoreCase("false") ||
|
2009-01-01 15:06:43 +00:00
|
|
|
value.equalsIgnoreCase("no") ||
|
2008-09-16 14:10:55 +00:00
|
|
|
value.equals("0"))
|
|
|
|
return false;
|
|
|
|
error("SaveStateDescriptor: %s '%s' has unknown value '%s' for boolean '%s'",
|
|
|
|
save_slot().c_str(), description().c_str(), value.c_str(), key.c_str());
|
2008-02-04 10:15:21 +00:00
|
|
|
}
|
2008-09-16 14:10:55 +00:00
|
|
|
return false;
|
2008-02-04 10:15:21 +00:00
|
|
|
}
|
2008-09-16 14:10:55 +00:00
|
|
|
|
|
|
|
void SaveStateDescriptor::setDeletableFlag(bool state) {
|
|
|
|
setVal("is_deletable", state ? "true" : "false");
|
|
|
|
}
|
|
|
|
|
2008-11-09 20:07:46 +00:00
|
|
|
void SaveStateDescriptor::setWriteProtectedFlag(bool state) {
|
|
|
|
setVal("is_write_protected", state ? "true" : "false");
|
|
|
|
}
|
|
|
|
|
2008-09-16 14:56:02 +00:00
|
|
|
void SaveStateDescriptor::setSaveDate(int year, int month, int day) {
|
|
|
|
char buffer[32];
|
|
|
|
snprintf(buffer, 32, "%.2d.%.2d.%.4d", day, month, year);
|
|
|
|
setVal("save_date", buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SaveStateDescriptor::setSaveTime(int hour, int min) {
|
|
|
|
char buffer[32];
|
|
|
|
snprintf(buffer, 32, "%.2d:%.2d", hour, min);
|
|
|
|
setVal("save_time", buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SaveStateDescriptor::setPlayTime(int hours, int minutes) {
|
|
|
|
char buffer[32];
|
|
|
|
snprintf(buffer, 32, "%.2d:%.2d", hours, minutes);
|
|
|
|
setVal("play_time", buffer);
|
|
|
|
}
|
|
|
|
|