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-11-05 12:25:42 +00:00
|
|
|
#include "common/scaler.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-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-11-05 12:25:42 +00:00
|
|
|
kMasterVolumeChanged = 'mavc',
|
2003-03-25 15:32:36 +00:00
|
|
|
kMusicVolumeChanged = 'muvc',
|
|
|
|
kSfxVolumeChanged = 'sfvc',
|
2003-11-05 12:25:42 +00:00
|
|
|
kChooseSaveDirCmd = 'chos'
|
2002-12-12 23:22:48 +00:00
|
|
|
};
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
OptionsDialog::OptionsDialog(const String &domain, int x, int y, int w, int h)
|
|
|
|
: Dialog(x, y, w, h),
|
|
|
|
_domain(domain),
|
2003-11-07 16:01:51 +00:00
|
|
|
_enableGraphicSettings(false),
|
2003-11-05 12:25:42 +00:00
|
|
|
_gfxPopUp(0), _fullscreenCheckbox(0), _aspectCheckbox(0),
|
2003-11-07 16:01:51 +00:00
|
|
|
_enableAudioSettings(false),
|
2003-11-05 12:25:42 +00:00
|
|
|
_multiMidiCheckbox(0), _mt32Checkbox(0),
|
2003-11-07 16:01:51 +00:00
|
|
|
_enableVolumeSettings(false),
|
2003-11-05 12:25:42 +00:00
|
|
|
_masterVolumeSlider(0), _masterVolumeLabel(0),
|
|
|
|
_musicVolumeSlider(0), _musicVolumeLabel(0),
|
|
|
|
_sfxVolumeSlider(0), _sfxVolumeLabel(0) {
|
2003-11-03 00:24:04 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
2003-11-03 00:24:04 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
void OptionsDialog::open() {
|
|
|
|
Dialog::open();
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// Reset result value
|
|
|
|
setResult(0);
|
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
if (_fullscreenCheckbox) {
|
|
|
|
// FIXME - disable GFX popup for now
|
|
|
|
_gfxPopUp->setSelected(0);
|
|
|
|
_gfxPopUp->setEnabled(false);
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
// Fullscreen setting
|
|
|
|
_fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain));
|
|
|
|
|
|
|
|
// Aspect ratio setting
|
|
|
|
_aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain));
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
if (_multiMidiCheckbox) {
|
|
|
|
// Music driver
|
|
|
|
const MidiDriverDescription *md = getAvailableMidiDrivers();
|
|
|
|
int i = 0;
|
|
|
|
const int midiDriver =
|
|
|
|
ConfMan.hasKey("music_driver", _domain)
|
|
|
|
? parseMusicDriver(ConfMan.get("music_driver", _domain))
|
|
|
|
: MD_AUTO;
|
|
|
|
while (md->name && md->id != midiDriver) {
|
|
|
|
i++;
|
|
|
|
md++;
|
|
|
|
}
|
|
|
|
_midiPopUp->setSelected(md->name ? i : 0);
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
// Multi midi setting
|
|
|
|
_multiMidiCheckbox->setState(ConfMan.getBool("multi_midi", _domain));
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
// Native mt32 setting
|
|
|
|
_mt32Checkbox->setState(ConfMan.getBool("native_mt32", _domain));
|
|
|
|
}
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
if (_masterVolumeSlider) {
|
|
|
|
int vol;
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
vol = ConfMan.getInt("master_volume", _domain);
|
|
|
|
_masterVolumeSlider->setValue(vol);
|
|
|
|
_masterVolumeLabel->setValue(vol);
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
vol = ConfMan.getInt("music_volume", _domain);
|
|
|
|
_musicVolumeSlider->setValue(vol);
|
|
|
|
_musicVolumeLabel->setValue(vol);
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
vol = ConfMan.getInt("sfx_volume", _domain);
|
|
|
|
_sfxVolumeSlider->setValue(vol);
|
|
|
|
_sfxVolumeLabel->setValue(vol);
|
|
|
|
}
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OptionsDialog::close() {
|
|
|
|
if (getResult()) {
|
|
|
|
if (_fullscreenCheckbox) {
|
2003-11-07 16:01:51 +00:00
|
|
|
if (_enableGraphicSettings) {
|
|
|
|
ConfMan.set("fullscreen", _fullscreenCheckbox->getState(), _domain);
|
|
|
|
ConfMan.set("aspect_ratio", _aspectCheckbox->getState(), _domain);
|
|
|
|
} else {
|
|
|
|
ConfMan.removeKey("fullscreen", _domain);
|
|
|
|
ConfMan.removeKey("aspect_ratio", _domain);
|
|
|
|
}
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_masterVolumeSlider) {
|
2003-11-07 16:01:51 +00:00
|
|
|
if (_enableVolumeSettings) {
|
|
|
|
ConfMan.set("master_volume", _masterVolumeSlider->getValue(), _domain);
|
|
|
|
ConfMan.set("music_volume", _musicVolumeSlider->getValue(), _domain);
|
|
|
|
ConfMan.set("sfx_volume", _sfxVolumeSlider->getValue(), _domain);
|
|
|
|
} else {
|
|
|
|
ConfMan.removeKey("master_volume", _domain);
|
|
|
|
ConfMan.removeKey("music_volume", _domain);
|
|
|
|
ConfMan.removeKey("sfx_volume", _domain);
|
|
|
|
}
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
2003-11-03 00:24:04 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
if (_multiMidiCheckbox) {
|
2003-11-07 16:01:51 +00:00
|
|
|
if (_enableAudioSettings) {
|
|
|
|
ConfMan.set("multi_midi", _multiMidiCheckbox->getState(), _domain);
|
|
|
|
ConfMan.set("native_mt32", _mt32Checkbox->getState(), _domain);
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
const MidiDriverDescription *md = getAvailableMidiDrivers();
|
|
|
|
while (md->name && md->id != (int)_midiPopUp->getSelectedTag())
|
|
|
|
md++;
|
|
|
|
if (md->name)
|
|
|
|
ConfMan.set("music_driver", md->name, _domain);
|
|
|
|
else
|
|
|
|
ConfMan.removeKey("music_driver", _domain);
|
|
|
|
} else {
|
|
|
|
ConfMan.removeKey("multi_midi", _domain);
|
|
|
|
ConfMan.removeKey("native_mt32", _domain);
|
2003-11-05 12:25:42 +00:00
|
|
|
ConfMan.removeKey("music_driver", _domain);
|
2003-11-07 16:01:51 +00:00
|
|
|
}
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// Save config file
|
|
|
|
ConfMan.flushToDisk();
|
|
|
|
}
|
|
|
|
|
|
|
|
Dialog::close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
|
|
|
switch (cmd) {
|
|
|
|
case kMasterVolumeChanged:
|
|
|
|
_masterVolumeLabel->setValue(_masterVolumeSlider->getValue());
|
|
|
|
_masterVolumeLabel->draw();
|
|
|
|
break;
|
|
|
|
case kMusicVolumeChanged:
|
|
|
|
_musicVolumeLabel->setValue(_musicVolumeSlider->getValue());
|
|
|
|
_musicVolumeLabel->draw();
|
|
|
|
break;
|
|
|
|
case kSfxVolumeChanged:
|
|
|
|
_sfxVolumeLabel->setValue(_sfxVolumeSlider->getValue());
|
|
|
|
_sfxVolumeLabel->draw();
|
|
|
|
break;
|
|
|
|
case kOKCmd:
|
|
|
|
setResult(1);
|
|
|
|
close();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Dialog::handleCommand(sender, cmd, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
void OptionsDialog::setGraphicSettingsState(bool enabled) {
|
|
|
|
_enableGraphicSettings = enabled;
|
|
|
|
|
|
|
|
// _gfxPopUp->setEnabled(enabled);
|
|
|
|
_fullscreenCheckbox->setEnabled(enabled);
|
|
|
|
_aspectCheckbox->setEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionsDialog::setAudioSettingsState(bool enabled) {
|
|
|
|
_enableAudioSettings = enabled;
|
|
|
|
|
|
|
|
_midiPopUp->setEnabled(enabled);
|
|
|
|
_multiMidiCheckbox->setEnabled(enabled);
|
|
|
|
_mt32Checkbox->setEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OptionsDialog::setVolumeSettingsState(bool enabled) {
|
|
|
|
_enableVolumeSettings = enabled;
|
|
|
|
|
|
|
|
_masterVolumeSlider->setEnabled(enabled);
|
|
|
|
_masterVolumeLabel->setEnabled(enabled);
|
|
|
|
_musicVolumeSlider->setEnabled(enabled);
|
|
|
|
_musicVolumeLabel->setEnabled(enabled);
|
|
|
|
_sfxVolumeSlider->setEnabled(enabled);
|
|
|
|
_sfxVolumeLabel->setEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
int OptionsDialog::addGraphicControls(GuiObject *boss, int yoffset) {
|
|
|
|
const int x = 10;
|
|
|
|
const int w = _w - 2 * 10;
|
|
|
|
|
|
|
|
// The GFX mode popup
|
2002-12-12 23:22:48 +00:00
|
|
|
// TODO - add an API to query the list of available GFX modes, and to get/set the mode
|
2003-11-05 12:25:42 +00:00
|
|
|
_gfxPopUp = new PopUpWidget(boss, x-5, yoffset, w+5, kLineHeight, "Graphics mode: ", 100);
|
2003-11-04 21:17:33 +00:00
|
|
|
yoffset += 16;
|
2003-11-03 05:27:53 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// FIXME: For the GlobalOptionsDialog, we don't want a <default> here;
|
|
|
|
// rather, we want to setSelected to the current global
|
2003-11-05 01:15:10 +00:00
|
|
|
_gfxPopUp->appendEntry("<default>");
|
|
|
|
_gfxPopUp->appendEntry("");
|
2003-11-05 12:25:42 +00:00
|
|
|
_gfxPopUp->appendEntry("Normal (no scaling)", GFX_NORMAL);
|
|
|
|
_gfxPopUp->appendEntry("2x", GFX_DOUBLESIZE);
|
|
|
|
_gfxPopUp->appendEntry("3x", GFX_TRIPLESIZE);
|
|
|
|
_gfxPopUp->appendEntry("2xSAI", GFX_2XSAI);
|
|
|
|
_gfxPopUp->appendEntry("Super2xSAI", GFX_SUPER2XSAI);
|
|
|
|
_gfxPopUp->appendEntry("SuperEagle", GFX_SUPEREAGLE);
|
|
|
|
_gfxPopUp->appendEntry("AdvMAME2x", GFX_ADVMAME2X);
|
|
|
|
_gfxPopUp->appendEntry("AdvMAME3x", GFX_ADVMAME3X);
|
|
|
|
_gfxPopUp->appendEntry("hq2x", GFX_HQ2X);
|
|
|
|
_gfxPopUp->appendEntry("hq3x", GFX_HQ3X);
|
|
|
|
_gfxPopUp->appendEntry("TV2x", GFX_TV2X);
|
|
|
|
_gfxPopUp->appendEntry("DotMatrix", GFX_DOTMATRIX);
|
|
|
|
|
|
|
|
// Fullscreen checkbox
|
|
|
|
_fullscreenCheckbox = new CheckboxWidget(boss, x, yoffset, w, 16, "Fullscreen mode");
|
2003-11-04 21:17:33 +00:00
|
|
|
yoffset += 16;
|
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// Aspect ratio checkbox
|
|
|
|
_aspectCheckbox = new CheckboxWidget(boss, x, yoffset, w, 16, "Aspect ratio correction");
|
2003-11-04 21:17:33 +00:00
|
|
|
yoffset += 16;
|
2003-11-07 16:01:51 +00:00
|
|
|
|
|
|
|
_enableGraphicSettings = true;
|
2003-11-03 00:24:04 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
return yoffset;
|
|
|
|
}
|
2003-11-03 00:24:04 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
int OptionsDialog::addMIDIControls(GuiObject *boss, int yoffset) {
|
|
|
|
const int x = 10;
|
|
|
|
const int w = _w - 20;
|
2002-12-12 23:22:48 +00:00
|
|
|
|
|
|
|
// The MIDI mode popup & a label
|
2003-11-05 12:25:42 +00:00
|
|
|
_midiPopUp = new PopUpWidget(boss, x-5, yoffset, w+5, kLineHeight, "Music driver: ", 100);
|
2003-11-04 21:17:33 +00:00
|
|
|
yoffset += 16;
|
2002-12-13 23:29:18 +00:00
|
|
|
|
|
|
|
// Populate it
|
2003-10-02 22:52:57 +00:00
|
|
|
const MidiDriverDescription *md = getAvailableMidiDrivers();
|
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);
|
2002-12-13 23:29:18 +00:00
|
|
|
md++;
|
|
|
|
}
|
2003-03-26 20:43:58 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// Multi midi setting
|
|
|
|
_multiMidiCheckbox = new CheckboxWidget(boss, x, yoffset, w, 16, "Mixed Adlib/MIDI mode");
|
|
|
|
yoffset += 16;
|
|
|
|
|
|
|
|
// Native mt32 setting
|
|
|
|
_mt32Checkbox = new CheckboxWidget(boss, x, yoffset, w, 16, "True Roland MT-32 (disable GM emulation)");
|
|
|
|
yoffset += 16;
|
2003-11-07 16:01:51 +00:00
|
|
|
|
|
|
|
_enableAudioSettings = true;
|
2003-11-05 12:25:42 +00:00
|
|
|
|
|
|
|
return yoffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
int OptionsDialog::addVolumeControls(GuiObject *boss, int yoffset) {
|
2003-11-03 00:24:04 +00:00
|
|
|
// Volume controllers
|
2003-11-05 12:25:42 +00:00
|
|
|
_masterVolumeSlider = new SliderWidget(boss, 5, yoffset, 185, 12, "Master volume: ", 100, kMasterVolumeChanged);
|
2003-11-08 23:22:16 +00:00
|
|
|
_masterVolumeLabel = new StaticTextWidget(boss, 200, yoffset + 2, 24, kLineHeight, "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-05 12:25:42 +00:00
|
|
|
_musicVolumeSlider = new SliderWidget(boss, 5, yoffset, 185, 12, "Music volume: ", 100, kMusicVolumeChanged);
|
2003-11-08 23:22:16 +00:00
|
|
|
_musicVolumeLabel = new StaticTextWidget(boss, 200, yoffset + 2, 24, kLineHeight, "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-05 12:25:42 +00:00
|
|
|
_sfxVolumeSlider = new SliderWidget(boss, 5, yoffset, 185, 12, "SFX volume: ", 100, kSfxVolumeChanged);
|
2003-11-08 23:22:16 +00:00
|
|
|
_sfxVolumeLabel = new StaticTextWidget(boss, 200, yoffset + 2, 24, kLineHeight, "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-08 23:22:16 +00:00
|
|
|
|
2003-11-07 16:01:51 +00:00
|
|
|
_enableVolumeSettings = true;
|
2003-11-04 21:17:33 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
return yoffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2002-12-12 23:22:48 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector)
|
|
|
|
: OptionsDialog(Common::ConfigManager::kApplicationDomain, 10, 20, 320 - 2 * 10, 200 - 2 * 20) {
|
|
|
|
|
|
|
|
const int vBorder = 5;
|
|
|
|
int yoffset;
|
|
|
|
|
|
|
|
// The tab widget
|
|
|
|
TabWidget *tab = new TabWidget(this, 0, vBorder, _w, _h - 24 - 2*vBorder);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 1) The graphics tab
|
|
|
|
//
|
|
|
|
tab->addTab("Graphics");
|
|
|
|
yoffset = vBorder;
|
|
|
|
yoffset = addGraphicControls(tab, yoffset);
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// 2) The audio tab
|
|
|
|
//
|
|
|
|
tab->addTab("Audio");
|
|
|
|
yoffset = vBorder;
|
|
|
|
yoffset = addMIDIControls(tab, yoffset);
|
|
|
|
yoffset = addVolumeControls(tab, yoffset);
|
2003-11-05 01:22:19 +00:00
|
|
|
// TODO: cd drive setting
|
2003-11-05 12:25:42 +00:00
|
|
|
|
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");
|
2003-11-04 21:17:33 +00:00
|
|
|
yoffset = vBorder;
|
2003-11-03 00:24:04 +00:00
|
|
|
|
|
|
|
#if !( defined(__DC__) || defined(__GP32__) )
|
|
|
|
// Save game path
|
2003-11-08 23:22:16 +00:00
|
|
|
new StaticTextWidget(tab, 5, yoffset + 2, 100, kLineHeight, "Savegame path: ", kTextAlignRight);
|
|
|
|
_savePath = new StaticTextWidget(tab, 105, yoffset + 2, 180, kLineHeight, "/foo/bar", kTextAlignLeft);
|
|
|
|
new ButtonWidget(tab, 105, yoffset + 14, 64, 16, "Choose...", kChooseSaveDirCmd, 0);
|
2003-04-03 16:01:03 +00:00
|
|
|
#endif
|
2003-11-03 00:24:04 +00:00
|
|
|
// TODO: joystick setting
|
|
|
|
|
2003-11-08 23:22:16 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
// Activate the first tab
|
|
|
|
tab->setActiveTab(0);
|
2002-12-14 01:49:08 +00:00
|
|
|
|
2002-12-12 23:22:48 +00:00
|
|
|
// Add OK & Cancel buttons
|
2003-03-06 19:52:54 +00:00
|
|
|
addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
|
|
|
|
addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
|
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");
|
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() {
|
2003-11-05 12:25:42 +00:00
|
|
|
OptionsDialog::open();
|
2003-11-01 22:21:18 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
#if !( defined(__DC__) || defined(__GP32__) )
|
|
|
|
// Set _savePath to the current save path
|
|
|
|
Common::String dir(ConfMan.get("savepath", _domain));
|
|
|
|
if (!dir.isEmpty()) {
|
|
|
|
_savePath->setLabel(dir);
|
|
|
|
} else {
|
|
|
|
// Default to the current directory...
|
|
|
|
char buf[256];
|
|
|
|
getcwd(buf, sizeof(buf));
|
|
|
|
_savePath->setLabel(buf);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2003-11-01 22:21:18 +00:00
|
|
|
|
2003-11-05 12:25:42 +00:00
|
|
|
void GlobalOptionsDialog::close() {
|
|
|
|
if (getResult()) {
|
2003-11-05 22:06:07 +00:00
|
|
|
// Savepath
|
|
|
|
ConfMan.set("savepath", _savePath->getLabel(), _domain);
|
2003-11-05 12:25:42 +00:00
|
|
|
}
|
|
|
|
OptionsDialog::close();
|
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;
|
|
|
|
default:
|
2003-11-05 12:25:42 +00:00
|
|
|
OptionsDialog::handleCommand(sender, cmd, data);
|
2002-12-12 23:22:48 +00:00
|
|
|
}
|
|
|
|
}
|