diff options
author | Max Horn | 2003-09-08 17:13:40 +0000 |
---|---|---|
committer | Max Horn | 2003-09-08 17:13:40 +0000 |
commit | 6455c819896d58782f9ec195e0b716a1df32c296 (patch) | |
tree | ba0d5a4c7fe2381177fe7d119f90e748204798da /common/plugins.cpp | |
parent | 90ec1dc34ea403c0e23ff820d5ca20a7b9ca0140 (diff) | |
download | scummvm-rg350-6455c819896d58782f9ec195e0b716a1df32c296.tar.gz scummvm-rg350-6455c819896d58782f9ec195e0b716a1df32c296.tar.bz2 scummvm-rg350-6455c819896d58782f9ec195e0b716a1df32c296.zip |
more plugin related work
svn-id: r10098
Diffstat (limited to 'common/plugins.cpp')
-rw-r--r-- | common/plugins.cpp | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/common/plugins.cpp b/common/plugins.cpp index cdfae734be..006f342e5f 100644 --- a/common/plugins.cpp +++ b/common/plugins.cpp @@ -22,6 +22,64 @@ #include "common/plugins.h" #include "common/engine.h" +#include "common/gameDetector.h" + + +PluginManager *g_pluginManager = 0; + + +#pragma mark - + + +int Plugin::countTargets() const { + const TargetSettings *target = getTargets(); + int count; + for (count = 0; target->targetName; target++, count++) + ; + return count; +} + +const TargetSettings *Plugin::findTarget(const char *targetName) const { + // Find the TargetSettings for this target + const TargetSettings *target = getTargets(); + assert(targetName); + while (target->targetName) { + if (!scumm_stricmp(target->targetName, targetName)) { + return target; + } + target++; + } + return 0; +} + + +#pragma mark - + + +class StaticPlugin : public Plugin { + const char *_name; + const TargetSettings *_targets; + int _targetCount; + EngineFactory _ef; +public: + StaticPlugin(const char *name, const TargetSettings *targets, EngineFactory ef) + : _name(name), _targets(targets), _ef(ef) { + _targetCount = Plugin::countTargets(); + } + + const char *getName() const { return _name; } + int getVersion() const { return 0; } + + int countTargets() const { return _targetCount; } + const TargetSettings *getTargets() const { return _targets; } + + Engine *createInstance(GameDetector *detector, OSystem *syst) const { + return (*_ef)(detector, syst); + } +}; + + +#pragma mark - PluginManager::PluginManager() { @@ -33,7 +91,21 @@ PluginManager::~PluginManager() { } void PluginManager::loadPlugins() { - // TODO +#ifndef DISABLE_SCUMM + _plugins.push_back(new StaticPlugin("scumm", Engine_SCUMM_targetList(), Engine_SCUMM_create)); +#endif + +#ifndef DISABLE_SIMON + _plugins.push_back(new StaticPlugin("simon", Engine_SIMON_targetList(), Engine_SIMON_create)); +#endif + +#ifndef DISABLE_SKY + _plugins.push_back(new StaticPlugin("sky", Engine_SKY_targetList(), Engine_SKY_create)); +#endif + +#ifndef DISABLE_SWORD2 + _plugins.push_back(new StaticPlugin("sword2", Engine_SWORD2_targetList(), Engine_SWORD2_create)); +#endif } void PluginManager::unloadPlugins() { |