aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/sdl/sdl-common.cpp1
-rw-r--r--common/gameDetector.cpp133
-rw-r--r--common/gameDetector.h17
-rw-r--r--common/main.cpp130
-rw-r--r--gui/launcher.cpp57
-rw-r--r--gui/launcher.h10
-rw-r--r--scumm/scumm.h2
-rw-r--r--scumm/scummvm.cpp2
8 files changed, 199 insertions, 153 deletions
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp
index d77d63c091..a98f9acdca 100644
--- a/backends/sdl/sdl-common.cpp
+++ b/backends/sdl/sdl-common.cpp
@@ -21,7 +21,6 @@
#include "sdl-common.h"
#include "sound/mididrv.h"
-#include "common/gameDetector.h"
#include "common/scaler.h"
#include "common/engine.h" // Only #included for error() and warning()
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);
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index b25afd6292..95dee83fa9 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -23,46 +23,73 @@
#include "newgui.h"
#include "ListWidget.h"
+#include "common/config-file.h"
#include "common/engine.h"
#include "common/gameDetector.h"
-#include "common/list.h"
enum {
- kOptionsCmd = 'QUIT',
+ kStartCmd = 'STRT',
+ kOptionsCmd = 'OPTN',
kQuitCmd = 'QUIT'
};
+
+/*
+ * TODO list
+ * - add an text entry widget
+ * - add an "Add Game..." button that opens a dialog where new games can be
+ * configured and added to the list of games
+ * - add an "Edit Game..." button that opens a dialog that allows to edit game
+ * settings, i.e. the datapath/savepath/sound driver/... for that game
+ * - add an "options" dialog
+ * - ...
+ */
-LauncherDialog::LauncherDialog(NewGui *gui)
- : Dialog(gui, 0, 0, 320, 200)
+LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector)
+ : Dialog(gui, 0, 0, 320, 200), _detector(detector)
{
// Add three buttons at the bottom
- addButton(1*(_w - 54)/4, _h - 24, 54, 16, "Quit", kQuitCmd, 'Q');
- addButton(2*(_w - 54)/4, _h - 24, 54, 16, "Options", kOptionsCmd, 'O');
- addButton(3*(_w - 54)/4, _h - 24, 54, 16, "Run", kCloseCmd, 'R');
+ addButton(1*(_w - 54)/6, _h - 24, 54, 16, "Quit", kQuitCmd, 'Q');
+ addButton(3*(_w - 54)/6, _h - 24, 54, 16, "Options", kOptionsCmd, 'O');
+ addButton(5*(_w - 54)/6, _h - 24, 54, 16, "Start", kStartCmd, 'S');
// Add list with game titles
- ListWidget *w = new ListWidget(this, 10, 10, 300, 112);
- w->setNumberingMode(kListNumberingOff);
+ _list = new ListWidget(this, 10, 10, 300, 112);
+ _list->setNumberingMode(kListNumberingOff);
const VersionSettings *v = version_settings;
ScummVM::StringList l;
+ // TODO - maybe only display those games for which settings are known
+ // (i.e. a path to the game data was set and is accesible) ?
while (v->filename && v->gamename) {
- l.push_back(v->gamename);
+ if (g_config->has_domain(v->filename)) {
+ l.push_back(v->gamename);
+ _filenames.push_back(v->filename);
+ }
v++;
}
- w->setList(l);
-
- // TODO - add an edit field with the path information; or maybe even a "file selector" ?
+ _list->setList(l);
+// _list->setSelected(0);
}
void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
{
+ int item;
+
switch (cmd) {
- case kListItemChangedCmd:
- break;
+ case kStartCmd:
case kListItemDoubleClickedCmd:
+ // Print out what was selected
+ item = _list->getSelected();
+ if (item >= 0) {
+ printf("Selected game: %s\n", _filenames[item].c_str());
+ _detector.setGame(_filenames[item].c_str());
+ close();
+ } else {
+ // TODO - beep or so ?
+ // Ideally, the start button should be disabled if no game is selected
+ }
break;
case kQuitCmd:
g_system->quit();
diff --git a/gui/launcher.h b/gui/launcher.h
index c0afb9a406..1bfcfc8e22 100644
--- a/gui/launcher.h
+++ b/gui/launcher.h
@@ -23,15 +23,23 @@
#include "dialog.h"
#include "common/str.h"
+#include "common/list.h"
+
+class GameDetector;
+class ListWidget;
class LauncherDialog : public Dialog {
typedef ScummVM::String String;
+ typedef ScummVM::StringList StringList;
public:
- LauncherDialog(NewGui *gui);
+ LauncherDialog(NewGui *gui, GameDetector &detector);
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
protected:
+ ListWidget *_list;
+ StringList _filenames;
+ GameDetector &_detector;
};
#endif
diff --git a/scumm/scumm.h b/scumm/scumm.h
index e1bc1c5441..82d4ae57c6 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -932,7 +932,7 @@ public:
/* String class */
CharsetRenderer charset;
byte _charsetColor;
- uint16 _noSubtitles; // Skip all subtitles?
+ bool _noSubtitles; // Skip all subtitles?
byte _charsetData[15][16];
void initCharset(int charset);
void restoreCharsetBg();
diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp
index c6a44a9fdf..c406520c09 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -81,7 +81,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
_debugMode = detector->_debugMode;
_bootParam = detector->_bootParam;
- _exe_name = detector->_exe_name;
+ _exe_name = detector->_gameFileName.c_str();
_gameId = detector->_gameId;
_gameText = detector->_gameText;
_features = detector->_features;