[Scummvm-cvs-logs] CVS: scummvm/gui dialog.cpp,1.26,1.27 dialog.h,1.16,1.17 widget.cpp,1.23,1.24 widget.h,1.21,1.22

Max Horn fingolfin at users.sourceforge.net
Fri Jul 26 17:06:16 CEST 2002


Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv1069/gui

Modified Files:
	dialog.cpp dialog.h widget.cpp widget.h 
Log Message:
improved the sound dialog; but my goal is to get rid of it, and merge the sound & misc dialogs into the options dialog

Index: dialog.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- dialog.cpp	26 Jul 2002 20:38:55 -0000	1.26
+++ dialog.cpp	27 Jul 2002 00:05:45 -0000	1.27
@@ -287,9 +287,6 @@
 	
 	// FIXME - test
 	new CheckboxWidget(this, 10, 20, 90, 16, "Toggle me", 0);
-
-	// FIXME - test
-	new SliderWidget(this, 110, 20, 80, 16, "Volume", 0);
 	
 	// FIXME - test
 	_savegameList = new ListWidget(this, 10, 40, 180, 74);
@@ -304,7 +301,7 @@
 		l.push_back(name);
 	}
 
-	((ListWidget *)_savegameList)->setList(l);
+	_savegameList->setList(l);
 }
 
 void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
@@ -356,11 +353,11 @@
 OptionsDialog::OptionsDialog(NewGui *gui)
 	: Dialog (gui, 50, 80, 210, 60)
 {
-	addButton( 10, 10, 40, 15, CUSTOM_STRING(5), kSoundCmd, 'S');	// Sound
-	addButton( 80, 10, 40, 15, CUSTOM_STRING(6), kKeysCmd, 'K');	// Keys
-	addButton(150, 10, 40, 15, CUSTOM_STRING(7), kAboutCmd, 'A');	// About
-	addButton( 10, 35, 40, 15, CUSTOM_STRING(18), kMiscCmd, 'M');	// Misc
-	addButton(150, 35, 40, 15, CUSTOM_STRING(23), kCloseCmd, 'C');	// Close dialog - FIXME
+	addButton( 10, 10, 40, 16, CUSTOM_STRING(5), kSoundCmd, 'S');	// Sound
+	addButton( 80, 10, 40, 16, CUSTOM_STRING(6), kKeysCmd, 'K');	// Keys
+	addButton(150, 10, 40, 16, CUSTOM_STRING(7), kAboutCmd, 'A');	// About
+	addButton( 10, 35, 40, 16, CUSTOM_STRING(18), kMiscCmd, 'M');	// Misc
+	addButton(150, 35, 40, 16, CUSTOM_STRING(23), kCloseCmd, 'C');	// Close dialog - FIXME
 }
 
 void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
