diff options
author | Max Horn | 2002-07-26 00:41:07 +0000 |
---|---|---|
committer | Max Horn | 2002-07-26 00:41:07 +0000 |
commit | 84c8d4b689168335da090bae57f4a162ee10018d (patch) | |
tree | f3f5ea98571500c4a203c6d173b8be9e8d486f95 | |
parent | 4211eb8437e5708d9644ded1dd89c9cf526fbf92 (diff) | |
download | scummvm-rg350-84c8d4b689168335da090bae57f4a162ee10018d.tar.gz scummvm-rg350-84c8d4b689168335da090bae57f4a162ee10018d.tar.bz2 scummvm-rg350-84c8d4b689168335da090bae57f4a162ee10018d.zip |
added painelf's (still unfinished) sound dialog in NewGUI. Beware, this is work in progress, don't report problems with it just yet, we already know they are there :-)
svn-id: r4635
-rw-r--r-- | gui.cpp | 8 | ||||
-rw-r--r-- | gui/dialog.cpp | 66 | ||||
-rw-r--r-- | gui/dialog.h | 24 | ||||
-rw-r--r-- | gui/widget.cpp | 12 | ||||
-rw-r--r-- | gui/widget.h | 8 | ||||
-rw-r--r-- | newgui.cpp | 7 | ||||
-rw-r--r-- | newgui.h | 2 | ||||
-rw-r--r-- | sound/imuse.cpp | 7 |
8 files changed, 127 insertions, 7 deletions
@@ -624,9 +624,11 @@ void Gui::handleSoundDialogCommand(int cmd) // (s)he is at it, HiFi equipment uses logarithmic volume controls // (not linear ones as we do) since they match the human ear better. - _s->_sound_volume_master = _gui_variables[0]; // Master - _s->_sound_volume_music = _gui_variables[1]; // Music - _s->_sound_volume_sfx = _gui_variables[2]; // SFX + // The * 256 / 100 is a quick recalibration hack, it will go + // away when we move to newgui + _s->_sound_volume_master = _gui_variables[0] * 255 / 100; // Master + _s->_sound_volume_music = _gui_variables[1] * 255 / 100; // Music + _s->_sound_volume_sfx = _gui_variables[2] * 255 / 100; // SFX _s->_imuse->set_music_volume(_s->_sound_volume_music); _s->_imuse->set_master_volume(_s->_sound_volume_master); 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); diff --git a/newgui.cpp b/newgui.cpp index eaf49ea849..817afcf24f 100644 --- a/newgui.cpp +++ b/newgui.cpp @@ -72,6 +72,13 @@ void NewGui::optionsDialog() openDialog(_optionsDialog); } +void NewGui::soundDialog() +{ + if (!_soundDialog) + _soundDialog = new SoundDialog(this); + openDialog(_soundDialog); +} + void NewGui::loop() { Dialog *activeDialog = _dialogStack.top(); @@ -61,6 +61,7 @@ public: void saveloadDialog(); void aboutDialog(); void optionsDialog(); + void soundDialog(); void loop(); @@ -83,6 +84,7 @@ protected: Dialog *_saveLoadDialog; Dialog *_aboutDialog; Dialog *_optionsDialog; + Dialog *_soundDialog; // for continuous events (keyDown) int _currentKeyDown, _currentKeyDownFlags; diff --git a/sound/imuse.cpp b/sound/imuse.cpp index 677a5c79f2..8e0e99e099 100644 --- a/sound/imuse.cpp +++ b/sound/imuse.cpp @@ -1255,6 +1255,9 @@ int IMuseInternal::get_music_volume() int IMuseInternal::set_music_volume(uint vol) { + // recalibrate from 0-255 range + vol = vol * 100 / 255; + if (vol > 100) vol = 100; else if (vol < 1) @@ -1267,6 +1270,10 @@ int IMuseInternal::set_music_volume(uint vol) int IMuseInternal::set_master_volume(uint vol) { int i; + + // recalibrate from 0-255 range + vol = vol * 127 / 255; + if (vol > 127) return -1; |