2002-09-27 23:27:14 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2005-01-01 16:09:25 +00:00
|
|
|
* Copyright (C) 2002-2005 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"
|
2003-09-08 18:09:32 +00:00
|
|
|
|
2003-11-05 00:59:03 +00:00
|
|
|
#include "backends/fs/fs.h"
|
|
|
|
|
|
|
|
#include "base/engine.h"
|
|
|
|
#include "base/gameDetector.h"
|
|
|
|
#include "base/plugins.h"
|
2004-02-09 01:27:27 +00:00
|
|
|
#include "base/version.h"
|
2003-11-05 00:59:03 +00:00
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/util.h"
|
|
|
|
|
2003-09-08 18:09:32 +00:00
|
|
|
#include "gui/about.h"
|
|
|
|
#include "gui/browser.h"
|
|
|
|
#include "gui/chooser.h"
|
|
|
|
#include "gui/launcher.h"
|
|
|
|
#include "gui/message.h"
|
|
|
|
#include "gui/newgui.h"
|
|
|
|
#include "gui/options.h"
|
|
|
|
#include "gui/EditTextWidget.h"
|
|
|
|
#include "gui/ListWidget.h"
|
2003-11-03 05:27:53 +00:00
|
|
|
#include "gui/TabWidget.h"
|
|
|
|
#include "gui/PopUpWidget.h"
|
2002-09-27 23:27:14 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
#include "sound/mididrv.h"
|
|
|
|
|
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
using Common::ConfigManager;
|
2002-09-27 23:27:14 +00:00
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
namespace GUI {
|
|
|
|
|
2002-09-27 23:27:14 +00:00
|
|
|
enum {
|
2002-09-30 00:55:47 +00:00
|
|
|
kStartCmd = 'STRT',
|
2003-09-08 18:09:32 +00:00
|
|
|
kAboutCmd = 'ABOU',
|
2002-09-30 00:55:47 +00:00
|
|
|
kOptionsCmd = 'OPTN',
|
2002-10-13 11:51:48 +00:00
|
|
|
kAddGameCmd = 'ADDG',
|
2002-11-21 13:11:29 +00:00
|
|
|
kEditGameCmd = 'EDTG',
|
|
|
|
kRemoveGameCmd = 'REMG',
|
2003-11-07 16:01:51 +00:00
|
|
|
kQuitCmd = 'QUIT',
|
|
|
|
|
|
|
|
|
|
|
|
kCmdGlobalGraphicsOverride = 'OGFX',
|
|
|
|
kCmdGlobalAudioOverride = 'OSFX',
|
2005-04-13 00:11:49 +00:00
|
|
|
kCmdGlobalMIDIOverride = 'OMID',
|
2004-06-29 14:23:39 +00:00
|
|
|
kCmdGlobalVolumeOverride = 'OVOL',
|
|
|
|
|
|
|
|
kCmdExtraBrowser = 'PEXT',
|
|
|
|
kCmdGameBrowser = 'PGME',
|
|
|
|
kCmdSaveBrowser = 'PSAV'
|
2002-09-27 23:27:14 +00:00
|
|
|
};
|
2002-11-21 02:19:02 +00:00
|
|
|
|
2004-12-30 12:54:04 +00:00
|
|
|
/*
|
|
|
|
* TODO: Clean up this ugly design: we subclass EditTextWidget to perform
|
|
|
|
* input validation. It would be much more elegant to use a decorator pattern,
|
|
|
|
* or a validation callback, or something like that.
|
|
|
|
*/
|
|
|
|
class DomainEditTextWidget : public EditTextWidget {
|
|
|
|
public:
|
|
|
|
DomainEditTextWidget(GuiObject *boss, int x, int y, int w, int h, const String &text)
|
|
|
|
: EditTextWidget(boss, x, y, w, h, text) {
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool tryInsertChar(char c, int pos) {
|
|
|
|
if (isalnum(c) || c == '-' || c == '_') {
|
2005-01-29 16:30:51 +00:00
|
|
|
_editString.insertChar(c, pos);
|
2004-12-30 12:54:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
* - 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
|
|
|
|
*/
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
class EditGameDialog : public OptionsDialog {
|
2003-10-02 17:43:02 +00:00
|
|
|
typedef Common::String String;
|
|
|
|
typedef Common::StringList StringList;
|
2002-11-21 14:12:55 +00:00
|
|
|
public:
|
2003-11-02 02:18:16 +00:00
|
|
|
EditGameDialog(const String &domain, GameSettings target);
|
2002-11-21 14:12:55 +00:00
|
|
|
|
2004-03-15 02:28:47 +00:00
|
|
|
void open();
|
|
|
|
void close();
|
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
|
|
|
EditTextWidget *_descriptionWidget;
|
2004-12-30 12:54:04 +00:00
|
|
|
DomainEditTextWidget *_domainWidget;
|
2003-11-05 12:25:42 +00:00
|
|
|
|
2004-06-29 14:23:39 +00:00
|
|
|
StaticTextWidget *_gamePathWidget;
|
|
|
|
StaticTextWidget *_extraPathWidget;
|
|
|
|
StaticTextWidget *_savePathWidget;
|
|
|
|
|
2003-11-05 00:59:03 +00:00
|
|
|
PopUpWidget *_langPopUp;
|
|
|
|
PopUpWidget *_platformPopUp;
|
2003-11-07 16:01:51 +00:00
|
|
|
|
|
|
|
CheckboxWidget *_globalGraphicsOverride;
|
|
|
|
CheckboxWidget *_globalAudioOverride;
|
2005-04-13 00:11:49 +00:00
|
|
|
CheckboxWidget *_globalMIDIOverride;
|
2003-11-07 16:01:51 +00:00
|
|
|
CheckboxWidget *_globalVolumeOverride;
|
2002-11-21 14:12:55 +00:00
|
|
|
};
|
|
|
|
|
2003-11-02 02:18:16 +00:00
|
|
|
EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
|
2003-11-07 16:01:51 +00:00
|
|
|
: OptionsDialog(domain, 10, 40, 320 - 2 * 10, 140) {
|
2003-11-03 23:42:53 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
const int x = 5;
|
|
|
|
const int w = _w - 15;
|
|
|
|
const int labelWidth = 65;
|
2003-11-03 23:42:53 +00:00
|
|
|
const int vBorder = 5; // Tab border
|
|
|
|
int yoffset;
|
2003-09-08 15:38:34 +00:00
|
|
|
|
2004-06-29 14:23:39 +00:00
|
|
|
// GAME: Path to game data (r/o), extra data (r/o), and save data (r/w)
|
|
|
|
String gamePath(ConfMan.get("path", _domain));
|
|
|
|
String extraPath(ConfMan.get("extrapath", _domain));
|
|
|
|
String savePath(ConfMan.get("savepath", _domain));
|
2003-11-03 05:27:53 +00:00
|
|
|
|
|
|
|
// GAME: Determine the description string
|
2003-10-08 21:59:23 +00:00
|
|
|
String description(ConfMan.get("description", domain));
|
2003-10-17 12:18:58 +00:00
|
|
|
if (description.isEmpty() && target.description) {
|
|
|
|
description = target.description;
|
2002-11-21 14:12:55 +00:00
|
|
|
}
|
2003-09-08 15:38:34 +00:00
|
|
|
|
2003-11-03 23:42:53 +00:00
|
|
|
// GUI: Add tab widget
|
|
|
|
TabWidget *tab = new TabWidget(this, 0, vBorder, _w, _h - 24 - 2*vBorder);
|
|
|
|
|
2003-11-04 21:17:33 +00:00
|
|
|
//
|
|
|
|
// 1) The game tab
|
|
|
|
//
|
2003-11-03 05:27:53 +00:00
|
|
|
tab->addTab("Game");
|
2003-11-03 23:42:53 +00:00
|
|
|
yoffset = vBorder;
|
2003-11-03 05:27:53 +00:00
|
|
|
|
|
|
|
// GUI: Label & edit widget for the game ID
|
2003-11-08 23:22:16 +00:00
|
|
|
new StaticTextWidget(tab, x, yoffset + 2, labelWidth, kLineHeight, "ID: ", kTextAlignRight);
|
2004-12-30 12:54:04 +00:00
|
|
|
_domainWidget = new DomainEditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10, kLineHeight, _domain);
|
2003-11-03 23:42:53 +00:00
|
|
|
yoffset += 16;
|
2003-11-03 05:27:53 +00:00
|
|
|
|
|
|
|
// GUI: Label & edit widget for the description
|
2003-11-08 23:22:16 +00:00
|
|
|
new StaticTextWidget(tab, x, yoffset + 2, labelWidth, kLineHeight, "Name: ", kTextAlignRight);
|
|
|
|
_descriptionWidget = new EditTextWidget(tab, x + labelWidth, yoffset, _w - labelWidth - 10, kLineHeight, description);
|
2003-11-03 23:42:53 +00:00
|
|
|
yoffset += 16;
|
2003-11-03 05:27:53 +00:00
|
|
|
|
2004-06-29 14:23:39 +00:00
|
|
|
// Language popup
|
2003-11-05 12:25:42 +00:00
|
|
|
_langPopUp = new PopUpWidget(tab, x, yoffset, w, kLineHeight, "Language: ", labelWidth);
|
2003-11-05 00:59:03 +00:00
|
|
|
yoffset += 16;
|
|
|
|
_langPopUp->appendEntry("<default>");
|
|
|
|
_langPopUp->appendEntry("");
|
|
|
|
const Common::LanguageDescription *l = Common::g_languages;
|
2003-12-30 19:07:55 +00:00
|
|
|
for (; l->code; ++l) {
|
2003-11-05 00:59:03 +00:00
|
|
|
_langPopUp->appendEntry(l->description, l->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Platform popup
|
2003-11-05 12:25:42 +00:00
|
|
|
_platformPopUp = new PopUpWidget(tab, x, yoffset, w, kLineHeight, "Platform: ", labelWidth);
|
2003-11-05 00:59:03 +00:00
|
|
|
yoffset += 16;
|
|
|
|
_platformPopUp->appendEntry("<default>");
|
|
|
|
_platformPopUp->appendEntry("");
|
2004-02-07 17:12:10 +00:00
|
|
|
const Common::PlatformDescription *p = Common::g_platforms;
|
|
|
|
for (; p->code; ++p) {
|
|
|
|
_platformPopUp->appendEntry(p->description, p->id);
|
|
|
|
}
|
2003-11-03 05:27:53 +00:00
|
|
|
|
2004-06-29 14:23:39 +00:00
|
|
|
// 2) The 'Path' tab
|
|
|
|
tab->addTab("Paths");
|
|
|
|
yoffset = vBorder;
|
|
|
|
// GUI: Button + Label for the game path
|
|
|
|
new ButtonWidget(tab, x, yoffset, kButtonWidth + 14, 16, "Game Path:", kCmdGameBrowser, 0);
|
2004-07-26 18:11:55 +00:00
|
|
|
_gamePathWidget = new StaticTextWidget(tab, x + kButtonWidth + 20, yoffset + 3, _w - (x + kButtonWidth + 20) - 10, kLineHeight, gamePath, kTextAlignLeft);
|
2004-06-29 14:23:39 +00:00
|
|
|
yoffset += 18;
|
|
|
|
|
|
|
|
// GUI: Button + Label for the additional path
|
|
|
|
new ButtonWidget(tab, x, yoffset, kButtonWidth + 14, 16, "Extra Path:", kCmdExtraBrowser, 0);
|
2004-07-26 18:11:55 +00:00
|
|
|
_extraPathWidget = new StaticTextWidget(tab, x + kButtonWidth + 20, yoffset + 3, _w - (x + kButtonWidth + 20) - 10, kLineHeight, extraPath, kTextAlignLeft);
|
|
|
|
if (extraPath.isEmpty() || !ConfMan.hasKey("extrapath", _domain)) {
|
2004-06-29 14:23:39 +00:00
|
|
|
_extraPathWidget->setLabel("None");
|
|
|
|
}
|
|
|
|
yoffset += 18;
|
|
|
|
|
|
|
|
// GUI: Button + Label for the save path
|
|
|
|
new ButtonWidget(tab, x, yoffset, kButtonWidth + 14, 16, "Save Path:", kCmdSaveBrowser, 0);
|
2004-07-26 18:11:55 +00:00
|
|
|
_savePathWidget = new StaticTextWidget(tab, x + kButtonWidth + 20, yoffset + 3, _w - (x + kButtonWidth + 20) - 10, kLineHeight, savePath, kTextAlignLeft);
|
|
|
|
if (savePath.isEmpty() || !ConfMan.hasKey("savepath", _domain)) {
|
2004-06-29 14:23:39 +00:00
|
|
|
_savePathWidget->setLabel("Default");
|
|
|
|
}
|
|
|
|
yoffset += 18;
|
|
|
|
|
2003-11-04 21:17:33 +00:00
|
|
|
//
|
2005-04-13 00:11:49 +00:00
|
|
|
// 3) The graphics tab
|
2003-11-04 21:17:33 +00:00
|
|
|
//
|
2004-06-29 14:23:39 +00:00
|
|
|
tab->addTab("Gfx");
|
2003-11-03 23:42:53 +00:00
|
|
|
yoffset = vBorder;
|
2003-11-07 16:01:51 +00:00
|
|
|
|
|
|
|
_globalGraphicsOverride = new CheckboxWidget(tab, x, yoffset, w, 16, "Override global graphic settings", kCmdGlobalGraphicsOverride);
|
|
|
|
yoffset += 16;
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
yoffset = addGraphicControls(tab, yoffset);
|
2003-11-04 21:17:33 +00:00
|
|
|
|
|
|
|
//
|
2005-04-13 00:11:49 +00:00
|
|
|
// 4) The audio tab
|
2003-11-04 21:17:33 +00:00
|
|
|
//
|
|
|
|
tab->addTab("Audio");
|
|
|
|
yoffset = vBorder;
|
2003-11-07 16:01:51 +00:00
|
|
|
|
|
|
|
_globalAudioOverride = new CheckboxWidget(tab, x, yoffset, w, 16, "Override global audio settings", kCmdGlobalAudioOverride);
|
|
|
|
yoffset += 16;
|
|
|
|
|
2005-04-13 00:11:49 +00:00
|
|
|
yoffset = addAudioControls(tab, yoffset);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 5) The MIDI tab
|
|
|
|
//
|
|
|
|
tab->addTab("MIDI");
|
|
|
|
yoffset = vBorder;
|
|
|
|
|
|
|
|
_globalMIDIOverride = new CheckboxWidget(tab, x, yoffset, w, 16, "Override global MIDI settings", kCmdGlobalMIDIOverride);
|
|
|
|
yoffset += 16;
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
yoffset = addMIDIControls(tab, yoffset);
|
2003-11-04 21:17:33 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
//
|
2005-04-13 00:11:49 +00:00
|
|
|
// 6) The volume tab
|
2003-11-05 12:25:42 +00:00
|
|
|
//
|
|
|
|
tab->addTab("Volume");
|
|
|
|
yoffset = vBorder;
|
2003-11-07 16:01:51 +00:00
|
|
|
|
|
|
|
_globalVolumeOverride = new CheckboxWidget(tab, x, yoffset, w, 16, "Override global volume settings", kCmdGlobalVolumeOverride);
|
|
|
|
yoffset += 16;
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
yoffset = addVolumeControls(tab, yoffset);
|
2003-11-04 21:17:33 +00:00
|
|
|
|
|
|
|
|
2003-11-03 23:42:53 +00:00
|
|
|
// Activate the first tab
|
|
|
|
tab->setActiveTab(0);
|
2003-11-03 05:27:53 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// Add OK & Cancel buttons
|
2003-03-06 19:52:54 +00:00
|
|
|
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
|
2004-03-15 02:28:47 +00:00
|
|
|
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
|
2002-11-21 14:12:55 +00:00
|
|
|
}
|
|
|
|
|
2004-03-15 02:28:47 +00:00
|
|
|
void EditGameDialog::open() {
|
|
|
|
OptionsDialog::open();
|
2003-11-05 12:25:42 +00:00
|
|
|
|
2004-02-07 17:12:10 +00:00
|
|
|
int sel, i;
|
2003-11-07 16:01:51 +00:00
|
|
|
bool e;
|
|
|
|
|
2004-02-07 17:12:10 +00:00
|
|
|
// En-/disable dialog items depending on whether overrides are active or not.
|
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
e = ConfMan.hasKey("fullscreen", _domain) ||
|
|
|
|
ConfMan.hasKey("aspect_ratio", _domain);
|
|
|
|
_globalGraphicsOverride->setState(e);
|
|
|
|
|
|
|
|
e = ConfMan.hasKey("music_driver", _domain) ||
|
2005-04-13 00:11:49 +00:00
|
|
|
ConfMan.hasKey("subtitles", _domain);
|
2003-11-07 16:01:51 +00:00
|
|
|
_globalAudioOverride->setState(e);
|
|
|
|
|
2005-04-13 00:11:49 +00:00
|
|
|
e = ConfMan.hasKey("multi_midi", _domain) ||
|
|
|
|
ConfMan.hasKey("native_mt32", _domain)||
|
|
|
|
ConfMan.hasKey("enable_gs", _domain);
|
|
|
|
_globalMIDIOverride->setState(e);
|
|
|
|
|
2004-12-25 23:43:05 +00:00
|
|
|
e = ConfMan.hasKey("music_volume", _domain) ||
|
2004-04-05 18:24:36 +00:00
|
|
|
ConfMan.hasKey("sfx_volume", _domain) ||
|
2004-04-06 11:50:35 +00:00
|
|
|
ConfMan.hasKey("speech_volume", _domain);
|
2003-11-07 16:01:51 +00:00
|
|
|
_globalVolumeOverride->setState(e);
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// TODO: game path
|
|
|
|
|
|
|
|
const Common::LanguageDescription *l = Common::g_languages;
|
2004-02-07 17:12:10 +00:00
|
|
|
const Common::Language lang = Common::parseLanguage(ConfMan.get("language", _domain));
|
|
|
|
sel = 0;
|
|
|
|
for (i = 0; l->code; ++l, ++i) {
|
2003-11-05 12:25:42 +00:00
|
|
|
if (lang == l->id)
|
|
|
|
sel = i + 2;
|
|
|
|
}
|
|
|
|
_langPopUp->setSelected(sel);
|
|
|
|
|
|
|
|
|
2004-02-07 17:12:10 +00:00
|
|
|
const Common::PlatformDescription *p = Common::g_platforms;
|
|
|
|
const Common::Platform platform = Common::parsePlatform(ConfMan.get("platform", _domain));
|
|
|
|
sel = 0;
|
|
|
|
for (i = 0; p->code; ++p, ++i) {
|
|
|
|
if (platform == p->id)
|
|
|
|
sel = i + 2;
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
|
|
|
_platformPopUp->setSelected(sel);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-15 02:28:47 +00:00
|
|
|
void EditGameDialog::close() {
|
|
|
|
if (getResult()) {
|
2005-01-29 18:04:34 +00:00
|
|
|
ConfMan.set("description", _descriptionWidget->getEditString(), _domain);
|
2003-11-05 12:25:42 +00:00
|
|
|
|
2004-03-15 02:28:47 +00:00
|
|
|
Common::Language lang = (Common::Language)_langPopUp->getSelectedTag();
|
|
|
|
if (lang < 0)
|
|
|
|
ConfMan.removeKey("language", _domain);
|
|
|
|
else
|
|
|
|
ConfMan.set("language", Common::getLanguageCode(lang), _domain);
|
2003-11-05 12:25:42 +00:00
|
|
|
|
2004-06-29 14:23:39 +00:00
|
|
|
String gamePath = _gamePathWidget->getLabel();
|
|
|
|
if (!gamePath.isEmpty())
|
|
|
|
ConfMan.set("path", gamePath, _domain);
|
|
|
|
|
|
|
|
String extraPath = _extraPathWidget->getLabel();
|
|
|
|
if (!extraPath.isEmpty() && (extraPath != "None"))
|
|
|
|
ConfMan.set("extrapath", extraPath, _domain);
|
|
|
|
|
|
|
|
String savePath = _savePathWidget->getLabel();
|
2004-07-01 10:24:42 +00:00
|
|
|
if (!savePath.isEmpty() && (savePath != "Default"))
|
|
|
|
ConfMan.set("savepath", savePath, _domain);
|
2004-06-29 14:23:39 +00:00
|
|
|
|
2004-03-15 02:28:47 +00:00
|
|
|
Common::Platform platform = (Common::Platform)_platformPopUp->getSelectedTag();
|
|
|
|
if (platform < 0)
|
|
|
|
ConfMan.removeKey("platform", _domain);
|
|
|
|
else
|
|
|
|
ConfMan.set("platform", Common::getPlatformCode(platform), _domain);
|
|
|
|
}
|
|
|
|
OptionsDialog::close();
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
2003-11-07 16:01:51 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case kCmdGlobalGraphicsOverride:
|
|
|
|
setGraphicSettingsState(data != 0);
|
|
|
|
draw();
|
|
|
|
break;
|
|
|
|
case kCmdGlobalAudioOverride:
|
|
|
|
setAudioSettingsState(data != 0);
|
|
|
|
draw();
|
|
|
|
break;
|
2005-04-13 00:11:49 +00:00
|
|
|
case kCmdGlobalMIDIOverride:
|
|
|
|
setMIDISettingsState(data != 0);
|
|
|
|
draw();
|
|
|
|
break;
|
2003-11-07 16:01:51 +00:00
|
|
|
case kCmdGlobalVolumeOverride:
|
|
|
|
setVolumeSettingsState(data != 0);
|
|
|
|
draw();
|
|
|
|
break;
|
2004-06-29 14:23:39 +00:00
|
|
|
|
|
|
|
// Change path for the game
|
|
|
|
case kCmdGameBrowser: {
|
2005-04-16 17:55:09 +00:00
|
|
|
BrowserDialog browser("Select additional game directory", true);
|
|
|
|
if (browser.runModal() > 0) {
|
2004-11-20 21:35:49 +00:00
|
|
|
// User made his choice...
|
2005-04-16 17:55:09 +00:00
|
|
|
FilesystemNode dir(browser.getResult());
|
2004-06-29 14:23:39 +00:00
|
|
|
|
|
|
|
// TODO: Verify the game can be found in the new directory... Best
|
|
|
|
// done with optional specific gameid to pluginmgr detectgames?
|
2004-11-20 21:35:49 +00:00
|
|
|
// FSList files = dir.listDir(FilesystemNode::kListFilesOnly);
|
2004-06-29 14:23:39 +00:00
|
|
|
|
2004-11-20 21:35:49 +00:00
|
|
|
_gamePathWidget->setLabel(dir.path());
|
2005-04-16 17:55:09 +00:00
|
|
|
draw();
|
2004-06-29 14:23:39 +00:00
|
|
|
}
|
|
|
|
draw();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Change path for extra game data (eg, using sword cutscenes when playing via CD)
|
|
|
|
case kCmdExtraBrowser: {
|
2005-04-16 17:55:09 +00:00
|
|
|
BrowserDialog browser("Select additional game directory", true);
|
|
|
|
if (browser.runModal() > 0) {
|
2004-11-20 21:35:49 +00:00
|
|
|
// User made his choice...
|
2005-04-16 17:55:09 +00:00
|
|
|
FilesystemNode dir(browser.getResult());
|
2004-11-20 21:35:49 +00:00
|
|
|
_extraPathWidget->setLabel(dir.path());
|
2005-04-16 17:55:09 +00:00
|
|
|
draw();
|
2004-06-29 14:23:39 +00:00
|
|
|
}
|
|
|
|
draw();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Change path for stored save game (perm and temp) data
|
|
|
|
case kCmdSaveBrowser: {
|
2005-04-16 17:55:09 +00:00
|
|
|
BrowserDialog browser("Select directory for saved games", true);
|
|
|
|
if (browser.runModal() > 0) {
|
2004-11-20 21:35:49 +00:00
|
|
|
// User made his choice...
|
2005-04-16 17:55:09 +00:00
|
|
|
FilesystemNode dir(browser.getResult());
|
2004-11-20 21:35:49 +00:00
|
|
|
_savePathWidget->setLabel(dir.path());
|
2005-04-16 17:55:09 +00:00
|
|
|
draw();
|
2004-06-29 14:23:39 +00:00
|
|
|
}
|
|
|
|
draw();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-03-15 02:28:47 +00:00
|
|
|
case kOKCmd: {
|
2002-11-21 16:56:29 +00:00
|
|
|
// Write back changes made to config object
|
2005-01-29 18:04:34 +00:00
|
|
|
String newDomain(_domainWidget->getEditString());
|
2002-11-21 17:25:31 +00:00
|
|
|
if (newDomain != _domain) {
|
2003-10-08 21:59:23 +00:00
|
|
|
if (newDomain.isEmpty() || ConfMan.hasGameDomain(newDomain)) {
|
2003-11-02 02:18:16 +00:00
|
|
|
MessageDialog alert("This game ID is already taken. Please choose another one.");
|
2002-11-21 17:25:31 +00:00
|
|
|
alert.runModal();
|
|
|
|
return;
|
|
|
|
}
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.renameGameDomain(_domain, newDomain);
|
2003-11-05 12:25:42 +00:00
|
|
|
_domain = newDomain;
|
2002-11-21 17:25:31 +00:00
|
|
|
}
|
2003-11-07 16:01:51 +00:00
|
|
|
}
|
|
|
|
// FALL THROUGH to default case
|
|
|
|
default:
|
|
|
|
OptionsDialog::handleCommand(sender, cmd, data);
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-05 00:59:03 +00:00
|
|
|
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
#pragma mark -
|
2003-11-05 00:59:03 +00:00
|
|
|
|
2002-11-21 14:12:55 +00:00
|
|
|
|
2003-11-02 02:18:16 +00:00
|
|
|
LauncherDialog::LauncherDialog(GameDetector &detector)
|
|
|
|
: Dialog(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-09-08 18:09:32 +00:00
|
|
|
const int border = 10;
|
|
|
|
const int space = 8;
|
|
|
|
const int buttons = 4;
|
|
|
|
const int width = (_w - 2 * border - space * (buttons - 1)) / buttons;
|
|
|
|
int x = border;
|
|
|
|
new ButtonWidget(this, x, _h - 24, width, 16, "Quit", kQuitCmd, 'Q'); x += space + width;
|
|
|
|
new ButtonWidget(this, x, _h - 24, width, 16, "About", kAboutCmd, 'B'); x += space + width;
|
|
|
|
new ButtonWidget(this, x, _h - 24, width, 16, "Options", kOptionsCmd, 'O'); x += space + width;
|
|
|
|
_startButton =
|
|
|
|
new ButtonWidget(this, x, _h - 24, width, 16, "Start", kStartCmd, 'S'); x += space + width;
|
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();
|
|
|
|
|
2004-10-01 21:12:18 +00:00
|
|
|
// Restore last selection
|
|
|
|
String last = ConfMan.get(String("lastselectedgame"), ConfigManager::kApplicationDomain);
|
2005-01-05 01:42:52 +00:00
|
|
|
selectGame(last);
|
|
|
|
|
|
|
|
// En-/Disable the buttons depending on the list selection
|
|
|
|
updateButtons();
|
|
|
|
|
|
|
|
// Create file browser dialog
|
2005-04-16 17:55:09 +00:00
|
|
|
_browser = new BrowserDialog("Select directory with game data", true);
|
2005-01-05 01:42:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LauncherDialog::selectGame(const String &name) {
|
|
|
|
if (!name.isEmpty()) {
|
2004-10-01 21:12:18 +00:00
|
|
|
int itemToSelect = 0;
|
|
|
|
StringList::const_iterator iter;
|
|
|
|
for (iter = _domains.begin(); iter != _domains.end(); ++iter, ++itemToSelect) {
|
2005-01-05 01:42:52 +00:00
|
|
|
if (name == *iter) {
|
2004-10-01 21:12:18 +00:00
|
|
|
_list->setSelected(itemToSelect);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2004-10-01 21:12:18 +00:00
|
|
|
void LauncherDialog::close() {
|
|
|
|
// Save last selection
|
|
|
|
const int sel = _list->getSelected();
|
|
|
|
if (sel >= 0)
|
|
|
|
ConfMan.set(String("lastselectedgame"), _domains[sel], ConfigManager::kApplicationDomain);
|
|
|
|
else
|
|
|
|
ConfMan.removeKey(String("lastselectedgame"), ConfigManager::kApplicationDomain);
|
|
|
|
|
|
|
|
ConfMan.flushToDisk();
|
|
|
|
Dialog::close();
|
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void LauncherDialog::updateListing() {
|
2003-10-02 17:43:02 +00:00
|
|
|
Common::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();
|
2003-10-08 21:59:23 +00:00
|
|
|
const ConfigManager::DomainMap &domains = ConfMan.getGameDomains();
|
2004-02-05 00:19:57 +00:00
|
|
|
ConfigManager::DomainMap::const_iterator iter = domains.begin();
|
2003-10-05 14:03:07 +00:00
|
|
|
for (iter = domains.begin(); iter != domains.end(); ++iter) {
|
2003-10-08 21:59:23 +00:00
|
|
|
String name(iter->_value.get("gameid"));
|
|
|
|
String description(iter->_value.get("description"));
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2002-11-21 16:56:29 +00:00
|
|
|
if (name.isEmpty())
|
2003-10-08 21:59:23 +00:00
|
|
|
name = iter->_key;
|
2002-11-21 16:56:29 +00:00
|
|
|
if (description.isEmpty()) {
|
2003-10-17 15:54:17 +00:00
|
|
|
GameSettings g = GameDetector::findGame(name);
|
2003-10-17 12:18:58 +00:00
|
|
|
if (g.description)
|
|
|
|
description = g.description;
|
2003-10-17 15:54:17 +00:00
|
|
|
}
|
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
|
|
|
|
2004-08-26 00:27:51 +00:00
|
|
|
while (pos < size && (scumm_stricmp(description.c_str(), l[pos].c_str()) > 0))
|
2002-10-15 15:32:54 +00:00
|
|
|
pos++;
|
2002-10-28 10:40:49 +00:00
|
|
|
l.insert_at(pos, description);
|
2003-10-08 21:59:23 +00:00
|
|
|
_domains.insert_at(pos, iter->_key);
|
2002-09-30 00:55:47 +00:00
|
|
|
}
|
2002-09-27 23:27:14 +00:00
|
|
|
}
|
|
|
|
|
2004-12-25 22:26:28 +00:00
|
|
|
const int oldSel = _list->getSelected();
|
2002-11-21 15:20:52 +00:00
|
|
|
_list->setList(l);
|
2004-12-25 23:19:42 +00:00
|
|
|
if (oldSel < (int)l.size())
|
2004-12-25 22:26:28 +00:00
|
|
|
_list->setSelected(oldSel); // Restore the old selection
|
2002-12-01 12:47:13 +00:00
|
|
|
updateButtons();
|
2002-09-27 23:27:14 +00:00
|
|
|
}
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
void LauncherDialog::addGame() {
|
|
|
|
// Allow user to add a new game to the list.
|
|
|
|
// 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.
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2004-03-17 00:07:43 +00:00
|
|
|
if (_browser->runModal() > 0) {
|
2003-11-05 12:25:42 +00:00
|
|
|
// User made his choice...
|
2004-11-20 21:35:49 +00:00
|
|
|
FilesystemNode dir(_browser->getResult());
|
2004-12-09 15:06:49 +00:00
|
|
|
FSList files = dir.listDir(FilesystemNode::kListAll);
|
2003-11-05 12:25:42 +00:00
|
|
|
|
|
|
|
// ...so let's determine a list of candidates, games that
|
|
|
|
// could be contained in the specified directory.
|
2004-11-20 21:35:49 +00:00
|
|
|
DetectedGameList candidates(PluginManager::instance().detectGames(files));
|
2004-03-25 21:31:03 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
int idx;
|
|
|
|
if (candidates.isEmpty()) {
|
|
|
|
// No game was found in the specified directory
|
|
|
|
MessageDialog alert("ScummVM could not find any game in the specified directory!");
|
|
|
|
alert.runModal();
|
|
|
|
idx = -1;
|
|
|
|
} else if (candidates.size() == 1) {
|
|
|
|
// Exact match
|
|
|
|
idx = 0;
|
|
|
|
} else {
|
|
|
|
// Display the candidates to the user and let her/him pick one
|
|
|
|
StringList list;
|
2004-02-05 00:19:57 +00:00
|
|
|
for (idx = 0; idx < (int)candidates.size(); idx++)
|
2003-11-05 12:25:42 +00:00
|
|
|
list.push_back(candidates[idx].description);
|
|
|
|
|
2003-11-28 21:56:14 +00:00
|
|
|
ChooserDialog dialog("Pick the game:");
|
|
|
|
dialog.setList(list);
|
2003-11-05 12:25:42 +00:00
|
|
|
idx = dialog.runModal();
|
|
|
|
}
|
2004-02-05 00:19:57 +00:00
|
|
|
if (0 <= idx && idx < (int)candidates.size()) {
|
2003-12-21 15:29:52 +00:00
|
|
|
DetectedGame result = candidates[idx];
|
2003-11-05 12:25:42 +00:00
|
|
|
|
|
|
|
// The auto detector or the user made a choice.
|
|
|
|
// Pick a domain name which does not yet exist (after all, we
|
|
|
|
// are *adding* a game to the config, not replacing).
|
2003-12-13 00:20:01 +00:00
|
|
|
String domain(result.name);
|
2003-11-05 12:25:42 +00:00
|
|
|
if (ConfMan.hasGameDomain(domain)) {
|
|
|
|
char suffix = 'a';
|
|
|
|
domain += suffix;
|
|
|
|
while (ConfMan.hasGameDomain(domain)) {
|
|
|
|
assert(suffix < 'z');
|
|
|
|
domain.deleteLastChar();
|
|
|
|
suffix++;
|
2002-11-21 14:12:55 +00:00
|
|
|
domain += suffix;
|
|
|
|
}
|
2003-12-13 00:20:01 +00:00
|
|
|
ConfMan.set("gameid", result.name, domain);
|
2003-11-05 12:25:42 +00:00
|
|
|
ConfMan.set("description", result.description, domain);
|
|
|
|
}
|
2004-11-20 21:35:49 +00:00
|
|
|
ConfMan.set("path", dir.path(), domain);
|
2004-02-07 17:12:10 +00:00
|
|
|
|
|
|
|
const bool customLanguage = (result.language != Common::UNK_LANG);
|
|
|
|
const bool customPlatform = (result.platform != Common::kPlatformUnknown);
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-12-21 15:29:52 +00:00
|
|
|
// Set language if specified
|
2004-02-07 17:12:10 +00:00
|
|
|
if (customLanguage)
|
2003-12-30 19:07:55 +00:00
|
|
|
ConfMan.set("language", Common::getLanguageCode(result.language), domain);
|
2003-12-21 15:29:52 +00:00
|
|
|
|
|
|
|
// Set platform if specified
|
2004-02-07 17:12:10 +00:00
|
|
|
if (customPlatform)
|
2003-12-30 19:07:55 +00:00
|
|
|
ConfMan.set("platform", Common::getPlatformCode(result.platform), domain);
|
2003-12-21 15:29:52 +00:00
|
|
|
|
2004-02-07 17:12:10 +00:00
|
|
|
// Adapt the description string if custom platform/language is set
|
|
|
|
if (customLanguage || customPlatform) {
|
|
|
|
String desc = result.description;
|
|
|
|
desc += " (";
|
|
|
|
if (customLanguage)
|
2004-02-09 07:52:21 +00:00
|
|
|
desc += Common::getLanguageDescription(result.language);
|
2004-02-07 17:12:10 +00:00
|
|
|
if (customLanguage && customPlatform)
|
|
|
|
desc += "/";
|
|
|
|
if (customPlatform)
|
2004-02-09 07:52:21 +00:00
|
|
|
desc += Common::getPlatformDescription(result.platform);
|
2004-02-07 17:12:10 +00:00
|
|
|
desc += ")";
|
|
|
|
|
|
|
|
ConfMan.set("description", desc, domain);
|
|
|
|
}
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// Display edit dialog for the new entry
|
|
|
|
EditGameDialog editDialog(domain, result);
|
2004-03-17 00:07:43 +00:00
|
|
|
if (editDialog.runModal() > 0) {
|
2003-11-05 12:25:42 +00:00
|
|
|
// User pressed OK, so make changes permanent
|
|
|
|
|
|
|
|
// Write config to disk
|
|
|
|
ConfMan.flushToDisk();
|
2003-12-21 15:29:52 +00:00
|
|
|
|
2005-01-05 01:42:52 +00:00
|
|
|
// Update the ListWidget, select the new item, and force a redraw
|
2003-11-05 12:25:42 +00:00
|
|
|
updateListing();
|
2005-01-05 01:42:52 +00:00
|
|
|
selectGame(domain);
|
2003-11-05 12:25:42 +00:00
|
|
|
draw();
|
|
|
|
} else {
|
|
|
|
// User aborted, remove the the new domain again
|
|
|
|
ConfMan.removeGameDomain(domain);
|
2002-11-21 02:19:02 +00:00
|
|
|
}
|
2002-11-19 01:36:47 +00:00
|
|
|
}
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LauncherDialog::removeGame(int item) {
|
|
|
|
MessageDialog alert("Do you really want to remove this game configuration?", "Yes", "No");
|
2003-11-02 11:32:18 +00:00
|
|
|
|
2004-08-11 21:49:58 +00:00
|
|
|
if (alert.runModal() == GUI::kMessageOK) {
|
2003-11-05 12:25:42 +00:00
|
|
|
// Remove the currently selected game from the list
|
|
|
|
assert(item >= 0);
|
|
|
|
ConfMan.removeGameDomain(_domains[item]);
|
|
|
|
|
|
|
|
// Write config to disk
|
|
|
|
ConfMan.flushToDisk();
|
2002-11-21 15:20:52 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// Update the ListWidget and force a redraw
|
|
|
|
updateListing();
|
|
|
|
draw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LauncherDialog::editGame(int item) {
|
|
|
|
// 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.
|
|
|
|
assert(item >= 0);
|
|
|
|
String gameId(ConfMan.get("gameid", _domains[item]));
|
|
|
|
if (gameId.isEmpty())
|
|
|
|
gameId = _domains[item];
|
|
|
|
EditGameDialog editDialog(_domains[item], GameDetector::findGame(gameId));
|
2004-03-17 00:07:43 +00:00
|
|
|
if (editDialog.runModal() > 0) {
|
2003-11-05 12:25:42 +00:00
|
|
|
// User pressed OK, so make changes permanent
|
|
|
|
|
|
|
|
// Write config to disk
|
|
|
|
ConfMan.flushToDisk();
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// Update the ListWidget and force a redraw
|
|
|
|
updateListing();
|
|
|
|
draw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
2003-11-10 23:40:48 +00:00
|
|
|
int item = _list->getSelected();
|
2003-11-05 12:25:42 +00:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case kAddGameCmd:
|
|
|
|
addGame();
|
2002-11-21 13:11:29 +00:00
|
|
|
break;
|
2003-11-05 12:25:42 +00:00
|
|
|
case kRemoveGameCmd:
|
|
|
|
removeGame(item);
|
|
|
|
break;
|
|
|
|
case kEditGameCmd:
|
|
|
|
editGame(item);
|
2002-10-17 22:43:13 +00:00
|
|
|
break;
|
2002-11-21 13:11:29 +00:00
|
|
|
case kOptionsCmd: {
|
2005-04-22 21:20:22 +00:00
|
|
|
GlobalOptionsDialog options;
|
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;
|
2003-09-08 18:09:32 +00:00
|
|
|
case kAboutCmd: {
|
2003-11-02 02:18:16 +00:00
|
|
|
AboutDialog about;
|
2003-09-08 18:09:32 +00:00
|
|
|
about.runModal();
|
|
|
|
}
|
|
|
|
break;
|
2002-09-30 00:55:47 +00:00
|
|
|
case kStartCmd:
|
2003-11-18 23:47:08 +00:00
|
|
|
case kListItemActivatedCmd:
|
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);
|
2003-10-12 18:40:12 +00:00
|
|
|
_detector.setTarget(_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:
|
2004-12-25 22:13:44 +00:00
|
|
|
setResult(-1);
|
2003-04-30 13:57:57 +00:00
|
|
|
close();
|
2002-09-27 23:27:14 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2003-11-10 23:40:48 +00:00
|
|
|
|
|
|
|
} // End of namespace GUI
|