diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 6516ee0..5a5428d 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -107,15 +107,11 @@ ScrollingList::~ScrollingList() void ScrollingList::setItems(std::vector *items) { - deallocateSpritePoints(); - items_ = items; if(items_) { itemIndex_ = loopDecrement(0, selectedOffsetIndex_, items_->size()); } - - allocateSpritePoints(); } unsigned int ScrollingList::loopIncrement(unsigned int offset, unsigned int i, unsigned int size) @@ -184,8 +180,6 @@ void ScrollingList::destroyItems() void ScrollingList::setPoints(std::vector *scrollPoints, std::vector *tweenPoints) { - deallocateSpritePoints(); - scrollPoints_ = scrollPoints; tweenPoints_ = tweenPoints; @@ -201,8 +195,6 @@ void ScrollingList::setPoints(std::vector *scrollPoints, std::vector { itemIndex_ = loopDecrement(0, selectedOffsetIndex_, items_->size()); } - - allocateSpritePoints(); } unsigned int ScrollingList::getScrollOffsetIndex() @@ -279,32 +271,19 @@ void ScrollingList::click(double nextScrollTime) void ScrollingList::pageUp() { if(components_.size() == 0) return; - - deallocateSpritePoints(); - itemIndex_ = loopDecrement(itemIndex_, components_.size(), items_->size()); - - allocateSpritePoints(); } void ScrollingList::pageDown() { if(components_.size() == 0) return; - - deallocateSpritePoints(); - itemIndex_ = loopIncrement(itemIndex_, components_.size(), items_->size()); - - allocateSpritePoints(); } void ScrollingList::random() { if(!items_ || items_->size() == 0) return; - - deallocateSpritePoints(); itemIndex_ = rand() % items_->size(); - allocateSpritePoints(); } void ScrollingList::letterUp() @@ -319,8 +298,6 @@ void ScrollingList::letterDown() void ScrollingList::letterChange(bool increment) { - deallocateSpritePoints(); - std::string startname = items_->at((itemIndex_+selectedOffsetIndex_)%items_->size())->lowercaseFullTitle(); for(unsigned int i = 0; i < items_->size(); ++i) @@ -360,7 +337,6 @@ void ScrollingList::letterChange(bool increment) } } - allocateSpritePoints(); } diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index da722da..5a15064 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -719,12 +719,6 @@ void Page::removePlaylist() { items->erase(it); collection->saveRequest = true; - - if(activeMenu_) - { - activeMenu_->deallocateSpritePoints(); - activeMenu_->allocateSpritePoints(); - } } } @@ -741,11 +735,6 @@ void Page::addPlaylist() { items->push_back(selectedItem_); collection->saveRequest = true; - if(activeMenu_) - { - activeMenu_->deallocateSpritePoints(); - activeMenu_->allocateSpritePoints(); - } } } @@ -839,10 +828,13 @@ void Page::launchExit() } -void Page::resetMenuItems() +void Page::reallocateMenuSpritePoints() { - activeMenu_->deallocateSpritePoints(); - activeMenu_->allocateSpritePoints(); + if (activeMenu_) + { + activeMenu_->deallocateSpritePoints(); + activeMenu_->allocateSpritePoints(); + } } diff --git a/RetroFE/Source/Graphics/Page.h b/RetroFE/Source/Graphics/Page.h index fc04820..96dfe2f 100644 --- a/RetroFE/Source/Graphics/Page.h +++ b/RetroFE/Source/Graphics/Page.h @@ -89,7 +89,7 @@ public: void highlightExit(); void addPlaylist(); void removePlaylist(); - void resetMenuItems(); + void reallocateMenuSpritePoints(); bool isMenuScrolling(); private: diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index c8c13bd..b388447 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -327,6 +327,8 @@ void RetroFE::run() currentPage_->onNewItemSelected(); currentPage_->start(); + currentPage_->reallocateMenuSpritePoints(); + state = RETROFE_ENTER; } else @@ -408,10 +410,11 @@ void RetroFE::run() currentPage_->setScrollOffsetIndex(lastMenuOffsets_[nextPageName]); } - currentPage_->resetMenuItems(); currentPage_->onNewItemSelected(); currentPage_->enterMenu(); + currentPage_->reallocateMenuSpritePoints(); + state = RETROFE_NEXT_PAGE_MENU_ENTER; } @@ -460,9 +463,9 @@ void RetroFE::run() currentPage_->popCollection(); } config_.setProperty("currentCollection", currentPage_->getCollectionName()); - currentPage_->resetMenuItems(); currentPage_->onNewItemSelected(); currentPage_->enterMenu(); + currentPage_->reallocateMenuSpritePoints(); state = RETROFE_BACK_MENU_ENTER; } break; @@ -594,39 +597,47 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page) if (input_.keystate(UserInput::KeyCodePageUp)) { page->pageScroll(Page::ScrollDirectionBack); + page->reallocateMenuSpritePoints(); state = RETROFE_HIGHLIGHT_REQUEST; } if (input_.keystate(UserInput::KeyCodePageDown)) { page->pageScroll(Page::ScrollDirectionForward); + page->reallocateMenuSpritePoints(); state = RETROFE_HIGHLIGHT_REQUEST; } if (input_.keystate(UserInput::KeyCodeLetterUp)) { page->letterScroll(Page::ScrollDirectionBack); + page->reallocateMenuSpritePoints(); state = RETROFE_HIGHLIGHT_REQUEST; } if (input_.keystate(UserInput::KeyCodeLetterDown)) { page->letterScroll(Page::ScrollDirectionForward); + page->reallocateMenuSpritePoints(); state = RETROFE_HIGHLIGHT_REQUEST; } if(input_.newKeyPressed(UserInput::KeyCodeNextPlaylist)) { page->nextPlaylist(); + page->reallocateMenuSpritePoints(); state = RETROFE_HIGHLIGHT_REQUEST; } if(input_.newKeyPressed(UserInput::KeyCodeRemovePlaylist)) { page->removePlaylist(); + page->reallocateMenuSpritePoints(); } if(input_.newKeyPressed(UserInput::KeyCodeAddPlaylist)) { page->addPlaylist(); + page->reallocateMenuSpritePoints(); } if(input_.keystate(UserInput::KeyCodeRandom)) { page->selectRandom(); + page->reallocateMenuSpritePoints(); state = RETROFE_HIGHLIGHT_REQUEST; } }