diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/config-file.h | 2 | ||||
-rw-r--r-- | common/engine.cpp | 4 | ||||
-rw-r--r-- | common/gameDetector.cpp | 64 | ||||
-rw-r--r-- | common/main.cpp | 30 | ||||
-rw-r--r-- | common/str.cpp | 4 | ||||
-rw-r--r-- | common/str.h | 4 |
6 files changed, 64 insertions, 44 deletions
diff --git a/common/config-file.h b/common/config-file.h index 594b4814c0..a4215116e3 100644 --- a/common/config-file.h +++ b/common/config-file.h @@ -60,6 +60,6 @@ protected: }; // The global config object -extern Config *scummcfg; +extern Config *g_config; #endif diff --git a/common/engine.cpp b/common/engine.cpp index 5352fd025c..0d4a0339af 100644 --- a/common/engine.cpp +++ b/common/engine.cpp @@ -63,11 +63,11 @@ const char *Engine::getSavePath() const // If SCUMMVM_SAVEPATH was not specified, try to use game specific savepath from config if (!dir || dir[0] == 0) - dir = scummcfg->get("savepath"); + dir = g_config->get("savepath"); // If SCUMMVM_SAVEPATH was not specified, try to use general path from config if (!dir || dir[0] == 0) - dir = scummcfg->get("savepath", "scummvm"); + dir = g_config->get("savepath", "scummvm"); // If no save path was specified, use no directory prefix if (dir == NULL) diff --git a/common/gameDetector.cpp b/common/gameDetector.cpp index 8f30cfe695..5e402eee7a 100644 --- a/common/gameDetector.cpp +++ b/common/gameDetector.cpp @@ -74,42 +74,42 @@ void GameDetector::updateconfig() { const char * val; - _amiga = scummcfg->getBool("amiga", _amiga); + _amiga = g_config->getBool("amiga", _amiga); - _save_slot = scummcfg->getInt("save_slot", _save_slot); + _save_slot = g_config->getInt("save_slot", _save_slot); - _cdrom = scummcfg->getInt("cdrom", _cdrom); + _cdrom = g_config->getInt("cdrom", _cdrom); - if ((val = scummcfg->get("music_driver"))) + if ((val = g_config->get("music_driver"))) if (!parseMusicDriver(val)) { printf("Error in the config file: invalid music_driver.\n"); printf(USAGE_STRING); exit(-1); } - _fullScreen = scummcfg->getBool("fullscreen", _fullScreen); + _fullScreen = g_config->getBool("fullscreen", _fullScreen); - if ((val = scummcfg->get("gfx_mode"))) + if ((val = g_config->get("gfx_mode"))) if ((_gfx_mode = parseGraphicsMode(val)) == -1) { printf("Error in the config file: invalid gfx_mode.\n"); printf(USAGE_STRING); exit(-1); } - _music_volume = scummcfg->getInt("music_volume", _music_volume); + _music_volume = g_config->getInt("music_volume", _music_volume); - _noSubtitles = scummcfg->getBool("nosubtitles", _noSubtitles ? true : false); + _noSubtitles = g_config->getBool("nosubtitles", _noSubtitles ? true : false); - if ((val = scummcfg->get("path"))) + if ((val = g_config->get("path"))) _gameDataPath = strdup(val); - _sfx_volume = scummcfg->getInt("sfx_volume", _sfx_volume); + _sfx_volume = g_config->getInt("sfx_volume", _sfx_volume); // We use strtol for the tempo to allow it to be specified in hex. - if ((val = scummcfg->get("tempo"))) + if ((val = g_config->get("tempo"))) _gameTempo = strtol(val, NULL, 0); - _talkSpeed = scummcfg->getInt("talkspeed", _talkSpeed); + _talkSpeed = g_config->getInt("talkspeed", _talkSpeed); } void GameDetector::parseCommandLine(int argc, char **argv) @@ -127,7 +127,7 @@ void GameDetector::parseCommandLine(int argc, char **argv) //exit(1); } - scummcfg->set_domain("game-specific"); + g_config->set_domain("game-specific"); /* Parse the arguments */ for (i = argc - 1; i >= 1; i--) { s = argv[i]; @@ -139,7 +139,7 @@ void GameDetector::parseCommandLine(int argc, char **argv) case 'a': CHECK_OPTION(); _amiga = (c == 'a'); - scummcfg->setBool("amiga", _amiga); + g_config->setBool("amiga", _amiga); break; case 'b': HANDLE_OPTION(); @@ -148,7 +148,7 @@ void GameDetector::parseCommandLine(int argc, char **argv) case 'c': HANDLE_OPTION(); _cdrom = atoi(option); - scummcfg->setInt("cdrom", _cdrom); + g_config->setInt("cdrom", _cdrom); break; case 'd': _debugMode = true; @@ -161,25 +161,25 @@ void GameDetector::parseCommandLine(int argc, char **argv) HANDLE_OPTION(); if (!parseMusicDriver(option)) goto ShowHelpAndExit; - scummcfg->set("music_driver", option); + g_config->set("music_driver", option); break; case 'f': CHECK_OPTION(); _fullScreen = (c == 'f'); - scummcfg->setBool("fullscreen", _fullScreen, "scummvm"); + g_config->setBool("fullscreen", _fullScreen, "scummvm"); break; case 'g': HANDLE_OPTION(); _gfx_mode = parseGraphicsMode(option); if (_gfx_mode == -1) goto ShowHelpAndExit; - scummcfg->set("gfx_mode", option, "scummvm"); + g_config->set("gfx_mode", option, "scummvm"); break; case 'l': HANDLE_OPTION(); { Config * newconfig = new Config(option, "scummvm"); - scummcfg->merge_config(*newconfig); + g_config->merge_config(*newconfig); delete newconfig; updateconfig(); break; @@ -188,17 +188,17 @@ void GameDetector::parseCommandLine(int argc, char **argv) case 'm': HANDLE_OPTION(); _music_volume = atoi(option); - scummcfg->setInt("music_volume", _music_volume); + g_config->setInt("music_volume", _music_volume); break; case 'n': CHECK_OPTION(); _noSubtitles = (c == 'n'); - scummcfg->setBool("nosubtitles", _noSubtitles ? true : false); + g_config->setBool("nosubtitles", _noSubtitles ? true : false); break; case 'p': HANDLE_OPTION(); _gameDataPath = option; - scummcfg->set("path", _gameDataPath); + g_config->set("path", _gameDataPath); break; case 'r': HANDLE_OPTION(); @@ -207,12 +207,12 @@ void GameDetector::parseCommandLine(int argc, char **argv) case 's': HANDLE_OPTION(); _sfx_volume = atoi(option); - scummcfg->setInt("sfx_volume", _sfx_volume); + g_config->setInt("sfx_volume", _sfx_volume); break; case 't': HANDLE_OPTION(); _gameTempo = strtol(option, 0, 0); - scummcfg->set("tempo", option); + g_config->set("tempo", option); break; case 'v': CHECK_OPTION(); @@ -224,23 +224,23 @@ void GameDetector::parseCommandLine(int argc, char **argv) exit(1); case 'w': _saveconfig = true; - scummcfg->set_writing(true); + g_config->set_writing(true); HANDLE_OPT_OPTION(); if (option != NULL) - scummcfg->set_filename(option); + g_config->set_filename(option); break; case 'x': _save_slot = 0; HANDLE_OPT_OPTION(); if (option != NULL) { _save_slot = atoi(option); - scummcfg->setInt("save_slot", _save_slot); + g_config->setInt("save_slot", _save_slot); } break; case 'y': HANDLE_OPTION(); _talkSpeed = atoi(option); - scummcfg->setInt("talkspeed", _talkSpeed); + g_config->setInt("talkspeed", _talkSpeed); break; default: goto ShowHelpAndExit; @@ -248,9 +248,9 @@ void GameDetector::parseCommandLine(int argc, char **argv) } else { if (i == (argc - 1)) { _exe_name = s; - scummcfg->set_domain(s); - scummcfg->rename_domain("game-specific"); - scummcfg->rename_domain(s); + g_config->set_domain(s); + g_config->rename_domain("game-specific"); + g_config->rename_domain(s); updateconfig(); } else { if (current_option == NULL) @@ -262,7 +262,7 @@ void GameDetector::parseCommandLine(int argc, char **argv) } if (_exe_name) - scummcfg->flush(); + g_config->flush(); return; diff --git a/common/main.cpp b/common/main.cpp index f4c319accc..a8a3449928 100644 --- a/common/main.cpp +++ b/common/main.cpp @@ -22,13 +22,15 @@ #include "stdafx.h" #include "engine.h" -#include "sound/mididrv.h" #include "gameDetector.h" #include "config-file.h" +#include "gui/newgui.h" +#include "gui/message.h" GameDetector detector; -Config *scummcfg = 0; +Config *g_config = 0; +NewGui *g_gui = 0; #if defined(QTOPIA) @@ -122,8 +124,8 @@ int main(int argc, char *argv[]) #endif // Read the config file - scummcfg = new Config(scummhome, "scummvm"); - scummcfg->set("versioninfo", SCUMMVM_VERSION); + g_config = new Config(scummhome, "scummvm"); + g_config->set("versioninfo", SCUMMVM_VERSION); // Parse the command line information result = detector.detectMain(argc, argv); @@ -145,6 +147,23 @@ int main(int argc, char *argv[]) prop.caption = (char *)detector.getGameName(); system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop); + // Create the GUI manager + // TODO - move this up for the launcher dialog? + g_gui = new NewGui(system); + +#if 0 + // FIXME - we need to be able to do an init_size() call on the system object here + // so that we can display stuff. But right now, init_size() can't safely be called + // multiple times (at least not for the SDL backend). So either we have to modify + // all the backends to allow for this, or come up with some other solution. + const char *message = "This dialog is shown before the Engine is even created!\n" + "Wow! Ain't e cool?\n"; + Dialog *dlg = new MessageDialog(g_gui, message); + dlg->open(); + g_gui->runLoop(); + delete dlg; +#endif + // Create the game engine Engine *engine = Engine::createFromDetector(&detector, system); @@ -153,7 +172,8 @@ int main(int argc, char *argv[]) // Free up memory delete engine; - delete scummcfg; + delete g_gui; + delete g_config; // ...and quit (the return 0 should never be reached) system->quit(); diff --git a/common/str.cpp b/common/str.cpp index 6a2333d39c..874b99938e 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -35,8 +35,8 @@ namespace ScummVM { String::String(const char *str, int len) { _refCount = new int(1); - if (str) { - if (len) + if (str && len != 0) { + if (len > 0) _capacity = _len = len; else _capacity = _len = resStrLen(str); diff --git a/common/str.h b/common/str.h index 3776ab64c3..c7c533d952 100644 --- a/common/str.h +++ b/common/str.h @@ -46,7 +46,7 @@ protected: public: ConstString() : _str(0), _len(0) {} - ConstString(const char *str, int len = 0) : _str((char*)str) { _len = str ? (len ? len : strlen(str)) : 0; } + ConstString(const char *str, int len = -1) : _str((char*)str) { _len = str ? (len >= 0 ? len : strlen(str)) : 0; } virtual ~ConstString() {} bool operator ==(const ConstString& x) const; @@ -77,7 +77,7 @@ protected: public: String() : _capacity(0) { _refCount = new int(1); } - String(const char *str, int len = 0); + String(const char *str, int len = -1); String(const ConstString &str); String(const String &str); virtual ~String(); |