diff options
author | Tony Puccinelli | 2010-08-02 08:43:47 +0000 |
---|---|---|
committer | Tony Puccinelli | 2010-08-02 08:43:47 +0000 |
commit | 44d7414215f5754f36be423aaf2c54236638d82f (patch) | |
tree | 6e692e9a7b08fc88d12759eb2f989d0542145425 | |
parent | 869e49d18597737e5955a083c02d47637db28393 (diff) | |
download | scummvm-rg350-44d7414215f5754f36be423aaf2c54236638d82f.tar.gz scummvm-rg350-44d7414215f5754f36be423aaf2c54236638d82f.tar.bz2 scummvm-rg350-44d7414215f5754f36be423aaf2c54236638d82f.zip |
changed plugins so games can be added in the launcher with only one plugin loaded into memory at a time (first refinement)
svn-id: r51607
-rw-r--r-- | base/plugins.cpp | 35 | ||||
-rw-r--r-- | base/plugins.h | 2 |
2 files changed, 25 insertions, 12 deletions
diff --git a/base/plugins.cpp b/base/plugins.cpp index e0ab85babb..c20fdd8a3e 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -306,7 +306,8 @@ void PluginManager::addPluginProvider(PluginProvider *pp) { _providers.push_back(pp); } -bool PluginManager::loadFirstPlugin() { +bool PluginManager::loadFirstPlugin() { //TODO: only deal with engine plugins here, and have a separate "loadNonEnginePlugins" function. + unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL); PluginList plugs; for (ProviderList::iterator pp = _providers.begin(); pp != _providers.end(); @@ -316,14 +317,17 @@ bool PluginManager::loadFirstPlugin() { plugs.push_back(*p); } } + _allPlugsEnd = plugs.end(); _allPlugs = plugs.begin(); - return tryLoadPlugin(*_allPlugs); //TODO: return false if no plugins! + if (plugs.empty()) return false; //return false if there are no plugins to load. + return tryLoadPlugin(*_allPlugs); } bool PluginManager::loadNextPlugin() { unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL); ++_allPlugs; - return tryLoadPlugin(*_allPlugs); //TODO: return false if got to the end of list of plugins. + if (_allPlugs == _allPlugsEnd) return false; //return false if already reached the end of list of plugins. + return tryLoadPlugin(*_allPlugs); } void PluginManager::loadPlugins() { @@ -424,15 +428,22 @@ GameDescriptor EngineManager::findGame(const Common::String &gameName, const Eng GameList EngineManager::detectGames(const Common::FSList &fslist) const { GameList candidates; - - const EnginePlugin::List &plugins = getPlugins(); - - // Iterate over all known games and for each check if it might be - // the game in the presented directory. - EnginePlugin::List::const_iterator iter; - for (iter = plugins.begin(); iter != plugins.end(); ++iter) { - candidates.push_back((**iter)->detectGames(fslist)); - } + EnginePlugin::List plugins; +#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT + PluginManager::instance().loadFirstPlugin(); + do { +#endif + printf("SUCCESS!!!\n"); + plugins = getPlugins(); + // Iterate over all known games and for each check if it might be + // the game in the presented directory. + EnginePlugin::List::const_iterator iter; + for (iter = plugins.begin(); iter != plugins.end(); ++iter) { + candidates.push_back((**iter)->detectGames(fslist)); + } +#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT + } while (PluginManager::instance().loadNextPlugin()); +#endif return candidates; } diff --git a/base/plugins.h b/base/plugins.h index 5697055e54..d20872707b 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -276,6 +276,8 @@ private: PluginList _plugins[PLUGIN_TYPE_MAX]; ProviderList _providers; PluginList::iterator _allPlugs; + PluginList::iterator _allPlugsEnd; + bool tryLoadPlugin(Plugin *plugin); |