CRYOMNI3D: Split detection features & adapt to new plugins.

This commit is contained in:
aryanrawlani28 2020-08-07 04:50:13 +05:30 committed by Eugene Sandulenko
parent fb458421cf
commit e9ad5efad1
7 changed files with 245 additions and 142 deletions

2
configure vendored
View File

@ -6169,7 +6169,7 @@ declare -a static_detect_engines=("PLUMBERS" "AGI" "SCUMM" "SKY" "DREAMWEB" "DRA
"PETKA" "PINK" "PRINCE" "SHERLOCK" "SLUDGE" "STARTREK" "SUPERNOVA"
"TEENAGENT" "TESTBED" "TINSEL" "TITANIC" "TOLTECS" "TONY" "TOON"
"TOUCHE" "TSAGE" "TUCKER" "VOYEUR" "WAGE" "AVALANCHE" "BBVS"
"BLADERUNNER" "CHEWY" "CINE" "CRUISE" "CRYO")
"BLADERUNNER" "CHEWY" "CINE" "CRUISE" "CRYO" "CRYOMNI3D")
detectId="_DETECTION"
echo "Creating engines/plugins_table.h"

View File

@ -38,6 +38,7 @@
#include "cryomni3d/font_manager.h"
#include "cryomni3d/objects.h"
#include "cryomni3d/sprites.h"
#include "cryomni3d/detection_enums.h"
class OSystem;
@ -63,24 +64,6 @@ namespace CryOmni3D {
class DATSeekableStream;
enum CryOmni3DGameType {
GType_VERSAILLES
};
enum CryOmni3DGameFeatures {
GF_VERSAILLES_FONTS_MASK = (3 << 0), // Fonts flag mask
GF_VERSAILLES_FONTS_NUMERIC = (0 << 0), // Fonts are font01.crf, ...
GF_VERSAILLES_FONTS_SET_A = (1 << 0), // Fonts are for French Macintosh (development version)
GF_VERSAILLES_FONTS_SET_B = (2 << 0), // Standard set (Helvet12 is used for debugging docs)
GF_VERSAILLES_FONTS_SET_C = (3 << 0), // Fonts for Italian version (Helvet12 is used for docs texts)
GF_VERSAILLES_AUDIOPADDING_NO = (0 << 2), // Audio files have underscore padding before extension
GF_VERSAILLES_AUDIOPADDING_YES = (1 << 2), // Audio files have underscore padding before extension
GF_VERSAILLES_LINK_STANDARD = (0 << 3), // Links file is lien_doc.txt
GF_VERSAILLES_LINK_LOCALIZED = (1 << 3) // Links file is taken from cryomni3d.dat
};
struct CryOmni3DGameDescription;
// Engine Debug Flags

View File

@ -23,53 +23,15 @@
#include "base/plugins.h"
#include "engines/advancedDetector.h"
#include "common/file.h"
#include "common/md5.h"
#include "common/savefile.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "cryomni3d/cryomni3d.h"
#ifdef ENABLE_VERSAILLES
#include "cryomni3d/versailles/engine.h"
#endif
#include "cryomni3d/detection.h"
#include "cryomni3d/detection_enums.h"
namespace CryOmni3D {
struct CryOmni3DGameDescription {
ADGameDescription desc;
uint8 gameType;
uint32 features;
};
const char *CryOmni3DEngine::getGameId() const {
return _gameDescription->desc.gameId;
}
uint32 CryOmni3DEngine::getFeatures() const {
return _gameDescription->features;
}
Common::Platform CryOmni3DEngine::getPlatform() const {
return _gameDescription->desc.platform;
}
uint8 CryOmni3DEngine::getGameType() const {
return _gameDescription->gameType;
}
Common::Language CryOmni3DEngine::getLanguage() const {
return _gameDescription->desc.language;
}
bool CryOmni3DEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsReturnToLauncher)
|| (f == kSupportsSubtitleOptions);
}
static const PlainGameDescriptor cryomni3DGames[] = {
{"versailles", "Versailles 1685"},
{0, 0}
@ -105,88 +67,8 @@ public:
const char *getOriginalCopyright() const override {
return "Cryo game Engine (C) 1997-2002 Cryo Interactive";
}
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 { return 999; }
void removeSaveState(const char *target, int slot) const override;
};
bool CryOmni3DMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves)
|| (f == kSupportsLoadingDuringStartup)
|| (f == kSupportsDeleteSave)
|| (f == kSimpleSavesNames);
}
SaveStateList CryOmni3DMetaEngine::listSaves(const char *target) const {
// Replicate constant here to shorten lines
static const uint kSaveDescriptionLen = CryOmni3DEngine::kSaveDescriptionLen;
SaveStateList saveList;
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
char saveName[kSaveDescriptionLen + 1];
saveName[kSaveDescriptionLen] = '\0';
Common::String pattern = Common::String::format("%s.????", target);
Common::StringArray filenames = saveMan->listSavefiles(pattern);
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
int slotNum;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end();
++file) {
// Obtain the last 4 digits of the filename, since they correspond to the save slot
slotNum = atoi(file->c_str() + file->size() - 4);
if (slotNum >= 1 && slotNum <= 99) {
Common::InSaveFile *in = saveMan->openForLoading(*file);
if (in) {
if (in->read(saveName, kSaveDescriptionLen) == kSaveDescriptionLen) {
saveList.push_back(SaveStateDescriptor(slotNum - 1, saveName));
}
delete in;
}
}
}
return saveList;
}
void CryOmni3DMetaEngine::removeSaveState(const char *target, int slot) const {
Common::String filename = Common::String::format("%s.%04d", target, slot + 1);
g_system->getSavefileManager()->removeSavefile(filename);
}
bool CryOmni3DMetaEngine::createInstance(OSystem *syst, Engine **engine,
const ADGameDescription *desc) const {
const CryOmni3DGameDescription *gd = (const CryOmni3DGameDescription *)desc;
if (gd) {
switch (gd->gameType) {
case GType_VERSAILLES:
#ifdef ENABLE_VERSAILLES
*engine = new Versailles::CryOmni3DEngine_Versailles(syst, gd);
break;
#else
warning("Versailles support not compiled in");
return false;
#endif
default:
error("Unknown Cryo Omni3D Engine");
}
}
return (gd != 0);
}
} // End of Namespace CryOmni3D
#if PLUGIN_ENABLED_DYNAMIC(CRYOMNI3D)
REGISTER_PLUGIN_DYNAMIC(CRYOMNI3D, PLUGIN_TYPE_ENGINE, CryOmni3D::CryOmni3DMetaEngine);
#else
REGISTER_PLUGIN_STATIC(CRYOMNI3D, PLUGIN_TYPE_ENGINE, CryOmni3D::CryOmni3DMetaEngine);
#endif
REGISTER_PLUGIN_STATIC(CRYOMNI3D_DETECTION, PLUGIN_TYPE_METAENGINE, CryOmni3D::CryOmni3DMetaEngine);

