2002-09-27 23:27:14 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2002-2006 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-09-27 23:27:14 +00:00
|
|
|
*
|
2006-02-11 10:08:56 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2002-09-27 23:27:14 +00:00
|
|
|
*/
|
|
|
|
|
2005-06-24 15:23:51 +00:00
|
|
|
#include "common/stdafx.h"
|
2003-09-08 18:09:32 +00:00
|
|
|
|
2006-09-23 00:42:35 +00:00
|
|
|
#include "engines/engine.h"
|
2006-05-04 23:24:09 +00:00
|
|
|
#include "base/game.h"
|
2003-11-05 00:59:03 +00:00
|
|
|
#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"
|
2007-03-17 16:05:16 +00:00
|
|
|
#include "common/events.h"
|
2006-06-24 08:07:48 +00:00
|
|
|
#include "common/fs.h"
|
2003-11-05 00:59:03 +00:00
|
|
|
#include "common/util.h"
|
2005-05-16 00:26:23 +00:00
|
|
|
#include "common/system.h"
|
2003-11-05 00:59:03 +00:00
|
|
|
|
2003-09-08 18:09:32 +00:00
|
|
|
#include "gui/about.h"
|
|
|
|
#include "gui/browser.h"
|
|
|
|
#include "gui/chooser.h"
|
2006-03-24 14:15:45 +00:00
|
|
|
#include "gui/eval.h"
|
2003-09-08 18:09:32 +00:00
|
|
|
#include "gui/launcher.h"
|
2007-02-18 18:23:52 +00:00
|
|
|
#include "gui/massadd.h"
|
2003-09-08 18:09:32 +00:00
|
|
|
#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"
|
|
|
|
|
|
|
|
|
2007-02-18 18:23:52 +00:00
|
|
|
|
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',
|
2005-07-30 21:11:48 +00:00
|
|
|
|
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
kCmdGlobalGraphicsOverride = 'OGFX',
|
|
|
|
kCmdGlobalAudioOverride = 'OSFX',
|
2005-04-13 00:11:49 +00:00
|
|
|
kCmdGlobalMIDIOverride = 'OMID',
|
2004-06-29 14:23:39 +00:00
|
|
|
kCmdGlobalVolumeOverride = 'OVOL',
|
|
|
|
|
2005-05-16 06:33:33 +00:00
|
|
|
kCmdChooseSoundFontCmd = 'chsf',
|
|
|
|
|
2004-06-29 14:23:39 +00:00
|
|
|
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:
|
2006-06-03 13:33:39 +00:00
|
|
|
DomainEditTextWidget(GuiObject *boss, const String &name, const String &text)
|
2006-03-09 05:18:00 +00:00
|
|
|
: EditTextWidget(boss, name, text) {
|
2004-12-30 12:54:04 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-30 12:54:04 +00:00
|
|
|
protected:
|
2006-06-20 22:50:27 +00:00
|
|
|
bool tryInsertChar(byte c, int pos) {
|
2004-12-30 12:54:04 +00:00
|
|
|
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:
|
2006-03-09 02:52:51 +00:00
|
|
|
EditGameDialog(const String &domain, const String &desc);
|
2002-11-21 14:12:55 +00:00
|
|
|
|
2006-08-04 13:55:53 +00:00
|
|
|
virtual void reflowLayout();
|
2006-06-11 21:26:43 +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
|
|
|
};
|
|
|
|
|
2006-03-09 02:52:51 +00:00
|
|
|
EditGameDialog::EditGameDialog(const String &domain, const String &desc)
|
2006-03-09 05:18:00 +00:00
|
|
|
: OptionsDialog(domain, "gameoptions") {
|
2003-11-03 23:42:53 +00:00
|
|
|
|
2006-03-09 05:18:00 +00:00
|
|
|
int labelWidth = g_gui.evaluator()->getVar("gameOptionsLabelWidth");
|
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));
|
2006-03-28 09:42:54 +00:00
|
|
|
if (description.empty() && !desc.empty()) {
|
2006-02-18 11:12:08 +00:00
|
|
|
description = desc;
|
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
|
2006-03-09 05:18:00 +00:00
|
|
|
TabWidget *tab = new TabWidget(this, "gameoptions_tabwidget");
|
2006-01-28 23:03:39 +00:00
|
|
|
tab->setHints(THEME_HINT_FIRST_DRAW | THEME_HINT_SAVE_BACKGROUND);
|
2003-11-03 23:42:53 +00:00
|
|
|
|
2003-11-04 21:17:33 +00:00
|
|
|
//
|
|
|
|
// 1) The game tab
|
|
|
|
//
|
2003-11-03 05:27:53 +00:00
|
|
|
tab->addTab("Game");
|
|
|
|
|
|
|
|
// GUI: Label & edit widget for the game ID
|
2006-03-24 01:24:26 +00:00
|
|
|
new StaticTextWidget(tab, "gameoptions_id", "ID: ");
|
2006-03-09 05:18:00 +00:00
|
|
|
_domainWidget = new DomainEditTextWidget(tab, "gameoptions_domain", _domain);
|
2003-11-03 05:27:53 +00:00
|
|
|
|
|
|
|
// GUI: Label & edit widget for the description
|
2006-03-24 01:24:26 +00:00
|
|
|
new StaticTextWidget(tab, "gameoptions_name", "Name: ");
|
2006-03-09 05:18:00 +00:00
|
|
|
_descriptionWidget = new EditTextWidget(tab, "gameoptions_desc", description);
|
2003-11-03 05:27:53 +00:00
|
|
|
|
2004-06-29 14:23:39 +00:00
|
|
|
// Language popup
|
2006-03-09 05:18:00 +00:00
|
|
|
_langPopUp = new PopUpWidget(tab, "gameoptions_lang", "Language: ", labelWidth);
|
2003-11-05 00:59:03 +00:00
|
|
|
_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
|
2006-03-09 05:18:00 +00:00
|
|
|
_platformPopUp = new PopUpWidget(tab, "gameoptions_platform", "Platform: ", labelWidth);
|
2003-11-05 00:59:03 +00:00
|
|
|
_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
|
|
|
|
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
|
|
|
//
|
2006-06-15 02:30:05 +00:00
|
|
|
tab->addTab("Graphics");
|
2003-11-07 16:01:51 +00:00
|
|
|
|
2006-03-09 05:18:00 +00:00
|
|
|
_globalGraphicsOverride = new CheckboxWidget(tab, "gameoptions_graphicsCheckbox", "Override global graphic settings", kCmdGlobalGraphicsOverride, 0);
|
2003-11-07 16:01:51 +00:00
|
|
|
|
2006-03-08 01:42:02 +00:00
|
|
|
addGraphicControls(tab, "gameoptions_");
|
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");
|
2003-11-07 16:01:51 +00:00
|
|
|
|
2006-03-09 05:18:00 +00:00
|
|
|
_globalAudioOverride = new CheckboxWidget(tab, "gameoptions_audioCheckbox", "Override global audio settings", kCmdGlobalAudioOverride, 0);
|
2003-11-07 16:01:51 +00:00
|
|
|
|
2006-03-08 01:42:02 +00:00
|
|
|
addAudioControls(tab, "gameoptions_");
|
2006-05-13 17:30:04 +00:00
|
|
|
addSubtitleControls(tab, "gameoptions_");
|
2005-04-13 00:11:49 +00:00
|
|
|
|
|
|
|
//
|
2006-05-30 17:35:57 +00:00
|
|
|
// 5) The volume tab
|
2005-04-13 00:11:49 +00:00
|
|
|
//
|
2006-06-15 13:18:28 +00:00
|
|
|
int volControlPos = g_gui.evaluator()->getVar("volumeControlsInAudio", true);
|
2005-04-13 00:11:49 +00:00
|
|
|
|
2006-06-15 13:18:28 +00:00
|
|
|
if (!volControlPos) {
|
|
|
|
tab->addTab("Volume");
|
|
|
|
|
|
|
|
_globalVolumeOverride = new CheckboxWidget(tab, "gameoptions_volumeCheckbox", "Override global volume settings", kCmdGlobalVolumeOverride, 0);
|
|
|
|
} else {
|
|
|
|
_globalVolumeOverride = NULL;
|
|
|
|
}
|
2005-04-13 00:11:49 +00:00
|
|
|
|
2006-05-30 17:35:57 +00:00
|
|
|
addVolumeControls(tab, "gameoptions_");
|
2003-11-04 21:17:33 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
//
|
2006-05-30 17:35:57 +00:00
|
|
|
// 6) The MIDI tab
|
2003-11-05 12:25:42 +00:00
|
|
|
//
|
2006-05-30 17:35:57 +00:00
|
|
|
tab->addTab("MIDI");
|
2003-11-07 16:01:51 +00:00
|
|
|
|
2006-05-30 17:35:57 +00:00
|
|
|
_globalMIDIOverride = new CheckboxWidget(tab, "gameoptions_midiCheckbox", "Override global MIDI settings", kCmdGlobalMIDIOverride, 0);
|
2003-11-07 16:01:51 +00:00
|
|
|
|
2006-05-30 17:35:57 +00:00
|
|
|
addMIDIControls(tab, "gameoptions_");
|
2003-11-04 21:17:33 +00:00
|
|
|
|
2006-06-15 02:30:05 +00:00
|
|
|
//
|
|
|
|
// 2) The 'Path' tab
|
|
|
|
//
|
|
|
|
tab->addTab("Paths");
|
|
|
|
|
|
|
|
// These buttons have to be extra wide, or the text will be truncated
|
|
|
|
// in the small version of the GUI.
|
|
|
|
|
|
|
|
// GUI: Button + Label for the game path
|
|
|
|
new ButtonWidget(tab, "gameoptions_gamepath", "Game Path: ", kCmdGameBrowser, 0);
|
|
|
|
_gamePathWidget = new StaticTextWidget(tab, "gameoptions_gamepathText", gamePath);
|
|
|
|
|
|
|
|
// GUI: Button + Label for the additional path
|
|
|
|
new ButtonWidget(tab, "gameoptions_extrapath", "Extra Path:", kCmdExtraBrowser, 0);
|
|
|
|
_extraPathWidget = new StaticTextWidget(tab, "gameoptions_extrapathText", extraPath);
|
|
|
|
if (extraPath.empty() || !ConfMan.hasKey("extrapath", _domain)) {
|
|
|
|
_extraPathWidget->setLabel("None");
|
|
|
|
}
|
|
|
|
|
|
|
|
// GUI: Button + Label for the save path
|
|
|
|
new ButtonWidget(tab, "gameoptions_savepath", "Save Path: ", kCmdSaveBrowser, 0);
|
|
|
|
_savePathWidget = new StaticTextWidget(tab, "gameoptions_savepathText", savePath);
|
|
|
|
if (savePath.empty() || !ConfMan.hasKey("savepath", _domain)) {
|
|
|
|
_savePathWidget->setLabel("Default");
|
|
|
|
}
|
|
|
|
|
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
|
2006-03-09 05:18:00 +00:00
|
|
|
new ButtonWidget(this, "gameoptions_cancel", "Cancel", kCloseCmd, 0);
|
|
|
|
new ButtonWidget(this, "gameoptions_ok", "OK", kOKCmd, 0);
|
2002-11-21 14:12:55 +00:00
|
|
|
}
|
|
|
|
|
2006-08-04 13:55:53 +00:00
|
|
|
void EditGameDialog::reflowLayout() {
|
|
|
|
OptionsDialog::reflowLayout();
|
2006-06-11 21:26:43 +00:00
|
|
|
|
|
|
|
int labelWidth = g_gui.evaluator()->getVar("gameOptionsLabelWidth");
|
|
|
|
|
|
|
|
if (_langPopUp)
|
|
|
|
_langPopUp->changeLabelWidth(labelWidth);
|
|
|
|
if (_platformPopUp)
|
|
|
|
_platformPopUp->changeLabelWidth(labelWidth);
|
|
|
|
}
|
|
|
|
|
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;
|
2007-03-10 18:25:37 +00:00
|
|
|
bool e, f;
|
2003-11-07 16:01:51 +00:00
|
|
|
|
2004-02-07 17:12:10 +00:00
|
|
|
// En-/disable dialog items depending on whether overrides are active or not.
|
|
|
|
|
2007-03-10 18:25:37 +00:00
|
|
|
e = ConfMan.hasKey("gfx_mode", _domain) ||
|
|
|
|
ConfMan.hasKey("render_mode", _domain) ||
|
|
|
|
ConfMan.hasKey("fullscreen", _domain) ||
|
2003-11-07 16:01:51 +00:00
|
|
|
ConfMan.hasKey("aspect_ratio", _domain);
|
|
|
|
_globalGraphicsOverride->setState(e);
|
|
|
|
|
|
|
|
e = ConfMan.hasKey("music_driver", _domain) ||
|
2007-03-10 18:25:37 +00:00
|
|
|
ConfMan.hasKey("output_rate", _domain) ||
|
2006-05-13 17:30:04 +00:00
|
|
|
ConfMan.hasKey("subtitles", _domain) ||
|
|
|
|
ConfMan.hasKey("talkspeed", _domain);
|
2003-11-07 16:01:51 +00:00
|
|
|
|
2007-03-10 18:25:37 +00:00
|
|
|
f = 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);
|
2006-06-15 13:18:28 +00:00
|
|
|
|
2007-03-10 18:25:37 +00:00
|
|
|
if (_globalVolumeOverride) {
|
|
|
|
_globalAudioOverride->setState(e);
|
|
|
|
_globalVolumeOverride->setState(f);
|
|
|
|
} else {
|
|
|
|
_globalAudioOverride->setState(e || f);
|
|
|
|
}
|
|
|
|
|
|
|
|
e = ConfMan.hasKey("soundfont", _domain) ||
|
|
|
|
ConfMan.hasKey("multi_midi", _domain) ||
|
|
|
|
ConfMan.hasKey("native_mt32", _domain) ||
|
|
|
|
ConfMan.hasKey("enable_gs", _domain) ||
|
|
|
|
ConfMan.hasKey("midi_gain", _domain);
|
|
|
|
_globalMIDIOverride->setState(e);
|
2003-11-07 16:01:51 +00:00
|
|
|
|
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));
|
2006-05-30 01:41:49 +00:00
|
|
|
|
2004-02-07 17:12:10 +00:00
|
|
|
sel = 0;
|
2006-05-30 01:41:49 +00:00
|
|
|
if (ConfMan.hasKey("language", _domain)) {
|
|
|
|
for (i = 0; l->code; ++l, ++i) {
|
|
|
|
if (lang == l->id)
|
|
|
|
sel = i + 2;
|
|
|
|
}
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
|
|
|
_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
|
|
|
|
2006-06-03 13:33:39 +00:00
|
|
|
String gamePath(_gamePathWidget->getLabel());
|
2006-03-28 09:42:54 +00:00
|
|
|
if (!gamePath.empty())
|
2004-06-29 14:23:39 +00:00
|
|
|
ConfMan.set("path", gamePath, _domain);
|
|
|
|
|
2006-06-03 13:33:39 +00:00
|
|
|
String extraPath(_extraPathWidget->getLabel());
|
2006-03-28 09:42:54 +00:00
|
|
|
if (!extraPath.empty() && (extraPath != "None"))
|
2004-06-29 14:23:39 +00:00
|
|
|
ConfMan.set("extrapath", extraPath, _domain);
|
|
|
|
|
2006-06-03 13:33:39 +00:00
|
|
|
String savePath(_savePathWidget->getLabel());
|
2006-03-28 09:42:54 +00:00
|
|
|
if (!savePath.empty() && (savePath != "Default"))
|
2004-07-01 10:24:42 +00:00
|
|
|
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);
|
2006-05-13 17:30:04 +00:00
|
|
|
setSubtitleSettingsState(data != 0);
|
2006-07-14 13:33:58 +00:00
|
|
|
if (_globalVolumeOverride == NULL)
|
2006-06-15 13:18:28 +00:00
|
|
|
setVolumeSettingsState(data != 0);
|
2003-11-07 16:01:51 +00:00
|
|
|
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;
|
2005-05-16 06:33:33 +00:00
|
|
|
case kCmdChooseSoundFontCmd: {
|
|
|
|
BrowserDialog browser("Select SoundFont", false);
|
|
|
|
|
|
|
|
if (browser.runModal() > 0) {
|
|
|
|
// User made this choice...
|
|
|
|
FilesystemNode file(browser.getResult());
|
|
|
|
_soundFont->setLabel(file.path());
|
2007-02-13 21:41:49 +00:00
|
|
|
|
|
|
|
if (!file.path().empty() && (file.path() != "None"))
|
|
|
|
_soundFontClearButton->setEnabled(true);
|
|
|
|
else
|
|
|
|
_soundFontClearButton->setEnabled(false);
|
|
|
|
|
2005-05-16 06:33:33 +00:00
|
|
|
draw();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-06-29 14:23:39 +00:00
|
|
|
// Change path for the game
|
|
|
|
case kCmdGameBrowser: {
|
2005-08-10 18:30:55 +00:00
|
|
|
BrowserDialog browser("Select directory with game data", true);
|
2005-04-16 17:55:09 +00:00
|
|
|
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)
|
2005-07-30 21:11:48 +00:00
|
|
|
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) {
|
2006-03-28 09:42:54 +00:00
|
|
|
if (newDomain.empty() || 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
|
|
|
|
2006-05-04 22:52:18 +00:00
|
|
|
LauncherDialog::LauncherDialog()
|
2007-03-17 16:05:16 +00:00
|
|
|
: Dialog(0, 0, 320, 200) {
|
2006-01-28 23:03:39 +00:00
|
|
|
_drawingHints |= THEME_HINT_MAIN_DIALOG;
|
2005-05-16 00:26:23 +00:00
|
|
|
|
|
|
|
const int screenW = g_system->getOverlayWidth();
|
|
|
|
const int screenH = g_system->getOverlayHeight();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-05-16 00:26:23 +00:00
|
|
|
_w = screenW;
|
|
|
|
_h = screenH;
|
|
|
|
|
2006-03-14 02:19:38 +00:00
|
|
|
#ifndef DISABLE_FANCY_THEMES
|
2006-04-20 12:25:25 +00:00
|
|
|
_logo = 0;
|
2006-10-25 21:49:33 +00:00
|
|
|
if (g_gui.evaluator()->getVar("launcher_logo.visible") == 1 && g_gui.theme()->supportsImages()) {
|
2006-04-17 18:50:33 +00:00
|
|
|
_logo = new GraphicsWidget(this, "launcher_logo");
|
2006-05-29 14:55:43 +00:00
|
|
|
_logo->useThemeTransparency(true);
|
2006-10-25 21:49:33 +00:00
|
|
|
_logo->setGfx(g_gui.theme()->getImageSurface(Theme::kImageLogo));
|
2006-03-14 03:08:14 +00:00
|
|
|
|
2006-03-24 01:24:26 +00:00
|
|
|
new StaticTextWidget(this, "launcher_version", gScummVMVersionDate);
|
2006-03-14 03:08:14 +00:00
|
|
|
} else
|
2006-03-24 01:24:26 +00:00
|
|
|
new StaticTextWidget(this, "launcher_version", gScummVMFullVersion);
|
2006-03-14 03:08:14 +00:00
|
|
|
#else
|
|
|
|
// Show ScummVM version
|
2006-03-24 01:24:26 +00:00
|
|
|
new StaticTextWidget(this, "launcher_version", gScummVMFullVersion);
|
2006-03-14 02:19:38 +00:00
|
|
|
#endif
|
|
|
|
|
2006-03-08 01:42:02 +00:00
|
|
|
new ButtonWidget(this, "launcher_quit_button", "Quit", kQuitCmd, 'Q');
|
|
|
|
new ButtonWidget(this, "launcher_about_button", "About", kAboutCmd, 'B');
|
|
|
|
new ButtonWidget(this, "launcher_options_button", "Options", kOptionsCmd, 'O');
|
2006-03-07 05:39:52 +00:00
|
|
|
_startButton =
|
2006-03-08 01:42:02 +00:00
|
|
|
new ButtonWidget(this, "launcher_start_button", "Start", kStartCmd, 'S');
|
2005-05-16 00:26:23 +00:00
|
|
|
|
|
|
|
// Above the lowest button rows: two more buttons (directly below the list box)
|
2007-02-04 02:36:23 +00:00
|
|
|
_addButton =
|
|
|
|
new ButtonWidget(this, "launcher_addGame_button", "Add Game...", kAddGameCmd, 'A');
|
2006-03-07 05:39:52 +00:00
|
|
|
_editButton =
|
2006-03-08 01:42:02 +00:00
|
|
|
new ButtonWidget(this, "launcher_editGame_button", "Edit Game...", kEditGameCmd, 'E');
|
2006-03-07 05:39:52 +00:00
|
|
|
_removeButton =
|
2006-03-08 01:42:02 +00:00
|
|
|
new ButtonWidget(this, "launcher_removeGame_button", "Remove Game", kRemoveGameCmd, 'R');
|
2005-05-16 00:26:23 +00:00
|
|
|
|
2002-09-27 23:27:14 +00:00
|
|
|
|
|
|
|
// Add list with game titles
|
2006-03-08 01:42:02 +00:00
|
|
|
_list = new ListWidget(this, "launcher_list");
|
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-12-01 12:47:13 +00:00
|
|
|
// Populate the list
|
|
|
|
updateListing();
|
|
|
|
|
2004-10-01 21:12:18 +00:00
|
|
|
// Restore last selection
|
2006-06-03 13:33:39 +00:00
|
|
|
String last(ConfMan.get("lastselectedgame", ConfigManager::kApplicationDomain));
|
2005-01-05 01:42:52 +00:00
|
|
|
selectGame(last);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-05-16 00:26:23 +00:00
|
|
|
// En-/disable the buttons depending on the list selection
|
2005-01-05 01:42:52 +00:00
|
|
|
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) {
|
2006-03-28 09:42:54 +00:00
|
|
|
if (!name.empty()) {
|
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;
|
|
|
|
}
|
|
|
|
|
2006-07-22 21:23:49 +00:00
|
|
|
void LauncherDialog::open() {
|
|
|
|
// Clear the active domain, in case we return to the dialog from a
|
|
|
|
// failure to launch a game. Otherwise, pressing ESC will attempt to
|
|
|
|
// re-launch the same game again.
|
|
|
|
ConfMan.setActiveDomain("");
|
|
|
|
Dialog::open();
|
2007-03-17 16:05:16 +00:00
|
|
|
|
|
|
|
updateButtons();
|
2006-07-22 21:23:49 +00:00
|
|
|
}
|
|
|
|
|
2004-10-01 21:12:18 +00:00
|
|
|
void LauncherDialog::close() {
|
|
|
|
// Save last selection
|
|
|
|
const int sel = _list->getSelected();
|
|
|
|
if (sel >= 0)
|
2006-06-03 13:33:39 +00:00
|
|
|
ConfMan.set("lastselectedgame", _domains[sel], ConfigManager::kApplicationDomain);
|
2004-10-01 21:12:18 +00:00
|
|
|
else
|
2006-06-03 13:33:39 +00:00
|
|
|
ConfMan.removeKey("lastselectedgame", ConfigManager::kApplicationDomain);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
|
|
|
ConfMan.flushToDisk();
|
2004-10-01 21:12:18 +00:00
|
|
|
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) {
|
2006-01-21 13:01:20 +00:00
|
|
|
String gameid(iter->_value.get("gameid"));
|
2003-10-08 21:59:23 +00:00
|
|
|
String description(iter->_value.get("description"));
|
2003-03-06 19:52:54 +00:00
|
|
|
|
2006-03-28 09:42:54 +00:00
|
|
|
if (gameid.empty())
|
2006-01-21 13:01:20 +00:00
|
|
|
gameid = iter->_key;
|
2006-03-28 09:42:54 +00:00
|
|
|
if (description.empty()) {
|
2006-05-04 23:24:09 +00:00
|
|
|
GameDescriptor g = Base::findGame(gameid);
|
2007-01-20 21:27:57 +00:00
|
|
|
if (g.contains("description"))
|
|
|
|
description = g.description();
|
2003-10-17 15:54:17 +00:00
|
|
|
}
|
2002-10-28 10:40:49 +00:00
|
|
|
|
2006-03-28 09:42:54 +00:00
|
|
|
if (!gameid.empty() && !description.empty()) {
|
2002-10-28 10:40:49 +00:00
|
|
|
// 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
|
2006-11-13 16:29:14 +00:00
|
|
|
else if (oldSel != -1)
|
|
|
|
// Select the last entry if the list has been reduced
|
|
|
|
_list->setSelected(_list->getList().size() - 1);
|
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() {
|
2007-03-17 16:05:16 +00:00
|
|
|
int modifiers = g_system->getEventManager()->getModifierState();
|
2007-03-17 19:02:05 +00:00
|
|
|
bool massAdd = (modifiers & Common::KBD_SHIFT) != 0;
|
2006-10-02 22:28:02 +00:00
|
|
|
|
|
|
|
if (massAdd) {
|
|
|
|
MessageDialog alert("Do you really want to run the mass game detector? "
|
|
|
|
"This could potentially add a huge number of games.", "Yes", "No");
|
|
|
|
if (alert.runModal() == GUI::kMessageOK && _browser->runModal() > 0) {
|
2007-02-18 18:23:52 +00:00
|
|
|
MassAddDialog massAddDlg(_browser->getResult());
|
|
|
|
massAddDlg.runModal();
|
2007-02-18 18:36:21 +00:00
|
|
|
|
|
|
|
// Update the ListWidget and force a redraw
|
|
|
|
updateListing();
|
|
|
|
draw();
|
2006-10-02 22:28:02 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// 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
|
2005-07-30 21:11:48 +00:00
|
|
|
// determine it uniquely preent a list of candidates to the user
|
2003-11-05 12:25:42 +00:00
|
|
|
// 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());
|
2006-05-03 20:43:26 +00:00
|
|
|
FSList files;
|
|
|
|
if (!dir.listDir(files, FilesystemNode::kListAll)) {
|
|
|
|
error("browser returned a node that is not a directory: '%s'",
|
|
|
|
dir.path().c_str());
|
|
|
|
}
|
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.
|
2007-01-20 21:27:57 +00:00
|
|
|
GameList candidates(PluginManager::instance().detectGames(files));
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
int idx;
|
2006-03-28 09:42:54 +00:00
|
|
|
if (candidates.empty()) {
|
2003-11-05 12:25:42 +00:00
|
|
|
// 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++)
|
2007-01-20 21:27:57 +00:00
|
|
|
list.push_back(candidates[idx].description());
|
2005-07-30 21:11:48 +00:00
|
|
|
|
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()) {
|
2007-01-20 21:27:57 +00:00
|
|
|
GameDescriptor result = candidates[idx];
|
2007-02-18 18:23:52 +00:00
|
|
|
|
|
|
|
// TODO: Change the detectors to set "path" !
|
|
|
|
result["path"] = dir.path();
|
|
|
|
|
|
|
|
Common::String domain = addGameToConf(result);
|
|
|
|
|
|
|
|
// Display edit dialog for the new entry
|
|
|
|
EditGameDialog editDialog(domain, result.description());
|
|
|
|
if (editDialog.runModal() > 0) {
|
|
|
|
// User pressed OK, so make changes permanent
|
|
|
|
|
|
|
|
// Write config to disk
|
|
|
|
ConfMan.flushToDisk();
|
|
|
|
|
|
|
|
// Update the ListWidget, select the new item, and force a redraw
|
|
|
|
updateListing();
|
|
|
|
selectGame(domain);
|
|
|
|
draw();
|
|
|
|
} else {
|
|
|
|
// User aborted, remove the the new domain again
|
|
|
|
ConfMan.removeGameDomain(domain);
|
|
|
|
}
|
|
|
|
|
2006-10-02 22:28:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-18 18:23:52 +00:00
|
|
|
Common::String addGameToConf(const GameDescriptor &result) {
|
2006-11-19 22:32:35 +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).
|
2007-01-29 23:25:51 +00:00
|
|
|
String domain;
|
|
|
|
|
|
|
|
if (result.contains("preferredtarget"))
|
|
|
|
domain = result["preferredtarget"];
|
|
|
|
else
|
|
|
|
domain = result.gameid();
|
|
|
|
|
2007-01-28 10:38:23 +00:00
|
|
|
assert(!domain.empty());
|
2006-11-19 22:32:35 +00:00
|
|
|
if (ConfMan.hasGameDomain(domain)) {
|
|
|
|
int suffixN = 1;
|
|
|
|
char suffix[16];
|
2007-01-29 23:25:51 +00:00
|
|
|
String gameid(domain);
|
2006-11-19 22:32:35 +00:00
|
|
|
|
|
|
|
while (ConfMan.hasGameDomain(domain)) {
|
|
|
|
snprintf(suffix, 16, "-%d", suffixN);
|
2007-01-29 23:25:51 +00:00
|
|
|
domain = gameid + suffix;
|
2006-11-19 22:32:35 +00:00
|
|
|
suffixN++;
|
|
|
|
}
|
|
|
|
}
|
2006-04-16 13:58:11 +00:00
|
|
|
|
2006-11-19 22:32:35 +00:00
|
|
|
// Add the name domain
|
|
|
|
ConfMan.addGameDomain(domain);
|
2007-02-18 18:39:46 +00:00
|
|
|
|
|
|
|
// Copy all non-empty key/value pairs into the new domain
|
|
|
|
for (GameDescriptor::const_iterator iter = result.begin(); iter != result.end(); ++iter) {
|
|
|
|
if (!iter->_value.empty() && iter->_key != "preferredtarget")
|
|
|
|
ConfMan.set(iter->_key, iter->_value, domain);
|
|
|
|
}
|
|
|
|
|
2006-11-19 22:32:35 +00:00
|
|
|
// TODO: Setting the description field here has the drawback
|
|
|
|
// that the user does never notice when we upgrade our descriptions.
|
|
|
|
// It might be nice ot leave this field empty, and only set it to
|
|
|
|
// a value when the user edits the description string.
|
|
|
|
// However, at this point, that's impractical. Once we have a method
|
|
|
|
// to query all backends for the proper & full description of a given
|
|
|
|
// game target, we can change this (currently, you can only query
|
|
|
|
// for the generic gameid description; it's not possible to obtain
|
|
|
|
// a description which contains extended information like language, etc.).
|
2007-02-18 18:23:52 +00:00
|
|
|
|
|
|
|
return domain;
|
2006-11-19 22:32:35 +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");
|
2005-07-30 21:11:48 +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();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// Update the ListWidget and force a redraw
|
|
|
|
updateListing();
|
|
|
|
draw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LauncherDialog::editGame(int item) {
|
2005-07-30 21:11:48 +00:00
|
|
|
// Set game specifc options. Most of these should be "optional", i.e. by
|
2003-11-05 12:25:42 +00:00
|
|
|
// 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]));
|
2006-03-28 09:42:54 +00:00
|
|
|
if (gameId.empty())
|
2003-11-05 12:25:42 +00:00
|
|
|
gameId = _domains[item];
|
2007-01-20 21:27:57 +00:00
|
|
|
EditGameDialog editDialog(_domains[item], Base::findGame(gameId).description());
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-02 22:28:02 +00:00
|
|
|
void LauncherDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
|
|
|
Dialog::handleKeyDown(ascii, keycode, modifiers);
|
2007-03-17 16:05:16 +00:00
|
|
|
updateButtons();
|
2006-10-02 22:28:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LauncherDialog::handleKeyUp(uint16 ascii, int keycode, int modifiers) {
|
|
|
|
Dialog::handleKeyUp(ascii, keycode, modifiers);
|
2007-03-17 16:05:16 +00:00
|
|
|
updateButtons();
|
2006-10-02 22:28:02 +00:00
|
|
|
}
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
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: {
|
2006-03-09 05:18:00 +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);
|
2006-05-05 00:26:03 +00:00
|
|
|
ConfMan.setActiveDomain(_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:
|
2006-06-11 21:41:04 +00:00
|
|
|
ConfMan.setActiveDomain("");
|
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();
|
|
|
|
}
|
2007-03-17 16:05:16 +00:00
|
|
|
|
|
|
|
// Update the label of the "Add" button depending on whether shift is pressed or not
|
|
|
|
int modifiers = g_system->getEventManager()->getModifierState();
|
2007-03-17 19:02:05 +00:00
|
|
|
const char *newAddButtonLabel = ((modifiers & Common::KBD_SHIFT) != 0)
|
2007-03-17 16:05:16 +00:00
|
|
|
? "Mass Add..."
|
|
|
|
: "Add Game...";
|
|
|
|
|
|
|
|
if (_addButton->getLabel() != newAddButtonLabel) {
|
|
|
|
_addButton->setLabel(newAddButtonLabel);
|
|
|
|
_addButton->draw();
|
|
|
|
}
|
2002-12-01 12:47:13 +00:00
|
|
|
}
|
2003-11-10 23:40:48 +00:00
|
|
|
|
2006-08-04 13:55:53 +00:00
|
|
|
void LauncherDialog::reflowLayout() {
|
2006-04-16 20:33:52 +00:00
|
|
|
#ifndef DISABLE_FANCY_THEMES
|
2006-10-25 21:49:33 +00:00
|
|
|
if (g_gui.evaluator()->getVar("launcher_logo.visible") == 1 && g_gui.theme()->supportsImages()) {
|
2006-04-19 01:05:28 +00:00
|
|
|
StaticTextWidget *ver = (StaticTextWidget*)findWidget("launcher_version");
|
|
|
|
if (ver) {
|
2006-06-03 22:00:20 +00:00
|
|
|
ver->setAlign((Graphics::TextAlignment)g_gui.evaluator()->getVar("launcher_version.align"));
|
2006-04-19 01:05:28 +00:00
|
|
|
ver->setLabel(gScummVMVersionDate);
|
|
|
|
}
|
|
|
|
|
2006-04-17 18:50:33 +00:00
|
|
|
if (!_logo)
|
|
|
|
_logo = new GraphicsWidget(this, "launcher_logo");
|
2006-05-29 14:55:43 +00:00
|
|
|
_logo->useThemeTransparency(true);
|
2006-10-25 21:49:33 +00:00
|
|
|
_logo->setGfx(g_gui.theme()->getImageSurface(Theme::kImageLogo));
|
2006-04-17 18:50:33 +00:00
|
|
|
} else {
|
2006-04-19 01:05:28 +00:00
|
|
|
StaticTextWidget *ver = (StaticTextWidget*)findWidget("launcher_version");
|
|
|
|
if (ver) {
|
2006-06-03 22:00:20 +00:00
|
|
|
ver->setAlign((Graphics::TextAlignment)g_gui.evaluator()->getVar("launcher_version.align"));
|
2006-04-19 01:05:28 +00:00
|
|
|
ver->setLabel(gScummVMFullVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_logo) {
|
2007-03-16 20:47:41 +00:00
|
|
|
removeWidget(_logo);
|
2006-04-19 01:05:28 +00:00
|
|
|
_logo->setNext(0);
|
|
|
|
delete _logo;
|
|
|
|
_logo = 0;
|
|
|
|
}
|
2006-04-16 20:33:52 +00:00
|
|
|
}
|
|
|
|
#endif
|
2006-04-19 01:05:28 +00:00
|
|
|
|
|
|
|
_w = g_system->getOverlayWidth();
|
|
|
|
_h = g_system->getOverlayHeight();
|
|
|
|
|
2006-08-04 13:55:53 +00:00
|
|
|
Dialog::reflowLayout();
|
2006-04-16 20:33:52 +00:00
|
|
|
}
|
|
|
|
|
2003-11-10 23:40:48 +00:00
|
|
|
} // End of namespace GUI
|