void SpriteManager::HighlightPrevious() { activatedHighlighted_ = false; Sprite* lowest = FindLowestIndex(); Sprite* highest = FindHighestIndex(); if( !currentHighlighted_ ) { currentHighlighted_ = highest; } else if( currentHighlighted_->GetSelectionIndex() == lowest->GetSelectionIndex() ) { currentHighlighted_ = highest; } else { Sprite* bestMatch = 0; for (int i=0; i<sprites_.GetItemCount(); i++) { Sprite* sprite=sprites_.Get(i); if( sprite != currentHighlighted_ && sprite->GetSelectionIndex() >=0 && sprite->GetSelectionIndex() < currentHighlighted_->GetSelectionIndex() ) { if( !bestMatch) { bestMatch = sprite; } else if( sprite->GetSelectionIndex() > bestMatch->GetSelectionIndex() ) { bestMatch = sprite; } } } currentHighlighted_ = bestMatch; } }
Sprite* SpriteManager::FindHighestIndex() { Sprite* bestMatch = 0; for (int i=0; i<sprites_.GetItemCount(); i++) { Sprite* sprite=sprites_.Get(i); int index = sprite->GetSelectionIndex(); if( index >=0 ) { if( !bestMatch ) { bestMatch = sprite; } else if( index > bestMatch->GetSelectionIndex() ) { bestMatch = sprite; } } } return bestMatch; }