[Scummvm-cvs-logs] CVS: scummvm/gui launcher.cpp,1.75,1.76 options.cpp,1.40,1.41 options.h,1.10,1.11 widget.cpp,1.28,1.29

Max Horn fingolfin at users.sourceforge.net
Fri Nov 7 08:03:14 CET 2003


Update of /cvsroot/scummvm/scummvm/gui
In directory sc8-pr-cvs1:/tmp/cvs-serv22881

Modified Files:
	launcher.cpp options.cpp options.h widget.cpp 
Log Message:
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)

Index: launcher.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/launcher.cpp,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- launcher.cpp	5 Nov 2003 22:06:06 -0000	1.75
+++ launcher.cpp	7 Nov 2003 16:01:50 -0000	1.76
@@ -53,7 +53,12 @@
 	kAddGameCmd = 'ADDG',
 	kEditGameCmd = 'EDTG',
 	kRemoveGameCmd = 'REMG',
-	kQuitCmd = 'QUIT'
+	kQuitCmd = 'QUIT',
+	
+	
+	kCmdGlobalGraphicsOverride = 'OGFX',
+	kCmdGlobalAudioOverride = 'OSFX',
+	kCmdGlobalVolumeOverride = 'OVOL'
 };
 
 /*
@@ -88,10 +93,14 @@
 
 	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 @@
 	//
 	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 @@
 	//
 	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 @@
 	//
 	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 @@
 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::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 @@
 			ConfMan.renameGameDomain(_domain, newDomain);
 			_domain = newDomain;
 		}
+		}
+		// FALL THROUGH to default case
+	default:
+		OptionsDialog::handleCommand(sender, cmd, data);
 	}
-	OptionsDialog::handleCommand(sender, cmd, data);
 }
 
 

Index: options.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- options.cpp	5 Nov 2003 22:06:07 -0000	1.40
+++ options.cpp	7 Nov 2003 16:01:51 -0000	1.41
@@ -53,8 +53,11 @@
 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 @@
 	// 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::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 @@
 	// Aspect ratio checkbox
 	_aspectCheckbox = new CheckboxWidget(boss, x, yoffset, w, 16, "Aspect ratio correction");
 	yoffset += 16;
+	
+	_enableGraphicSettings = true;
 
 	return yoffset;
 }
@@ -223,6 +282,8 @@
 	// 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 @@
 	_sfxVolumeSlider->setMinValue(0); _sfxVolumeSlider->setMaxValue(255);
 	_sfxVolumeLabel->setFlags(WIDGET_CLEARBG);
 	yoffset += 16;
+	
+	_enableVolumeSettings = true;
 
 	return yoffset;
 }

Index: options.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/options.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- options.h	5 Nov 2003 12:25:42 -0000	1.10
+++ options.h	7 Nov 2003 16:01:51 -0000	1.11
@@ -52,11 +52,16 @@
 	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 @@
 	//
 	// MIDI controls
 	//
+	bool _enableAudioSettings;
 	PopUpWidget *_midiPopUp;
-
 	CheckboxWidget *_multiMidiCheckbox;
 	CheckboxWidget *_mt32Checkbox;
 
 	//
 	// Volume controls
 	//
+	bool _enableVolumeSettings;
+
 	SliderWidget *_masterVolumeSlider;
 	StaticTextWidget *_masterVolumeLabel;
 

Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- widget.cpp	7 Nov 2003 15:05:14 -0000	1.28
+++ widget.cpp	7 Nov 2003 16:01:51 -0000	1.29
@@ -167,7 +167,6 @@
 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 @@
 		_flags ^= WIDGET_INV_BORDER;
 		draw();
 	}
+	sendCommand(_cmd, _state);
 }
 
 void CheckboxWidget::drawWidget(bool hilite) {
@@ -248,7 +248,9 @@
 	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) {





More information about the Scummvm-git-logs mailing list