mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-28 10:44:49 +01:00
Remember the last highlighted item when re-entering a menu.
This commit is contained in:
parent
836e18abd3
commit
a3948b9ad2
@ -269,6 +269,21 @@ void ScrollingList::SetPoints(std::vector<ViewInfo *> *scrollPoints, std::vector
|
||||
TweenPoints = tweenPoints;
|
||||
}
|
||||
|
||||
unsigned int ScrollingList::GetScrollOffsetIndex()
|
||||
{
|
||||
return FirstSpriteIndex;
|
||||
}
|
||||
|
||||
void ScrollingList::SetScrollOffsetIndex(unsigned int index)
|
||||
{
|
||||
if(SpriteList && index < SpriteList->size())
|
||||
{
|
||||
DeallocateSpritePoints();
|
||||
FirstSpriteIndex = index;
|
||||
AllocateSpritePoints();
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollingList::SetSelectedIndex(int selectedIndex)
|
||||
{
|
||||
SelectedSpriteListIndex = selectedIndex;
|
||||
|
||||
@ -68,6 +68,8 @@ public:
|
||||
void LetterUp();
|
||||
void LetterDown();
|
||||
bool IsIdle();
|
||||
unsigned int GetScrollOffsetIndex();
|
||||
void SetScrollOffsetIndex(unsigned int index);
|
||||
void SetSelectedIndex(int selectedIndex);
|
||||
ComponentItemBinding *GetSelectedCollectionItemSprite();
|
||||
ComponentItemBinding *GetPendingCollectionItemSprite();
|
||||
|
||||
@ -291,6 +291,20 @@ void Page::RemoveSelectedItem()
|
||||
|
||||
}
|
||||
|
||||
void Page::SetScrollOffsetIndex(unsigned int i)
|
||||
{
|
||||
if(!ActiveMenu) return;
|
||||
|
||||
ActiveMenu->SetScrollOffsetIndex(i);
|
||||
}
|
||||
|
||||
unsigned int Page::GetScrollOffsetIndex()
|
||||
{
|
||||
if(!ActiveMenu) return -1;
|
||||
|
||||
return ActiveMenu->GetScrollOffsetIndex();
|
||||
}
|
||||
|
||||
void Page::SetMinShowTime(float value)
|
||||
{
|
||||
MinShowTime = value;
|
||||
|
||||
@ -63,6 +63,8 @@ public:
|
||||
unsigned int GetMenuDepth();
|
||||
Item *GetSelectedItem();
|
||||
void RemoveSelectedItem();
|
||||
void SetScrollOffsetIndex(unsigned int i);
|
||||
unsigned int GetScrollOffsetIndex();
|
||||
bool IsIdle();
|
||||
bool IsMenuIdle();
|
||||
bool IsHidden();
|
||||
|
||||
@ -307,6 +307,7 @@ void RetroFE::Run()
|
||||
break;
|
||||
|
||||
case RETROFE_BACK_REQUEST:
|
||||
LastMenuOffsets[CurrentPage->GetCollectionName()] = CurrentPage->GetScrollOffsetIndex();
|
||||
CurrentPage->PopCollection();
|
||||
Config.SetCurrentCollection(CurrentPage->GetCollectionName());
|
||||
|
||||
@ -419,7 +420,7 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page)
|
||||
}
|
||||
if (Input.GetKeyState(UserInput::KeyCodeDown))
|
||||
{
|
||||
page->SetScrolling(Page::ScrollDirectionForward);
|
||||
page->SetScrolling(Page::ScrollDirectionForward);
|
||||
}
|
||||
}
|
||||
if (Input.GetKeyState(UserInput::KeyCodePageUp))
|
||||
@ -461,6 +462,11 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page)
|
||||
MenuParser mp;
|
||||
mp.GetMenuItems(info);
|
||||
page->PushCollection(info);
|
||||
|
||||
if(LastMenuOffsets.find(NextPageItem->GetName()) != LastMenuOffsets.end())
|
||||
{
|
||||
page->SetScrollOffsetIndex(LastMenuOffsets[NextPageItem->GetName()]);
|
||||
}
|
||||
|
||||
state = RETROFE_NEXT_PAGE_REQUEST;
|
||||
}
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include <SDL2/SDL.h>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class CollectionInfo;
|
||||
class Configuration;
|
||||
@ -78,5 +79,6 @@ private:
|
||||
Item *NextPageItem;
|
||||
FontCache FC;
|
||||
AttractMode Attract;
|
||||
std::map<std::string, unsigned int> LastMenuOffsets;
|
||||
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user