diff options
author | Max Horn | 2008-05-06 15:21:46 +0000 |
---|---|---|
committer | Max Horn | 2008-05-06 15:21:46 +0000 |
commit | ba6c4a6239d5496f0f218d8fa76c11e77bf9139e (patch) | |
tree | 8c7c9d3d32b38e8ddd10499ab10e2b63b5eb8f36 /base | |
parent | 4331411ebea61072ff0189d7d61ac57199a120af (diff) | |
parent | 397e04d0b1ff6d96502c4eca42c1ab4a31b2dbcd (diff) | |
download | scummvm-rg350-ba6c4a6239d5496f0f218d8fa76c11e77bf9139e.tar.gz scummvm-rg350-ba6c4a6239d5496f0f218d8fa76c11e77bf9139e.tar.bz2 scummvm-rg350-ba6c4a6239d5496f0f218d8fa76c11e77bf9139e.zip |
Merge with trunk, using the svnmerge tool
svn-id: r31898
Diffstat (limited to 'base')
-rw-r--r-- | base/commandLine.cpp | 14 | ||||
-rw-r--r-- | base/main.cpp | 6 | ||||
-rw-r--r-- | base/plugins.cpp | 103 | ||||
-rw-r--r-- | base/plugins.h | 34 |
4 files changed, 118 insertions, 39 deletions
diff --git a/base/commandLine.cpp b/base/commandLine.cpp index 573cb59c79..a4c867edee 100644 --- a/base/commandLine.cpp +++ b/base/commandLine.cpp @@ -116,14 +116,14 @@ static const char HELP_STRING[] = " --render-mode=MODE Enable additional render modes (cga, ega, hercGreen,\n" " hercAmber, amiga)\n" "\n" -#if !defined(DISABLE_SKY) || !defined(DISABLE_QUEEN) +#if defined(ENABLE_SKY) || defined(ENABLE_QUEEN) " --alt-intro Use alternative intro for CD versions of Beneath a\n" " Steel Sky and Flight of the Amazon Queen\n" #endif " --copy-protection Enable copy protection in SCUMM games, when\n" " ScummVM disables it by default.\n" " --talkspeed=NUM Set talk speed for games (default: 60)\n" -#ifndef DISABLE_SCUMM +#ifdef ENABLE_SCUMM " --demo-mode Start demo mode of Maniac Mansion\n" " --tempo=NUM Set music tempo (in percent, 50-200) for SCUMM games\n" " (default: 100)\n" @@ -190,19 +190,19 @@ void registerDefaults() { ConfMan.registerDefault("save_slot", -1); ConfMan.registerDefault("autosave_period", 5 * 60); // By default, trigger autosave every 5 minutes -#if !defined(DISABLE_SCUMM) || !defined(DISABLE_SWORD2) +#if defined(ENABLE_SCUMM) || defined(ENABLE_SWORD2) ConfMan.registerDefault("object_labels", true); #endif ConfMan.registerDefault("copy_protection", false); ConfMan.registerDefault("talkspeed", 60); -#ifndef DISABLE_SCUMM +#ifdef ENABLE_SCUMM ConfMan.registerDefault("demo_mode", false); ConfMan.registerDefault("tempo", 0); #endif -#if !defined(DISABLE_SKY) || !defined(DISABLE_QUEEN) +#if defined(ENABLE_SKY) || defined(ENABLE_QUEEN) ConfMan.registerDefault("alt_intro", false); #endif @@ -513,7 +513,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar DO_LONG_OPTION("target-md5") END_OPTION -#ifndef DISABLE_SCUMM +#ifdef ENABLE_SCUMM DO_LONG_OPTION_INT("tempo") END_OPTION @@ -521,7 +521,7 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, char **ar END_OPTION #endif -#if !defined(DISABLE_SKY) || !defined(DISABLE_QUEEN) +#if defined(ENABLE_SKY) || defined(ENABLE_QUEEN) DO_LONG_OPTION_BOOL("alt-intro") END_OPTION #endif diff --git a/base/main.cpp b/base/main.cpp index 257d691139..a666110b83 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -343,9 +343,9 @@ extern "C" int scummvm_main(int argc, char *argv[]) { launcherDialog(system); } PluginManager::instance().unloadPluginsExcept(NULL); - PluginManager::instance().destroy(); - ConfMan.destroy(); - g_gui.destroy(); + PluginManager::destroy(); + Common::ConfigManager::destroy(); + GUI::NewGui::destroy(); return 0; } diff --git a/base/plugins.cpp b/base/plugins.cpp index 188eb10475..9e2c2599ce 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -63,7 +63,6 @@ SaveStateList Plugin::listSaves(const char *target) const { } -#ifndef DYNAMIC_MODULES class StaticPlugin : public Plugin { public: StaticPlugin(PluginObject *pluginobject, PluginType type) { @@ -100,61 +99,61 @@ public: // "Loader" for the static plugins. // Iterate over all registered (static) plugins and load them. - #ifndef DISABLE_SCUMM + #if PLUGIN_ENABLED_STATIC(SCUMM) LINK_PLUGIN(SCUMM) #endif - #ifndef DISABLE_AGI + #if PLUGIN_ENABLED_STATIC(AGI) LINK_PLUGIN(AGI) #endif - #ifndef DISABLE_AGOS + #if PLUGIN_ENABLED_STATIC(AGOS) LINK_PLUGIN(AGOS) #endif - #ifndef DISABLE_CINE + #if PLUGIN_ENABLED_STATIC(CINE) LINK_PLUGIN(CINE) #endif - #ifndef DISABLE_CRUISE + #if PLUGIN_ENABLED_STATIC(CRUISE) LINK_PLUGIN(CRUISE) #endif - #ifndef DISABLE_DRASCULA + #if PLUGIN_ENABLED_STATIC(DRASCULA) LINK_PLUGIN(DRASCULA) #endif - #ifndef DISABLE_GOB + #if PLUGIN_ENABLED_STATIC(GOB) LINK_PLUGIN(GOB) #endif - #ifndef DISABLE_IGOR + #if PLUGIN_ENABLED_STATIC(IGOR) LINK_PLUGIN(IGOR) #endif - #ifndef DISABLE_KYRA + #if PLUGIN_ENABLED_STATIC(KYRA) LINK_PLUGIN(KYRA) #endif - #ifndef DISABLE_LURE + #if PLUGIN_ENABLED_STATIC(LURE) LINK_PLUGIN(LURE) #endif - #ifndef DISABLE_M4 + #if PLUGIN_ENABLED_STATIC(M4) LINK_PLUGIN(M4) #endif - #ifndef DISABLE_MADE + #if PLUGIN_ENABLED_STATIC(MADE) LINK_PLUGIN(MADE) #endif - #ifndef DISABLE_PARALLACTION + #if PLUGIN_ENABLED_STATIC(PARALLACTION) LINK_PLUGIN(PARALLACTION) #endif - #ifndef DISABLE_QUEEN + #if PLUGIN_ENABLED_STATIC(QUEEN) LINK_PLUGIN(QUEEN) #endif - #ifndef DISABLE_SAGA + #if PLUGIN_ENABLED_STATIC(SAGA) LINK_PLUGIN(SAGA) #endif - #ifndef DISABLE_SKY + #if PLUGIN_ENABLED_STATIC(SKY) LINK_PLUGIN(SKY) #endif - #ifndef DISABLE_SWORD1 + #if PLUGIN_ENABLED_STATIC(SWORD1) LINK_PLUGIN(SWORD1) #endif - #ifndef DISABLE_SWORD2 + #if PLUGIN_ENABLED_STATIC(SWORD2) LINK_PLUGIN(SWORD2) #endif - #ifndef DISABLE_TOUCHE + #if PLUGIN_ENABLED_STATIC(TOUCHE) LINK_PLUGIN(TOUCHE) #endif @@ -162,19 +161,75 @@ public: } }; +#ifdef DYNAMIC_MODULES + +PluginList FilePluginProvider::getPlugins() { + PluginList pl; + + // Prepare the list of directories to search + Common::StringList pluginDirs; + // TODO: Add the user specified directory (via config file) + pluginDirs.push_back("."); + pluginDirs.push_back("plugins"); + + // Add the provider's custom directories + addCustomDirectories(pluginDirs); + + Common::StringList::const_iterator d; + for (d = pluginDirs.begin(); d != pluginDirs.end(); d++) { + // Load all plugins. + // Scan for all plugins in this directory + FilesystemNode dir(*d); + FSList files; + if (!dir.getChildren(files, FilesystemNode::kListFilesOnly)) { + debug(1, "Couldn't open plugin directory '%s'", d->c_str()); + continue; + } else { + debug(1, "Reading plugins from plugin directory '%s'", d->c_str()); + } + + for (FSList::const_iterator i = files.begin(); i != files.end(); ++i) { + Common::String name(i->getName()); + if (name.hasPrefix(getPrefix()) && name.hasSuffix(getSuffix())) { + pl.push_back(createPlugin(i->getPath())); + } + } + } + + return pl; +} + +const char* FilePluginProvider::getPrefix() const { +#ifdef PLUGIN_PREFIX + return PLUGIN_PREFIX; +#else + return ""; +#endif +} + +const char* FilePluginProvider::getSuffix() const { +#ifdef PLUGIN_SUFFIX + return PLUGIN_SUFFIX; +#else + return ""; +#endif +} +void FilePluginProvider::addCustomDirectories(Common::StringList &dirs) const { +#ifdef PLUGIN_DIRECTORY + dirs.push_back(PLUGIN_DIRECTORY); #endif +} + +#endif // DYNAMIC_MODULES #pragma mark - DECLARE_SINGLETON(PluginManager); PluginManager::PluginManager() { -#ifndef DYNAMIC_MODULES - // Add the static plugin provider if we do not build with dynamic - // plugins. + // Always add the static plugin provider. addPluginProvider(new StaticPluginProvider()); -#endif } PluginManager::~PluginManager() { diff --git a/base/plugins.h b/base/plugins.h index da48a7c22a..ca08a0c628 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -100,6 +100,15 @@ public: }; +#define STATIC_PLUGIN 1 +#define DYNAMIC_PLUGIN 2 + +#define PLUGIN_ENABLED_STATIC(ID) \ + (defined(ENABLE_##ID) && !PLUGIN_ENABLED_DYNAMIC(ID)) + +#define PLUGIN_ENABLED_DYNAMIC(ID) \ + (defined(ENABLE_##ID) && (ENABLE_##ID == DYNAMIC_PLUGIN) && defined(DYNAMIC_MODULES)) + /** * REGISTER_PLUGIN is a convenience macro meant to ease writing * the plugin interface for our modules. In particular, using it @@ -109,15 +118,16 @@ public: * @todo add some means to query the plugin API version etc. */ -#ifndef DYNAMIC_MODULES -#define REGISTER_PLUGIN(ID,TYPE,PLUGINCLASS) \ +#define REGISTER_PLUGIN_STATIC(ID,TYPE,PLUGINCLASS) \ PluginType g_##ID##_type = TYPE; \ PluginObject *g_##ID##_getObject() { \ return new PLUGINCLASS(); \ } \ void dummyFuncToAllowTrailingSemicolon() -#else -#define REGISTER_PLUGIN(ID,TYPE,PLUGINCLASS) \ + +#ifdef DYNAMIC_MODULES + +#define REGISTER_PLUGIN_DYNAMIC(ID,TYPE,PLUGINCLASS) \ extern "C" { \ PLUGIN_EXPORT int32 PLUGIN_getVersion() { return PLUGIN_VERSION; } \ PLUGIN_EXPORT int32 PLUGIN_getType() { return TYPE; } \ @@ -127,7 +137,8 @@ public: } \ } \ void dummyFuncToAllowTrailingSemicolon() -#endif + +#endif // DYNAMIC_MODULES /** List of plugins. */ @@ -147,6 +158,19 @@ public: virtual PluginList getPlugins() = 0; }; +class FilePluginProvider : public PluginProvider { +public: + virtual PluginList getPlugins(); + +protected: + virtual Plugin* createPlugin(const Common::String &filename) const = 0; + + virtual const char* getPrefix() const; + virtual const char* getSuffix() const; + + virtual void addCustomDirectories(Common::StringList &dirs) const; +}; + /** * Instances of this class manage all plugins, including loading them, * making wrapper objects of class Plugin available, and unloading them. |