aboutsummaryrefslogtreecommitdiff
path: root/common/plugins.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/plugins.cpp')
-rw-r--r--common/plugins.cpp74
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() {