aboutsummaryrefslogtreecommitdiff
path: root/gui/options.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/options.cpp')
-rw-r--r--gui/options.cpp179
1 files changed, 116 insertions, 63 deletions
diff --git a/gui/options.cpp b/gui/options.cpp
index cb42735246..f4ffaf98e5 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -55,6 +55,8 @@ enum {
OptionsDialog::OptionsDialog(const String &domain, int x, int y, int w, int h)
: Dialog(x, y, w, h),
_domain(domain),
+ _isActiveDomain(domain.isEmpty() || domain == ConfMan.getActiveDomain() ||
+ (ConfMan.getActiveDomain().isEmpty() && domain == Common::ConfigManager::kApplicationDomain)),
_enableGraphicSettings(false),
_gfxPopUp(0), _fullscreenCheckbox(0), _aspectCheckbox(0),
_enableAudioSettings(false),
@@ -64,6 +66,7 @@ OptionsDialog::OptionsDialog(const String &domain, int x, int y, int w, int h)
_musicVolumeSlider(0), _musicVolumeLabel(0),
_sfxVolumeSlider(0), _sfxVolumeLabel(0) {
+printf("_isActiveDomain = %d, _domain = %s, active domain = %s\n", _isActiveDomain, _domain.c_str(), ConfMan.getActiveDomain().c_str());
}
void OptionsDialog::open() {
@@ -71,15 +74,49 @@ void OptionsDialog::open() {
// Reset result value
setResult(0);
+
+ loadSettings();
+}
+
+void OptionsDialog::handleScreenChanged() {
+ loadSettings();
+}
+
+void OptionsDialog::close() {
+ if (getResult() == kSaveCmd) {
+ saveSettings();
+ }
+
+ if (_isActiveDomain && (getResult() == kSaveCmd || getResult() == kApplyCmd)) {
+ applySettings();
+ }
+
+ Dialog::close();
+}
+
+void OptionsDialog::applySettings() {
+ // Activate changes now
+ if (_enableGraphicSettings) {
+ g_system->setFeatureState(OSystem::kFeatureFullscreenMode, _fullscreenCheckbox->getState());
+ g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, _aspectCheckbox->getState());
+ if ((int32)_gfxPopUp->getSelectedTag() >= 0)
+ g_system->setGraphicsMode(_gfxPopUp->getSelectedTag());
+ }
+}
+
+void OptionsDialog::loadSettings() {
+ bool state;
if (_fullscreenCheckbox) {
_gfxPopUp->setSelected(0);
- _gfxPopUp->setEnabled(false);
- if (ConfMan.hasKey("gfx_mode", _domain)) {
+ if (_isActiveDomain) {
+ int gfxMode = g_system->getGraphicsMode();
+ _gfxPopUp->setSelectedTag(gfxMode);
+ } else if (ConfMan.hasKey("gfx_mode", _domain)) {
const OSystem::GraphicsMode *gm = g_system->getSupportedGraphicsModes();
- String gfxMode = ConfMan.get("gfx_mode", _domain);
int gfxCount = 1;
+ String gfxMode = ConfMan.get("gfx_mode", _domain);
while (gm->name) {
gfxCount++;
@@ -92,10 +129,16 @@ void OptionsDialog::open() {
#ifndef _WIN32_WCE
// Fullscreen setting
- _fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain));
+ state = _isActiveDomain ?
+ g_system->getFeatureState(OSystem::kFeatureFullscreenMode) :
+ ConfMan.getBool("fullscreen", _domain);
+ _fullscreenCheckbox->setState(state);
// Aspect ratio setting
- _aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain));
+ state = _isActiveDomain ?
+ g_system->getFeatureState(OSystem::kFeatureAspectRatioCorrection) :
+ ConfMan.getBool("aspect_ratio", _domain);
+ _aspectCheckbox->setState(state);
#endif
}
@@ -140,59 +183,55 @@ void OptionsDialog::open() {
}
}
-void OptionsDialog::close() {
- if (getResult()) {
- if (_fullscreenCheckbox) {
- if (_enableGraphicSettings) {
- ConfMan.set("fullscreen", _fullscreenCheckbox->getState(), _domain);
- ConfMan.set("aspect_ratio", _aspectCheckbox->getState(), _domain);
-
- if ((int32)_gfxPopUp->getSelectedTag() >= 0)
- ConfMan.set("gfx_mode", _gfxPopUp->getSelectedString(), _domain);
- } else {
- ConfMan.removeKey("fullscreen", _domain);
- ConfMan.removeKey("aspect_ratio", _domain);
- ConfMan.removeKey("gfx_mode", _domain);
- }
+void OptionsDialog::saveSettings() {
+ if (_fullscreenCheckbox) {
+ if (_enableGraphicSettings) {
+ ConfMan.set("fullscreen", _fullscreenCheckbox->getState(), _domain);
+ ConfMan.set("aspect_ratio", _aspectCheckbox->getState(), _domain);
+
+ if ((int32)_gfxPopUp->getSelectedTag() >= 0)
+ ConfMan.set("gfx_mode", _gfxPopUp->getSelectedString(), _domain);
+ } else {
+ ConfMan.removeKey("fullscreen", _domain);
+ ConfMan.removeKey("aspect_ratio", _domain);
+ ConfMan.removeKey("gfx_mode", _domain);
}
+ }
- if (_masterVolumeSlider) {
- 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);
- }
+ if (_masterVolumeSlider) {
+ 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);
}
+ }
- if (_multiMidiCheckbox) {
- if (_enableAudioSettings) {
- ConfMan.set("multi_midi", _multiMidiCheckbox->getState(), _domain);
- ConfMan.set("native_mt32", _mt32Checkbox->getState(), _domain);
- ConfMan.set("subtitles", _subCheckbox->getState(), _domain);
- 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);
+ if (_multiMidiCheckbox) {
+ if (_enableAudioSettings) {
+ ConfMan.set("multi_midi", _multiMidiCheckbox->getState(), _domain);
+ ConfMan.set("native_mt32", _mt32Checkbox->getState(), _domain);
+ ConfMan.set("subtitles", _subCheckbox->getState(), _domain);
+ 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);
- ConfMan.removeKey("subtitles", _domain);
- }
+ } else {
+ ConfMan.removeKey("multi_midi", _domain);
+ ConfMan.removeKey("native_mt32", _domain);
+ ConfMan.removeKey("music_driver", _domain);
+ ConfMan.removeKey("subtitles", _domain);
}
-
- // Save config file
- ConfMan.flushToDisk();
}
- Dialog::close();
+ // Save config file
+ ConfMan.flushToDisk();
}
void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
@@ -209,10 +248,14 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
_sfxVolumeLabel->setValue(_sfxVolumeSlider->getValue());
_sfxVolumeLabel->draw();
break;
- case kOKCmd:
- setResult(1);
+ case kApplyCmd:
+ case kSaveCmd:
+ setResult(cmd);
close();
break;
+ case kRevertCmd:
+ // TODO: Implement this!
+ break;
default:
Dialog::handleCommand(sender, cmd, data);
}
@@ -344,7 +387,7 @@ int OptionsDialog::addVolumeControls(GuiObject *boss, int yoffset) {
GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector)
- : OptionsDialog(Common::ConfigManager::kApplicationDomain, 10, 20, 320 - 2 * 10, 200 - 2 * 20) {
+ : OptionsDialog(Common::ConfigManager::kApplicationDomain, 10, 10, 320 - 2 * 10, 200 - 2 * 10) {
const int vBorder = 5;
int yoffset;
@@ -388,19 +431,30 @@ GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector)
tab->setActiveTab(0);
// Add OK & Cancel buttons
- addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Cancel", kCloseCmd, 0);
- addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0);
+ addButton(10, _h - 24, "Revert", kRevertCmd, 0);
+ addButton(_w - 2 * (kButtonWidth + 10), _h - 24, "Save", kSaveCmd, 0);
+ addButton(_w - (kButtonWidth + 10), _h - 24, "Apply", kApplyCmd, 0);
// Create file browser dialog
_browser = new BrowserDialog("Select directory for savegames");
+
+ setGraphicSettingsState(true);
+ setAudioSettingsState(true);
+ setVolumeSettingsState(true);
}
GlobalOptionsDialog::~GlobalOptionsDialog() {
delete _browser;
}
-void GlobalOptionsDialog::open() {
- OptionsDialog::open();
+void GlobalOptionsDialog::applySettings() {
+ OptionsDialog::applySettings();
+
+ // TODO ?
+}
+
+void GlobalOptionsDialog::loadSettings() {
+ OptionsDialog::loadSettings();
#if !( defined(__DC__) || defined(__GP32__) )
// Set _savePath to the current save path
@@ -416,12 +470,11 @@ void GlobalOptionsDialog::open() {
#endif
}
-void GlobalOptionsDialog::close() {
- if (getResult()) {
- // Savepath
- ConfMan.set("savepath", _savePath->getLabel(), _domain);
- }
- OptionsDialog::close();
+void GlobalOptionsDialog::saveSettings() {
+ // Savepath
+ ConfMan.set("savepath", _savePath->getLabel(), _domain);
+
+ OptionsDialog::saveSettings();
}
void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {