Fixed the EngineFeature vs. MetaEngineFeature mess, clarified some EngineFeature comments

svn-id: r34896
This commit is contained in:
Max Horn 2008-11-04 16:11:40 +00:00
parent 70679e6895
commit 61aadb378d
32 changed files with 193 additions and 142 deletions

View File

@ -696,7 +696,8 @@ struct StringData {
class AgiBase : public ::Engine {
protected:
// Engine API
int init();
virtual int init();
virtual bool hasFeature(EngineFeature f) const;
virtual void initialize() = 0;
@ -743,7 +744,10 @@ class AgiEngine : public AgiBase {
int _gameId;
protected:
int go();
// Engine APIs
virtual int go();
virtual void syncSoundSettings();
void initialize();
uint32 _lastSaveTime;
@ -755,7 +759,6 @@ public:
return _gameId;
}
virtual void syncSoundSettings();
private:

View File

@ -2132,12 +2132,15 @@ public:
bool AgiMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave);
}
bool AgiBase::hasFeature(EngineFeature f) const {
return (f == kSupportsRTL);
}
bool AgiMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
const Agi::AGIGameDescription *gd = (const Agi::AGIGameDescription *)desc;

View File

@ -163,7 +163,13 @@ class AGOSEngine : public Engine {
friend class Debugger;
friend class MoviePlayer;
GUI::Debugger *getDebugger();
// Engine APIs
virtual int init();
virtual int go();
virtual GUI::Debugger *getDebugger();
virtual bool hasFeature(EngineFeature f) const;
virtual void syncSoundSettings();
virtual void pauseEngineIntern(bool pause);
public:
virtual void setupOpcodes();
@ -588,7 +594,6 @@ protected:
void loadSoundFile(const char *filename);
virtual void syncSoundSettings();
int getUserFlag(Item *item, int a);
int getUserFlag1(Item *item, int a);
@ -1147,9 +1152,6 @@ protected:
void loadVGAVideoFile(uint16 id, uint8 type);
bool loadVGASoundFile(uint16 id, uint8 type);
int init();
int go();
void openGameFile();
void readGameFile(void *dst, uint32 offs, uint32 size);
@ -1210,7 +1212,6 @@ protected:
void checkTimerCallback();
void delay(uint delay);
void pause();
virtual void pauseEngineIntern(bool pause);
void waitForMark(uint i);
void scrollScreen();

View File

@ -118,10 +118,14 @@ public:
bool AgosMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves);
}
bool AGOS::AGOSEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
}
bool AgosMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
const AGOS::AGOSGameDescription *gd = (const AGOS::AGOSGameDescription *)desc;
bool res = true;

View File

