MAIN: Fix --gfx-mode regression

We cannot check for supported graphics mode until after the backend has
been initialised, or there won't be a graphics manager to ask.

svn-id: r54534
This commit is contained in:
Torbjörn Andersson 2010-11-28 17:26:27 +00:00
parent bed8c34a87
commit 1857076d76
2 changed files with 19 additions and 13 deletions

View file

@ -383,19 +383,6 @@ Common::String parseCommandLine(Common::StringMap &settings, int argc, const cha
END_OPTION END_OPTION
DO_OPTION('g', "gfx-mode") DO_OPTION('g', "gfx-mode")
// Check whether 'option' specifies a valid graphics mode.
bool isValid = false;
if (!scumm_stricmp(option, "normal") || !scumm_stricmp(option, "default"))
isValid = true;
if (!isValid) {
const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
while (gm->name && !isValid) {
isValid = !scumm_stricmp(gm->name, option);
gm++;
}
}
if (!isValid)
usage("Unrecognized graphics mode '%s'", option);
END_OPTION END_OPTION
DO_OPTION_INT('m', "music-volume") DO_OPTION_INT('m', "music-volume")

View file

@ -372,6 +372,25 @@ extern "C" int scummvm_main(int argc, const char * const argv[]) {
// the command line params) was read. // the command line params) was read.
system.initBackend(); system.initBackend();
// If we received an invalid graphics mode parameter via command line
// we check this here. We can't do it until after the backend is inited,
// or there won't be a graphics manager to ask for the supported modes.
if (settings.contains("gfx-mode")) {
const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
Common::String option = settings["gfx-mode"];
bool isValid = false;
while (gm->name && !isValid) {
isValid = !scumm_stricmp(gm->name, option.c_str());
gm++;
}
if (!isValid) {
warning("Unrecognized graphics mode '%s'. Switching to default mode", option.c_str());
settings["gfx-mode"] = "default";
}
}
setupGraphics(system); setupGraphics(system);
// Init the different managers that are used by the engines. // Init the different managers that are used by the engines.