aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorMax Horn2003-11-07 16:01:51 +0000
committerMax Horn2003-11-07 16:01:51 +0000
commita93c9f49ba970fc9abaecbee99dc5ea96ec5a345 (patch)
tree3859d1632c9d43fbb9c11ba893e6a1080bcccf63 /gui
parentced5921ac08e0c352f0f4d41bbafcfa2282adb67 (diff)
downloadscummvm-rg350-a93c9f49ba970fc9abaecbee99dc5ea96ec5a345.tar.gz
scummvm-rg350-a93c9f49ba970fc9abaecbee99dc5ea96ec5a345.tar.bz2
scummvm-rg350-a93c9f49ba970fc9abaecbee99dc5ea96ec5a345.zip
added checkboxes to the 'Edit Game...' dialog which let the user determine whether to override global settings or not; besides other things, this fixes bug #837599 (Default volume is 0 for newly added games)
svn-id: r11196
Diffstat (limited to 'gui')
-rw-r--r--gui/launcher.cpp62
-rw-r--r--gui/options.cpp165
-rw-r--r--gui/options.h9
-rw-r--r--gui/widget.cpp6
4 files changed, 184 insertions, 58 deletions
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 5dc1bfbede..c1596d95c5 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -53,7 +53,12 @@ enum {
kAddGameCmd = 'ADDG',
kEditGameCmd = 'EDTG',
kRemoveGameCmd = 'REMG',
- kQuitCmd = 'QUIT'
+ kQuitCmd = 'QUIT',
+
+
+ kCmdGlobalGraphicsOverride = 'OGFX',
+ kCmdGlobalAudioOverride = 'OSFX',
+ kCmdGlobalVolumeOverride = 'OVOL'
};
/*
@@ -88,10 +93,14 @@ protected:
PopUpWidget *_langPopUp;
PopUpWidget *_platformPopUp;
+
+ CheckboxWidget *_globalGraphicsOverride;
+ CheckboxWidget *_globalAudioOverride;
+ CheckboxWidget *_globalVolumeOverride;
};
EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
- : OptionsDialog(domain, 10, 50, 320 - 2 * 10, 140) {
+ : OptionsDialog(domain, 10, 40, 320 - 2 * 10, 140) {
const int x = 5;
const int w = _w - 15;
@@ -157,6 +166,10 @@ EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
//
tab->addTab("Graphics");
yoffset = vBorder;
+
+ _globalGraphicsOverride = new CheckboxWidget(tab, x, yoffset, w, 16, "Override global graphic settings", kCmdGlobalGraphicsOverride);
+ yoffset += 16;
+
yoffset = addGraphicControls(tab, yoffset);
//
@@ -164,6 +177,10 @@ EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
//
tab->addTab("Audio");
yoffset = vBorder;
+
+ _globalAudioOverride = new CheckboxWidget(tab, x, yoffset, w, 16, "Override global audio settings", kCmdGlobalAudioOverride);
+ yoffset += 16;
+
yoffset = addMIDIControls(tab, yoffset);
//
@@ -171,6 +188,10 @@ EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
//
tab->addTab("Volume");
yoffset = vBorder;
+
+ _globalVolumeOverride = new CheckboxWidget(tab, x, yoffset, w, 16, "Override global volume settings", kCmdGlobalVolumeOverride);
+ yoffset += 16;
+
yoffset = addVolumeControls(tab, yoffset);
@@ -185,6 +206,23 @@ EditGameDialog::EditGameDialog(const String &domain, GameSettings target)
void EditGameDialog::open() {
OptionsDialog::open();
+ // En-/disable dialog items depending on whether overrides are active or not.
+ bool e;
+
+ e = ConfMan.hasKey("fullscreen", _domain) ||
+ ConfMan.hasKey("aspect_ratio", _domain);
+ _globalGraphicsOverride->setState(e);
+
+ e = ConfMan.hasKey("music_driver", _domain) ||
+ ConfMan.hasKey("multi_midi", _domain) ||
+ ConfMan.hasKey("native_mt32", _domain);
+ _globalAudioOverride->setState(e);
+
+ e = ConfMan.hasKey("master_volume", _domain) ||
+ ConfMan.hasKey("music_volume", _domain) ||
+ ConfMan.hasKey("sfx_volume", _domain);
+ _globalVolumeOverride->setState(e);
+
int sel = 0;
// TODO: game path
@@ -229,7 +267,20 @@ void EditGameDialog::close() {
}
void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
- if (cmd == kOKCmd) {
+ switch (cmd) {
+ case kCmdGlobalGraphicsOverride:
+ setGraphicSettingsState(data != 0);
+ draw();
+ break;
+ case kCmdGlobalAudioOverride:
+ setAudioSettingsState(data != 0);
+ draw();
+ break;
+ case kCmdGlobalVolumeOverride:
+ setVolumeSettingsState(data != 0);
+ draw();
+ break;
+ case kOKCmd: {
// Write back changes made to config object
String newDomain(_domainWidget->getLabel());
if (newDomain != _domain) {
@@ -241,8 +292,11 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
ConfMan.renameGameDomain(_domain, newDomain);
_domain = newDomain;
}
+ }
+ // FALL THROUGH to default case
+ default:
+ OptionsDialog::handleCommand(sender, cmd, data);
}
- OptionsDialog::handleCommand(sender, cmd, data);
}
diff --git a/gui/options.cpp b/gui/options.cpp
index 1346434050..8e995e06e5 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -53,8 +53,11 @@ enum {
OptionsDialog::OptionsDialog(const String &domain, int x, int y, int w, int h)
: Dialog(x, y, w, h),
_domain(domain),
+ _enableGraphicSettings(false),
_gfxPopUp(0), _fullscreenCheckbox(0), _aspectCheckbox(0),
+ _enableAudioSettings(false),
_multiMidiCheckbox(0), _mt32Checkbox(0),
+ _enableVolumeSettings(false),
_masterVolumeSlider(0), _masterVolumeLabel(0),
_musicVolumeSlider(0), _musicVolumeLabel(0),
_sfxVolumeSlider(0), _sfxVolumeLabel(0) {
@@ -67,71 +70,97 @@ void OptionsDialog::open() {
// Reset result value
setResult(0);
- // FIXME - disable GFX popup for now
- _gfxPopUp->setSelected(0);
- _gfxPopUp->setEnabled(false);
-
- // Fullscreen setting
- _fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain));
-
- // Aspect ratio setting
- _aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain));
-
- // Music driver
- const MidiDriverDescription *md = getAvailableMidiDrivers();
- const int midiDriver = parseMusicDriver(ConfMan.get("music_driver", _domain));
- int i = 0;
- while (md->name && md->id != midiDriver) {
- i++;
- md++;
+ if (_fullscreenCheckbox) {
+ // FIXME - disable GFX popup for now
+ _gfxPopUp->setSelected(0);
+ _gfxPopUp->setEnabled(false);
+
+ // Fullscreen setting
+ _fullscreenCheckbox->setState(ConfMan.getBool("fullscreen", _domain));
+
+ // Aspect ratio setting
+ _aspectCheckbox->setState(ConfMan.getBool("aspect_ratio", _domain));
}
- _midiPopUp->setSelected(md->name ? i : 0);
- // Multi midi setting
- _multiMidiCheckbox->setState(ConfMan.getBool("multi_midi", _domain));
-
- // Native mt32 setting
- _mt32Checkbox->setState(ConfMan.getBool("native_mt32", _domain));
-
- int vol;
-
- vol = ConfMan.getInt("master_volume", _domain);
- _masterVolumeSlider->setValue(vol);
- _masterVolumeLabel->setValue(vol);
-
- vol = ConfMan.getInt("music_volume", _domain);
- _musicVolumeSlider->setValue(vol);
- _musicVolumeLabel->setValue(vol);
-
- vol = ConfMan.getInt("sfx_volume", _domain);
- _sfxVolumeSlider->setValue(vol);
- _sfxVolumeLabel->setValue(vol);
+ 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);
+
+ // Multi midi setting
+ _multiMidiCheckbox->setState(ConfMan.getBool("multi_midi", _domain));
+
+ // Native mt32 setting
+ _mt32Checkbox->setState(ConfMan.getBool("native_mt32", _domain));
+ }
+
+ if (_masterVolumeSlider) {
+ int vol;
+
+ vol = ConfMan.getInt("master_volume", _domain);
+ _masterVolumeSlider->setValue(vol);
+ _masterVolumeLabel->setValue(vol);
+
+ vol = ConfMan.getInt("music_volume", _domain);
+ _musicVolumeSlider->setValue(vol);
+ _musicVolumeLabel->setValue(vol);
+
+ vol = ConfMan.getInt("sfx_volume", _domain);
+ _sfxVolumeSlider->setValue(vol);
+ _sfxVolumeLabel->setValue(vol);
+ }
}
void OptionsDialog::close() {
if (getResult()) {
if (_fullscreenCheckbox) {
- ConfMan.set("fullscreen", _fullscreenCheckbox->getState(), _domain);
- ConfMan.set("aspect_ratio", _aspectCheckbox->getState(), _domain);
+ 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);
+ }
}
if (_masterVolumeSlider) {
- ConfMan.set("master_volume", _masterVolumeSlider->getValue(), _domain);
- ConfMan.set("music_volume", _musicVolumeSlider->getValue(), _domain);
- ConfMan.set("sfx_volume", _sfxVolumeSlider->getValue(), _domain);
+ 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) {
- ConfMan.set("multi_midi", _multiMidiCheckbox->getState(), _domain);
- ConfMan.set("native_mt32", _mt32Checkbox->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
+ if (_enableAudioSettings) {
+ ConfMan.set("multi_midi", _multiMidiCheckbox->getState(), _domain);
+ ConfMan.set("native_mt32", _mt32Checkbox->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);
ConfMan.removeKey("music_driver", _domain);
+ }
}
// Save config file
@@ -164,6 +193,34 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
}
}
+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);
+}
+
+
int OptionsDialog::addGraphicControls(GuiObject *boss, int yoffset) {
const int x = 10;
const int w = _w - 2 * 10;
@@ -197,6 +254,8 @@ int OptionsDialog::addGraphicControls(GuiObject *boss, int yoffset) {
// Aspect ratio checkbox
_aspectCheckbox = new CheckboxWidget(boss, x, yoffset, w, 16, "Aspect ratio correction");
yoffset += 16;
+
+ _enableGraphicSettings = true;
return yoffset;
}
@@ -223,6 +282,8 @@ int OptionsDialog::addMIDIControls(GuiObject *boss, int yoffset) {
// Native mt32 setting
_mt32Checkbox = new CheckboxWidget(boss, x, yoffset, w, 16, "True Roland MT-32 (disable GM emulation)");
yoffset += 16;
+
+ _enableAudioSettings = true;
return yoffset;
}
@@ -246,6 +307,8 @@ int OptionsDialog::addVolumeControls(GuiObject *boss, int yoffset) {
_sfxVolumeSlider->setMinValue(0); _sfxVolumeSlider->setMaxValue(255);
_sfxVolumeLabel->setFlags(WIDGET_CLEARBG);
yoffset += 16;
+
+ _enableVolumeSettings = true;
return yoffset;
}
diff --git a/gui/options.h b/gui/options.h
index ead93b545a..53ea5e76f0 100644
--- a/gui/options.h
+++ b/gui/options.h
@@ -52,11 +52,16 @@ protected:
int addGraphicControls(GuiObject *boss, int yoffset);
int addMIDIControls(GuiObject *boss, int yoffset);
int addVolumeControls(GuiObject *boss, int yoffset);
+
+ void setGraphicSettingsState(bool enabled);
+ void setAudioSettingsState(bool enabled);
+ void setVolumeSettingsState(bool enabled);
private:
//
// Graphics controls
//
+ bool _enableGraphicSettings;
PopUpWidget *_gfxPopUp;
CheckboxWidget *_fullscreenCheckbox;
CheckboxWidget *_aspectCheckbox;
@@ -64,14 +69,16 @@ private:
//
// MIDI controls
//
+ bool _enableAudioSettings;
PopUpWidget *_midiPopUp;
-
CheckboxWidget *_multiMidiCheckbox;
CheckboxWidget *_mt32Checkbox;
//
// Volume controls
//
+ bool _enableVolumeSettings;
+
SliderWidget *_masterVolumeSlider;
StaticTextWidget *_masterVolumeLabel;
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 9e1df23494..75254fcfe9 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -167,7 +167,6 @@ CheckboxWidget::CheckboxWidget(GuiObject *boss, int x, int y, int w, int h, cons
void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) {
if (isEnabled() && x >= 0 && x < _w && y >= 0 && y < _h) {
toggleState();
- sendCommand(_cmd, _state);
}
}
@@ -177,6 +176,7 @@ void CheckboxWidget::setState(bool state) {
_flags ^= WIDGET_INV_BORDER;
draw();
}
+ sendCommand(_cmd, _state);
}
void CheckboxWidget::drawWidget(bool hilite) {
@@ -248,7 +248,9 @@ void SliderWidget::drawWidget(bool hilite) {
gui->box(_x + _labelWidth, _y, _w - _labelWidth, _h, gui->_color, gui->_shadowcolor);
// Draw the 'bar'
- gui->fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
+ gui->fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4,
+ !isEnabled() ? gui->_color :
+ hilite ? gui->_textcolorhi : gui->_textcolor);
}
int SliderWidget::valueToPos(int value) {