View File

@ -0,0 +1,32 @@
/* 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.
*
*/
namespace CryOmni3D {
struct CryOmni3DGameDescription {
ADGameDescription desc;
uint8 gameType;
uint32 features;
};
} // End of namespace CryOmni3D

View File

@ -0,0 +1,43 @@
/* 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.
*
*/
namespace CryOmni3D {
enum CryOmni3DGameType {
GType_VERSAILLES
};
enum CryOmni3DGameFeatures {
GF_VERSAILLES_FONTS_MASK = (3 << 0), // Fonts flag mask
GF_VERSAILLES_FONTS_NUMERIC = (0 << 0), // Fonts are font01.crf, ...
GF_VERSAILLES_FONTS_SET_A = (1 << 0), // Fonts are for French Macintosh (development version)
GF_VERSAILLES_FONTS_SET_B = (2 << 0), // Standard set (Helvet12 is used for debugging docs)
GF_VERSAILLES_FONTS_SET_C = (3 << 0), // Fonts for Italian version (Helvet12 is used for docs texts)
GF_VERSAILLES_AUDIOPADDING_NO = (0 << 2), // Audio files have underscore padding before extension
GF_VERSAILLES_AUDIOPADDING_YES = (1 << 2), // Audio files have underscore padding before extension
GF_VERSAILLES_LINK_STANDARD = (0 << 3), // Links file is lien_doc.txt
GF_VERSAILLES_LINK_LOCALIZED = (1 << 3) // Links file is taken from cryomni3d.dat
};
} // End of namespace CryOmni3D

View File