@ -70,8 +70,11 @@ typedef Common::HashMap<Common::String, const char *> StringPtrHashMap;
class CineEngine : public Engine {
protected:
int init();
int go();
// Engine APIs
virtual int init();
virtual int go();
virtual bool hasFeature(EngineFeature f) const;
void shutdown();
bool initGame();

View File

@ -540,11 +540,15 @@ public:
bool CineMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup);
}
bool Cine::CineEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
}
bool CineMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
const Cine::CINEGameDescription *gd = (const Cine::CINEGameDescription *)desc;
if (gd) {

View File

@ -99,13 +99,11 @@ MainMenuDialog::MainMenuDialog(Engine *engine)
_loadButton = new GUI::ButtonWidget(this, "GlobalMenu.Load", "Load", kLoadCmd, 'L');
// TODO: setEnabled -> setVisible
_loadButton->setEnabled(_engine->hasFeature(Engine::kSupportsListSaves) &&
_engine->hasFeature(Engine::kSupportsLoadingDuringRuntime));
_loadButton->setEnabled(_engine->hasFeature(Engine::kSupportsLoadingDuringRuntime));
_saveButton = new GUI::ButtonWidget(this, "GlobalMenu.Save", "Save", kSaveCmd, 'S');
// TODO: setEnabled -> setVisible
_saveButton->setEnabled(_engine->hasFeature(Engine::kSupportsListSaves) &&
_engine->hasFeature(Engine::kSupportsSavingDuringRuntime));
_saveButton->setEnabled(_engine->hasFeature(Engine::kSupportsSavingDuringRuntime));
new GUI::ButtonWidget(this, "GlobalMenu.Options", "Options", kOptionsCmd, 'O');
@ -197,12 +195,10 @@ void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
}
void MainMenuDialog::reflowLayout() {
if (_engine->hasFeature(Engine::kSupportsListSaves)) {
if (_engine->hasFeature(Engine::kSupportsLoadingDuringRuntime))
_loadButton->setEnabled(_engine->canLoadGameStateCurrently());
if (_engine->hasFeature(Engine::kSupportsSavingDuringRuntime))
_saveButton->setEnabled(_engine->canSaveGameStateCurrently());
}
if (_engine->hasFeature(Engine::kSupportsLoadingDuringRuntime))
_loadButton->setEnabled(_engine->canLoadGameStateCurrently());
if (_engine->hasFeature(Engine::kSupportsSavingDuringRuntime))
_saveButton->setEnabled(_engine->canSaveGameStateCurrently());
#ifndef DISABLE_FANCY_THEMES
if (g_gui.xmlEval()->getVar("Globals.ShowGlobalMenuLogo", 0) == 1 && g_gui.theme()->supportsImages()) {

View File

@ -286,27 +286,14 @@ bool Engine::shouldQuit() const {
return (_eventMan->shouldQuit() || _eventMan->shouldRTL());
}
bool Engine::hasFeature(EngineFeature f) {
// TODO: Get rid of this hack!!!
if (f != kSupportsRTL && f != kSupportsListSaves &&
f != kSupportsLoadingDuringRuntime &&
f != kSupportsSavingDuringRuntime)
return false;
/*
EnginePlugin *Engine::getMetaEnginePlugin() const {
const EnginePlugin *plugin = 0;
Common::String gameid = ConfMan.get("gameid");
gameid.toLowercase();
EngineMan.findGame(gameid, &plugin);
assert(plugin);
if (f == kSupportsRTL)
return (*plugin)->hasFeature(MetaEngine::kSupportsRTL);
else if (f == kSupportsListSaves)
return (*plugin)->hasFeature(MetaEngine::kSupportsListSaves);
else if (f == kSupportsLoadingDuringRuntime)
return (*plugin)->hasFeature(MetaEngine::kSupportsLoadingDuringRuntime);
else if (f == kSupportsSavingDuringRuntime)
return (*plugin)->hasFeature(MetaEngine::kSupportsSavingDuringRuntime);
else
return false;
return plugin;
}
*/

View File

@ -83,6 +83,39 @@ private:
public:
/**
* A feature in this context means an ability of the engine which can be
* either available or not.
* @see Engine::hasFeature()
*/
enum EngineFeature {
/**
* 'Return to launcher' feature is supported, i.e., EVENT_RTL is handled
* either directly, or indirectly (that is, the engine calls and honors
* the result of the Engine::shouldQuit() method appropriately).
*/
kSupportsRTL,
/**
* Loading savestates during runtime is supported, that is, this engine
* implements loadGameState() and canLoadGameStateCurrently().
* If this feature is supported, then the corresponding MetaEngine *must*
* support the kSupportsListSaves feature.
*/
kSupportsLoadingDuringRuntime,
/**
* Loading savestates during runtime is supported, that is, this engine
* implements saveGameState() and canSaveGameStateCurrently().
* If this feature is supported, then the corresponding MetaEngine *must*
* support the kSupportsListSaves feature.
*/
kSupportsSavingDuringRuntime
};
/** @name Overloadable methods
*
* All Engine subclasses should consider overloading some or all of the following methods.
@ -117,6 +150,13 @@ public:
*/
virtual GUI::Debugger *getDebugger() { return 0; }
/**
* Determine whether the engine supports the specified feature.
*/
virtual bool hasFeature(EngineFeature f) const { return false; }
// virtual EnginePlugin *getMetaEnginePlugin() const;
/**
* Notify the engine that the sound settings in the config manager may have
* changed and that it hence should adjust any internal volume etc. values
@ -199,42 +239,6 @@ public:
*/
void openMainMenuDialog();
/**
* A feature in this context means an ability of the engine which can be
* either available or not.
*/
enum EngineFeature {
/**
* 'Return to launcher' feature is supported, i.e., EVENT_RTL is handled.
*/
kSupportsRTL = 0,
/**
* Listing all Save States for a given target is supported, i.e.,
* the listSaves() method is implemented.
* Used for --list-saves support, as well as the GMM load dialog.
*/
kSupportsListSaves = 1,
/**
* Loading from the in-game common ScummVM options dialog is supported
*/
kSupportsLoadingDuringRuntime = 8,
/**
* Saving from the in-game common ScummVM options dialog is supported
*/
kSupportsSavingDuringRuntime = 9
};
/**
* Determine whether the engine supports the specified feature.
*
* @todo Let this return false by default, or even turn it into a pure virtual method.
*/
bool hasFeature(EngineFeature f);
public:
/** On some systems, check if the game appears to be run from CD. */

View File

@ -2134,10 +2134,13 @@ public:
};
bool GobMetaEngine::hasFeature(MetaEngineFeature f) const {
return false;
}
bool Gob::GobEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
}
bool GobMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
const Gob::GOBGameDescription *gd = (const Gob::GOBGameDescription *)desc;
if (gd) {

View File

@ -190,10 +190,12 @@ private:
uint32 _pauseStart;
int go();
int init();
// Engine APIs
virtual int init();
virtual int go();
virtual bool hasFeature(EngineFeature f) const;
virtual void pauseEngineIntern(bool pause);
void pauseEngineIntern(bool pause);
bool initGameParts();
void deinitGameParts();

View File

@ -1073,12 +1073,16 @@ public:
bool KyraMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave) ||
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSavesSupportThumbnail);
}
bool Kyra::KyraEngine_v1::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsLoadingDuringRuntime);
}

