mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-12 17:58:53 +01:00
Reduced page loading time by reducing the number of calls to
allocateSpritPoints.
This commit is contained in:
parent
50148fa213
commit
3e0b866ff5
@ -107,15 +107,11 @@ ScrollingList::~ScrollingList()
|
||||
|
||||
void ScrollingList::setItems(std::vector<Item *> *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<ViewInfo *> *scrollPoints, std::vector<AnimationEvents *> *tweenPoints)
|
||||
{
|
||||
deallocateSpritePoints();
|
||||
|
||||
scrollPoints_ = scrollPoints;
|
||||
tweenPoints_ = tweenPoints;
|
||||
|
||||
@ -201,8 +195,6 @@ void ScrollingList::setPoints(std::vector<ViewInfo *> *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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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()
|
||||
{
|
||||
if (activeMenu_)
|
||||
{
|
||||
activeMenu_->deallocateSpritePoints();
|
||||
activeMenu_->allocateSpritePoints();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ public:
|
||||
void highlightExit();
|
||||
void addPlaylist();
|
||||
void removePlaylist();
|
||||
void resetMenuItems();
|
||||
void reallocateMenuSpritePoints();
|
||||
bool isMenuScrolling();
|
||||
|
||||
private:
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user