diff options
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.cpp | 35 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.h | 15 |
2 files changed, 49 insertions, 1 deletions
diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp index b5fa407dd4..1aea34f708 100644 --- a/engines/titanic/pet_control/pet_glyphs.cpp +++ b/engines/titanic/pet_control/pet_glyphs.cpp @@ -219,7 +219,11 @@ void CPetGlyphs::changeHighlight(int index) { } void CPetGlyphs::highlight(int index) { - warning("TODO: CPetGlyphs::highlight"); + if (index >= 0) { + setSelectedIndex(index); + changeHighlight(index); + makePetDirty(); + } } void CPetGlyphs::highlight(const CPetGlyph *glyph) { @@ -235,6 +239,15 @@ int CPetGlyphs::getItemIndex(int index) { return _firstVisibleIndex + index; } +void CPetGlyphs::setSelectedIndex(int index) { + if (index >= 0 && index < (int)size() && getHighlightedIndex(index) == -1) { + if (_firstVisibleIndex <= index) + index -= _numVisibleGlyphs - 1; + + setFirstVisible(index); + } +} + CPetGlyph *CPetGlyphs::getGlyph(int index) { for (iterator i = begin(); i != end(); ++i) { if (index-- == 0) @@ -459,4 +472,24 @@ int CPetGlyphs::indexOf(const CPetGlyph *glyph) const { return -1; } +void CPetGlyphs::incSelection() { + if (_highlightIndex >= 0 && _highlightIndex < ((int)size() - 1)) { + if (getHighlightedIndex(_highlightIndex) >= (_numVisibleGlyphs - 1)) + scrollRight(); + + changeHighlight(_highlightIndex + 1); + makePetDirty(); + } +} + +void CPetGlyphs::decSelection() { + if (_highlightIndex > 0) { + if (getHighlightedIndex(_highlightIndex) == 0) + scrollLeft(); + + changeHighlight(_highlightIndex - 1); + makePetDirty(); + } +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h index 26b1a658a6..f1587e3e5a 100644 --- a/engines/titanic/pet_control/pet_glyphs.h +++ b/engines/titanic/pet_control/pet_glyphs.h @@ -245,6 +245,11 @@ private: int getItemIndex(int index); /** + * Set the item index + */ + void setSelectedIndex(int index); + + /** * Return a specified glyph */ CPetGlyph *getGlyph(int index); @@ -419,6 +424,16 @@ public: * Resets the scrolling of the glyphs list back to the start */ void scrollToStart() { _firstVisibleIndex = 0; } + + /** + * Increment the currently selected index + */ + void incSelection(); + + /** + * Decrement the currently selected index + */ + void decSelection(); }; } // End of namespace Titanic |