2002-12-12 23:22:48 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2003-03-06 21:46:56 +00:00
|
|
|
* Copyright (C) 2002-2003 The ScummVM project
|
2002-12-12 23:22:48 +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-10-02 22:52:57 +00:00
|
|
|
#include "gui/browser.h"
|
|
|
|
#include "gui/chooser.h"
|
|
|
|
#include "gui/newgui.h"
|
|
|
|
#include "gui/options.h"
|
|
|
|
#include "gui/PopUpWidget.h"
|
2003-11-03 00:24:04 +00:00
|
|
|
#include "gui/TabWidget.h"
|
2002-12-12 23:22:48 +00:00
|
|
|
|
2003-03-25 15:32:36 +00:00
|
|
|
#include "backends/fs/fs.h"
|
2003-09-17 22:41:01 +00:00
|
|
|
#include "base/gameDetector.h"
|
2003-10-08 21:59:23 +00:00
|
|
|
#include "common/config-manager.h"
|
2003-10-02 22:52:57 +00:00
|
|
|
#include "sound/mididrv.h"
|
2002-12-12 23:22:48 +00:00
|
|
|
|
2003-05-29 18:30:40 +00:00
|
|
|
#if (!( defined(__DC__) || defined(__GP32__)) && !defined(_MSC_VER))
|
2003-05-27 23:34:37 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2002-12-14 14:26:37 +00:00
|
|
|
/*
|
|
|
|
_____ _ _ _ _ _
|
|
|
|
|_ _| |__ (_)___ (_)___ __ _ __| |_ _ _ __ ___ _ __ ___ _ _| |
|
|
|
|
| | | '_ \| / __| | / __| / _` | / _` | | | | '_ ` _ \| '_ ` _ \| | | | |
|
|
|
|
| | | | | | \__ \ | \__ \ | (_| | | (_| | |_| | | | | | | | | | | | |_| |_|
|
|
|
|
|_| |_| |_|_|___/ |_|___/ \__,_| \__,_|\__,_|_| |_| |_|_| |_| |_|\__, (_)
|
|
|
|
|___/
|
|
|
|
|
2002-12-14 14:32:19 +00:00
|
|
|
This just looks like an option dialog, but it doesn't change any actual settings currently!
|
2002-12-14 14:26:37 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2002-12-12 23:22:48 +00:00
|
|
|
// TODO - allow changing options for:
|
|
|
|
// - 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-11-01 22:21:18 +00:00
|
|
|
// - aspect ratio, language, platform, subtitles, debug mode/level, cd drive, joystick, multi midi, native mt32
|
2002-12-12 23:22:48 +00:00
|
|
|
|
|
|
|
enum {
|
2003-03-25 15:32:36 +00:00
|
|
|
kMasterVolumeChanged = 'mavc',
|
|
|
|
kMusicVolumeChanged = 'muvc',
|
|
|
|
kSfxVolumeChanged = 'sfvc',
|
|
|
|
kChooseSaveDirCmd = 'chos',
|
|
|
|
kOKCmd = 'ok '
|
2002-12-12 23:22:48 +00:00
|
|
|
};
|
|
|
|
|
2003-11-02 02:18:16 +00:00
|
|
|
GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector)
|
2003-11-03 00:24:04 +00:00
|
|
|
: Dialog(10, 20, 320 - 2 * 10, 200 - 2 * 20) {
|
|
|
|
|
|
|
|
const int vBorder = 5;
|
|
|
|
|
|
|
|
// The tab widget
|
|
|
|
TabWidget *tab = new TabWidget(this, 0, vBorder, _w, _h - 24 - 2*vBorder);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 1) The graphics tab
|
|
|
|
//
|
|
|
|
tab->addTab("Graphics");
|
|
|
|
|
2002-12-12 23:22:48 +00:00
|
|
|
// The GFX mode popup & a label
|
|
|
|
// TODO - add an API to query the list of available GFX modes, and to get/set the mode
|
2003-11-03 01:00:26 +00:00
|
|
|
//new StaticTextWidget(tab, 5, vBorder+2, 100, kLineHeight, "Graphics mode: ", kTextAlignRight);
|
2002-12-12 23:22:48 +00:00
|
|
|
PopUpWidget *gfxPopUp;
|
2003-11-03 01:04:55 +00:00
|
|
|
gfxPopUp = new PopUpWidget(tab, 5, vBorder, 280, kLineHeight, "Graphics mode: ", 100);
|
2002-12-13 22:19:35 +00:00
|
|
|
gfxPopUp->appendEntry("<default>");
|
2002-12-14 17:59:22 +00:00
|
|
|
gfxPopUp->appendEntry("");
|
2002-12-12 23:22:48 +00:00
|
|
|
gfxPopUp->appendEntry("Normal (no scaling)");
|
|
|
|
gfxPopUp->appendEntry("2x");
|
|
|
|
gfxPopUp->appendEntry("3x");
|
|
|
|
gfxPopUp->appendEntry("2xSAI");
|
|
|
|
gfxPopUp->appendEntry("Super2xSAI");
|
2002-12-13 23:29:18 +00:00
|
|
|
gfxPopUp->appendEntry("SuperEagle");
|
2002-12-12 23:22:48 +00:00
|
|
|
gfxPopUp->appendEntry("AdvMAME2x");
|
2003-01-15 02:11:37 +00:00
|
|
|
gfxPopUp->appendEntry("TV2x");
|
2003-03-02 16:36:52 +00:00
|
|
|
gfxPopUp->appendEntry("DotMatrix");
|
2002-12-12 23:22:48 +00:00
|
|
|
gfxPopUp->setSelected(0);
|
2003-03-26 20:43:58 +00:00
|
|
|
|
|
|
|
// FIXME - disable GFX popup for now
|
|
|
|
gfxPopUp->setEnabled(false);
|
|
|
|
|
2003-11-03 00:24:04 +00:00
|
|
|
// TODO: Aspect ratio setting
|
|
|
|
// TODO: Fullscreen setting
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// 2) The audio tab
|
|
|
|
//
|
|
|
|
tab->addTab("Audio");
|
2002-12-12 23:22:48 +00:00
|
|
|
|
|
|
|
// The MIDI mode popup & a label
|
2003-11-03 01:00:26 +00:00
|
|
|
//new StaticTextWidget(tab, 5, vBorder+2, 100, kLineHeight, "Music driver: ", kTextAlignRight);
|
2003-11-03 01:04:55 +00:00
|
|
|
_midiPopUp = new PopUpWidget(tab, 5, vBorder, 280, kLineHeight, "Music driver: ", 100);
|
2002-12-13 23:29:18 +00:00
|
|
|
|
|
|
|
// Populate it
|
2003-10-02 22:52:57 +00:00
|
|
|
const MidiDriverDescription *md = getAvailableMidiDrivers();
|
2003-10-18 00:22:46 +00:00
|
|
|
const int midiDriver = parseMusicDriver(ConfMan.get("music_driver"));
|
2003-11-03 00:24:04 +00:00
|
|
|
int midiSelected = 0, i = 0;
|
2002-12-13 23:29:18 +00:00
|
|
|
while (md->name) {
|
2003-10-02 22:52:57 +00:00
|
|
|
_midiPopUp->appendEntry(md->description, md->id);
|
2003-10-18 00:22:46 +00:00
|
|
|
if (md->id == midiDriver)
|
2003-10-02 22:52:57 +00:00
|
|
|
midiSelected = i;
|
|
|
|
i++;
|
2002-12-13 23:29:18 +00:00
|
|
|
md++;
|
|
|
|
}
|
2003-03-26 20:43:58 +00:00
|
|
|
_midiPopUp->setSelected(midiSelected);
|
|
|
|
|
2003-11-03 00:24:04 +00:00
|
|
|
// Volume controllers
|
|
|
|
int yoffset = vBorder + 16;
|
2003-11-01 22:21:18 +00:00
|
|
|
|
2003-11-03 00:43:29 +00:00
|
|
|
_masterVolumeSlider = new SliderWidget(tab, 5, yoffset, 185, 12, "Master volume: ", 100, kMasterVolumeChanged);
|
2003-11-03 00:24:04 +00:00
|
|
|
_masterVolumeLabel = new StaticTextWidget(tab, 200, yoffset+2, 24, 16, "100%", kTextAlignLeft);
|
2003-11-01 22:21:18 +00:00
|
|
|
_masterVolumeSlider->setMinValue(0); _masterVolumeSlider->setMaxValue(255);
|
2003-03-25 15:32:36 +00:00
|
|
|
_masterVolumeLabel->setFlags(WIDGET_CLEARBG);
|
2003-11-01 22:21:18 +00:00
|
|
|
yoffset += 16;
|
|
|
|
|
2003-11-03 00:43:29 +00:00
|
|
|
_musicVolumeSlider = new SliderWidget(tab, 5, yoffset, 185, 12, "Music volume: ", 100, kMusicVolumeChanged);
|
2003-11-03 00:24:04 +00:00
|
|
|
_musicVolumeLabel = new StaticTextWidget(tab, 200, yoffset+2, 24, 16, "100%", kTextAlignLeft);
|
2003-11-01 22:21:18 +00:00
|
|
|
_musicVolumeSlider->setMinValue(0); _musicVolumeSlider->setMaxValue(255);
|
2003-03-25 15:32:36 +00:00
|
|
|
_musicVolumeLabel->setFlags(WIDGET_CLEARBG);
|
2003-11-01 22:21:18 +00:00
|
|
|
yoffset += 16;
|
|
|
|
|
2003-11-03 00:43:29 +00:00
|
|
|
_sfxVolumeSlider = new SliderWidget(tab, 5, yoffset, 185, 12, "SFX volume: ", 100, kSfxVolumeChanged);
|
2003-11-03 00:24:04 +00:00
|
|
|
_sfxVolumeLabel = new StaticTextWidget(tab, 200, yoffset+2, 24, 16, "100%", kTextAlignLeft);
|
2003-11-01 22:21:18 +00:00
|
|
|
_sfxVolumeSlider->setMinValue(0); _sfxVolumeSlider->setMaxValue(255);
|
2003-03-25 15:32:36 +00:00
|
|
|
_sfxVolumeLabel->setFlags(WIDGET_CLEARBG);
|
2003-11-01 22:21:18 +00:00
|
|
|
yoffset += 16;
|
2003-11-03 00:24:04 +00:00
|
|
|
|
|
|
|
// TODO: cd drive setting
|
|
|
|
// TODO: multi midi setting
|
|
|
|
// TODO: native mt32 setting
|
2002-12-12 23:22:48 +00:00
|
|
|
|
|
|
|
|
2002-12-14 01:49:08 +00:00
|
|
|
//
|
2003-11-03 00:24:04 +00:00
|
|
|
// 3) The miscellaneous tab
|
2002-12-14 01:49:08 +00:00
|
|
|
//
|
2003-11-03 00:24:04 +00:00
|
|
|
tab->addTab("Misc");
|
|
|
|
|
|
|
|
#if !( defined(__DC__) || defined(__GP32__) )
|
|
|
|
// Save game path
|
|
|
|
new StaticTextWidget(tab, 5, vBorder+2, 100, kLineHeight, "Savegame path: ", kTextAlignRight);
|
|
|
|
_savePath = new StaticTextWidget(tab, 105, vBorder+2, 180, kLineHeight, "/foo/bar", kTextAlignLeft);
|
|
|
|
new ButtonWidget(tab, 105, vBorder+14, 64, 16, "Choose...", kChooseSaveDirCmd, 0);
|
2002-12-14 01:49:08 +00:00
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
// TODO: set _savePath to the current save path
|
|
|
|
Common::String dir(ConfMan.get("savepath"));
|
|
|
|
if (!dir.isEmpty()) {
|
2003-03-25 15:32:36 +00:00
|
|
|
_savePath->setLabel(dir);
|
|
|
|
} else {
|
2003-03-25 15:55:27 +00:00
|
|
|
// Default to the current directory...
|
2003-03-25 15:32:36 +00:00
|
|
|
char buf[256];
|
|
|
|
getcwd(buf, sizeof(buf));
|
|
|
|
_savePath->setLabel(buf);
|
|
|
|
}
|
2003-04-03 16:01:03 +00:00
|
|
|
#endif
|
2003-11-03 00:24:04 +00:00
|
|
|
// TODO: joystick setting
|
|
|
|
|
2002-12-14 01:49:08 +00:00
|
|
|
|
|
|
|
//
|
2002-12-12 23:22:48 +00:00
|
|
|
// Add OK & Cancel buttons
|
2002-12-14 01:49:08 +00:00
|
|
|
//
|
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);
|
2003-03-25 15:32:36 +00:00
|
|
|
|
|
|
|
// Create file browser dialog
|
2003-11-02 02:18:16 +00:00
|
|
|
_browser = new BrowserDialog("Select directory for savegames");
|
2003-11-03 00:24:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Activate the first tab
|
|
|
|
tab->setActiveTab(0);
|
2002-12-12 23:22:48 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
GlobalOptionsDialog::~GlobalOptionsDialog() {
|
2003-03-25 15:32:36 +00:00
|
|
|
delete _browser;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GlobalOptionsDialog::open() {
|
|
|
|
Dialog::open();
|
|
|
|
|
2003-10-08 21:59:23 +00:00
|
|
|
_soundVolumeMaster = ConfMan.getInt("master_volume");
|
2003-03-25 15:32:36 +00:00
|
|
|
_masterVolumeSlider->setValue(_soundVolumeMaster);
|
|
|
|
_masterVolumeLabel->setValue(_soundVolumeMaster);
|
2003-11-01 22:21:18 +00:00
|
|
|
|
|
|
|
_soundVolumeMusic = ConfMan.getInt("music_volume");
|
|
|
|
_musicVolumeSlider->setValue(_soundVolumeMusic);
|
2003-03-25 15:32:36 +00:00
|
|
|
_musicVolumeLabel->setValue(_soundVolumeMusic);
|
2003-11-01 22:21:18 +00:00
|
|
|
|
|
|
|
_soundVolumeSfx = ConfMan.getInt("sfx_volume");
|
|
|
|
_sfxVolumeSlider->setValue(_soundVolumeSfx);
|
2003-03-25 15:32:36 +00:00
|
|
|
_sfxVolumeLabel->setValue(_soundVolumeSfx);
|
2002-12-12 23:22:48 +00:00
|
|
|
}
|
|
|
|
|
2003-03-06 19:52:54 +00:00
|
|
|
void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
2003-03-25 15:32:36 +00:00
|
|
|
switch (cmd) {
|
|
|
|
case kChooseSaveDirCmd:
|
|
|
|
if (_browser->runModal()) {
|
|
|
|
// User made his choice...
|
|
|
|
FilesystemNode *dir = _browser->getResult();
|
|
|
|
_savePath->setLabel(dir->path());
|
2003-10-08 21:59:23 +00:00
|
|
|
// TODO - we should check if the directory is writeable before accepting it
|
2003-03-25 15:32:36 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kMasterVolumeChanged:
|
|
|
|
_soundVolumeMaster = _masterVolumeSlider->getValue();
|
|
|
|
_masterVolumeLabel->setValue(_soundVolumeMaster);
|
|
|
|
_masterVolumeLabel->draw();
|
|
|
|
break;
|
|
|
|
case kMusicVolumeChanged:
|
|
|
|
_soundVolumeMusic = _musicVolumeSlider->getValue();
|
|
|
|
_musicVolumeLabel->setValue(_soundVolumeMusic);
|
|
|
|
_musicVolumeLabel->draw();
|
|
|
|
break;
|
|
|
|
case kSfxVolumeChanged:
|
|
|
|
_soundVolumeSfx = _sfxVolumeSlider->getValue();
|
|
|
|
_sfxVolumeLabel->setValue(_soundVolumeSfx);
|
|
|
|
_sfxVolumeLabel->draw();
|
|
|
|
break;
|
2003-03-26 20:43:58 +00:00
|
|
|
case kPopUpItemSelectedCmd:
|
|
|
|
if (sender == _midiPopUp) {
|
2003-10-02 22:52:57 +00:00
|
|
|
const MidiDriverDescription *md = getAvailableMidiDrivers();
|
2003-06-11 06:49:47 +00:00
|
|
|
for (; md->name; md++) {
|
|
|
|
if (md->id == (int) data) {
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.set("music_driver", md->name);
|
2003-06-11 06:49:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-03-26 20:43:58 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-03-25 15:32:36 +00:00
|
|
|
case kOKCmd:
|
2002-12-12 23:22:48 +00:00
|
|
|
setResult(1);
|
2003-10-08 21:59:23 +00:00
|
|
|
ConfMan.set("master_volume", _soundVolumeMaster);
|
|
|
|
ConfMan.set("music_volume", _soundVolumeMusic);
|
|
|
|
ConfMan.set("sfx_volume", _soundVolumeSfx);
|
2002-12-12 23:22:48 +00:00
|
|
|
close();
|
2003-03-25 15:32:36 +00:00
|
|
|
break;
|
|
|
|
default:
|
2002-12-12 23:22:48 +00:00
|
|
|
Dialog::handleCommand(sender, cmd, data);
|
|
|
|
}
|
|
|
|
}
|