View File

@ -114,9 +114,6 @@ public:
KyraEngine_v1(OSystem *system, const GameFlags &flags);
virtual ~KyraEngine_v1();
::GUI::Debugger *getDebugger();
virtual void pauseEngineIntern(bool pause);
uint8 game() const { return _flags.gameID; }
const GameFlags &gameFlags() const { return _flags; }
@ -170,8 +167,11 @@ public:
virtual void delayWithTicks(int ticks);
protected:
virtual int go() = 0;
// Engine APIs
virtual int init();
virtual ::GUI::Debugger *getDebugger();
virtual bool hasFeature(EngineFeature f) const;
virtual void pauseEngineIntern(bool pause);
// intern
Resource *_res;

View File

@ -193,12 +193,16 @@ public:
bool LureMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave);
}
bool Lure::LureEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
}
bool LureMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
const Lure::LureGameDescription *gd = (const Lure::LureGameDescription *)desc;
if (gd) {

View File

@ -69,10 +69,12 @@ public:
~LureEngine();
static LureEngine &getReference();
// Engine APIs
virtual int init();
virtual int go();
virtual void pauseEngineIntern(bool pause);
virtual bool hasFeature(EngineFeature f) const;
virtual void syncSoundSettings();
virtual void pauseEngineIntern(bool pause);
Disk &disk() { return *_disk; }

View File

@ -133,11 +133,6 @@ public:
* either available or not.
*/
enum MetaEngineFeature {
/**
* 'Return to launcher' feature is supported, i.e., EVENT_RTL is handled.
*/
kSupportsRTL,
/**
* Listing all Save States for a given target is supported, i.e.,
* the listSaves() method is implemented.
@ -183,18 +178,8 @@ public:
* the game till the save.
* This flag may only be set when 'kSavesSupportMetaInfo' is set.
*/
kSavesSupportPlayTime,
/**
* Features loading from the Common ScummVM options dialog in-game.
*/
kSupportsLoadingDuringRuntime,
/**
* Features saving from the Common ScummVM options dialog in-game.
*/
kSupportsSavingDuringRuntime
};
kSavesSupportPlayTime
};
/**
* Determine whether the engine supports the specified MetaEngine feature.

View File

@ -252,12 +252,16 @@ public:
bool ParallactionMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave);
}
bool Parallaction::Parallaction::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
}
bool ParallactionMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
const Parallaction::PARALLACTIONGameDescription *gd = (const Parallaction::PARALLACTIONGameDescription *)desc;
bool res = true;

View File

@ -227,7 +227,9 @@ public:
Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc);
~Parallaction();
int init();
// Engine APIs
virtual int init();
virtual bool hasFeature(EngineFeature f) const;
// info
int32 _screenWidth;
@ -360,8 +362,9 @@ public:
Parallaction_ns(OSystem* syst, const PARALLACTIONGameDescription *gameDesc) : Parallaction(syst, gameDesc) { }
~Parallaction_ns();
int init();
int go();
// Engine APIs
virtual int init();
virtual int go();
public:
virtual void parseLocation(const char *filename);

View File

@ -23,8 +23,6 @@
*
*/
#include "base/plugins.h"
#include "common/config-manager.h"
@ -80,12 +78,16 @@ const char *QueenMetaEngine::getCopyright() const {
bool QueenMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave);
}
bool Queen::QueenEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
}
GameList QueenMetaEngine::getSupportedGames() const {
GameList games;
games.push_back(queenGameDescriptor);

View File

@ -97,7 +97,6 @@ public:
void checkOptionSettings();
void readOptionSettings();
void writeOptionSettings();
virtual void syncSoundSettings();
int talkSpeed() const { return _talkSpeed; }
void talkSpeed(int speed) { _talkSpeed = speed; }
@ -129,10 +128,12 @@ public:
protected:
GUI::Debugger *getDebugger();
int go();
int init();
// Engine APIs
virtual int init();
virtual int go();
virtual GUI::Debugger *getDebugger();
virtual bool hasFeature(EngineFeature f) const;
virtual void syncSoundSettings();
int _talkSpeed;

View File

@ -156,10 +156,14 @@ public:
bool SagaMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave) ||
(f == kSupportsDeleteSave);
}
bool Saga::SagaEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsLoadingDuringRuntime) ||
(f == kSupportsSavingDuringRuntime);
}

