diff options
author | Paul Gilbert | 2016-04-23 11:16:33 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:11:47 -0400 |
commit | 58e1a807f3c7c9e0342ef1edd964d6d13de57dc3 (patch) | |
tree | 8ba734b03ca8ccaef46077a0de6ca7b523b830f0 /engines/titanic/pet_control | |
parent | 990f7b87c1b328b0cb2b663d37f4a1de50edf56c (diff) | |
download | scummvm-rg350-58e1a807f3c7c9e0342ef1edd964d6d13de57dc3.tar.gz scummvm-rg350-58e1a807f3c7c9e0342ef1edd964d6d13de57dc3.tar.bz2 scummvm-rg350-58e1a807f3c7c9e0342ef1edd964d6d13de57dc3.zip |
TITANIC: Clean up on element highlighting
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.cpp | 38 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.h | 4 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory.h | 4 |
4 files changed, 39 insertions, 11 deletions
diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp index 1ab7d7ee1b..7144378548 100644 --- a/engines/titanic/pet_control/pet_glyphs.cpp +++ b/engines/titanic/pet_control/pet_glyphs.cpp @@ -38,7 +38,7 @@ void CPetGlyph::drawAt(CScreenManager *screenManager, const Point &pt) { _element.translate(-pt.x, -pt.y); } -void CPetGlyph::proc14(const Point &pt) { +void CPetGlyph::proc14() { warning("TODO: CPetGlyph::proc14"); } @@ -183,7 +183,34 @@ Rect CPetGlyphs::getRect(int index) { } void CPetGlyphs::changeHighlight(int index) { - warning("TODO: CPetGlyphs::changeHighlight"); + if (index == _highlightIndex) + return; + + if (_highlightIndex >= 0 && (_field20 & 4)) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + if (glyph) + glyph->unhighlightCurrent(); + } + + _highlightIndex = index; + if (index >= 0) { + CPetGlyph *glyph = getGlyph(_highlightIndex); + + if (glyph) { + if (_field20 & 4) { + Point pt; + int idx = getHighlightedIndex(_highlightIndex); + if (idx >= 0) + pt = getPosition(idx); + + glyph->highlightCurrent(pt); + } + + glyph->proc14(); + } + } else if (_owner) { + _owner->proc28(); + } } void CPetGlyphs::highlight(int index) { @@ -281,11 +308,10 @@ bool CPetGlyphs::mouseButtonDown(const Point &pt) { int index = getItemIndex(idx); CPetGlyph *glyph = getGlyph(index); if (glyph) { - if (index == _highlightIndex) { - glyph->proc28(glyphRect); - glyph->proc14(pt); + if (glyph->checkHighlight(pt)) return true; - } else { + + if (!(_field20 & 2)) { changeHighlight(index); makePetDirty(); return true; diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h index 496654762e..24d0a0840b 100644 --- a/engines/titanic/pet_control/pet_glyphs.h +++ b/engines/titanic/pet_control/pet_glyphs.h @@ -110,7 +110,7 @@ public: */ virtual void draw2(CScreenManager *screenManager) {} - virtual void proc14(const Point &pt); + virtual void proc14(); /** * Get the bounds for the glyph @@ -150,7 +150,7 @@ public: /** * Highlight any currently highlighted element */ - virtual void highlightCurrent() {} + virtual void highlightCurrent(const Point &pt) {} virtual void proc27(const Point &pt, bool flag) {} virtual void proc28(const Point &pt) {} diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp index b27b664ab9..621bf2df0d 100644 --- a/engines/titanic/pet_control/pet_inventory.cpp +++ b/engines/titanic/pet_control/pet_inventory.cpp @@ -90,6 +90,10 @@ void CPetInventory::leave() { _items.leave(); } +CGameObject *CPetInventory::getBackground(int index) const { + return (index >= 0 && index < 46) ? _itemBackgrounds[index] : nullptr; +} + bool CPetInventory::setPetControl(CPetControl *petControl) { if (!petControl) return false; diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h index ed1b679c63..969e253676 100644 --- a/engines/titanic/pet_control/pet_inventory.h +++ b/engines/titanic/pet_control/pet_inventory.h @@ -112,9 +112,7 @@ public: */ virtual void leave(); - virtual CGameObject *getBackground(int index) const { - return (index >= 0 && index < 46) ? _itemBackgrounds[index] : nullptr; - } + virtual CGameObject *getBackground(int index) const; /** * |