aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2017-09-05 21:11:06 -0400
committerPaul Gilbert2017-09-05 21:11:06 -0400
commit0c2fc12756311baf3457718fae7e9394aea390b8 (patch)
tree4ce13fb3a31c2da4d79657ed7a1ddd3f3056fed5 /engines
parent128edeebda490794d0ce78d3d6d84beab29c2246 (diff)
downloadscummvm-rg350-0c2fc12756311baf3457718fae7e9394aea390b8.tar.gz
scummvm-rg350-0c2fc12756311baf3457718fae7e9394aea390b8.tar.bz2
scummvm-rg350-0c2fc12756311baf3457718fae7e9394aea390b8.zip
TITANIC: Hook up in-game sound sliders to ScummVM volumes
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/pet_control/pet_control.cpp4
-rw-r--r--engines/titanic/pet_control/pet_control.h5
-rw-r--r--engines/titanic/pet_control/pet_real_life.cpp8
-rw-r--r--engines/titanic/pet_control/pet_real_life.h4
-rw-r--r--engines/titanic/pet_control/pet_sound.cpp109
-rw-r--r--engines/titanic/pet_control/pet_sound.h10
-rw-r--r--engines/titanic/sound/sound_manager.h4
-rw-r--r--engines/titanic/titanic.cpp13
-rw-r--r--engines/titanic/titanic.h5
9 files changed, 107 insertions, 55 deletions
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index cfd209f763..a86a72f99d 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -562,6 +562,10 @@ bool CPetControl::checkNode(const CString &name) {
return nameLower.contains(str);
}
+void CPetControl::syncSoundSettings() {
+ _realLife.syncSoundSettings();
+}
+
void CPetControl::playSound(int soundNum) {
CTreeItem *player = getHiddenObject("PETSoundPlayer");
if (player) {
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index 35556e08d2..6408c8a29b 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -297,6 +297,11 @@ public:
bool checkNode(const CString &name);
/**
+ * Handles updates to the sound levels
+ */
+ void syncSoundSettings();
+
+ /**
* Play a sound
*/
void playSound(int soundNum);
diff --git a/engines/titanic/pet_control/pet_real_life.cpp b/engines/titanic/pet_control/pet_real_life.cpp
index 57d81c739e..ff87a2fab4 100644
--- a/engines/titanic/pet_control/pet_real_life.cpp
+++ b/engines/titanic/pet_control/pet_real_life.cpp
@@ -123,6 +123,12 @@ void CPetRealLife::addButton(CPetGlyph *glyph) {
}
}
-
+void CPetRealLife::syncSoundSettings() {
+ for (CPetGlyphs::iterator i = _glyphs.begin(); i != _glyphs.end(); ++i) {
+ CPetSound *sound = dynamic_cast<CPetSound *>(*i);
+ if (sound)
+ sound->setSliders();
+ }
+}
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_real_life.h b/engines/titanic/pet_control/pet_real_life.h
index 294f9a3f9f..965b4eab2a 100644
--- a/engines/titanic/pet_control/pet_real_life.h
+++ b/engines/titanic/pet_control/pet_real_life.h
@@ -126,6 +126,10 @@ public:
*/
virtual CTextControl *getText() { return &_text; }
+ /**
+ * Handles updates to the sound levels
+ */
+ void syncSoundSettings();
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_sound.cpp b/engines/titanic/pet_control/pet_sound.cpp
index e4fac34ee8..c2c9110b03 100644
--- a/engines/titanic/pet_control/pet_sound.cpp
+++ b/engines/titanic/pet_control/pet_sound.cpp
@@ -24,6 +24,8 @@
#include "titanic/pet_control/pet_control.h"
#include "titanic/pet_control/pet_real_life.h"
#include "titanic/game_manager.h"
+#include "titanic/titanic.h"
+#include "common/config-manager.h"
namespace Titanic {
@@ -110,21 +112,59 @@ bool CPetSound::reset() {
}
void CPetSound::setSliders() {
- CPetControl *pet = getPetControl();
- CGameManager *gameMan = pet ? pet->getGameManager() : nullptr;
-
- if (gameMan) {
- CSoundManager &soundMan = gameMan->_sound._soundManager;
- uint masterVol = soundMan.getModeVolume(VOL_NORMAL);
- uint musicVol = soundMan.getMusicVolume();
- uint parrotVol = soundMan.getParrotVolume();
- uint speechVol = soundMan.getSpeechVolume();
-
- _masterVolume.setSliderOffset(masterVol * 0.01);
- _musicVolume.setSliderOffset(musicVol * 0.01);
- _parrotVolume.setSliderOffset(parrotVol * 0.01);
- _speechVolume.setSliderOffset(speechVol * 0.01);
+ // Get the mute settings
+ bool muteAll = ConfMan.hasKey("mute") ? ConfMan.getBool("mute") : false;
+ bool musicMute = muteAll || (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute"));
+ bool sfxMute = muteAll || (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute"));
+ bool speechMute = muteAll || (ConfMan.hasKey("speech_mute") && ConfMan.getBool("speech_mute"));
+
+ // Get the volume levels
+ uint musicVol = musicMute ? 0 : MIN(255, ConfMan.getInt("music_volume"));
+ uint parrotVol = sfxMute ? 0 : MIN(255, ConfMan.getInt("sfx_volume"));
+ uint speechVol = speechMute ? 0 : MIN(255, ConfMan.getInt("speech_volume"));
+ uint masterVol = MAX(musicVol, MAX(parrotVol, speechVol));
+
+ const double FACTOR = 1.0 / 255.0;
+ _masterVolume.setSliderOffset(masterVol * FACTOR);
+ _musicVolume.setSliderOffset(musicVol * FACTOR);
+ _parrotVolume.setSliderOffset(parrotVol * FACTOR);
+ _speechVolume.setSliderOffset(speechVol * FACTOR);
+}
+
+void CPetSound::sliderChanged(double offset, SliderType sliderNum) {
+ uint newVol = (uint)(offset * 255.0);
+
+ switch (sliderNum) {
+ case MASTER_SLIDER:
+ ConfMan.setBool("music_mute", false);
+ ConfMan.setBool("sfx_mute", false);
+ ConfMan.setBool("sfx_mute", false);
+ ConfMan.setInt("music_volume", newVol);
+ ConfMan.setInt("sfx_volume", newVol);
+ ConfMan.setInt("speech_volume", newVol);
+
+ _musicVolume.setSliderOffset(newVol * 0.01);
+ _parrotVolume.setSliderOffset(newVol * 0.01);
+ _speechVolume.setSliderOffset(newVol * 0.01);
+ break;
+ case MUSIC_SLIDER:
+ ConfMan.setBool("music_mute", false);
+ ConfMan.setInt("music_volume", newVol);
+ break;
+ case PARROT_SLIDER:
+ ConfMan.setBool("sfx_mute", false);
+ ConfMan.setInt("sfx_volume", newVol);
+ break;
+ case SPEECH_SLIDER:
+ ConfMan.setBool("speech_mute", false);
+ ConfMan.setInt("speech_volume", newVol);
+ break;
+ default:
+ return;
}
+
+ ConfMan.setBool("mute", false);
+ g_vm->syncSoundSettings();
}
void CPetSound::draw2(CScreenManager *screenManager) {
@@ -187,36 +227,6 @@ bool CPetSound::MouseButtonDownMsg(const Point &pt) {
return false;
}
-void CPetSound::sliderChanged(double offset, SliderType sliderNum) {
- CPetControl *pet = getPetControl();
- if (!pet)
- return;
-
- CGameManager *gameManager = pet->getGameManager();
- if (!gameManager)
- return;
-
- QSoundManager &soundManager = gameManager->_sound._soundManager;
- double percent = offset * 100.0;
-
- switch (sliderNum) {
- case MASTER_SLIDER:
- soundManager.setMasterPercent(percent);
- break;
- case MUSIC_SLIDER:
- soundManager.setMusicPercent(percent);
- break;
- case PARROT_SLIDER:
- soundManager.setParrotPercent(percent);
- break;
- case SPEECH_SLIDER:
- soundManager.setSpeechPercent(percent);
- break;
- default:
- break;
- }
-}
-
bool CPetSound::MouseDragStartMsg(CMouseDragStartMsg *msg) {
if (_masterVolume.resetThumbFocus()) {
_draggingSlider = &_masterVolume;
@@ -262,6 +272,9 @@ bool CPetSound::MouseDragEndMsg(CMouseDragEndMsg *msg) {
if (!_draggingSlider)
return false;
+ // Flush the changed settings
+ ConfMan.flushToDisk();
+
bool result = _draggingSlider->MouseDragEndMsg(msg->_mousePos);
getOwner()->endDragging();
@@ -272,12 +285,12 @@ bool CPetSound::MouseButtonUpMsg(const Point &pt) {
SliderType sliderNum = MASTER_SLIDER;
CPetSlider *slider = nullptr;
- if (_musicVolume.MouseButtonUpMsg(pt)) {
+ if (_masterVolume.MouseButtonUpMsg(pt)) {
sliderNum = MASTER_SLIDER;
- slider = &_musicVolume;
- } else if (_masterVolume.MouseButtonUpMsg(pt)) {
- sliderNum = MUSIC_SLIDER;
slider = &_masterVolume;
+ } else if (_musicVolume.MouseButtonUpMsg(pt)) {
+ sliderNum = MUSIC_SLIDER;
+ slider = &_musicVolume;
} else if (_parrotVolume.MouseButtonUpMsg(pt)) {
sliderNum = PARROT_SLIDER;
slider = &_parrotVolume;
diff --git a/engines/titanic/pet_control/pet_sound.h b/engines/titanic/pet_control/pet_sound.h
index 9365b31ee0..54e2fc12e7 100644
--- a/engines/titanic/pet_control/pet_sound.h
+++ b/engines/titanic/pet_control/pet_sound.h
@@ -50,11 +50,6 @@ private:
SliderType _draggingSliderNum;
private:
/**
- * Sets the positions of the volume sliders
- */
- void setSliders();
-
- /**
* Called when a slider has changed
*/
void sliderChanged(double offset, SliderType sliderNum);
@@ -112,6 +107,11 @@ public:
* Returns the tooltip text for when the glyph is selected
*/
virtual void getTooltip(CTextControl *text);
+
+ /**
+ * Sets the positions of the volume sliders
+ */
+ void setSliders();
};
} // End of namespace Titanic
diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h
index 59a514ca3d..e07c62ddec 100644
--- a/engines/titanic/sound/sound_manager.h
+++ b/engines/titanic/sound/sound_manager.h
@@ -42,11 +42,13 @@ enum VolumeMode {
*/
class CSoundManager {
protected:
+ uint _handleCtr;
+ // Old volume levels, deprecated in favor of setting the volumes
+ // directly in the ScummVM mixer
double _musicPercent;
double _speechPercent;
double _masterPercent;
double _parrotPercent;
- uint _handleCtr;
public:
CSoundManager();
virtual ~CSoundManager() {}
diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp
index 67bdf82fa0..9c05a13d81 100644
--- a/engines/titanic/titanic.cpp
+++ b/engines/titanic/titanic.cpp
@@ -119,6 +119,8 @@ bool TitanicEngine::initialize() {
setItemNames();
setRoomNames();
+ syncSoundSettings();
+
_window->applicationStarting();
return true;
}
@@ -258,6 +260,17 @@ CString TitanicEngine::getSavegameName(int slot) {
return CString();
}
+void TitanicEngine::syncSoundSettings() {
+ Engine::syncSoundSettings();
+
+ if (_window->_project) {
+ CPetControl *pet = _window->_project->getPetControl();
+ if (pet) {
+ pet->syncSoundSettings();
+ }
+ }
+}
+
void TitanicEngine::GUIError(const char *msg, ...) {
char buffer[STRINGBUFLEN];
va_list va;
diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h
index c49a13747f..0fea87988b 100644
--- a/engines/titanic/titanic.h
+++ b/engines/titanic/titanic.h
@@ -156,6 +156,11 @@ public:
virtual Common::Error saveGameState(int slot, const Common::String &desc);
/**
+ * Handles updates to the sound levels
+ */
+ virtual void syncSoundSettings();
+
+ /**
* Gets the game features
*/
uint32 getFeatures() const;