added intermediary function 'findGameOnePlugAtATime' and switched load game and run game code to use it. Added checks for DYNAMIC_MODULES defines to the checks for NEW_PLUGIN_DESIGN_FIRST_REFINEMENT
svn-id: r51746
This commit is contained in:
parent
520c0a4009
commit
66b42d486b
4 changed files with 28 additions and 12 deletions
|
@ -103,8 +103,12 @@ static const EnginePlugin *detectPlugin() {
|
|||
// Query the plugins and find one that will handle the specified gameid
|
||||
printf("User picked target '%s' (gameid '%s')...\n", ConfMan.getActiveDomainName().c_str(), gameid.c_str());
|
||||
printf(" Looking for a plugin supporting this gameid... ");
|
||||
|
||||
|
||||
#if defined(NEW_PLUGIN_DESIGN_FIRST_REFINEMENT) && defined(DYNAMIC_MODULES)
|
||||
GameDescriptor game = EngineMan.findGameOnePlugAtATime(gameid, &plugin);
|
||||
#else
|
||||
GameDescriptor game = EngineMan.findGame(gameid, &plugin);
|
||||
#endif
|
||||
|
||||
if (plugin == 0) {
|
||||
printf("failed\n");
|
||||
|
@ -336,7 +340,7 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
|
|||
settings.erase("debugflags");
|
||||
}
|
||||
|
||||
#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT //note: I'm going to refactor this name later :P
|
||||
#if defined(NEW_PLUGIN_DESIGN_FIRST_REFINEMENT) && defined(DYNAMIC_MODULES) //note: I'm going to refactor this name later :P
|
||||
// Don't load the plugins initially in this case.
|
||||
#else
|
||||
// Load the plugins.
|
||||
|
|
|
@ -400,6 +400,18 @@ bool PluginManager::tryLoadPlugin(Plugin *plugin) {
|
|||
|
||||
DECLARE_SINGLETON(EngineManager)
|
||||
|
||||
GameDescriptor EngineManager::findGameOnePlugAtATime(const Common::String &gameName, const EnginePlugin **plugin) const {
|
||||
GameDescriptor result;
|
||||
PluginManager::instance().loadFirstPlugin();
|
||||
do {
|
||||
result = findGame(gameName, plugin);
|
||||
if (!result.gameid().empty()) {
|
||||
break;
|
||||
}
|
||||
} while (PluginManager::instance().loadNextPlugin());
|
||||
return result;
|
||||
}
|
||||
|
||||
GameDescriptor EngineManager::findGame(const Common::String &gameName, const EnginePlugin **plugin) const {
|
||||
// Find the GameDescriptor for this target
|
||||
const EnginePlugin::List &plugins = getPlugins();
|
||||
|
@ -410,10 +422,6 @@ GameDescriptor EngineManager::findGame(const Common::String &gameName, const Eng
|
|||
|
||||
EnginePlugin::List::const_iterator iter;
|
||||
|
||||
#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT
|
||||
PluginManager::instance().loadFirstPlugin();
|
||||
do {
|
||||
#endif
|
||||
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
|
||||
result = (**iter)->findGame(gameName.c_str());
|
||||
if (!result.gameid().empty()) {
|
||||
|
@ -422,9 +430,6 @@ GameDescriptor EngineManager::findGame(const Common::String &gameName, const Eng
|
|||
return result;
|
||||
}
|
||||
}
|
||||
#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT
|
||||
} while(PluginManager::instance().loadNextPlugin());
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -432,7 +437,8 @@ GameList EngineManager::detectGames(const Common::FSList &fslist) const {
|
|||
GameList candidates;
|
||||
EnginePlugin::List plugins;
|
||||
EnginePlugin::List::const_iterator iter;
|
||||
#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT
|
||||
#if defined(NEW_PLUGIN_DESIGN_FIRST_REFINEMENT) && defined(DYNAMIC_MODULES)
|
||||
PluginManager::instance().unloadPlugins();
|
||||
PluginManager::instance().loadFirstPlugin();
|
||||
do {
|
||||
#endif
|
||||
|
@ -442,7 +448,7 @@ GameList EngineManager::detectGames(const Common::FSList &fslist) const {
|
|||
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
|
||||
candidates.push_back((**iter)->detectGames(fslist));
|
||||
}
|
||||
#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT
|
||||
#if defined(NEW_PLUGIN_DESIGN_FIRST_REFINEMENT) && defined(DYNAMIC_MODULES)
|
||||
} while (PluginManager::instance().loadNextPlugin());
|
||||
#endif
|
||||
return candidates;
|
||||
|
|
|
@ -231,6 +231,7 @@ private:
|
|||
friend class Common::Singleton<SingletonBaseType>;
|
||||
|
||||
public:
|
||||
GameDescriptor findGameOnePlugAtATime(const Common::String &gameName, const EnginePlugin **plugin = NULL) const;
|
||||
GameDescriptor findGame(const Common::String &gameName, const EnginePlugin **plugin = NULL) const;
|
||||
GameList detectGames(const Common::FSList &fslist) const;
|
||||
const EnginePlugin::List &getPlugins() const;
|
||||
|
|
|
@ -708,7 +708,7 @@ void LauncherDialog::addGame() {
|
|||
// ...so let's determine a list of candidates, games that
|
||||
// could be contained in the specified directory.
|
||||
GameList candidates(EngineMan.detectGames(files));
|
||||
|
||||
|
||||
int idx;
|
||||
if (candidates.empty()) {
|
||||
// No game was found in the specified directory
|
||||
|
@ -849,7 +849,12 @@ void LauncherDialog::loadGame(int item) {
|
|||
gameId = _domains[item];
|
||||
|
||||
const EnginePlugin *plugin = 0;
|
||||
|
||||
#if defined(NEW_PLUGIN_DESIGN_FIRST_REFINEMENT) && defined(DYNAMIC_MODULES)
|
||||
EngineMan.findGameOnePlugAtATime(gameId, &plugin);
|
||||
#else
|
||||
EngineMan.findGame(gameId, &plugin);
|
||||
#endif
|
||||
|
||||
String target = _domains[item];
|
||||
target.toLowercase();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue