2002-09-27 23:27:14 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2002-2003 The ScummVM project
|
2002-09-27 23:27:14 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* $Header$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "launcher.h"
|
2002-11-14 13:46:35 +00:00
|
|
|
#include "browser.h"
|
2002-11-21 12:48:50 +00:00
|
|
|
#include "chooser.h"
|
2002-11-21 13:11:29 +00:00
|
|
|
#include "message.h"
|
2002-12-12 23:22:48 +00:00
|
|
|
#include "newgui.h"
|
|
|
|
#include "options.h"
|
2002-11-21 14:12:55 +00:00
|
|
|
#include "EditTextWidget.h"
|
2002-09-27 23:27:14 +00:00
|
|
|
#include "ListWidget.h"
|
|
|
|
|
2002-11-19 01:36:47 +00:00
|
|
|
#include "backends/fs/fs.h"
|
2002-09-30 00:55:47 +00:00
|
|
|
#include "common/config-file.h"
|
2002-09-27 23:27:14 +00:00
|
|
|
#include "common/engine.h"
|
|
|
|
#include "common/gameDetector.h"
|
2003-09-08 17:25:44 +00:00
|
|
|
#include "common/plugins.h"
|
2002-09-27 23:27:14 +00:00
|
|
|
|
|
|
|
enum {
|
2002-09-30 00:55:47 +00:00
|
|
|
kStartCmd = 'STRT',
|
|
|
|
kOptionsCmd = 'OPTN',
|
2002-10-13 11:51:48 +00:00
|
|
|
kAddGameCmd = 'ADDG',
|
2002-11-21 13:11:29 +00:00
|
|
|
kEditGameCmd = 'EDTG',
|
|
|
|
kRemoveGameCmd = 'REMG',
|
2002-09-27 23:27:14 +00:00
|
|
|
kQuitCmd = 'QUIT'
|
|
|
|
};
|
2002-11-21 02:19:02 +00:00
|
|
|
|
2003-09-08 15:38:34 +00:00
|
|
|
typedef ScummVM::List<const TargetSettings *> GameList;
|
2002-11-21 02:19:02 +00:00
|
|
|
|
2002-11-21 14:12:55 +00:00
|
|
|
/*
|
|
|
|
* A dialog that allows the user to edit a config game entry.
|
2002-11-21 15:24:38 +00:00
|
|
|
* TODO: add widgets for some/all of the following
|
|
|
|
* - Amiga/subtitles flag? Although those only make sense for Scumm games, not Simon
|
|
|
|
* - The music driver for that game (<Default> or custom)
|
2002-11-21 15:20:52 +00:00
|
|
|
* Of course this means we need an API to query the available music drivers.
|
2002-11-21 15:24:38 +00:00
|
|
|
* - Maybe scaler/graphics mode. But there are two problems:
|
|
|
|
* 1) Different backends can have different scalers with different names,
|
2002-11-21 14:12:55 +00:00
|
|
|
* so we first have to add a way to query those... no Ender, I don't
|
|
|
|
* think a bitmasked property() value is nice for this, because we would
|
|
|
|
* have to add to the bitmask values whenever a backends adds a new scaler).
|
2002-11-21 15:24:38 +00:00
|
|
|
* 2) At the time the launcher is running, the GFX backend is already setup.
|
|
|
|
* So when a game is run via the launcher, the custom scaler setting for it won't be
|
2002-11-21 14:12:55 +00:00
|
|
|
* used. So we'd also have to add an API to change the scaler during runtime
|
|
|
|
* (the SDL backend can already do that based on user input, but there is no API
|
|
|
|
* to achieve it)
|
|
|
|
* If the APIs for 1&2 are in place, we can think about adding this to the Edit&Option dialogs
|
2002-11-21 15:24:38 +00:00
|
|
|
* - Maybe SFX/Master/Music volumes?
|
2002-11-21 14:12:55 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kOKCmd = 'OK '
|
|
|
|
};
|
|
|
|
|
|
|
|
class EditGameDialog : public Dialog {
|
|
|
|
typedef ScummVM::String String;
|
|
|
|
typedef ScummVM::StringList StringList;
|
|
|
|
public:
|
2003-09-08 15:38:34 +00:00
|
|
|
EditGameDialog(NewGui *gui, const String &domain, const TargetSettings *target);
|
2002-11-21 14:12:55 +00:00
|
|
|
|
|
|
|
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
|
|
|
|
|
|
|
protected:
|
2003-03-06 19:52:54 +00:00
|
|
|
Config &_config;
|
|
|
|
const String &_domain;
|
|
|
|
EditTextWidget *_descriptionWidget;
|
|
|
|
EditTextWidget *_domainWidget;
|
|
|
|
CheckboxWidget *_fullscreenCheckbox;
|
2003-08-20 14:01:39 +00:00
|
|
|
CheckboxWidget *_amigaCheckbox;
|
2002-11-21 14:12:55 +00:00
|
|
|
};
|
|
|
|
|
2003-09-08 15:38:34 +00:00
|
|
|
EditGameDialog::EditGameDialog(NewGui *gui, const String &domain, const TargetSettings *target)
|
|
|
|
: Dialog(gui, 8, 50, 320 - 2 * 8, 200 - 2 * 40), _config(*g_config), _domain(domain) {
|
|
|
|
|
2002-11-21 14:12:55 +00:00
|
|
|
// Determine the description string
|
2002-11-21 16:56:29 +00:00
|
|
|
String description(_config.get("description", _domain));
|
2002-12-20 22:41:03 +00:00
|
|
|
if (description.isEmpty()) {
|
2003-09-08 15:38:34 +00:00
|
|
|
description = target->description;
|
2002-11-21 14:12:55 +00:00
|
|
|
}
|
2003-09-08 15:38:34 +00:00
|
|
|
|
|
|
|
// Determine whether this is a SCUMM game
|
2003-09-08 16:10:05 +00:00
|
|
|
// FIXME: This check is evil, as it requires us to hard code GIDs.
|
2003-09-08 15:38:34 +00:00
|
|
|
bool isScumm = (GID_SCUMM_FIRST <= target->id && target->id <= GID_SCUMM_LAST);
|
|
|
|
|
2002-11-21 14:12:55 +00:00
|
|
|
|
2002-11-21 17:25:31 +00:00
|
|
|
// Label & edit widget for the game ID
|
|
|
|
new StaticTextWidget(this, 10, 10, 40, kLineHeight, "ID: ", kTextAlignRight);
|
|
|
|
_domainWidget =
|
2003-03-06 19:52:54 +00:00
|
|
|
new EditTextWidget(this, 50, 10, _w - 50 - 10, kLineHeight, _domain);
|
|
|
|
|
2002-11-21 14:12:55 +00:00
|
|
|
// Label & edit widget for the description
|
2002-11-21 17:25:31 +00:00
|
|
|
new StaticTextWidget(this, 10, 26, 40, kLineHeight, "Name: ", kTextAlignRight);
|
2002-11-21 16:56:29 +00:00
|
|
|
_descriptionWidget =
|
2003-03-06 19:52:54 +00:00
|
|
|
new EditTextWidget(this, 50, 26, _w - 50 - 10, kLineHeight, description);
|
2002-11-21 15:20:52 +00:00
|
|
|
|
2002-11-21 14:12:55 +00:00
|
|
|
// Path to game data (view only)
|
2002-11-21 16:56:29 +00:00
|
|
|
String path(_config.get("path", _domain));
|
2002-11-21 17:25:31 +00:00
|
|
|
new StaticTextWidget(this, 10, 42, 40, kLineHeight, "Path: ", kTextAlignRight);
|
2003-03-06 19:52:54 +00:00
|
|
|
new StaticTextWidget(this, 50, 42, _w - 50 - 10, kLineHeight, path, kTextAlignLeft);
|
|
|
|
|
2002-12-20 22:41:03 +00:00
|
|
|
// Full screen checkbox
|
2002-11-25 09:43:22 +00:00
|
|
|
_fullscreenCheckbox = new CheckboxWidget(this, 15, 62, 200, 16, "Use Fullscreen Mode", 0, 'F');
|
2002-12-20 22:41:03 +00:00
|
|
|
_fullscreenCheckbox->setState(_config.getBool("fullscreen", false, _domain));
|
|
|
|
|
|
|
|
// Display 'Amiga' checkbox, but only for Scumm games.
|
2003-09-08 15:38:34 +00:00
|
|
|
if (isScumm) {
|
2003-08-20 14:01:39 +00:00
|
|
|
_amigaCheckbox = new CheckboxWidget(this, 15, 82, 200, 16, "Amiga Version", 0, 'A');
|
|
|
|
_amigaCheckbox->setState(_config.getBool("amiga", false, _domain));
|
2003-08-12 02:08:21 +00:00
|
|
|
} else {
|
2003-08-20 14:01:39 +00:00
|
|
|
_amigaCheckbox = 0;
|
2002-12-20 22:41:03 +00:00
|
|
|
}
|
2002-11-21 14:12:55 +00:00
|
|
|
|
|
|
|
// Add OK & Cancel buttons
|
2003-03-06 19:52:54 +00:00
|
|
|
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
|
|
|
|
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
|
2002-11-21 14:12:55 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
2002-11-21 17:29:57 +00:00
|
|
|
if (cmd == kOKCmd) {
|
2002-11-21 16:56:29 +00:00
|
|
|
// Write back changes made to config object
|
2002-11-21 17:25:31 +00:00
|
|
|
String newDomain(_domainWidget->getLabel());
|
|
|
|
if (newDomain != _domain) {
|
|
|
|
if (newDomain.isEmpty() || _config.has_domain(newDomain)) {
|
|
|
|
MessageDialog alert(_gui, "This game ID is already taken. Please choose another one.");
|
|
|
|
alert.runModal();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_config.rename_domain(_domain, newDomain);
|
|
|
|
}
|
|
|
|
_config.set("description", _descriptionWidget->getLabel(), newDomain);
|
2003-08-20 14:01:39 +00:00
|
|
|
if (_amigaCheckbox)
|
|
|
|
_config.setBool("amiga", _amigaCheckbox->getState(), newDomain);
|
2002-11-25 09:43:22 +00:00
|
|
|
_config.setBool("fullscreen", _fullscreenCheckbox->getState(), newDomain);
|
2002-11-21 14:12:55 +00:00
|
|
|
setResult(1);
|
|
|
|
close();
|
2002-11-21 17:29:57 +00:00
|
|
|
} else {
|
2002-11-21 14:12:55 +00:00
|
|
|
Dialog::handleCommand(sender, cmd, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-30 00:55:47 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* - ...
|
|
|
|
*/
|
2002-09-27 23:27:14 +00:00
|
|
|
|
2002-09-30 00:55:47 +00:00
|
|
|
LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector)
|
2003-03-06 19:52:54 +00:00
|
|
|
: Dialog(gui, 0, 0, 320, 200), _detector(detector) {
|
2002-10-13 11:51:48 +00:00
|
|
|
// Show game name
|
2003-07-15 02:16:33 +00:00
|
|
|
new StaticTextWidget(this, 10, 8, 300, kLineHeight, gScummVMFullVersion, kTextAlignCenter);
|
2002-10-13 11:51:48 +00:00
|
|
|
|
2002-09-27 23:27:14 +00:00
|
|
|
// Add three buttons at the bottom
|
2003-03-06 19:52:54 +00:00
|
|
|
addButton(1 * (_w - kButtonWidth) / 6, _h - 24, "Quit", kQuitCmd, 'Q');
|
|
|
|
addButton(3 * (_w - kButtonWidth) / 6, _h - 24, "Options", kOptionsCmd, 'O');
|
|
|
|
_startButton = addButton(5 * (_w - kButtonWidth)/6, _h - 24, "Start", kStartCmd, 'S');
|
2002-09-27 23:27:14 +00:00
|
|
|
|
|
|
|
// Add list with game titles
|
2002-10-13 11:51:48 +00:00
|
|
|
_list = new ListWidget(this, 10, 28, 300, 112);
|
2002-09-30 12:56:59 +00:00
|
|
|
_list->setEditable(false);
|
2002-09-30 00:55:47 +00:00
|
|
|
_list->setNumberingMode(kListNumberingOff);
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-11-21 02:19:02 +00:00
|
|
|
// Two more buttons directly below the list box
|
2002-11-21 13:11:29 +00:00
|
|
|
const int kBigButtonWidth = 90;
|
|
|
|
new ButtonWidget(this, 10, 144, kBigButtonWidth, 16, "Add Game...", kAddGameCmd, 'A');
|
2003-03-06 19:52:54 +00:00
|
|
|
_editButton = new ButtonWidget(this, (320-kBigButtonWidth) / 2, 144, kBigButtonWidth, 16, "Edit Game...", kEditGameCmd, 'E');
|
|
|
|
_removeButton = new ButtonWidget(this, 320-kBigButtonWidth - 10, 144, kBigButtonWidth, 16, "Remove Game", kRemoveGameCmd, 'R');
|
|
|
|
|
2002-12-01 12:47:13 +00:00
|
|
|
// Populate the list
|
|
|
|
updateListing();
|
|
|
|
|
|
|
|
// TODO - make a default selection (maybe the game user played last?)
|
|
|
|
//_list->setSelected(0);
|
|
|
|
|
|
|
|
// En-/Disable the buttons depending on the list selection
|
|
|
|
updateButtons();
|
|
|
|
|
2002-11-21 02:19:02 +00:00
|
|
|
// Create file browser dialog
|
2003-03-25 15:32:36 +00:00
|
|
|
_browser = new BrowserDialog(_gui, "Select directory with game data");
|
2002-11-21 02:19:02 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
LauncherDialog::~LauncherDialog() {
|
2002-11-21 02:19:02 +00:00
|
|
|
delete _browser;
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void LauncherDialog::open() {
|
2002-11-21 15:20:52 +00:00
|
|
|
Dialog::open();
|
|
|
|
g_config->set_writing(true);
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void LauncherDialog::close() {
|
2002-11-21 15:20:52 +00:00
|
|
|
g_config->flush();
|
|
|
|
g_config->set_writing(false);
|
|
|
|
Dialog::close();
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void LauncherDialog::updateListing() {
|
2002-11-21 02:19:02 +00:00
|
|
|
int i;
|
2002-09-27 23:27:14 +00:00
|
|
|
ScummVM::StringList l;
|
2002-10-28 09:03:02 +00:00
|
|
|
|
2002-10-28 10:40:49 +00:00
|
|
|
// Retrieve a list of all games defined in the config file
|
2002-11-21 15:20:52 +00:00
|
|
|
_domains.clear();
|
2002-11-13 20:23:24 +00:00
|
|
|
StringList domains = g_config->get_domains();
|
2002-11-21 15:20:52 +00:00
|
|
|
for (i = 0; i < domains.size(); i++) {
|
2002-11-21 14:12:55 +00:00
|
|
|
String name(g_config->get("gameid", domains[i]));
|
|
|
|
String description(g_config->get("description", domains[i]));
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-11-21 16:56:29 +00:00
|
|
|
if (name.isEmpty())
|
|
|
|
name = domains[i];
|
|
|
|
if (description.isEmpty()) {
|
2003-09-08 17:25:44 +00:00
|
|
|
const TargetSettings *v = _detector.findTarget(name.c_str());
|
|
|
|
if (v && v->description)
|
|
|
|
description = v->description;
|
2002-10-28 10:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!name.isEmpty() && !description.isEmpty()) {
|
|
|
|
// Insert the game into the launcher list
|
|
|
|
int pos = 0, size = l.size();
|
2002-10-28 09:03:02 +00:00
|
|
|
|
2002-11-13 20:23:24 +00:00
|
|
|
while (pos < size && (description > l[pos]))
|
2002-10-15 15:32:54 +00:00
|
|
|
pos++;
|
2002-10-28 10:40:49 +00:00
|
|
|
l.insert_at(pos, description);
|
2002-11-21 14:12:55 +00:00
|
|
|
_domains.insert_at(pos, domains[i]);
|
2002-09-30 00:55:47 +00:00
|
|
|
}
|
2002-09-27 23:27:14 +00:00
|
|
|
}
|
|
|
|
|
2002-11-21 15:20:52 +00:00
|
|
|
_list->setList(l);
|
2002-12-01 12:47:13 +00:00
|
|
|
updateButtons();
|
2002-09-27 23:27:14 +00:00
|
|
|
}
|
|
|
|
|
2002-11-21 02:19:02 +00:00
|
|
|
/*
|
|
|
|
* Return a list of all games which might be the game in the specified directory.
|
|
|
|
*/
|
2003-03-06 19:52:54 +00:00
|
|
|
GameList findGame(FilesystemNode *dir) {
|
2002-11-21 02:19:02 +00:00
|
|
|
GameList list;
|
2002-11-19 01:36:47 +00:00
|
|
|
|
|
|
|
FSList *files = dir->listDir(FilesystemNode::kListFilesOnly);
|
2002-11-21 02:19:02 +00:00
|
|
|
const int size = files->size();
|
2003-04-29 04:27:08 +00:00
|
|
|
char detectName[128];
|
|
|
|
char detectName2[128];
|
2003-06-15 02:02:36 +00:00
|
|
|
char detectName3[128];
|
2002-11-21 02:19:02 +00:00
|
|
|
|
|
|
|
// Iterate over all known games and for each check if it might be
|
|
|
|
// the game in the presented directory.
|
2003-09-08 17:25:44 +00:00
|
|
|
assert(g_pluginManager);
|
|
|
|
const PluginList &plugins = g_pluginManager->getPlugins();
|
|
|
|
int p;
|
|
|
|
for (p = 0; p < plugins.size(); p++) {
|
|
|
|
const TargetSettings *v = plugins[p]->getTargets();
|
|
|
|
while (v->targetName && v->description) {
|
|
|
|
|
|
|
|
// Determine the 'detectname' for this game, that is, the name of a
|
|
|
|
// file that *must* be presented if the directory contains the data
|
|
|
|
// for this game. For example, FOA requires atlantis.000
|
|
|
|
if (v->detectname) {
|
|
|
|
strcpy(detectName, v->detectname);
|
|
|
|
strcpy(detectName2, v->detectname);
|
|
|
|
strcat(detectName2, ".");
|
|
|
|
detectName3[0] = '\0';
|
|
|
|
} else {
|
|
|
|
strcpy(detectName, v->targetName);
|
|
|
|
strcpy(detectName2, v->targetName);
|
|
|
|
strcpy(detectName3, v->targetName);
|
|
|
|
strcat(detectName, ".000");
|
|
|
|
if (v->version >= 7) {
|
|
|
|
strcat(detectName2, ".la0");
|
|
|
|
} else
|
|
|
|
strcat(detectName2, ".sm0");
|
|
|
|
strcat(detectName3, ".he0");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Iterate over all files in the given directory
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
const char *targetName = (*files)[i].displayName().c_str();
|
|
|
|
|
|
|
|
if ((0 == scumm_stricmp(detectName, targetName)) ||
|
|
|
|
(0 == scumm_stricmp(detectName2, targetName)) ||
|
|
|
|
(0 == scumm_stricmp(detectName3, targetName))) {
|
|
|
|
// Match found, add to list of candidates, then abort inner loop.
|
|
|
|
list.push_back(v);
|
|
|
|
break;
|
|
|
|
}
|
2002-11-19 01:36:47 +00:00
|
|
|
}
|
2003-09-08 17:25:44 +00:00
|
|
|
|
|
|
|
v++;
|
2002-11-19 01:36:47 +00:00
|
|
|
}
|
|
|
|
}
|
2002-11-21 02:19:02 +00:00
|
|
|
|
|
|
|
return list;
|
2002-11-19 01:36:47 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
2002-11-21 13:11:29 +00:00
|
|
|
int item = _list->getSelected();
|
|
|
|
|
2002-09-27 23:27:14 +00:00
|
|
|
switch (cmd) {
|
2002-11-21 14:12:55 +00:00
|
|
|
case kAddGameCmd:
|
2002-11-21 02:19:02 +00:00
|
|
|
// Allow user to add a new game to the list.
|
2002-11-21 14:12:55 +00:00
|
|
|
// 1) show a dir selection dialog which lets the user pick the directory
|
|
|
|
// the game data resides in.
|
|
|
|
// 2) try to auto detect which game is in the directory, if we cannot
|
|
|
|
// determine it uniquely preent a list of candidates to the user
|
|
|
|
// to pick from
|
|
|
|
// 3) Display the 'Edit' dialog for that item, letting the user specify
|
|
|
|
// an alternate description (to distinguish multiple versions of the
|
|
|
|
// game, e.g. 'Monkey German' and 'Monkey English') and set default
|
|
|
|
// options for that game.
|
2002-11-21 02:19:02 +00:00
|
|
|
|
|
|
|
if (_browser->runModal()) {
|
2003-03-25 15:32:36 +00:00
|
|
|
// User made his choice...
|
2002-11-21 02:19:02 +00:00
|
|
|
FilesystemNode *dir = _browser->getResult();
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-11-21 02:19:02 +00:00
|
|
|
// ...so let's determine a list of candidates, games that
|
|
|
|
// could be contained in the specified directory.
|
|
|
|
GameList candidates = findGame(dir);
|
2003-09-08 15:38:34 +00:00
|
|
|
const TargetSettings *v = 0;
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-11-21 02:19:02 +00:00
|
|
|
if (candidates.isEmpty()) {
|
2002-11-21 13:11:29 +00:00
|
|
|
// No game was found in the specified directory
|
2002-11-21 14:12:55 +00:00
|
|
|
MessageDialog alert(_gui, "ScummVM could not find any game in the specified directory!");
|
2002-11-21 13:11:29 +00:00
|
|
|
alert.runModal();
|
2002-11-21 02:19:02 +00:00
|
|
|
} else if (candidates.size() == 1) {
|
|
|
|
// Exact match
|
|
|
|
v = candidates[0];
|
|
|
|
} else {
|
2002-11-21 03:51:07 +00:00
|
|
|
// Display the candidates to the user and let her/him pick one
|
|
|
|
StringList list;
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < candidates.size(); i++)
|
2003-09-08 15:38:34 +00:00
|
|
|
list.push_back(candidates[i]->description);
|
2002-11-21 03:51:07 +00:00
|
|
|
|
2002-11-21 12:48:50 +00:00
|
|
|
ChooserDialog dialog(_gui, "Pick the game:", list);
|
2002-11-21 03:51:07 +00:00
|
|
|
i = dialog.runModal();
|
|
|
|
if (0 <= i && i < candidates.size())
|
|
|
|
v = candidates[i];
|
2002-11-21 02:19:02 +00:00
|
|
|
}
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-11-21 02:19:02 +00:00
|
|
|
if (v != 0) {
|
|
|
|
// The auto detector or the user made a choice.
|
2002-11-21 14:12:55 +00:00
|
|
|
// Pick a domain name which does not yet exist (after all, we
|
|
|
|
// are *adding* a game to the config, not replacing).
|
2003-09-08 15:38:34 +00:00
|
|
|
String domain(v->targetName);
|
2002-11-21 14:12:55 +00:00
|
|
|
if (g_config->has_domain(domain)) {
|
2002-11-21 16:56:29 +00:00
|
|
|
char suffix = 'a';
|
2002-11-21 14:12:55 +00:00
|
|
|
domain += suffix;
|
|
|
|
while (g_config->has_domain(domain)) {
|
|
|
|
domain.deleteLastChar();
|
|
|
|
suffix++;
|
|
|
|
domain += suffix;
|
|
|
|
}
|
2003-09-08 15:38:34 +00:00
|
|
|
g_config->set("gameid", v->targetName, domain);
|
|
|
|
g_config->set("description", v->description, domain);
|
2002-11-21 14:12:55 +00:00
|
|
|
}
|
|
|
|
g_config->set("path", dir->path(), domain);
|
2002-11-21 02:19:02 +00:00
|
|
|
|
2002-11-21 14:12:55 +00:00
|
|
|
// Display edit dialog for the new entry
|
2003-09-08 15:38:34 +00:00
|
|
|
EditGameDialog editDialog(_gui, domain, v);
|
2002-11-21 14:12:55 +00:00
|
|
|
if (editDialog.runModal()) {
|
|
|
|
// User pressed OK, so make changes permanent
|
|
|
|
|
|
|
|
// Write config to disk
|
|
|
|
g_config->flush();
|
|
|
|
|
|
|
|
// Update the ListWidget and force a redraw
|
|
|
|
updateListing();
|
|
|
|
draw();
|
|
|
|
} else {
|
|
|
|
// User aborted, remove the the new domain again
|
|
|
|
g_config->delete_domain(domain);
|
|
|
|
}
|
2002-11-21 02:19:02 +00:00
|
|
|
}
|
2002-11-19 01:36:47 +00:00
|
|
|
}
|
2002-10-17 22:43:13 +00:00
|
|
|
break;
|
2002-11-21 14:12:55 +00:00
|
|
|
case kRemoveGameCmd:
|
|
|
|
// Remove the currently selected game from the list
|
2002-11-21 13:11:29 +00:00
|
|
|
assert(item >= 0);
|
2002-11-21 14:12:55 +00:00
|
|
|
g_config->delete_domain(_domains[item]);
|
2002-11-21 15:20:52 +00:00
|
|
|
|
|
|
|
// Write config to disk
|
|
|
|
g_config->flush();
|
|
|
|
|
|
|
|
// Update the ListWidget and force a redraw
|
2002-11-21 14:12:55 +00:00
|
|
|
updateListing();
|
|
|
|
draw();
|
2002-11-21 13:11:29 +00:00
|
|
|
break;
|
|
|
|
case kEditGameCmd: {
|
2002-10-17 22:43:13 +00:00
|
|
|
// Set game specifc options. Most of these should be "optional", i.e. by
|
|
|
|
// default set nothing and use the global ScummVM settings. E.g. the user
|
|
|
|
// can set here an optional alternate music volume, or for specific games
|
|
|
|
// a different music driver etc.
|
|
|
|
// This is useful because e.g. MonkeyVGA needs Adlib music to have decent
|
|
|
|
// music support etc.
|
2002-11-21 13:11:29 +00:00
|
|
|
assert(item >= 0);
|
2003-09-08 15:38:34 +00:00
|
|
|
const char *gameId = g_config->get("gameid", _domains[item]);
|
|
|
|
if (!gameId)
|
|
|
|
gameId = _domains[item].c_str();
|
|
|
|
EditGameDialog editDialog(_gui, _domains[item], _detector.findTarget(gameId));
|
2002-11-21 14:12:55 +00:00
|
|
|
if (editDialog.runModal()) {
|
|
|
|
// User pressed OK, so make changes permanent
|
|
|
|
|
|
|
|
// Write config to disk
|
|
|
|
g_config->flush();
|
|
|
|
|
|
|
|
// Update the ListWidget and force a redraw
|
|
|
|
updateListing();
|
|
|
|
draw();
|
|
|
|
}
|
2002-11-21 13:11:29 +00:00
|
|
|
}
|
2002-10-17 22:43:13 +00:00
|
|
|
break;
|
2002-11-21 13:11:29 +00:00
|
|
|
case kOptionsCmd: {
|
2002-11-21 16:56:29 +00:00
|
|
|
// TODO - show up a generic options dialog with global options, including:
|
|
|
|
// - the save path (use _browser!)
|
|
|
|
// - music & graphics driver (but see also the comments on EditGameDialog
|
|
|
|
// for some techincal difficulties with this)
|
|
|
|
// - default volumes (sfx/master/music)
|
2003-03-25 15:32:36 +00:00
|
|
|
GlobalOptionsDialog options(_gui, _detector);
|
2002-12-12 23:22:48 +00:00
|
|
|
options.runModal();
|
2002-11-21 13:11:29 +00:00
|
|
|
}
|
2002-10-17 22:43:13 +00:00
|
|
|
break;
|
2002-09-30 00:55:47 +00:00
|
|
|
case kStartCmd:
|
2002-09-27 23:27:14 +00:00
|
|
|
case kListItemDoubleClickedCmd:
|
2002-09-30 00:55:47 +00:00
|
|
|
// Print out what was selected
|
2002-10-01 23:11:19 +00:00
|
|
|
assert(item >= 0);
|
2002-11-21 14:12:55 +00:00
|
|
|
_detector.setGame(_domains[item]);
|
2002-10-01 23:11:19 +00:00
|
|
|
close();
|
|
|
|
break;
|
2002-12-01 12:47:13 +00:00
|
|
|
case kListSelectionChangedCmd:
|
|
|
|
updateButtons();
|
2002-09-27 23:27:14 +00:00
|
|
|
break;
|
|
|
|
case kQuitCmd:
|
2003-04-30 13:57:57 +00:00
|
|
|
#ifdef __PALM_OS__
|
|
|
|
close();
|
|
|
|
#endif
|
2002-09-27 23:27:14 +00:00
|
|
|
g_system->quit();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Dialog::handleCommand(sender, cmd, data);
|
|
|
|
}
|
|
|
|
}
|
2002-12-01 12:47:13 +00:00
|
|
|
|
|
|
|
void LauncherDialog::updateButtons() {
|
|
|
|
bool enable = (_list->getSelected() >= 0);
|
|
|
|
if (enable != _startButton->isEnabled()) {
|
|
|
|
_startButton->setEnabled(enable);
|
|
|
|
_startButton->draw();
|
|
|
|
}
|
|
|
|
if (enable != _editButton->isEnabled()) {
|
|
|
|
_editButton->setEnabled(enable);
|
|
|
|
_editButton->draw();
|
|
|
|
}
|
|
|
|
if (enable != _removeButton->isEnabled()) {
|
|
|
|
_removeButton->setEnabled(enable);
|
|
|
|
_removeButton->draw();
|
|
|
|
}
|
|
|
|
}
|