@ -0,0 +1,160 @@
/* 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 "base/plugins.h"
#include "engines/advancedDetector.h"
#include "common/file.h"
#include "common/md5.h"
#include "common/savefile.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "common/translation.h"
#include "cryomni3d/cryomni3d.h"
#ifdef ENABLE_VERSAILLES
#include "cryomni3d/versailles/engine.h"
#endif
#include "cryomni3d/detection.h"
namespace CryOmni3D {
const char *CryOmni3DEngine::getGameId() const {
return _gameDescription->desc.gameId;
}
uint32 CryOmni3DEngine::getFeatures() const {
return _gameDescription->features;
}
Common::Platform CryOmni3DEngine::getPlatform() const {
return _gameDescription->desc.platform;
}
uint8 CryOmni3DEngine::getGameType() const {
return _gameDescription->gameType;
}
Common::Language CryOmni3DEngine::getLanguage() const {
return _gameDescription->desc.language;
}
bool CryOmni3DEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsReturnToLauncher)
|| (f == kSupportsSubtitleOptions);
}
class CryOmni3DMetaEngineConnect : public AdvancedMetaEngineConnect {
public:
const char *getName() const override {
return "cryomni3d";
}
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 { return 999; }
void removeSaveState(const char *target, int slot) const override;
};
bool CryOmni3DMetaEngineConnect::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves)
|| (f == kSupportsLoadingDuringStartup)
|| (f == kSupportsDeleteSave)
|| (f == kSimpleSavesNames);
}
SaveStateList CryOmni3DMetaEngineConnect::listSaves(const char *target) const {
// Replicate constant here to shorten lines
static const uint kSaveDescriptionLen = CryOmni3DEngine::kSaveDescriptionLen;
SaveStateList saveList;
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
char saveName[kSaveDescriptionLen + 1];
saveName[kSaveDescriptionLen] = '\0';
Common::String pattern = Common::String::format("%s.????", target);
Common::StringArray filenames = saveMan->listSavefiles(pattern);
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
int slotNum;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end();
++file) {
// Obtain the last 4 digits of the filename, since they correspond to the save slot
slotNum = atoi(file->c_str() + file->size() - 4);
if (slotNum >= 1 && slotNum <= 99) {
Common::InSaveFile *in = saveMan->openForLoading(*file);
if (in) {
if (in->read(saveName, kSaveDescriptionLen) == kSaveDescriptionLen) {
saveList.push_back(SaveStateDescriptor(slotNum - 1, saveName));
}
delete in;
}
}
}
return saveList;
}
void CryOmni3DMetaEngineConnect::removeSaveState(const char *target, int slot) const {
Common::String filename = Common::String::format("%s.%04d", target, slot + 1);
g_system->getSavefileManager()->removeSavefile(filename);
}
bool CryOmni3DMetaEngineConnect::createInstance(OSystem *syst, Engine **engine,
const ADGameDescription *desc) const {
const CryOmni3DGameDescription *gd = (const CryOmni3DGameDescription *)desc;
if (gd) {
switch (gd->gameType) {
case GType_VERSAILLES:
#ifdef ENABLE_VERSAILLES
*engine = new Versailles::CryOmni3DEngine_Versailles(syst, gd);
break;
#else
warning("Versailles support not compiled in");
return false;
#endif
default:
error("Unknown Cryo Omni3D Engine");
}
}
return (gd != 0);
}
} // End of namespace CryOmni3D
#if PLUGIN_ENABLED_DYNAMIC(CRYOMNI3D)
REGISTER_PLUGIN_DYNAMIC(CRYOMNI3D, PLUGIN_TYPE_ENGINE, CryOmni3D::CryOmni3DMetaEngineConnect);
#else
REGISTER_PLUGIN_STATIC(CRYOMNI3D, PLUGIN_TYPE_ENGINE, CryOmni3D::CryOmni3DMetaEngineConnect);
#endif

View File

@ -8,10 +8,10 @@ MODULE_OBJS = \
video/hnm_decoder.o \
cryomni3d.o \
datstream.o \
detection.o \
dialogs_manager.o \
fixed_image.o \
font_manager.o \
metaengine.o \
mouse_boxes.o \
objects.o \
omni3d.o \
@ -39,3 +39,6 @@ endif
# Include common rules
include $(srcdir)/rules.mk
# Detection objects
DETECT_OBJS += $(MODULE)/detection.o