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)
|
void ScrollingList::setItems(std::vector<Item *> *items)
|
||||||
{
|
{
|
||||||
deallocateSpritePoints();
|
|
||||||
|
|
||||||
items_ = items;
|
items_ = items;
|
||||||
if(items_)
|
if(items_)
|
||||||
{
|
{
|
||||||
itemIndex_ = loopDecrement(0, selectedOffsetIndex_, items_->size());
|
itemIndex_ = loopDecrement(0, selectedOffsetIndex_, items_->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
allocateSpritePoints();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ScrollingList::loopIncrement(unsigned int offset, unsigned int i, unsigned int size)
|
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)
|
void ScrollingList::setPoints(std::vector<ViewInfo *> *scrollPoints, std::vector<AnimationEvents *> *tweenPoints)
|
||||||
{
|
{
|
||||||
deallocateSpritePoints();
|
|
||||||
|
|
||||||
scrollPoints_ = scrollPoints;
|
scrollPoints_ = scrollPoints;
|
||||||
tweenPoints_ = tweenPoints;
|
tweenPoints_ = tweenPoints;
|
||||||
|
|
||||||
@ -201,8 +195,6 @@ void ScrollingList::setPoints(std::vector<ViewInfo *> *scrollPoints, std::vector
|
|||||||
{
|
{
|
||||||
itemIndex_ = loopDecrement(0, selectedOffsetIndex_, items_->size());
|
itemIndex_ = loopDecrement(0, selectedOffsetIndex_, items_->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
allocateSpritePoints();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int ScrollingList::getScrollOffsetIndex()
|
unsigned int ScrollingList::getScrollOffsetIndex()
|
||||||
@ -279,32 +271,19 @@ void ScrollingList::click(double nextScrollTime)
|
|||||||
void ScrollingList::pageUp()
|
void ScrollingList::pageUp()
|
||||||
{
|
{
|
||||||
if(components_.size() == 0) return;
|
if(components_.size() == 0) return;
|
||||||
|
|
||||||
deallocateSpritePoints();
|
|
||||||
|
|
||||||
itemIndex_ = loopDecrement(itemIndex_, components_.size(), items_->size());
|
itemIndex_ = loopDecrement(itemIndex_, components_.size(), items_->size());
|
||||||
|
|
||||||
allocateSpritePoints();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollingList::pageDown()
|
void ScrollingList::pageDown()
|
||||||
{
|
{
|
||||||
if(components_.size() == 0) return;
|
if(components_.size() == 0) return;
|
||||||
|
|
||||||
deallocateSpritePoints();
|
|
||||||
|
|
||||||
itemIndex_ = loopIncrement(itemIndex_, components_.size(), items_->size());
|
itemIndex_ = loopIncrement(itemIndex_, components_.size(), items_->size());
|
||||||
|
|
||||||
allocateSpritePoints();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollingList::random()
|
void ScrollingList::random()
|
||||||
{
|
{
|
||||||
if(!items_ || items_->size() == 0) return;
|
if(!items_ || items_->size() == 0) return;
|
||||||
|
|
||||||
deallocateSpritePoints();
|
|
||||||
itemIndex_ = rand() % items_->size();
|
itemIndex_ = rand() % items_->size();
|
||||||
allocateSpritePoints();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrollingList::letterUp()
|
void ScrollingList::letterUp()
|
||||||
@ -319,8 +298,6 @@ void ScrollingList::letterDown()
|
|||||||
|
|
||||||
void ScrollingList::letterChange(bool increment)
|
void ScrollingList::letterChange(bool increment)
|
||||||
{
|
{
|
||||||
deallocateSpritePoints();
|
|
||||||
|
|
||||||
std::string startname = items_->at((itemIndex_+selectedOffsetIndex_)%items_->size())->lowercaseFullTitle();
|
std::string startname = items_->at((itemIndex_+selectedOffsetIndex_)%items_->size())->lowercaseFullTitle();
|
||||||
|
|
||||||
for(unsigned int i = 0; i < items_->size(); ++i)
|
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);
|
items->erase(it);
|
||||||
collection->saveRequest = true;
|
collection->saveRequest = true;
|
||||||
|
|
||||||
if(activeMenu_)
|
|
||||||
{
|
|
||||||
activeMenu_->deallocateSpritePoints();
|
|
||||||
activeMenu_->allocateSpritePoints();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -741,11 +735,6 @@ void Page::addPlaylist()
|
|||||||
{
|
{
|
||||||
items->push_back(selectedItem_);
|
items->push_back(selectedItem_);
|
||||||
collection->saveRequest = true;
|
collection->saveRequest = true;
|
||||||
if(activeMenu_)
|
|
||||||
{
|
|
||||||
activeMenu_->deallocateSpritePoints();
|
|
||||||
activeMenu_->allocateSpritePoints();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -839,10 +828,13 @@ void Page::launchExit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Page::resetMenuItems()
|
void Page::reallocateMenuSpritePoints()
|
||||||
{
|
{
|
||||||
activeMenu_->deallocateSpritePoints();
|
if (activeMenu_)
|
||||||
activeMenu_->allocateSpritePoints();
|
{
|
||||||
|
activeMenu_->deallocateSpritePoints();
|
||||||
|
activeMenu_->allocateSpritePoints();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -89,7 +89,7 @@ public:
|
|||||||
void highlightExit();
|
void highlightExit();
|
||||||
void addPlaylist();
|
void addPlaylist();
|
||||||
void removePlaylist();
|
void removePlaylist();
|
||||||
void resetMenuItems();
|
void reallocateMenuSpritePoints();
|
||||||
bool isMenuScrolling();
|
bool isMenuScrolling();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -327,6 +327,8 @@ void RetroFE::run()
|
|||||||
currentPage_->onNewItemSelected();
|
currentPage_->onNewItemSelected();
|
||||||
currentPage_->start();
|
currentPage_->start();
|
||||||
|
|
||||||
|
currentPage_->reallocateMenuSpritePoints();
|
||||||
|
|
||||||
state = RETROFE_ENTER;
|
state = RETROFE_ENTER;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -408,10 +410,11 @@ void RetroFE::run()
|
|||||||
currentPage_->setScrollOffsetIndex(lastMenuOffsets_[nextPageName]);
|
currentPage_->setScrollOffsetIndex(lastMenuOffsets_[nextPageName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPage_->resetMenuItems();
|
|
||||||
currentPage_->onNewItemSelected();
|
currentPage_->onNewItemSelected();
|
||||||
currentPage_->enterMenu();
|
currentPage_->enterMenu();
|
||||||
|
|
||||||
|
currentPage_->reallocateMenuSpritePoints();
|
||||||
|
|
||||||
state = RETROFE_NEXT_PAGE_MENU_ENTER;
|
state = RETROFE_NEXT_PAGE_MENU_ENTER;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -460,9 +463,9 @@ void RetroFE::run()
|
|||||||
currentPage_->popCollection();
|
currentPage_->popCollection();
|
||||||
}
|
}
|
||||||
config_.setProperty("currentCollection", currentPage_->getCollectionName());
|
config_.setProperty("currentCollection", currentPage_->getCollectionName());
|
||||||
currentPage_->resetMenuItems();
|
|
||||||
currentPage_->onNewItemSelected();
|
currentPage_->onNewItemSelected();
|
||||||
currentPage_->enterMenu();
|
currentPage_->enterMenu();
|
||||||
|
currentPage_->reallocateMenuSpritePoints();
|
||||||
state = RETROFE_BACK_MENU_ENTER;
|
state = RETROFE_BACK_MENU_ENTER;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -594,39 +597,47 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
|
|||||||
if (input_.keystate(UserInput::KeyCodePageUp))
|
if (input_.keystate(UserInput::KeyCodePageUp))
|
||||||
{
|
{
|
||||||
page->pageScroll(Page::ScrollDirectionBack);
|
page->pageScroll(Page::ScrollDirectionBack);
|
||||||
|
page->reallocateMenuSpritePoints();
|
||||||
state = RETROFE_HIGHLIGHT_REQUEST;
|
state = RETROFE_HIGHLIGHT_REQUEST;
|
||||||
}
|
}
|
||||||
if (input_.keystate(UserInput::KeyCodePageDown))
|
if (input_.keystate(UserInput::KeyCodePageDown))
|
||||||
{
|
{
|
||||||
page->pageScroll(Page::ScrollDirectionForward);
|
page->pageScroll(Page::ScrollDirectionForward);
|
||||||
|
page->reallocateMenuSpritePoints();
|
||||||
state = RETROFE_HIGHLIGHT_REQUEST;
|
state = RETROFE_HIGHLIGHT_REQUEST;
|
||||||
}
|
}
|
||||||
if (input_.keystate(UserInput::KeyCodeLetterUp))
|
if (input_.keystate(UserInput::KeyCodeLetterUp))
|
||||||
{
|
{
|
||||||
page->letterScroll(Page::ScrollDirectionBack);
|
page->letterScroll(Page::ScrollDirectionBack);
|
||||||
|
page->reallocateMenuSpritePoints();
|
||||||
state = RETROFE_HIGHLIGHT_REQUEST;
|
state = RETROFE_HIGHLIGHT_REQUEST;
|
||||||
}
|
}
|
||||||
if (input_.keystate(UserInput::KeyCodeLetterDown))
|
if (input_.keystate(UserInput::KeyCodeLetterDown))
|
||||||
{
|
{
|
||||||
page->letterScroll(Page::ScrollDirectionForward);
|
page->letterScroll(Page::ScrollDirectionForward);
|
||||||
|
page->reallocateMenuSpritePoints();
|
||||||
state = RETROFE_HIGHLIGHT_REQUEST;
|
state = RETROFE_HIGHLIGHT_REQUEST;
|
||||||
}
|
}
|
||||||
if(input_.newKeyPressed(UserInput::KeyCodeNextPlaylist))
|
if(input_.newKeyPressed(UserInput::KeyCodeNextPlaylist))
|
||||||
{
|
{
|
||||||
page->nextPlaylist();
|
page->nextPlaylist();
|
||||||
|
page->reallocateMenuSpritePoints();
|
||||||
state = RETROFE_HIGHLIGHT_REQUEST;
|
state = RETROFE_HIGHLIGHT_REQUEST;
|
||||||
}
|
}
|
||||||
if(input_.newKeyPressed(UserInput::KeyCodeRemovePlaylist))
|
if(input_.newKeyPressed(UserInput::KeyCodeRemovePlaylist))
|
||||||
{
|
{
|
||||||
page->removePlaylist();
|
page->removePlaylist();
|
||||||
|
page->reallocateMenuSpritePoints();
|
||||||
}
|
}
|
||||||
if(input_.newKeyPressed(UserInput::KeyCodeAddPlaylist))
|
if(input_.newKeyPressed(UserInput::KeyCodeAddPlaylist))
|
||||||
{
|
{
|
||||||
page->addPlaylist();
|
page->addPlaylist();
|
||||||
|
page->reallocateMenuSpritePoints();
|
||||||
}
|
}
|
||||||
if(input_.keystate(UserInput::KeyCodeRandom))
|
if(input_.keystate(UserInput::KeyCodeRandom))
|
||||||
{
|
{
|
||||||
page->selectRandom();
|
page->selectRandom();
|
||||||
|
page->reallocateMenuSpritePoints();
|
||||||
state = RETROFE_HIGHLIGHT_REQUEST;
|
state = RETROFE_HIGHLIGHT_REQUEST;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user