diff options
Diffstat (limited to 'common/main.cpp')
-rw-r--r-- | common/main.cpp | 130 |
1 files changed, 66 insertions, 64 deletions
diff --git a/common/main.cpp b/common/main.cpp index 651d1d2891..fee7d71183 100644 --- a/common/main.cpp +++ b/common/main.cpp @@ -28,8 +28,6 @@ #include "gui/launcher.h" #include "gui/message.h" -GameDetector detector; - Config *g_config = 0; NewGui *g_gui = 0; @@ -97,9 +95,55 @@ static void do_memory_test(void) { #endif +static void launcherDialog(GameDetector &detector, OSystem *system) +{ + // FIXME - we need to call init_size() here so that we can display for example + // the launcher dialog. But the Engine object will also call it again (possibly + // with a different widht/height!9 However, this method is not for all OSystem + // implementations reentrant (it is so now for the SDL backend). Thus we need + // to fix all backends to support it, if they don't already. + system->init_size(320, 200); + + // FIXME - mouse cursors are currently always set via 8 bit data. + // Thus for now we need to setup a dummy palette. On the long run, we might + // want to add a set_mouse_cursor_overlay() method to OSystem, which would serve + // two purposes: + // 1) allow for 16 bit mouse cursors in overlay mode + // 2) no need to backup & restore the mouse cursor before/after the overlay is shown + const byte dummy_palette[] = { + 0, 0, 0, 0, + 0, 0, 171, 0, + 0, 171, 0, 0, + 0, 171, 171, 0, + 171, 0, 0, 0, + 171, 0, 171, 0, + 171, 87, 0, 0, + 171, 171, 171, 0, + 87, 87, 87, 0, + 87, 87, 255, 0, + 87, 255, 87, 0, + 87, 255, 255, 0, + 255, 87, 87, 0, + 255, 87, 255, 0, + 255, 255, 87, 0, + 255, 255, 255, 0, + }; + + system->set_palette(dummy_palette, 0, 16); + + // FIXME - hack we use because LauncherDialog accesses g_system + extern OSystem *g_system; + g_system = system; + + Dialog *dlg = new LauncherDialog(g_gui, detector); + dlg->open(); + g_gui->runLoop(); + delete dlg; +} + int main(int argc, char *argv[]) { - int result; + GameDetector detector; #ifdef __DC__ extern void dc_init_hardware(); dc_init_hardware(); @@ -129,79 +173,37 @@ int main(int argc, char *argv[]) g_config->set("versioninfo", SCUMMVM_VERSION); // Parse the command line information - result = detector.detectMain(argc, argv); +#if defined(__DC__) + extern int dc_setup(GameDetector &detector); + dc_setup(detector); +#else + detector._saveconfig = false; + detector.updateconfig(); + detector.parseCommandLine(argc, argv); +#endif // Create the system object OSystem *system = detector.createSystem(); - // TODO - if detectMain() returns an error, fire up the launcher dialog - // TODO - implement the launcher dialog; also implement some sort of generic - // error dialog, to be used by the launcher if e.g. the game data can't - // be found. - if (result) { + // Create the GUI manager + // TODO - move this up for the launcher dialog? + g_gui = new NewGui(system); + + // Unless a game was specified, show the launcher dialog + if (detector._gameFileName.isEmpty()) + launcherDialog(detector, system); + + // Verify the given game name + if (detector.detectMain()) { system->quit(); return (-1); } - + // Set the window caption (for OSystems that support it) OSystem::Property prop; 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 call init_size() here so that we can display for example - // the launcher dialog. But the Engine object will also call it again (possibly - // with a different widht/height!9 However, this method is not for all OSystem - // implementations reentrant (it is so now for the SDL backend). Thus we need - // to fix all backends to support it, if they don't already. - system->init_size(320, 200); - - // FIXME - mouse cursors are currently always set via 8 bit data. - // Thus for now we need to setup a dummy palette. On the long run, we might - // want to add a set_mouse_cursor_overlay() method to OSystem, which would serve - // two purposes: - // 1) allow for 16 bit mouse cursors in overlay mode - // 2) no need to backup & restore the mouse cursor before/after the overlay is shown - const byte dummy_palette[] = { - 0, 0, 0, 0, - 0, 0, 171, 0, - 0, 171, 0, 0, - 0, 171, 171, 0, - 171, 0, 0, 0, - 171, 0, 171, 0, - 171, 87, 0, 0, - 171, 171, 171, 0, - 87, 87, 87, 0, - 87, 87, 255, 0, - 87, 255, 87, 0, - 87, 255, 255, 0, - 255, 87, 87, 0, - 255, 87, 255, 0, - 255, 255, 87, 0, - 255, 255, 255, 0, - }; - - system->set_palette(dummy_palette, 0, 16); - -#if 1 - extern OSystem *g_system; - g_system = system; - Dialog *dlg = new LauncherDialog(g_gui); -#else - const char *message = "This dialog is shown before the\n" - "Engine obejct is even created.\n" - "Wow! Ain't we cool?\n"; - Dialog *dlg = new MessageDialog(g_gui, message); -#endif - dlg->open(); - g_gui->runLoop(); - delete dlg; -#endif - // Create the game engine Engine *engine = Engine::createFromDetector(&detector, system); |