Removed Base::setTarget, and some minor cleanup & tweaks

svn-id: r22356
This commit is contained in:
Max Horn 2006-05-05 00:26:03 +00:00
parent b56139b3aa
commit dad44b45d3
5 changed files with 20 additions and 33 deletions

View file

@ -24,7 +24,6 @@
#include <common/stdafx.h> #include <common/stdafx.h>
#include <common/scummsys.h> #include <common/scummsys.h>
#include <base/engine.h> #include <base/engine.h>
#include <base/game.h>
#include <base/main.h> #include <base/main.h>
#include <base/plugins.h> #include <base/plugins.h>
#include "dc.h" #include "dc.h"
@ -224,7 +223,7 @@ int DCLauncherDialog::runModal()
ConfMan.set("path", dir, base); ConfMan.set("path", dir, base);
// Set the target. // Set the target.
Base::setTarget(base); ConfMan.setActiveDomain(base);
return 0; return 0;
} }

View file

@ -61,9 +61,6 @@ namespace Base {
// TODO: Find a better place for this function. // TODO: Find a better place for this function.
GameDescriptor findGame(const Common::String &gameName, const Plugin **plugin = NULL); GameDescriptor findGame(const Common::String &gameName, const Plugin **plugin = NULL);
// TODO: Find a better place for this function.
void setTarget(const Common::String &name);
} // End of namespace Base } // End of namespace Base

View file

@ -84,18 +84,6 @@ GameDescriptor findGame(const Common::String &gameName, const Plugin **plugin) {
return result; return result;
} }
// TODO: Find a better place for this function.
void setTarget(const Common::String &target) {
ConfMan.setActiveDomain(target);
// Make sure the gameid is set in the config manager, and that it is lowercase.
Common::String gameid(target);
if (ConfMan.hasKey("gameid"))
gameid = ConfMan.get("gameid");
gameid.toLowercase();
ConfMan.set("gameid", gameid);
}
} // End of namespace Base } // End of namespace Base
@ -157,14 +145,18 @@ static bool launcherDialog(OSystem &system) {
static const Plugin *detectMain() { static const Plugin *detectMain() {
const Plugin *plugin = 0; const Plugin *plugin = 0;
if (ConfMan.getActiveDomainName().empty()) {
warning("No game was specified...");
return 0;
}
printf("Looking for %s\n", ConfMan.get("gameid").c_str()); // Make sure the gameid is set in the config manager, and that it is lowercase.
GameDescriptor game = Base::findGame(ConfMan.get("gameid"), &plugin); Common::String gameid(ConfMan.getActiveDomainName());
assert(!gameid.empty());
if (ConfMan.hasKey("gameid"))
gameid = ConfMan.get("gameid");
gameid.toLowercase();
ConfMan.set("gameid", gameid);
// Query the plugins and find one that will handle the specified gameid
printf("Looking for %s\n", gameid.c_str());
GameDescriptor game = Base::findGame(gameid, &plugin);
if (plugin == 0) { if (plugin == 0) {
printf("Failed game detection\n"); printf("Failed game detection\n");
@ -177,7 +169,6 @@ static const Plugin *detectMain() {
Common::String gameDataPath(ConfMan.get("path")); Common::String gameDataPath(ConfMan.get("path"));
if (gameDataPath.empty()) { if (gameDataPath.empty()) {
warning("No path was provided. Assuming the data files are in the current directory"); warning("No path was provided. Assuming the data files are in the current directory");
gameDataPath = "./";
} else if (gameDataPath.lastChar() != '/' } else if (gameDataPath.lastChar() != '/'
#if defined(__MORPHOS__) || defined(__amigaos4__) #if defined(__MORPHOS__) || defined(__amigaos4__)
&& gameDataPath.lastChar() != ':' && gameDataPath.lastChar() != ':'
@ -275,7 +266,6 @@ static int runGame(const Plugin *plugin, OSystem &system, const Common::String &
extern "C" int scummvm_main(int argc, char *argv[]) { extern "C" int scummvm_main(int argc, char *argv[]) {
Common::String specialDebug; Common::String specialDebug;
Common::String command; Common::String command;
bool running = true;
// Verify that the backend has been initialized (i.e. g_system has been set). // Verify that the backend has been initialized (i.e. g_system has been set).
assert(g_system); assert(g_system);
@ -348,8 +338,8 @@ extern "C" int scummvm_main(int argc, char *argv[]) {
setupDummyPalette(system); setupDummyPalette(system);
// Unless a game was specified, show the launcher dialog // Unless a game was specified, show the launcher dialog
if (ConfMan.getActiveDomainName().empty()) { if (0 == ConfMan.getActiveDomain()) {
running = launcherDialog(system); launcherDialog(system);
// Discard any command line options. Those that affect the graphics // Discard any command line options. Those that affect the graphics
// mode etc. already have should have been handled by the backend at // mode etc. already have should have been handled by the backend at
@ -361,7 +351,7 @@ extern "C" int scummvm_main(int argc, char *argv[]) {
// FIXME: We're now looping the launcher. This, of course, doesn't // FIXME: We're now looping the launcher. This, of course, doesn't
// work as well as it should. In theory everything should be destroyed // work as well as it should. In theory everything should be destroyed
// cleanly, so this is now enabled to encourage people to fix bits :) // cleanly, so this is now enabled to encourage people to fix bits :)
while (running) { while (0 != ConfMan.getActiveDomain()) {
// Verify the given game name is a valid supported game // Verify the given game name is a valid supported game
const Plugin *plugin = detectMain(); const Plugin *plugin = detectMain();
if (plugin) { if (plugin) {
@ -377,13 +367,14 @@ extern "C" int scummvm_main(int argc, char *argv[]) {
// wanted to apply them to *all* games ever launched. // wanted to apply them to *all* games ever launched.
ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear(); ConfMan.getDomain(Common::ConfigManager::kTransientDomain)->clear();
// TODO: Unset the active config domain // Clear the active config domain
ConfMan.setActiveDomain("");
// PluginManager::instance().unloadPlugins(); // PluginManager::instance().unloadPlugins();
PluginManager::instance().loadPlugins(); PluginManager::instance().loadPlugins();
} }
running = launcherDialog(system); launcherDialog(system);
} }
// Deinit the timer // Deinit the timer

View file

@ -665,7 +665,7 @@ bool processSettings(Common::String &command, Common::StringMap &settings) {
// whether there is a gameid matching that name. // whether there is a gameid matching that name.
if (!command.empty()) { if (!command.empty()) {
if (ConfMan.hasGameDomain(command) || Base::findGame(command).gameid.size() > 0) { if (ConfMan.hasGameDomain(command) || Base::findGame(command).gameid.size() > 0) {
Base::setTarget(command); ConfMan.setActiveDomain(command);
} else { } else {
usage("Unrecognized game target '%s'", command.c_str()); usage("Unrecognized game target '%s'", command.c_str());
} }

View file

@ -737,7 +737,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
case kListItemDoubleClickedCmd: case kListItemDoubleClickedCmd:
// Print out what was selected // Print out what was selected
assert(item >= 0); assert(item >= 0);
Base::setTarget(_domains[item]); ConfMan.setActiveDomain(_domains[item]);
close(); close();
break; break;
case kListSelectionChangedCmd: case kListSelectionChangedCmd: