diff options
author | Paul Gilbert | 2016-04-23 20:30:02 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:11:53 -0400 |
commit | 2b1e045b5c57f1bae61bd3ffbd05577062f6f34c (patch) | |
tree | 4c5d5ad232a572dd7760dc6703b860e7fa98c19b /engines | |
parent | f6f68e547d39957fc4678859a95cbec839cc41e4 (diff) | |
download | scummvm-rg350-2b1e045b5c57f1bae61bd3ffbd05577062f6f34c.tar.gz scummvm-rg350-2b1e045b5c57f1bae61bd3ffbd05577062f6f34c.tar.bz2 scummvm-rg350-2b1e045b5c57f1bae61bd3ffbd05577062f6f34c.zip |
TITANIC: Implemented remainder of CPetSound methods
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.cpp | 21 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.h | 30 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_slider.cpp | 5 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_slider.h | 18 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_sound.cpp | 82 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_sound.h | 36 |
6 files changed, 175 insertions, 17 deletions
diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp index 6c5454844a..fd4828ab40 100644 --- a/engines/titanic/pet_control/pet_glyphs.cpp +++ b/engines/titanic/pet_control/pet_glyphs.cpp @@ -68,7 +68,7 @@ void CPetGlyph::setName(const CString &name, CPetControl *petControl) { CPetGlyphs::CPetGlyphs() : _firstVisibleIndex(0), _numVisibleGlyphs(TOTAL_GLYPHS), _highlightIndex(-1), _field1C(-1), _flags(0), - _field94(nullptr), _owner(nullptr) { + _dragGlyph(nullptr), _owner(nullptr) { } void CPetGlyphs::setNumVisible(int total) { @@ -366,16 +366,16 @@ bool CPetGlyphs::MouseDragStartMsg(CMouseDragStartMsg *msg) { } bool CPetGlyphs::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { - if (_field94) { - error("TODO"); + if (_dragGlyph) { + return _dragGlyph->MouseDragMoveMsg(msg); } else { return false; } } bool CPetGlyphs::MouseDragEndMsg(CMouseDragEndMsg *msg) { - if (_field94) { - error("TODO"); + if (_dragGlyph) { + return _dragGlyph->MouseDragEndMsg(msg); } else { return false; } @@ -419,4 +419,15 @@ bool CPetGlyphs::leaveHighlighted() { return false; } +void CPetGlyphs::startDragging(CPetGlyph *glyph, CMouseDragStartMsg *msg) { + if (glyph) { + _dragGlyph = glyph; + msg->_dragItem = getPetControl(); + } +} + +void CPetGlyphs::endDragging() { + _dragGlyph = nullptr; +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h index c7966e5e6a..e4f4b1f59a 100644 --- a/engines/titanic/pet_control/pet_glyphs.h +++ b/engines/titanic/pet_control/pet_glyphs.h @@ -25,6 +25,7 @@ #include "common/keyboard.h" #include "titanic/core/list.h" +#include "titanic/messages/mouse_messages.h" #include "titanic/pet_control/pet_gfx_element.h" #include "titanic/support/rect.h" @@ -125,9 +126,20 @@ public: */ virtual bool checkHighlight(const Point &pt) { return false; } - virtual bool MouseDragStartMsg(const CMouseDragStartMsg *msg) { return false; } - virtual int proc18() { return 0; } - virtual int proc19() { return 0; } + /** + * Called when mouse drag starts + */ + virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg) { return false; } + + /** + * Called during mouse drags + */ + virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg) { return false; } + + /** + * Called when mouse drag ends + */ + virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg) { return false; } /** * Handles mouse button up messages @@ -245,7 +257,7 @@ protected: int _highlightIndex; int _field1C; int _flags; - void *_field94; + CPetGlyph *_dragGlyph; CPetSection *_owner; CPetGfxElement _selection; CPetGfxElement _scrollLeft; @@ -357,6 +369,16 @@ public: * glyph, if any */ bool leaveHighlighted(); + + /** + * Called when a dragging operation starts + */ + void startDragging(CPetGlyph *glyph, CMouseDragStartMsg *msg); + + /** + * Called when a dragging operation ends + */ + void endDragging(); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_slider.cpp b/engines/titanic/pet_control/pet_slider.cpp index 1bbad969a2..e8f31a70d2 100644 --- a/engines/titanic/pet_control/pet_slider.cpp +++ b/engines/titanic/pet_control/pet_slider.cpp @@ -53,12 +53,13 @@ bool CPetSlider::resetThumbFocus() { return result; } -void CPetSlider::proc10(const Point &pt) { +bool CPetSlider::MouseDragMoveMsg(const Point &pt) { int newOffset = calcSliderOffset(pt); setOffsetPixels(newOffset); + return true; } -bool CPetSlider::proc12(const Point &pt) { +bool CPetSlider::MouseButtonUpMsg(const Point &pt) { if (thumbContains(pt)) return true; if (!containsPt(pt)) diff --git a/engines/titanic/pet_control/pet_slider.h b/engines/titanic/pet_control/pet_slider.h index 58b2aa68cc..93390a5d59 100644 --- a/engines/titanic/pet_control/pet_slider.h +++ b/engines/titanic/pet_control/pet_slider.h @@ -126,9 +126,21 @@ public: */ virtual bool resetThumbFocus(); - virtual void proc10(const Point &pt); - virtual bool proc11() { return true; } - virtual bool proc12(const Point &pt); + /** + * Handles dragging the slider + */ + virtual bool MouseDragMoveMsg(const Point &pt); + + /** + * Called when a slider drag ends + */ + virtual bool MouseDragEndMsg(const Point &pt) { return true; } + + /** + * Handles mouse button up messaes + */ + virtual bool MouseButtonUpMsg(const Point &pt); + virtual bool proc13() { return false; } virtual bool proc14() { return false; } diff --git a/engines/titanic/pet_control/pet_sound.cpp b/engines/titanic/pet_control/pet_sound.cpp index 2305f42a8f..736b966974 100644 --- a/engines/titanic/pet_control/pet_sound.cpp +++ b/engines/titanic/pet_control/pet_sound.cpp @@ -22,11 +22,12 @@ #include "titanic/pet_control/pet_sound.h" #include "titanic/pet_control/pet_control.h" +#include "titanic/pet_control/pet_real_life.h" #include "titanic/game_manager.h" namespace Titanic { -CPetSound::CPetSound() : CPetGlyph(), _field198(0), _field19C(0) { +CPetSound::CPetSound() : CPetGlyph(), _draggingSlider(nullptr), _draggingSliderNum(0) { } bool CPetSound::setup(CPetControl *petControl, CPetGlyphs *owner) { @@ -198,4 +199,83 @@ void CPetSound::sliderChanged(double offset, int sliderNum) { } } +bool CPetSound::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (_musicVolume.resetThumbFocus()) { + _draggingSlider = &_musicVolume; + getOwner()->startDragging(this, msg); + _draggingSliderNum = 0; + return true; + } else if (_masterVolume.resetThumbFocus()) { + _draggingSlider = &_masterVolume; + getOwner()->startDragging(this, msg); + _draggingSliderNum = 1; + return true; + } else if (_parrotVolume.resetThumbFocus()) { + _draggingSlider = &_parrotVolume; + getOwner()->startDragging(this, msg); + _draggingSliderNum = 2; + return true; + } else if (_speechVolume.resetThumbFocus()) { + _draggingSlider = &_speechVolume; + getOwner()->startDragging(this, msg); + _draggingSliderNum = 3; + return true; + } + + _draggingSlider = nullptr; + return false; +} + +bool CPetSound::MouseDragMoveMsg(CMouseDragMoveMsg *msg) { + if (!_draggingSlider) + return false; + + if (_draggingSlider->MouseDragMoveMsg(msg->_mousePos)) { + double offset = _draggingSlider->getOffsetPixels(); + sliderChanged(offset, _draggingSliderNum); + getPetControl()->makeDirty(); + return true; + } + + return false; +} + +bool CPetSound::MouseDragEndMsg(CMouseDragEndMsg *msg) { + if (!_draggingSlider) + return false; + + _draggingSlider->MouseDragEndMsg(msg->_mousePos); + getOwner()->endDragging(); + + return false; +} + +bool CPetSound::MouseButtonUpMsg(const Point &pt) { + int sliderNum = 0; + CPetSlider *slider = nullptr; + + if (_musicVolume.MouseButtonUpMsg(pt)) { + sliderNum = 0; + slider = &_musicVolume; + } else if (_masterVolume.MouseButtonUpMsg(pt)) { + sliderNum = 1; + slider = &_masterVolume; + } else if (_parrotVolume.MouseButtonUpMsg(pt)) { + sliderNum = 2; + slider = &_parrotVolume; + } else if (_speechVolume.MouseButtonUpMsg(pt)) { + sliderNum = 3; + slider = &_speechVolume; + } else { + return false; + } + + double offset = slider->getOffsetPixels(); + sliderChanged(offset, sliderNum); +} + +void CPetSound::getTooltip(CPetText *text) { + text->setText("Change the volume settings."); +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_sound.h b/engines/titanic/pet_control/pet_sound.h index 36b6a8bb33..3727780c4b 100644 --- a/engines/titanic/pet_control/pet_sound.h +++ b/engines/titanic/pet_control/pet_sound.h @@ -30,6 +30,8 @@ namespace Titanic { +class CPetRealLife; + class CPetSound : public CPetGlyph { private: CPetGfxElement _element; @@ -41,8 +43,8 @@ private: CPetText _textMusicVolume; CPetText _textParrotVolume; CPetText _textSpeechVolume; - int _field198; - int _field19C; + CPetSlider *_draggingSlider; + int _draggingSliderNum; private: /** * Called when a slider has changed @@ -71,6 +73,36 @@ public: * information it displays */ virtual bool checkHighlight(const Point &pt); + + /** + * Called when mouse drag starts + */ + virtual bool MouseDragStartMsg(CMouseDragStartMsg *msg); + + /** + * Called during mouse drags + */ + virtual bool MouseDragMoveMsg(CMouseDragMoveMsg *msg); + + /** + * Called when mouse drag ends + */ + virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg); + + /** + * Handles mouse button up messages + */ + virtual bool MouseButtonUpMsg(const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); + + /** + * Get the parent RealLife area + */ + CPetGlyphs *getOwner() { return _owner; } }; } // End of namespace Titanic |