played a bit with the launcher - it now is already somewhat usable <g>
svn-id: r5047
This commit is contained in:
parent
e9e75ffd0a
commit
d921d06d39
8 changed files with 201 additions and 155 deletions
|
@ -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()
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
public:
|
||||
int detectMain(int argc, char **argv);
|
||||
void parseCommandLine(int argc, char **argv);
|
||||
typedef ScummVM::String String;
|
||||
protected:
|
||||
bool detectGame(void);
|
||||
|
||||
public:
|
||||
GameDetector();
|
||||
|
||||
void parseCommandLine(int argc, char **argv);
|
||||
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;
|
||||
|
||||
|
|
132
common/main.cpp
132
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,62 +95,8 @@ static void do_memory_test(void) {
|
|||
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
static void launcherDialog(GameDetector &detector, OSystem *system)
|
||||
{
|
||||
int result;
|
||||
#ifdef __DC__
|
||||
extern void dc_init_hardware();
|
||||
dc_init_hardware();
|
||||
#endif
|
||||
|
||||
#if defined(UNIX)
|
||||
/* On Unix, do a quick endian / alignement check before starting */
|
||||
do_memory_test();
|
||||
|
||||
char scummhome[MAXPATHLEN];
|
||||
if(getenv("HOME") != NULL)
|
||||
sprintf(scummhome,"%s/%s", getenv("HOME"), DEFAULT_CONFIG_FILE);
|
||||
else strcpy(scummhome,DEFAULT_CONFIG_FILE);
|
||||
#else
|
||||
char scummhome[255];
|
||||
#if defined (WIN32) && !defined(_WIN32_WCE)
|
||||
GetWindowsDirectory(scummhome, 255);
|
||||
strcat(scummhome, "\\");
|
||||
strcat(scummhome, DEFAULT_CONFIG_FILE);
|
||||
#else
|
||||
strcpy(scummhome, DEFAULT_CONFIG_FILE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Read the config file
|
||||
g_config = new Config(scummhome, "scummvm");
|
||||
g_config->set("versioninfo", SCUMMVM_VERSION);
|
||||
|
||||
// Parse the command line information
|
||||
result = detector.detectMain(argc, argv);
|
||||
|
||||
// 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) {
|
||||
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
|
||||
|
@ -187,21 +131,79 @@ int main(int argc, char *argv[])
|
|||
|
||||
system->set_palette(dummy_palette, 0, 16);
|
||||
|
||||
#if 1
|
||||
// FIXME - hack we use because LauncherDialog accesses g_system
|
||||
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
|
||||
|
||||
Dialog *dlg = new LauncherDialog(g_gui, detector);
|
||||
dlg->open();
|
||||
g_gui->runLoop();
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
GameDetector detector;
|
||||
#ifdef __DC__
|
||||
extern void dc_init_hardware();
|
||||
dc_init_hardware();
|
||||
#endif
|
||||
|
||||
#if defined(UNIX)
|
||||
/* On Unix, do a quick endian / alignement check before starting */
|
||||
do_memory_test();
|
||||
|
||||
char scummhome[MAXPATHLEN];
|
||||
if(getenv("HOME") != NULL)
|
||||
sprintf(scummhome,"%s/%s", getenv("HOME"), DEFAULT_CONFIG_FILE);
|
||||
else strcpy(scummhome,DEFAULT_CONFIG_FILE);
|
||||
#else
|
||||
char scummhome[255];
|
||||
#if defined (WIN32) && !defined(_WIN32_WCE)
|
||||
GetWindowsDirectory(scummhome, 255);
|
||||
strcat(scummhome, "\\");
|
||||
strcat(scummhome, DEFAULT_CONFIG_FILE);
|
||||
#else
|
||||
strcpy(scummhome, DEFAULT_CONFIG_FILE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Read the config file
|
||||
g_config = new Config(scummhome, "scummvm");
|
||||
g_config->set("versioninfo", SCUMMVM_VERSION);
|
||||
|
||||
// Parse the command line information
|
||||
#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();
|
||||
|
||||
// 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 game engine
|
||||
Engine *engine = Engine::createFromDetector(&detector, system);
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue