aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2002-09-30 00:55:47 +0000
committerMax Horn2002-09-30 00:55:47 +0000
commitd921d06d3965d2ee5ad072503d72d52564947b21 (patch)
treeb99d57405d1022f93eedde934175acd9c8954774 /common
parente9e75ffd0a8ac86c36a13057bfee1719dd8b76f5 (diff)
downloadscummvm-rg350-d921d06d3965d2ee5ad072503d72d52564947b21.tar.gz
scummvm-rg350-d921d06d3965d2ee5ad072503d72d52564947b21.tar.bz2
scummvm-rg350-d921d06d3965d2ee5ad072503d72d52564947b21.zip
played a bit with the launcher - it now is already somewhat usable <g>
svn-id: r5047
Diffstat (limited to 'common')
-rw-r--r--common/gameDetector.cpp133
-rw-r--r--common/gameDetector.h17
-rw-r--r--common/main.cpp130
3 files changed, 146 insertions, 134 deletions
diff --git a/common/gameDetector.cpp b/common/gameDetector.cpp
index 95d66cea40..0579405ff7 100644
--- a/common/gameDetector.cpp
+++ b/common/gameDetector.cpp
@@ -70,6 +70,59 @@ static const char USAGE_STRING[] =
"\t-y - set text speed (default: 60)\n"
;
+
+GameDetector::GameDetector()
+{
+ _fullScreen = false;
+ _gameId = 0;
+
+ _use_adlib = false;
+
+ _music_volume = kDefaultMusicVolume;
+ _sfx_volume = kDefaultSFXVolume;
+ _amiga = false;
+
+ _talkSpeed = 60;
+ _debugMode = 0;
+ _noSubtitles = false;
+ _bootParam = 0;
+ _soundCardType = 3;
+
+ _gameDataPath = 0;
+ _gameTempo = 0;
+ _midi_driver = MD_AUTO;
+ _gameText = 0;
+ _features = 0;
+
+ _cdrom = 0;
+ _save_slot = 0;
+
+ _saveconfig = false;
+
+#ifndef _WIN32_WCE
+ _gfx_mode = GFX_DOUBLESIZE;
+#else
+ _gfx_mode = GFX_NORMAL;
+#endif
+
+#if defined(USE_NULL_DRIVER)
+ _gfx_driver = GD_NULL;
+#elif defined(__DC__)
+ _gfx_driver = GD_DC;
+#elif defined(X11_BACKEND)
+ _gfx_driver = GD_X;
+#elif defined(__MORPHOS__)
+ _gfx_driver = GD_MORPHOS;
+#elif defined(_WIN32_WCE)
+ _gfx_driver = GD_WINCE;
+#elif defined(MACOS_CARBON)
+ _gfx_driver = GD_MAC;
+#else
+ /* SDL is the default driver for now */
+ _gfx_driver = GD_SDL;
+#endif
+}
+
void GameDetector::updateconfig()
{
const char * val;
@@ -247,11 +300,7 @@ void GameDetector::parseCommandLine(int argc, char **argv)
}
} else {
if (i == (argc - 1)) {
- _exe_name = s;
- g_config->set_domain(s);
- g_config->rename_domain("game-specific");
- g_config->rename_domain(s);
- updateconfig();
+ setGame(s);
} else {
if (current_option == NULL)
current_option = s;
@@ -261,7 +310,7 @@ void GameDetector::parseCommandLine(int argc, char **argv)
}
}
- if (_exe_name)
+ if (!_gameFileName.isEmpty())
g_config->flush();
return;
@@ -271,6 +320,15 @@ void GameDetector::parseCommandLine(int argc, char **argv)
exit(1);
}
+void GameDetector::setGame(const String &name)
+{
+ _gameFileName = name;
+ g_config->set_domain(name);
+ g_config->rename_domain("game-specific");
+ g_config->rename_domain(name);
+ updateconfig();
+}
+
int GameDetector::parseGraphicsMode(const char *s) {
struct GraphicsModes {
const char *name;
@@ -429,7 +487,7 @@ bool GameDetector::detectGame()
_gameId = 0;
_gameText = NULL;
do {
- if (!scumm_stricmp(_exe_name, gnl->filename)) {
+ if (!scumm_stricmp(_gameFileName.c_str(), gnl->filename)) {
_gameId = gnl->id;
_features = gnl->features;
@@ -449,74 +507,19 @@ const char *GameDetector::getGameName()
{
if (_gameText == NULL) {
char buf[256];
- sprintf(buf, "Unknown game: \"%s\"", _exe_name);
+ sprintf(buf, "Unknown game: \"%s\"", _gameFileName.c_str());
_gameText = strdup(buf);
}
return _gameText;
}
-int GameDetector::detectMain(int argc, char **argv)
+int GameDetector::detectMain()
{
- _debugMode = 0; // off by default...
-
- _noSubtitles = 0; // use by default - should this depend on soundtrack?
-
- _talkSpeed = 60;
-
-#ifndef _WIN32_WCE
- _gfx_mode = GFX_DOUBLESIZE;
-#else
- _gfx_mode = GFX_NORMAL;
-#endif
- _sfx_volume = kDefaultSFXVolume;
- _music_volume = kDefaultMusicVolume;
-
-#if defined(USE_NULL_DRIVER)
- _gfx_driver = GD_NULL;
-#elif defined(__DC__)
- _gfx_driver = GD_DC;
-#elif defined(X11_BACKEND)
- _gfx_driver = GD_X;
-#elif defined(__MORPHOS__)
- _gfx_driver = GD_MORPHOS;
-#elif defined(_WIN32_WCE)
- _gfx_driver = GD_WINCE;
-#elif defined(MACOS_CARBON)
- _gfx_driver = GD_MAC;
-#else
- /* SDL is the default driver for now */
- _gfx_driver = GD_SDL;
-#endif
-
- _gameDataPath = NULL;
- _gameTempo = 0;
- _soundCardType = 3;
-
-
-
- _midi_driver = MD_AUTO;
-
-#if defined(__DC__)
- extern int dc_setup(GameDetector &detector);
- dc_setup(*this);
-#elif defined(MACOS_CARBON)
- extern char* SelectGame();
- char *game_name = SelectGame();
- printf(game_name);
-#else
- _saveconfig = false;
- updateconfig();
- parseCommandLine(argc, argv);
-#endif
-
- if (_exe_name == NULL) {
- //launcherLoop();
- //setWindowName(this);
+ if (_gameFileName.isEmpty()) {
warning("No game was specified...");
return (-1);
}
-
if (!detectGame()) {
warning("Game detection failed. Using default settings");
_features = GF_DEFAULT;
diff --git a/common/gameDetector.h b/common/gameDetector.h
index 857b73a5ef..cdfb77d8e3 100644
--- a/common/gameDetector.h
+++ b/common/gameDetector.h
@@ -23,6 +23,8 @@
#ifndef GAMEDETECTOR_H
#define GAMEDETECTOR_H
+#include "common/str.h"
+
class OSystem;
class MidiDriver;
@@ -37,15 +39,20 @@ extern const VersionSettings version_settings[];
class GameDetector {
+ typedef ScummVM::String String;
+protected:
+ bool detectGame(void);
+
public:
- int detectMain(int argc, char **argv);
+ GameDetector();
+
void parseCommandLine(int argc, char **argv);
- bool detectGame(void);
+ int detectMain();
+ void setGame(const String &name);
const char *getGameName(void);
bool _fullScreen;
byte _gameId;
- bool _simon;
bool _use_adlib;
@@ -55,14 +62,14 @@ public:
uint16 _talkSpeed;
uint16 _debugMode;
- uint16 _noSubtitles;
+ bool _noSubtitles;
uint16 _bootParam;
uint16 _soundCardType;
char *_gameDataPath;
int _gameTempo;
int _midi_driver;
- char *_exe_name;
+ String _gameFileName;
const char *_gameText;
uint32 _features;
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);