scummvm/engines/ultima/detection.cpp

124 lines
3.5 KiB
C++
Raw Normal View History

2019-12-01 10:19:47 -08: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.
*
*/
#include "ultima/detection.h"
2019-12-01 10:19:47 -08:00
#include "base/plugins.h"
#include "common/savefile.h"
#include "common/str-array.h"
#include "common/memstream.h"
#include "common/system.h"
#include "common/translation.h"
#ifdef ENABLE_ULTIMA6
#include "ultima/ultima6/ultima6.h"
#endif
2019-12-15 21:28:15 -08:00
#ifdef ENABLE_ULTIMA8
#include "ultima/ultima8/ultima8.h"
#endif
2019-12-01 10:19:47 -08:00
static const PlainGameDescriptor ULTIMA_GAMES[] = {
2019-12-17 07:49:53 -08:00
#ifdef ENABLE_ULTIMA6
{ "ultima6", "Ultima VI - The False Prophet" },
#endif
#ifdef ENABLE_ULTIMA8
2019-12-01 10:19:47 -08:00
{ "ultima8", "Ultima 8 - Pagan" },
#endif
{ 0, 0 }
2019-12-01 10:19:47 -08:00
};
#include "ultima/detection_tables.h"
2019-12-01 10:19:47 -08:00
2020-01-01 20:48:52 -10:00
namespace Ultima {
UltimaMetaEngine *g_metaEngine;
}; // End of namespace Ultima
UltimaMetaEngine::UltimaMetaEngine() : AdvancedMetaEngine(Ultima::GAME_DESCRIPTIONS,
sizeof(Ultima::UltimaGameDescription), ULTIMA_GAMES) {
2020-01-01 20:48:52 -10:00
Ultima::g_metaEngine = this;
#ifdef ENABLE_ULTIMA8
static const char *const DIRECTORY_GLOBS[2] = { "usecode", 0 };
_maxScanDepth = 2;
_directoryGlobs = DIRECTORY_GLOBS;
#endif
2019-12-01 10:19:47 -08:00
}
2020-01-01 20:48:52 -10:00
UltimaMetaEngine::~UltimaMetaEngine() {
Ultima::g_metaEngine = nullptr;
}
bool UltimaMetaEngine::hasFeature(MetaEngineFeature f) const {
2019-12-01 10:19:47 -08:00
return
(f == kSupportsListSaves) ||
(f == kSupportsDeleteSave) ||
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSavesSupportCreationDate) ||
(f == kSavesSupportPlayTime) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSavesUseExtendedFormat);
2019-12-01 10:19:47 -08:00
}
bool UltimaMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
const Ultima::UltimaGameDescription *gd = (const Ultima::UltimaGameDescription *)desc;
2019-12-01 10:19:47 -08:00
if (gd) {
switch (gd->gameId) {
#ifdef ENABLE_ULTIMA6
case Ultima::GAME_ULTIMA6:
*engine = new Ultima::Ultima6::Ultima6Engine(syst, gd);
break;
#endif
2019-12-15 21:28:15 -08:00
#ifdef ENABLE_ULTIMA8
case Ultima::GAME_ULTIMA8:
*engine = new Ultima::Ultima8::Ultima8Engine(syst, gd);
break;
2019-12-15 21:28:15 -08:00
#endif
default:
error("Unsupported game specified");
}
2019-12-01 10:19:47 -08:00
}
return gd != 0;
}
int UltimaMetaEngine::getMaximumSaveSlot() const {
2019-12-01 10:19:47 -08:00
return MAX_SAVES;
}
const char *UltimaMetaEngine::getSavegamePattern(const char *target) const {
static char buffer[100];
snprintf(buffer, 200, "%s.###", target == nullptr ? getEngineId() : target);
2019-12-01 10:19:47 -08:00
return buffer;
2019-12-01 10:19:47 -08:00
}
2020-01-01 20:48:52 -10:00
const char *UltimaMetaEngine::getSavegameFile(int saveGameIdx, const char *target) const {
static char buffer[100];
snprintf(buffer, 200, "%s.%.3d", target == nullptr ? getEngineId() : target, saveGameIdx);
return buffer;
}
#if PLUGIN_ENABLED_DYNAMIC(ULTIMA)
REGISTER_PLUGIN_DYNAMIC(ULTIMA, PLUGIN_TYPE_ENGINE, UltimaMetaEngine);
2019-12-01 10:19:47 -08:00
#else
REGISTER_PLUGIN_STATIC(ULTIMA, PLUGIN_TYPE_ENGINE, UltimaMetaEngine);
2019-12-01 10:19:47 -08:00
#endif