aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-23 19:03:55 -0400
committerPaul Gilbert2016-07-10 16:11:52 -0400
commitf6f68e547d39957fc4678859a95cbec839cc41e4 (patch)
tree12a9c5c9af3fa758119959c56fcb17ef48305c19 /engines
parenta8d4e827d23110e978319a2a6d7f036d16c7f66a (diff)
downloadscummvm-rg350-f6f68e547d39957fc4678859a95cbec839cc41e4.tar.gz
scummvm-rg350-f6f68e547d39957fc4678859a95cbec839cc41e4.tar.bz2
scummvm-rg350-f6f68e547d39957fc4678859a95cbec839cc41e4.zip
TITANIC: Implement changing sound slider percentages
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/pet_control/pet_control.cpp8
-rw-r--r--engines/titanic/pet_control/pet_control.h5
-rw-r--r--engines/titanic/pet_control/pet_slider.cpp12
-rw-r--r--engines/titanic/pet_control/pet_slider.h5
-rw-r--r--engines/titanic/pet_control/pet_sound.cpp77
-rw-r--r--engines/titanic/pet_control/pet_sound.h11
-rw-r--r--engines/titanic/sound/sound.h1
-rw-r--r--engines/titanic/sound/sound_manager.cpp4
-rw-r--r--engines/titanic/sound/sound_manager.h16
9 files changed, 129 insertions, 10 deletions
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index 0bba2c2330..145543fb07 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -423,4 +423,12 @@ void CPetControl::moveToHiddenRoom(CTreeItem *item) {
}
}
+void CPetControl::playSound(int soundNum) {
+ CTreeItem *player = getHiddenObject("PETSoundPlayer");
+ if (player) {
+ CPETPlaySoundMsg playMsg(soundNum);
+ playMsg.execute(player);
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index e7ec993ba9..e4f0710b76 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -240,6 +240,11 @@ public:
void moveToHiddenRoom(CTreeItem *item);
void setC8(int val) { _fieldC8 = val; }
+
+ /**
+ * Play a sound
+ */
+ void playSound(int soundNum);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_slider.cpp b/engines/titanic/pet_control/pet_slider.cpp
index 3e579a4b33..1bbad969a2 100644
--- a/engines/titanic/pet_control/pet_slider.cpp
+++ b/engines/titanic/pet_control/pet_slider.cpp
@@ -168,6 +168,18 @@ void CPetSlider::setOrientation(SliderOrientation orientation) {
_orientation |= orientation;
}
+void CPetSlider::stepPosition(int direction) {
+ double val = getOffsetPixels();
+
+ if (direction == -1) {
+ val = MAX(val - 0.1, 0.0);
+ } else if (direction == 1) {
+ val = MIN(val + 0.1, 1.0);
+ }
+
+ setSliderOffset(val);
+}
+
/*------------------------------------------------------------------------*/
void CPetSoundSlider::setupBackground(const CString &name, CPetControl *petControl) {
diff --git a/engines/titanic/pet_control/pet_slider.h b/engines/titanic/pet_control/pet_slider.h
index 7a61741143..58b2aa68cc 100644
--- a/engines/titanic/pet_control/pet_slider.h
+++ b/engines/titanic/pet_control/pet_slider.h
@@ -180,6 +180,11 @@ public:
_bounds.translate(pt.x, pt.y);
_slidingRect.translate(pt.x, pt.y);
}
+
+ /**
+ * Change the current position of a slider by a step amount
+ */
+ void stepPosition(int direction);
};
class CPetSoundSlider : public CPetSlider {
diff --git a/engines/titanic/pet_control/pet_sound.cpp b/engines/titanic/pet_control/pet_sound.cpp
index d4c6fb376c..2305f42a8f 100644
--- a/engines/titanic/pet_control/pet_sound.cpp
+++ b/engines/titanic/pet_control/pet_sound.cpp
@@ -22,6 +22,7 @@
#include "titanic/pet_control/pet_sound.h"
#include "titanic/pet_control/pet_control.h"
+#include "titanic/game_manager.h"
namespace Titanic {
@@ -121,4 +122,80 @@ void CPetSound::draw2(CScreenManager *screenManager) {
_textSpeechVolume.draw(screenManager);
}
+bool CPetSound::checkHighlight(const Point &pt) {
+ if (_musicVolume.checkThumb(pt) || _masterVolume.checkThumb(pt) ||
+ _speechVolume.checkThumb(pt))
+ return true;
+
+ if (_parrotVolume.checkThumb(pt)) {
+ CPetControl *pet = getPetControl();
+ if (pet)
+ pet->playSound(2);
+
+ return true;
+ }
+
+ Rect rectLeft(0, 0, 10, 11);
+ Rect rectRight(0, 0, 10, 11);
+ rectLeft.translate(415, 379);
+ rectRight.translate(567, 378);
+
+ CPetSlider *sliders[4] = { &_masterVolume, &_musicVolume, &_parrotVolume, &_speechVolume };
+ for (int idx = 0; idx < 4; ++idx) {
+ CPetSlider *slider = sliders[idx];
+ bool isLeft = rectLeft.contains(pt);
+ bool isRight = rectRight.contains(pt);
+ int offset;
+
+ if (isLeft) {
+ slider->stepPosition(-1);
+ offset = slider->getOffsetPixels();
+ } else if (isRight) {
+ slider->stepPosition(1);
+ offset = slider->getOffsetPixels();
+ }
+
+ if (isLeft || isRight) {
+ sliderChanged(offset, idx);
+ return true;
+ }
+
+ // Move to next slider row
+ rectLeft.translate(0, 20);
+ rectRight.translate(0, 20);
+ }
+
+ return false;
+}
+
+void CPetSound::sliderChanged(double offset, int 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 0:
+ soundManager.setMasterPercent(percent);
+ break;
+ case 1:
+ soundManager.setMusicPercent(percent);
+ break;
+ case 2:
+ soundManager.setParrotPercent(percent);
+ break;
+ case 3:
+ soundManager.setSpeechPercent(percent);
+ break;
+ default:
+ break;
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_sound.h b/engines/titanic/pet_control/pet_sound.h
index 55e1f8a45c..36b6a8bb33 100644
--- a/engines/titanic/pet_control/pet_sound.h
+++ b/engines/titanic/pet_control/pet_sound.h
@@ -43,6 +43,11 @@ private:
CPetText _textSpeechVolume;
int _field198;
int _field19C;
+private:
+ /**
+ * Called when a slider has changed
+ */
+ void sliderChanged(double offset, int sliderNum);
public:
CPetSound();
@@ -60,6 +65,12 @@ public:
* Handles any secondary drawing of the glyph
*/
virtual void draw2(CScreenManager *screenManager);
+
+ /**
+ * Checks and updates any highlight of the glyph or any contextual
+ * information it displays
+ */
+ virtual bool checkHighlight(const Point &pt);
};
} // End of namespace Titanic
diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h
index 07300264af..488d4deb5e 100644
--- a/engines/titanic/sound/sound.h
+++ b/engines/titanic/sound/sound.h
@@ -34,6 +34,7 @@ class CGameManager;
class CSound {
private:
CGameManager *_gameManager;
+public:
QSoundManager _soundManager;
public:
CSound(CGameManager *owner);
diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp
index 9b78a9e5b6..53e5a3dfe0 100644
--- a/engines/titanic/sound/sound_manager.cpp
+++ b/engines/titanic/sound/sound_manager.cpp
@@ -24,8 +24,8 @@
namespace Titanic {
-SoundManager::SoundManager() : _field4(0), _field8(0),
- _fieldC(0), _field10(0), _field14(1) {
+SoundManager::SoundManager() : _musicPercent(75.0), _speechPercent(75.0),
+ _masterPercent(75.0), _parrotPercent(75.0), _field14(1) {
}
/*------------------------------------------------------------------------*/
diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h
index d37db60e28..68843dd1f2 100644
--- a/engines/titanic/sound/sound_manager.h
+++ b/engines/titanic/sound/sound_manager.h
@@ -29,10 +29,10 @@ namespace Titanic {
class SoundManager {
protected:
- int _field4;
- int _field8;
- int _fieldC;
- int _field10;
+ double _musicPercent;
+ double _speechPercent;
+ double _masterPercent;
+ double _parrotPercent;
int _field14;
public:
SoundManager();
@@ -53,10 +53,10 @@ public:
virtual int proc16() const { return 0; }
virtual void WaveMixPump() {}
virtual int proc18() const { return 0; }
- virtual void proc19(int v) { _field4 = v; }
- virtual void proc20(int v) { _field8 = v; }
- virtual void proc21(int v) { _fieldC = v; }
- virtual void proc22(int v) { _field10 = v; }
+ virtual void setMusicPercent(double percent) { _musicPercent = percent; }
+ virtual void setSpeechPercent(double percent) { _speechPercent = percent; }
+ virtual void setMasterPercent(double percent) { _masterPercent = percent; }
+ virtual void setParrotPercent(double percent) { _parrotPercent = percent; }
/**
* Called when a game is about to be loaded