diff options
author | Paul Gilbert | 2016-06-24 08:39:56 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-15 19:24:44 -0400 |
commit | c2f6110d0218802b811c1172f114b5d8ed8bf37c (patch) | |
tree | d03afb5547dbcece374b95750e77746f6113c654 /engines/titanic | |
parent | 6b376e2fa1cce5323ae2a462451b7742ff5840d6 (diff) | |
download | scummvm-rg350-c2f6110d0218802b811c1172f114b5d8ed8bf37c.tar.gz scummvm-rg350-c2f6110d0218802b811c1172f114b5d8ed8bf37c.tar.bz2 scummvm-rg350-c2f6110d0218802b811c1172f114b5d8ed8bf37c.zip |
TITANIC: Added CPetGlyphs methods
Diffstat (limited to 'engines/titanic')
-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 |