mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-06 18:00:44 +00:00
GLK: Implement passing detection options to the engines
This commit is contained in:
parent
fa51ea2138
commit
4938ac9ea1
@ -63,6 +63,18 @@ bool Glk::GlkEngine::hasFeature(EngineFeature f) const {
|
||||
(f == kSupportsSavingDuringRuntime);
|
||||
}
|
||||
|
||||
template<class META, class ENG>Engine *create(OSystem *syst, Glk::GlkGameDescription &gameDesc) {
|
||||
Glk::GameDescriptor gd = META::findGame(gameDesc._gameId.c_str());
|
||||
if (gd._description) {
|
||||
gameDesc._options = gd._options;
|
||||
return new ENG(syst, gameDesc);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#define CREATE(META, ENG) if (!(*engine = create<META, ENG>(syst, gameDesc)))
|
||||
|
||||
Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
|
||||
Glk::GameDescriptor td = Glk::GameDescriptor::empty();
|
||||
assert(engine);
|
||||
@ -96,15 +108,11 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons
|
||||
f.close();
|
||||
|
||||
// Create the correct engine
|
||||
if (Glk::Alan2::Alan2MetaEngine::findGame(gameDesc._gameId.c_str())._description) {
|
||||
*engine = new Glk::Alan2::Alan2(syst, gameDesc);
|
||||
} else if (Glk::Frotz::FrotzMetaEngine::findGame(gameDesc._gameId.c_str())._description) {
|
||||
*engine = new Glk::Frotz::Frotz(syst, gameDesc);
|
||||
} else if (Glk::Glulxe::GlulxeMetaEngine::findGame(gameDesc._gameId.c_str())._description) {
|
||||
*engine = new Glk::Glulxe::Glulxe(syst, gameDesc);
|
||||
} else if (Glk::Scott::ScottMetaEngine::findGame(gameDesc._gameId.c_str())._description) {
|
||||
*engine = new Glk::Scott::Scott(syst, gameDesc);
|
||||
} else if ((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str()))._description) {
|
||||
CREATE(Glk::Alan2::Alan2MetaEngine, Glk::Alan2::Alan2)
|
||||
CREATE(Glk::Frotz::FrotzMetaEngine, Glk::Frotz::Frotz)
|
||||
CREATE(Glk::Glulxe::GlulxeMetaEngine, Glk::Glulxe::Glulxe)
|
||||
CREATE(Glk::Scott::ScottMetaEngine, Glk::Scott::Scott)
|
||||
if (!((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str()))._description)) {
|
||||
if (td._options & Glk::TADS::OPTION_TADS3)
|
||||
*engine = new Glk::TADS::TADS3::TADS3(syst, gameDesc);
|
||||
else
|
||||
@ -116,6 +124,8 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
#undef CREATE
|
||||
|
||||
Common::String GlkMetaEngine::findFileByGameId(const Common::String &gameId) const {
|
||||
// Get the list of files in the folder and return detection against them
|
||||
Common::FSNode folder = Common::FSNode(ConfMan.get("path"));
|
||||
|
@ -21,6 +21,8 @@
|
||||
*/
|
||||
|
||||
#include "glk/frotz/config.h"
|
||||
#include "glk/frotz/detection.h"
|
||||
#include "glk/glk.h"
|
||||
#include "common/config-manager.h"
|
||||
#include "common/textconsole.h"
|
||||
|
||||
@ -162,5 +164,9 @@ UserOptions::UserOptions() : _undo_slots(MAX_UNDO_SLOTS), _sound(true), _quetzal
|
||||
_defaultBackground = getConfigInt("background", 0x000080, 0xffffff);
|
||||
}
|
||||
|
||||
bool UserOptions::isInfocom() const {
|
||||
return g_vm->getOptions() & OPTION_INFOCOM;
|
||||
}
|
||||
|
||||
} // End of namespace Scott
|
||||
} // End of namespace Glk
|
||||
|
@ -155,6 +155,11 @@ struct UserOptions {
|
||||
* Constructor
|
||||
*/
|
||||
UserOptions();
|
||||
|
||||
/**
|
||||
* Returns true if the game being played is one of the original Infocom releases
|
||||
*/
|
||||
bool isInfocom() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -41,8 +41,11 @@ void FrotzMetaEngine::getSupportedGames(PlainGameList &games) {
|
||||
|
||||
GameDescriptor FrotzMetaEngine::findGame(const char *gameId) {
|
||||
for (const PlainGameDescriptor *pd = INFOCOM_GAME_LIST; pd->gameId; ++pd) {
|
||||
if (!strcmp(gameId, pd->gameId))
|
||||
return *pd;
|
||||
if (!strcmp(gameId, pd->gameId)) {
|
||||
GameDescriptor gd(*pd);
|
||||
gd._options |= OPTION_INFOCOM;
|
||||
return gd;
|
||||
}
|
||||
}
|
||||
for (const PlainGameDescriptor *pd = ZCODE_GAME_LIST; pd->gameId; ++pd) {
|
||||
if (!strcmp(gameId, pd->gameId))
|
||||
|
@ -32,6 +32,13 @@
|
||||
namespace Glk {
|
||||
namespace Frotz {
|
||||
|
||||
/**
|
||||
* Game descriptor detection options
|
||||
*/
|
||||
enum DetectionOption {
|
||||
OPTION_INFOCOM = 1
|
||||
};
|
||||
|
||||
class FrotzMetaEngine {
|
||||
public:
|
||||
/**
|
||||
|
@ -48,6 +48,8 @@ void Frotz::runGame(Common::SeekableReadStream *gameFile) {
|
||||
story_fp = gameFile;
|
||||
initialize();
|
||||
|
||||
debug("Game %s an Infocom original", isInfocom() ? "is" : "isn't");
|
||||
|
||||
// If save was selected from the launcher, handle loading it
|
||||
int saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
|
||||
if (saveSlot != -1) {
|
||||
|
@ -60,6 +60,7 @@ struct GlkGameDescription {
|
||||
Common::Platform _platform;
|
||||
Common::String _filename;
|
||||
Common::String _md5;
|
||||
uint _options;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -163,6 +164,11 @@ public:
|
||||
*/
|
||||
const Common::String &getFilename() const { return _gameDescription._filename; }
|
||||
|
||||
/**
|
||||
* Returns any options returned with the game's detection entry
|
||||
*/
|
||||
const uint getOptions() const { return _gameDescription._options; }
|
||||
|
||||
/**
|
||||
* Return the game engine's target name
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user