View File

@ -486,9 +486,13 @@ inline uint16 objectIndexToId(int type, int index) {
class SagaEngine : public Engine {
friend class Scene;
protected:
int go();
int init();
public:
// Engine APIs
virtual int init();
virtual int go();
virtual bool hasFeature(EngineFeature f) const;
virtual void syncSoundSettings();
public:
SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc);
virtual ~SagaEngine();
@ -512,8 +516,6 @@ public:
return isSaveListFull() ? _saveFilesCount : _saveFilesCount + 1;
}
virtual void syncSoundSettings();
int16 _framesEsc;
uint32 _globalFlags;

View File

@ -691,7 +691,6 @@ public:
bool ScummMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave) ||
@ -701,6 +700,10 @@ bool ScummMetaEngine::hasFeature(MetaEngineFeature f) const {
(f == kSavesSupportPlayTime);
}
bool ScummEngine::hasFeature(EngineFeature f) const {
return (f == kSupportsRTL);
}
GameList ScummMetaEngine::getSupportedGames() const {
return GameList(gameDescriptions);
}

View File

@ -447,6 +447,8 @@ public:
virtual int go();
virtual void errorString(const char *buf_input, char *buf_output);
virtual GUI::Debugger *getDebugger();
virtual bool hasFeature(EngineFeature f) const;
virtual void syncSoundSettings();
virtual void pauseEngineIntern(bool pause);
protected:
@ -462,7 +464,6 @@ protected:
virtual void loadLanguageBundle() {}
void loadCJKFont();
void setupMusic(int midi);
virtual void syncSoundSettings();
void setTalkDelay(int talkdelay);
int getTalkDelay();