@@ -387,7 +384,7 @@
 AboutDialog::AboutDialog(NewGui *gui)
 	: Dialog (gui, 30, 10, 260, 134)
 {
-	addButton(110, 110, 40, 15, CUSTOM_STRING(23), kCloseCmd, 'C');	// Close dialog - FIXME
+	addButton(110, 110, 40, 16, CUSTOM_STRING(23), kCloseCmd, 'C');	// Close dialog - FIXME
 	new StaticTextWidget(this, 10, 17, 240, 16, "Build " SCUMMVM_VERSION " (" SCUMMVM_CVS ")", true);
 	new StaticTextWidget(this, 10, 37, 240, 16, "ScummVM http://scummvm.sourceforge.net", true);
 	new StaticTextWidget(this, 10, 67, 240, 16, "All games (c) LucasArts", true);
@@ -406,40 +403,81 @@
 {
 
 	// set up dialog
-	addButton(110, 90, 40, 15, CUSTOM_STRING(23), kCloseCmd, 'C');	// Close dialog - FIXME
-	new StaticTextWidget(this, 10, 17, 140, 16, "Master volume", false);
-	new StaticTextWidget(this, 10, 37, 140, 16, "Music volume", false);
-	new StaticTextWidget(this, 10, 57, 140, 16, "SFX volume", false);
+	addButton(70, 90, 54, 16, "OK", kOKCmd, 'O');	// Confirm dialog
+	addButton(136, 90, 54, 16, "Cancel", kCancelCmd, 'C');	// Abort dialog
+	new StaticTextWidget(this, 10, 17, 140, 16, "Master volume:", false);
+	new StaticTextWidget(this, 10, 37, 140, 16, "Music volume:", false);
+	new StaticTextWidget(this, 10, 57, 140, 16, "SFX volume:", false);
 
-	// get current variables
-	_soundVolumeMaster = _gui->getScumm()->_sound_volume_master;
-	_soundVolumeMusic = _gui->getScumm()->_sound_volume_music;
-	_soundVolumeSfx = _gui->getScumm()->_sound_volume_sfx;
+	masterVolumeSlider = new SliderWidget(this, 100, 13, 80, 16, "Volume1", kMasterVolumeChanged);
+	musicVolumeSlider = new SliderWidget(this, 100, 33, 80, 16, "Volume2", kMusicVolumeChanged);
+	sfxVolumeSlider = new SliderWidget(this, 100, 53, 80, 16, "Volume3", kSfxVolumeChanged);
 
-	widgetMasterVolume = new SliderWidget(this, 100, 13, 80, 16, "Volume1", kMasterVolumeChanged);
-	widgetMusicVolume = new SliderWidget(this, 100, 33, 80, 16, "Volume2", kMusicVolumeChanged);
-	widgetSfxVolume = new SliderWidget(this, 100, 53, 80, 16, "Volume3", kSfxVolumeChanged);
+	masterVolumeSlider->setMinValue(0);	masterVolumeSlider->setMaxValue(255);
+	musicVolumeSlider->setMinValue(0);	musicVolumeSlider->setMaxValue(255);
+	sfxVolumeSlider->setMinValue(0);	sfxVolumeSlider->setMaxValue(255);
 
-	widgetMasterVolume->setMinValue(0);	widgetMasterVolume->setMaxValue(255);
-	widgetMusicVolume->setMinValue(0);	widgetMusicVolume->setMaxValue(255);
-	widgetSfxVolume->setMinValue(0);	widgetSfxVolume->setMaxValue(255);
+	masterVolumeLabel = new StaticTextWidget(this, 190, 16, 60, 16, "Volume1");
+	musicVolumeLabel = new StaticTextWidget(this, 190, 36, 60, 16, "Volume2");
+	sfxVolumeLabel = new StaticTextWidget(this, 190, 56, 60, 16, "Volume3");
+}
 
-	widgetMasterVolume->setValue(_soundVolumeMaster);
-	widgetMusicVolume->setValue(_soundVolumeMusic);
-	widgetSfxVolume->setValue(_soundVolumeSfx);
+void SoundDialog::open()
+{
+	Scumm	*scumm = _gui->getScumm();
+	
+	Dialog::open();
+
+	// get current variables
+	_soundVolumeMaster = scumm->_sound_volume_master;
+	_soundVolumeMusic = scumm->_sound_volume_music;
+	_soundVolumeSfx = scumm->_sound_volume_sfx;
+
+	masterVolumeSlider->setValue(_soundVolumeMaster);
+	musicVolumeSlider->setValue(_soundVolumeMusic);
+	sfxVolumeSlider->setValue(_soundVolumeSfx);
+
+	masterVolumeLabel->setValue(_soundVolumeMaster);
+	musicVolumeLabel->setValue(_soundVolumeMusic);
+	sfxVolumeLabel->setValue(_soundVolumeSfx);
 }
 
+
 void SoundDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
 {
 	switch (cmd) {
 	case kMasterVolumeChanged:
-		_soundVolumeMaster = widgetMasterVolume->getValue();
+		_soundVolumeMaster = masterVolumeSlider->getValue();
+		masterVolumeLabel->setValue(_soundVolumeMaster);
 		break;
 	case kMusicVolumeChanged:
-		_soundVolumeMusic = widgetMusicVolume->getValue();
+		_soundVolumeMusic = musicVolumeSlider->getValue();
+		musicVolumeLabel->setValue(_soundVolumeMusic);
 		break;
 	case kSfxVolumeChanged:
-		_soundVolumeSfx = widgetSfxVolume->getValue();
+		_soundVolumeSfx = sfxVolumeSlider->getValue();
+		sfxVolumeLabel->setValue(_soundVolumeSfx);
+		break;
+	case kOKCmd: {
+		Scumm	*scumm = _gui->getScumm();
+		
+		// FIXME: Look at Fingolfins comments in Gui::handleSoundDialogCommand(), gui.cpp 
+		scumm->_sound_volume_master = _soundVolumeMaster;	// Master
+		scumm->_sound_volume_music = _soundVolumeMusic;	// Music
+		scumm->_sound_volume_sfx = _soundVolumeSfx;	// SFX
+		
+		scumm->_imuse->set_music_volume(_soundVolumeMusic);
+		scumm->_imuse->set_master_volume(_soundVolumeMaster);
+		scumm->_mixer->set_volume(_soundVolumeSfx);
+		scumm->_mixer->set_music_volume(_soundVolumeMusic);
+		
+		scummcfg->set("master_volume", _soundVolumeMaster);
+		scummcfg->set("music_volume", _soundVolumeMusic);
+		scummcfg->set("sfx_volume", _soundVolumeSfx);
+		scummcfg->flush();
+		}
+	case kCancelCmd:
+		close();
 		break;
 	default:
 		Dialog::handleCommand(sender, cmd, data);
@@ -447,18 +485,4 @@
 
 	draw();
 
-	// FIXME: Look at Fingolfins comments in Gui::handleSoundDialogCommand(), gui.cpp 
-	_gui->getScumm()->_sound_volume_master = _soundVolumeMaster;	// Master
-	_gui->getScumm()->_sound_volume_music = _soundVolumeMusic;	// Music
-	_gui->getScumm()->_sound_volume_sfx = _soundVolumeSfx;	// SFX
-
-	_gui->getScumm()->_imuse->set_music_volume(_gui->getScumm()->_sound_volume_music);
-	_gui->getScumm()->_imuse->set_master_volume(_gui->getScumm()->_sound_volume_master);
-	_gui->getScumm()->_mixer->set_volume(_gui->getScumm()->_sound_volume_sfx);
-	_gui->getScumm()->_mixer->set_music_volume(_gui->getScumm()->_sound_volume_music);
-
-	scummcfg->set("master_volume", _gui->getScumm()->_sound_volume_master);
-	scummcfg->set("music_volume", _gui->getScumm()->_sound_volume_music);
-	scummcfg->set("sfx_volume", _gui->getScumm()->_sound_volume_sfx);
-	scummcfg->flush();
 }

Index: dialog.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/dialog.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- dialog.h	26 Jul 2002 20:38:55 -0000	1.16
+++ dialog.h	27 Jul 2002 00:05:46 -0000	1.17
@@ -85,8 +85,9 @@
 	SaveLoadDialog(NewGui *gui);
 
 	virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
+
 protected:
-	ListWidget* _savegameList;
+	ListWidget	*_savegameList;
 };
 
 
@@ -140,8 +141,12 @@
 		kMasterVolumeChanged	= 'mavc',
 		kMusicVolumeChanged		= 'muvc',
 		kSfxVolumeChanged		= 'sfvc',
+		kOKCmd					= 'ok  ',
+		kCancelCmd				= 'cncl',
 	};
 
+	virtual void open();
+
 	virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
 
 protected:
@@ -149,9 +154,13 @@
 	int _soundVolumeMusic;
 	int _soundVolumeSfx;
 
-	SliderWidget *widgetMasterVolume;
-	SliderWidget *widgetMusicVolume;
-	SliderWidget *widgetSfxVolume;
+	SliderWidget *masterVolumeSlider;
+	SliderWidget *musicVolumeSlider;
+	SliderWidget *sfxVolumeSlider;
+	
+	StaticTextWidget *masterVolumeLabel;
+	StaticTextWidget *musicVolumeLabel;
+	StaticTextWidget *sfxVolumeLabel;
 };
 
 

Index: widget.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- widget.cpp	26 Jul 2002 23:29:43 -0000	1.23
+++ widget.cpp	27 Jul 2002 00:05:46 -0000	1.24
@@ -104,6 +104,16 @@
 		_label = 0;
 }
 
+void StaticTextWidget::setValue(int value)
+{
+	// Free old label if any
+	if (_label)
+		free(_label);
+
+	_label = (char *)malloc(10);
+	sprintf(_label, "%d", value);
+}
+
 void StaticTextWidget::drawWidget(bool hilite)
 {
 	NewGui *gui = _boss->getGui();
@@ -197,7 +207,7 @@
 }
 
 void SliderWidget::handleMouseMoved(int x, int y, int button) { 
-	if (_isDragging) {
+	if ((_flags & WIDGET_ENABLED) && _isDragging) {
 		int newValue = posToValue(x);
 		
 		if (newValue < _valueMin)
@@ -208,25 +218,28 @@
 		if (newValue != _value) {
 			_value = newValue; 
 			draw();
+			sendCommand(_cmd, _value);	// FIXME - hack to allow for "live update" in sound dialog
 		}
 	}
 }
 
 void SliderWidget::handleMouseDown(int x, int y, int button) {
-	int barx;
-	
-	barx = valueToPos(_value);
 	
-	// only start dragging if mouse is over bar
-	if (x > (barx - 3) && x < (barx + 3))
-		_isDragging = true;
+	if (_flags & WIDGET_ENABLED) {
+		int barx;
+		
+		barx = valueToPos(_value);
+		
+		// only start dragging if mouse is over bar
+		if (x > (barx - 3) && x < (barx + 3))
+			_isDragging = true;
+	}
 }
 
 void SliderWidget::handleMouseUp(int x, int y, int button) {
 
-	if (_isDragging) {
-		if (_flags & WIDGET_ENABLED)
-			sendCommand(_cmd, 0);
+	if ((_flags & WIDGET_ENABLED) && _isDragging) {
+		sendCommand(_cmd, _value);
 	}
 
 	_isDragging = false;

Index: widget.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/widget.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- widget.h	26 Jul 2002 23:29:43 -0000	1.21
+++ widget.h	27 Jul 2002 00:05:46 -0000	1.22
@@ -122,6 +122,7 @@
 public:
 	StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const char *text, bool centred = false);
 	~StaticTextWidget();
+	void setValue(int value);
 	void setLabel(const char *label);
 	const char *getLabel() const	{ return _label; }
 	void setCentred(bool centred)	{ _centred = centred; }





More information about the Scummvm-git-logs mailing list