diff options
author | Paul Gilbert | 2016-04-22 22:32:28 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:11:45 -0400 |
commit | f79ebfa3e26cc748ef495a96da8acb9e005b3324 (patch) | |
tree | c4f9867aab26b6ef9072bc4edf2ad0200b2d02c7 /engines/titanic/pet_control | |
parent | 4915f8900aff374b2a71545e788cb95d9da7138a (diff) | |
download | scummvm-rg350-f79ebfa3e26cc748ef495a96da8acb9e005b3324.tar.gz scummvm-rg350-f79ebfa3e26cc748ef495a96da8acb9e005b3324.tar.bz2 scummvm-rg350-f79ebfa3e26cc748ef495a96da8acb9e005b3324.zip |
TITANIC: Added PET Sound tab setup
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r-- | engines/titanic/pet_control/pet_element.h | 5 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_slider.cpp | 41 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_slider.h | 41 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_sound.cpp | 67 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_sound.h | 13 |
5 files changed, 126 insertions, 41 deletions
diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h index 7ee28368b2..17e5881a2b 100644 --- a/engines/titanic/pet_control/pet_element.h +++ b/engines/titanic/pet_control/pet_element.h @@ -134,6 +134,11 @@ public: * Translate the position of the element */ void translate(int deltaX, int deltaY) { _bounds.translate(deltaX, deltaY); } + + /** + * Translate the position of the element + */ + void translate(const Point &delta) { _bounds.translate(delta.x, delta.y); } }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_slider.cpp b/engines/titanic/pet_control/pet_slider.cpp index bb43cf5741..3e579a4b33 100644 --- a/engines/titanic/pet_control/pet_slider.cpp +++ b/engines/titanic/pet_control/pet_slider.cpp @@ -26,7 +26,7 @@ namespace Titanic { CPetSlider::CPetSlider() { - _flags = 0; + _orientation = 0; _thumbWidth = 0; _thumbHeight = 0; _sliderOffset = 0; @@ -53,12 +53,9 @@ bool CPetSlider::resetThumbFocus() { return result; } -void CPetSlider::proc10() { - -} - -void CPetSlider::proc11() { - +void CPetSlider::proc10(const Point &pt) { + int newOffset = calcSliderOffset(pt); + setOffsetPixels(newOffset); } bool CPetSlider::proc12(const Point &pt) { @@ -68,30 +65,22 @@ bool CPetSlider::proc12(const Point &pt) { return false; int newOffset = calcSliderOffset(pt); - setSliderOffset(newOffset); + setOffsetPixels(newOffset); return true; } -void CPetSlider::proc13() { - -} - -void CPetSlider::proc14() { - -} - bool CPetSlider::contains(const Point &pt) const { return thumbContains(pt) || containsPt(pt); } double CPetSlider::getOffsetPixels() const { int maxVal = 0, minVal = 0; - if (_flags & ORIENTATION_HORIZONTAL) { + if (_orientation & ORIENTATION_HORIZONTAL) { maxVal = _slidingRect.right; minVal = _slidingRect.left; } - if (_flags & ORIENTATION_VERTICAL) { + if (_orientation & ORIENTATION_VERTICAL) { maxVal = _slidingRect.bottom; minVal = _slidingRect.top; } @@ -103,10 +92,10 @@ double CPetSlider::getOffsetPixels() const { } void CPetSlider::setSliderOffset(double offset) { - if (_flags & ORIENTATION_HORIZONTAL) + if (_orientation & ORIENTATION_HORIZONTAL) _sliderOffset = offset * (_slidingRect.right - _slidingRect.left); - if (_flags & ORIENTATION_VERTICAL) + if (_orientation & ORIENTATION_VERTICAL) _sliderOffset = offset * (_slidingRect.bottom - _slidingRect.top); } @@ -136,12 +125,12 @@ Point CPetSlider::getThumbDrawPos() { Point CPetSlider::getThumbCentroidPos() const { Point pt; - if (_flags & ORIENTATION_HORIZONTAL) { + if (_orientation & ORIENTATION_HORIZONTAL) { pt = Point(_slidingRect.left + _sliderOffset, _slidingRect.top + _slidingRect.height() / 2); } - if (_flags & ORIENTATION_VERTICAL) { + if (_orientation & ORIENTATION_VERTICAL) { pt = Point(_slidingRect.left + _slidingRect.width() / 2, _slidingRect.top + _sliderOffset); } @@ -164,17 +153,21 @@ Rect CPetSlider::getThumbRect() const { int CPetSlider::calcSliderOffset(const Point &pt) const { int result = 0; - if (_flags & ORIENTATION_HORIZONTAL) { + if (_orientation & ORIENTATION_HORIZONTAL) { result = CLIP(pt.x, _slidingRect.left, _slidingRect.right) - _slidingRect.left; } - if (_flags & ORIENTATION_VERTICAL) { + if (_orientation & ORIENTATION_VERTICAL) { result = CLIP(pt.y, _slidingRect.top, _slidingRect.bottom) - _slidingRect.top; } return result; } +void CPetSlider::setOrientation(SliderOrientation orientation) { + _orientation |= orientation; +} + /*------------------------------------------------------------------------*/ 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 a8ef3cbf36..7a61741143 100644 --- a/engines/titanic/pet_control/pet_slider.h +++ b/engines/titanic/pet_control/pet_slider.h @@ -35,7 +35,7 @@ class CPetControl; class CPetSlider { private: - int _flags; + int _orientation; Rect _bounds; Rect _slidingRect; int _thumbWidth; @@ -126,11 +126,11 @@ public: */ virtual bool resetThumbFocus(); - virtual void proc10(); - virtual void proc11(); + virtual void proc10(const Point &pt); + virtual bool proc11() { return true; } virtual bool proc12(const Point &pt); - virtual void proc13(); - virtual void proc14(); + virtual bool proc13() { return false; } + virtual bool proc14() { return false; } virtual bool contains(const Point &pt) const; @@ -149,6 +149,37 @@ public: * Set a new slider offset in pixels */ virtual void setOffsetPixels(int offset); + + /** + * Enables a given orientation + */ + void setOrientation(SliderOrientation orientation); + + /** + * Set the bounds for the slider + */ + void setBounds(const Rect &r) { _bounds = r; } + + /** + * Set the sliding bounds for the slider + */ + void setSlidingBounds(const Rect &r) { _slidingRect = r; } + + /** + * Set the size of the slider thumb + */ + void setThumbSize(const Point &pt) { + _thumbWidth = pt.x; + _thumbHeight = pt.y; + } + + /** + * Move the slider + */ + void translate(const Point &pt) { + _bounds.translate(pt.x, pt.y); + _slidingRect.translate(pt.x, pt.y); + } }; class CPetSoundSlider : public CPetSlider { diff --git a/engines/titanic/pet_control/pet_sound.cpp b/engines/titanic/pet_control/pet_sound.cpp index 6c6c2ead64..75dff34db5 100644 --- a/engines/titanic/pet_control/pet_sound.cpp +++ b/engines/titanic/pet_control/pet_sound.cpp @@ -30,7 +30,58 @@ CPetSound::CPetSound() : CPetGlyph(), _field198(0), _field19C(0) { bool CPetSound::setup(CPetControl *petControl, CPetGlyphs *owner) { CPetGlyph::setup(petControl, owner); - // TODO + + _masterVolume.setOrientation(ORIENTATION_HORIZONTAL); + _masterVolume.setBounds(Rect(17, 0, 147, 15)); + _masterVolume.setSlidingBounds(Rect(35, 5, 127, 11)); + _masterVolume.setThumbSize(Point(25, 15)); + _masterVolume.translate(Point(415, 376)); + + _musicVolume.setOrientation(ORIENTATION_HORIZONTAL); + _musicVolume.setBounds(Rect(17, 20, 147, 35)); + _musicVolume.setSlidingBounds(Rect(35, 25, 127, 31)); + _musicVolume.setThumbSize(Point(25, 15)); + _musicVolume.translate(Point(415, 376)); + + _parrotVolume.setOrientation(ORIENTATION_HORIZONTAL); + _parrotVolume.setBounds(Rect(17, 40, 147, 55)); + _parrotVolume.setSlidingBounds(Rect(35, 45, 127, 51)); + _parrotVolume.setThumbSize(Point(25, 15)); + _parrotVolume.translate(Point(415, 376)); + + _parrotVolume.setOrientation(ORIENTATION_HORIZONTAL); + _parrotVolume.setBounds(Rect(17, 60, 147, 75)); + _parrotVolume.setSlidingBounds(Rect(35, 65, 127, 71)); + _parrotVolume.setThumbSize(Point(25, 15)); + _parrotVolume.translate(Point(415, 376)); + + _element.setBounds(Rect(0, 0, 165, 77)); + _element.translate(Point(415, 376)); + + Rect rect(0, 0, 88, 16); + rect.translate(320, 376); + _textMasterVolume.setBounds(rect); + _textMasterVolume.resize(3); + _textMasterVolume.setHasBorder(false); + _textMasterVolume.setText("Master volume"); + + rect.translate(0, 20); + _textMusicVolume.setBounds(rect); + _textMusicVolume.resize(3); + _textMusicVolume.setHasBorder(false); + _textMusicVolume.setText("Music volume"); + + rect.translate(0, 20); + _textParrotVolume.setBounds(rect); + _textParrotVolume.resize(3); + _textParrotVolume.setHasBorder(false); + _textParrotVolume.setText("Parrot volume"); + + rect.translate(0, 20); + _textSpeechVolume.setBounds(rect); + _textSpeechVolume.resize(3); + _textSpeechVolume.setHasBorder(false); + _textSpeechVolume.setText("Speech volume"); return true; } @@ -40,15 +91,17 @@ bool CPetSound::reset() { if (pet) { setName("PetSound", pet); _element.reset("PetVolChannels", pet, MODE_UNSELECTED); - _slider1.reset("PetVolSlug"); - _slider2.reset("PetVolSlug"); - _slider3.reset("PetVolSlug"); - _slider4.reset("PetVolSlug"); + _musicVolume.reset("PetVolSlug"); + _masterVolume.reset("PetVolSlug"); + _parrotVolume.reset("PetVolSlug"); + _speechVolume.reset("PetVolSlug"); CPetSection *section = getPetSection(); uint col = section->getColor(0); - for (int idx = 0; idx < 4; ++idx) - _text[idx].setColor(0, col); + _textMusicVolume.setColor(0, col); + _textMasterVolume.setColor(0, col); + _textParrotVolume.setColor(0, col); + _textSpeechVolume.setColor(0, col); } return false; diff --git a/engines/titanic/pet_control/pet_sound.h b/engines/titanic/pet_control/pet_sound.h index e52cccabf8..de6c637bd2 100644 --- a/engines/titanic/pet_control/pet_sound.h +++ b/engines/titanic/pet_control/pet_sound.h @@ -33,11 +33,14 @@ namespace Titanic { class CPetSound : public CPetGlyph { private: CPetGfxElement _element; - CPetSlider _slider1; - CPetSlider _slider2; - CPetSlider _slider3; - CPetSlider _slider4; - CPetText _text[4]; + CPetSlider _masterVolume; + CPetSlider _musicVolume; + CPetSlider _parrotVolume; + CPetSlider _speechVolume; + CPetText _textMasterVolume; + CPetText _textMusicVolume; + CPetText _textParrotVolume; + CPetText _textSpeechVolume; int _field198; int _field19C; public: |