View File

@ -130,11 +130,15 @@ const char *SkyMetaEngine::getCopyright() const {
bool SkyMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup);
}
bool Sky::SkyEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
}
GameList SkyMetaEngine::getSupportedGames() const {
GameList games;
games.push_back(skySetting);

View File

@ -58,7 +58,6 @@ class Debugger;
class SkyCompact;
class SkyEngine : public Engine {
GUI::Debugger *getDebugger();
protected:
Common::KeyState _keyPressed;
bool _floppyIntro;
@ -89,15 +88,19 @@ public:
static SystemVars _systemVars;
protected:
// Engine APIs
virtual int init();
virtual int go();
virtual GUI::Debugger *getDebugger();
virtual bool hasFeature(EngineFeature f) const;
byte _fastMode;
void delay(int32 amount);
int go();
void handleKey(void);
uint32 _lastSaveTime;
int init();
void initItemList();
void initVirgin();

View File

@ -106,11 +106,15 @@ public:
bool SwordMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup);
}
bool Sword1::SwordEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
}
GameList SwordMetaEngine::getSupportedGames() const {
GameList games;
games.push_back(sword1FullSettings);

View File

@ -77,12 +77,15 @@ public:
virtual ~SwordEngine();
static SystemVars _systemVars;
void reinitialize(void);
virtual void syncSoundSettings();
uint32 _features;
protected:
int go();
int init();
// Engine APIs
virtual int init();
virtual int go();
virtual bool hasFeature(EngineFeature f) const;
virtual void syncSoundSettings();
private:
void delay(int32 amount);

View File

@ -92,12 +92,16 @@ public:
bool Sword2MetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave);
}
bool Sword2::Sword2Engine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
}
GameList Sword2MetaEngine::getSupportedGames() const {
const Sword2::GameSettings *g = Sword2::sword2_settings;
GameList games;

View File

@ -113,8 +113,6 @@ private:
uint32 calcChecksum(byte *buffer, uint32 size);
virtual void pauseEngineIntern(bool pause);
uint32 _totalStartups;
uint32 _totalScreenManagers;
uint32 _startRes;
@ -127,8 +125,13 @@ private:
public:
Sword2Engine(OSystem *syst);
~Sword2Engine();
int go();
int init();
// Engine APIs
virtual int init();
virtual int go();
virtual GUI::Debugger *getDebugger();
virtual bool hasFeature(EngineFeature f) const;
virtual void pauseEngineIntern(bool pause);
int getFramesPerSecond();
@ -212,7 +215,6 @@ public:
void sleepUntil(uint32 time);
GUI::Debugger *getDebugger();
void initialiseFontResourceFlags();
void initialiseFontResourceFlags(uint8 language);

View File

@ -145,12 +145,16 @@ public:
bool ToucheMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsRTL) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSupportsDeleteSave);
}
bool Touche::ToucheEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsRTL);
}
bool ToucheMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::ADGameDescription *desc) const {
const Common::ADGameDescription *gd = desc;
if (gd) {

View File

@ -361,8 +361,10 @@ public:
ToucheEngine(OSystem *system, Common::Language language);
virtual ~ToucheEngine();
// Engine APIs
virtual int init();
virtual int go();
virtual bool hasFeature(EngineFeature f) const;
virtual void syncSoundSettings();
protected: