aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/dialog.cpp66
-rw-r--r--gui/dialog.h24
-rw-r--r--gui/widget.cpp12
-rw-r--r--gui/widget.h8
4 files changed, 106 insertions, 4 deletions
diff --git a/gui/dialog.cpp b/gui/dialog.cpp
index d59a6c34bc..c2b96fe824 100644
--- a/gui/dialog.cpp
+++ b/gui/dialog.cpp
@@ -26,6 +26,9 @@
#include "widget.h"
#include "scumm.h"
#include "ListWidget.h"
+#include "config-file.h"
+#include "sound/mididrv.h"
+#include "sound/imuse.h"
Dialog::~Dialog()
{
@@ -353,6 +356,7 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
{
switch (cmd) {
case kSoundCmd:
+ _gui->soundDialog();
break;
case kKeysCmd:
break;
@@ -385,3 +389,65 @@ PauseDialog::PauseDialog(NewGui *gui)
{
addResText(4, 4, 220, 16, 10);
}
+
+SoundDialog::SoundDialog(NewGui *gui)
+ : Dialog (gui, 30, 20, 260, 110)
+{
+
+ // 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);
+
+ // get current variables
+ _soundVolumeMaster = _gui->getScumm()->_sound_volume_master;
+ _soundVolumeMusic = _gui->getScumm()->_sound_volume_music;
+ _soundVolumeSfx = _gui->getScumm()->_sound_volume_sfx;
+
+ 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);
+
+ widgetMasterVolume->setMinValue(0); widgetMasterVolume->setMaxValue(255);
+ widgetMusicVolume->setMinValue(0); widgetMusicVolume->setMaxValue(255);
+ widgetSfxVolume->setMinValue(0); widgetSfxVolume->setMaxValue(255);
+
+ widgetMasterVolume->setValue(_soundVolumeMaster);
+ widgetMusicVolume->setValue(_soundVolumeMusic);
+ widgetSfxVolume->setValue(_soundVolumeSfx);
+}
+
+void SoundDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
+{
+ switch (cmd) {
+ case kMasterVolumeChanged:
+ _soundVolumeMaster = widgetMasterVolume->getValue();
+ break;
+ case kMusicVolumeChanged:
+ _soundVolumeMusic = widgetMusicVolume->getValue();
+ break;
+ case kSfxVolumeChanged:
+ _soundVolumeSfx = widgetSfxVolume->getValue();
+ break;
+ default:
+ Dialog::handleCommand(sender, cmd, data);
+ }
+
+ 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();
+}
diff --git a/gui/dialog.h b/gui/dialog.h
index 40c109c220..63b1544950 100644
--- a/gui/dialog.h
+++ b/gui/dialog.h
@@ -129,4 +129,28 @@ public:
};
+
+class SoundDialog : public Dialog {
+public:
+ SoundDialog(NewGui *gui);
+
+ enum {
+ kMasterVolumeChanged = 'mavc',
+ kMusicVolumeChanged = 'muvc',
+ kSfxVolumeChanged = 'sfvc',
+ };
+
+ virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
+
+protected:
+ int _soundVolumeMaster;
+ int _soundVolumeMusic;
+ int _soundVolumeSfx;
+
+ SliderWidget *widgetMasterVolume;
+ SliderWidget *widgetMusicVolume;
+ SliderWidget *widgetSfxVolume;
+};
+
+
#endif
diff --git a/gui/widget.cpp b/gui/widget.cpp
index b2967f85d2..06c6161ce4 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -219,18 +219,18 @@ void SliderWidget::drawWidget(bool hilite)
// Remove old 'bar' if necessary
if (_value != _old_value) {
- gui->fillRect(_x + 2 + ((_w - 5) * _old_value / 100), _y + 2, 2, _h - 4, gui->_bgcolor);
+ gui->fillRect(_x + 2 + ((_w - 5) * (_old_value - _valueMin) / _valueDelta), _y + 2, 2, _h - 4, gui->_bgcolor);
_old_value = _value;
}
// Draw the 'bar'
- gui->fillRect(_x + 2 + ((_w - 5) * _value / 100), _y + 2, 2, _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
+ gui->fillRect(_x + 2 + ((_w - 5) * (_value - _valueMin) / _valueDelta), _y + 2, 2, _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
}
void SliderWidget::handleMouseDown(int x, int y, int button) {
int barx;
- barx = 2 + ((_w - 5) * _old_value / 100);
+ barx = 2 + ((_w - 5) * (_value - _valueMin) / _valueDelta);
// only start dragging if mouse is over bar
if (x > (barx - 3) && x < (barx + 3))
@@ -238,5 +238,11 @@ void SliderWidget::handleMouseDown(int x, int y, int button) {
}
void SliderWidget::handleMouseUp(int x, int y, int button) {
+
+ if (_isDragging) {
+ if (_flags & WIDGET_ENABLED)
+ sendCommand(_cmd, 0);
+ }
+
_isDragging = false;
}
diff --git a/gui/widget.h b/gui/widget.h
index 3acb063218..7f1e663e2e 100644
--- a/gui/widget.h
+++ b/gui/widget.h
@@ -170,13 +170,19 @@ protected:
/* SliderWidget */
class SliderWidget : public ButtonWidget {
protected:
- uint8 _value, _old_value;
+ int _value, _old_value;
+ int _valueMin, _valueMax, _valueDelta;
bool _isDragging;
public:
SliderWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd = 0, uint8 hotkey = 0);
void setValue(uint8 value) { _value = value; }
uint8 getValue() const { return _value; }
+ void setMinValue(int value) { _valueMin = value; _valueDelta = _valueMax - _valueMin; }
+ int getMinValue() const { return _valueMin; }
+ void setMaxValue(int value) { _valueMax = value; _valueDelta = _valueMax - _valueMin; }
+ int getMaxValue() const { return _valueMax; }
+
void handleMouseMoved(int x, int y, int button);
void handleMouseDown(int x, int y, int button);
void handleMouseUp(int x, int y, int button);