aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEric Fry2018-06-17 00:07:36 +1000
committerEugene Sandulenko2018-07-20 06:43:33 +0000
commit102dd462734f0baa67ae4f8439094f6aa50b42fa (patch)
tree86b153edc0fec565d0c3a198309d7254c494df7b /engines
parent09281b85f507a8859de3b03ac512e871d849611e (diff)
downloadscummvm-rg350-102dd462734f0baa67ae4f8439094f6aa50b42fa.tar.gz
scummvm-rg350-102dd462734f0baa67ae4f8439094f6aa50b42fa.tar.bz2
scummvm-rg350-102dd462734f0baa67ae4f8439094f6aa50b42fa.zip
ILLUSIONS: Wire up audio sliders on option menu.
Set volumes based on scummvm config
Diffstat (limited to 'engines')
-rw-r--r--engines/illusions/duckman/menusystem_duckman.cpp57
-rw-r--r--engines/illusions/duckman/menusystem_duckman.h14
-rw-r--r--engines/illusions/sound.cpp35
-rw-r--r--engines/illusions/sound.h9
4 files changed, 89 insertions, 26 deletions
diff --git a/engines/illusions/duckman/menusystem_duckman.cpp b/engines/illusions/duckman/menusystem_duckman.cpp
index 7cadd7ebf5..502a0ac865 100644
--- a/engines/illusions/duckman/menusystem_duckman.cpp
+++ b/engines/illusions/duckman/menusystem_duckman.cpp
@@ -22,6 +22,7 @@
#include "illusions/illusions.h"
#include "illusions/actor.h"
+#include "illusions/sound.h"
#include "illusions/duckman/illusions_duckman.h"
#include "illusions/duckman/menusystem_duckman.h"
#include "illusions/resources/scriptresource.h"
@@ -106,29 +107,34 @@ BaseMenu *DuckmanMenuSystem::createLoadGameMenu() {
return 0; // TODO
}
+MenuItem *DuckmanMenuSystem::createOptionsSliderMenuItem(const Common::String &text, SliderActionType type, BaseMenu *baseMenu) {
+ int sliderValue = 0;
+ Common::String sliderText = "{~~~~~~~~~~~~~~~~}";
+ switch (type) {
+ case SFX : sliderValue = _vm->_soundMan->getSfxVolume()/(255/15); break;
+ case MUSIC : sliderValue = _vm->_soundMan->getMusicVolume()/(255/15); break;
+ case VOICE : sliderValue = _vm->_soundMan->getSpeechVolume()/(255/15); break;
+ case TEXT_DURATION : sliderValue = 128/(255/15); break; // TODO wire up text duration config
+ default: break;
+ }
+
+ sliderText.setChar('|', sliderValue + 1);
+
+ MenuActionUpdateSlider *action = new MenuActionUpdateSlider(this, baseMenu, type, _vm);
+ MenuItem *menuItem = new MenuItem(text + sliderText, action);
+ action->setMenuItem(menuItem);
+ return menuItem;
+}
+
BaseMenu *DuckmanMenuSystem::createOptionsMenu() {
BaseMenu *menu = new BaseMenu(this, 0x00120003, 12, 17, 11, 27, 6);
menu->addText(" GAME OPTIONS @@@@");
menu->addText("--------------------------------------");
- MenuActionUpdateSlider *action = new MenuActionUpdateSlider(this, menu);
- MenuItem *menuItem = new MenuItem("SFX Volume @@{~~~~~~~~~~~~|~~~} @@@", action);
- action->setMenuItem(menuItem);
- menu->addMenuItem(menuItem);
- action = new MenuActionUpdateSlider(this, menu);
- menuItem = new MenuItem("Music Volume @@@{~~~~~~~~~~~~|~~~} @@@", action);
- action->setMenuItem(menuItem);
- menu->addMenuItem(menuItem);
-
- action = new MenuActionUpdateSlider(this, menu);
- menuItem = new MenuItem("Speech Volume {~~~~~~~~~~~~|~~~} @@@", action);
- action->setMenuItem(menuItem);
- menu->addMenuItem(menuItem);
-
- action = new MenuActionUpdateSlider(this, menu);
- menuItem = new MenuItem("Text Duration @@@{~~~~~~~~~~~~|~~~} @@@", action);
- action->setMenuItem(menuItem);
- menu->addMenuItem(menuItem);
+ menu->addMenuItem(createOptionsSliderMenuItem("SFX Volume @@", SFX, menu));
+ menu->addMenuItem(createOptionsSliderMenuItem("Music Volume @@@", MUSIC, menu));
+ menu->addMenuItem(createOptionsSliderMenuItem("Speech Volume ", VOICE, menu));
+ menu->addMenuItem(createOptionsSliderMenuItem("Text Duration @@@", TEXT_DURATION, menu));
menu->addMenuItem(new MenuItem("Restore Defaults", new MenuActionLeaveMenu(this)));
@@ -289,7 +295,7 @@ void DuckmanMenuSystem::playSoundEffect(int sfxId) {
_vm->playSoundEffect(sfxId);
}
-MenuActionInventoryAddRemove::MenuActionInventoryAddRemove(BaseMenuSystem *menuSystem, IllusionsEngine_Duckman *vm, uint choiceIndex)
+ MenuActionInventoryAddRemove::MenuActionInventoryAddRemove(BaseMenuSystem *menuSystem, IllusionsEngine_Duckman *vm, uint choiceIndex)
: BaseMenuAction(menuSystem), _choiceIndex(choiceIndex), _vm(vm) {
}
@@ -307,8 +313,8 @@ void MenuActionInventoryAddRemove::execute() {
_menuSystem->leaveMenu();
}
-MenuActionUpdateSlider::MenuActionUpdateSlider(BaseMenuSystem *menuSystem, BaseMenu *menu)
- : BaseMenuAction(menuSystem), menu(menu) {
+MenuActionUpdateSlider::MenuActionUpdateSlider(BaseMenuSystem *menuSystem, BaseMenu *baseMenu, SliderActionType type, IllusionsEngine_Duckman *vm)
+ : BaseMenuAction(menuSystem), menu(baseMenu), _type(type), _vm(vm) {
menuItem = NULL;
}
@@ -324,7 +330,14 @@ void MenuActionUpdateSlider::execute() {
menuItem->setText(text);
_menuSystem->redrawMenuText(menu);
- // TODO update slider here set value callback.
+
+ switch(_type) {
+ case SFX : _vm->_soundMan->setSfxVolume(newSliderValue * (255/15)); break;
+ case MUSIC : _vm->_soundMan->setMusicVolume(newSliderValue * (255/15)); break;
+ case VOICE : _vm->_soundMan->setSpeechVolume(newSliderValue * (255/15)); break;
+ case TEXT_DURATION : break; // TODO
+ default: break;
+ }
}
int MenuActionUpdateSlider::calcNewSliderValue(Common::String &text, int newOffset) {
diff --git a/engines/illusions/duckman/menusystem_duckman.h b/engines/illusions/duckman/menusystem_duckman.h
index 22bfefa794..3ebab4dea4 100644
--- a/engines/illusions/duckman/menusystem_duckman.h
+++ b/engines/illusions/duckman/menusystem_duckman.h
@@ -27,7 +27,14 @@
namespace Illusions {
-enum {
+ enum SliderActionType {
+ SFX,
+ MUSIC,
+ VOICE,
+ TEXT_DURATION
+ };
+
+ enum {
kDuckmanMainMenu,
kDuckmanLoadGameMenu,
kDuckmanOptionsMenu,
@@ -59,6 +66,7 @@ public://protected:
BaseMenu *createMainMenu();
BaseMenu *createLoadGameMenu();
BaseMenu *createOptionsMenu();
+ MenuItem *createOptionsSliderMenuItem(const Common::String &text, SliderActionType type, BaseMenu *baseMenu);
BaseMenu *createPauseMenu();
BaseMenu *createQueryRestartMenu();
BaseMenu *createQueryQuitMenu();
@@ -85,13 +93,15 @@ protected:
class MenuActionUpdateSlider : public BaseMenuAction {
public:
- MenuActionUpdateSlider(BaseMenuSystem *menuSystem, BaseMenu *baseMenu);
+ MenuActionUpdateSlider(BaseMenuSystem *menuSystem, BaseMenu *baseMenu, SliderActionType type, IllusionsEngine_Duckman *vm);
void setMenuItem(MenuItem *newMmenuItem) {
menuItem = newMmenuItem;
}
virtual void execute();
protected:
+ IllusionsEngine_Duckman *_vm;
+ SliderActionType _type;
MenuItem *menuItem;
BaseMenu *menu;
int calcNewSliderValue(Common::String &text, int newOffset);
diff --git a/engines/illusions/sound.cpp b/engines/illusions/sound.cpp
index cf6e4f8748..bbcf8ad75b 100644
--- a/engines/illusions/sound.cpp
+++ b/engines/illusions/sound.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "common/config-manager.h"
#include "illusions/illusions.h"
#include "illusions/sound.h"
#include "audio/midiparser.h"
@@ -296,7 +297,7 @@ void SoundMan::stopCueingVoice() {
}
void SoundMan::startVoice(int16 volume, int16 pan) {
- _voicePlayer->start(volume, pan);
+ _voicePlayer->start(calcAdjustedVolume("speech_volume", (uint8)volume), pan);
}
void SoundMan::stopVoice() {
@@ -323,7 +324,7 @@ void SoundMan::loadSound(uint32 soundEffectId, uint32 soundGroupId, bool looping
void SoundMan::playSound(uint32 soundEffectId, int16 volume, int16 pan) {
Sound *sound = getSound(soundEffectId);
if (sound)
- sound->play(volume, pan);
+ sound->play(calcAdjustedVolume("sfx_volume", (uint8)volume), pan);
}
void SoundMan::stopSound(uint32 soundEffectId) {
@@ -364,4 +365,34 @@ void SoundMan::fadeMidiMusic(int16 finalVolume, int16 duration) {
_midiPlayer->fade(finalVolume, duration);
}
+void SoundMan::setMusicVolume(uint8 volume) {
+ ConfMan.setInt("music_volume", volume);
+ _midiPlayer->syncVolume();
+}
+
+void SoundMan::setSfxVolume(uint8 volume) {
+ ConfMan.setInt("sfx_volume", volume);
+}
+
+void SoundMan::setSpeechVolume(uint8 volume) {
+ ConfMan.setInt("speech_volume", volume);
+}
+
+uint8 SoundMan::calcAdjustedVolume(const Common::String &volumeConfigKey, uint8 volume) {
+ uint8 masterVolume = (uint8)ConfMan.getInt(volumeConfigKey);
+ return (uint8)(((float)masterVolume/255) * (float)volume);
+}
+
+uint8 SoundMan::getMusicVolume() {
+ return (uint8)ConfMan.getInt("music_volume");
+}
+
+uint8 SoundMan::getSfxVolume() {
+ return (uint8)ConfMan.getInt("sfx_volume");
+}
+
+uint8 SoundMan::getSpeechVolume() {
+ return (uint8)ConfMan.getInt("speech_volume");
+}
+
} // End of namespace Illusions
diff --git a/engines/illusions/sound.h b/engines/illusions/sound.h
index d2da8ed48e..f0786b2e4d 100644
--- a/engines/illusions/sound.h
+++ b/engines/illusions/sound.h
@@ -117,6 +117,14 @@ public:
void stopMidiMusic();
void fadeMidiMusic(int16 finalVolume, int16 duration);
+ uint8 getMusicVolume();
+ uint8 getSfxVolume();
+ uint8 getSpeechVolume();
+
+ void setMusicVolume(uint8 volume);
+ void setSfxVolume(uint8 volume);
+ void setSpeechVolume(uint8 volume);
+
bool cueVoice(const char *voiceName);
void stopCueingVoice();
void startVoice(int16 volume, int16 pan);
@@ -140,6 +148,7 @@ protected:
VoicePlayer *_voicePlayer;
SoundList _sounds;
Sound *getSound(uint32 soundEffectId);
+ uint8 calcAdjustedVolume(const Common::String &volumeConfigKey, uint8 volume);
};
} // End of namespace Illusions