Remember the last highlighted item when re-entering a menu.

This commit is contained in:
emb 2015-05-29 19:25:16 -05:00
parent 836e18abd3
commit a3948b9ad2
6 changed files with 42 additions and 1 deletions

View File

@ -269,6 +269,21 @@ void ScrollingList::SetPoints(std::vector<ViewInfo *> *scrollPoints, std::vector
TweenPoints = tweenPoints; 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) void ScrollingList::SetSelectedIndex(int selectedIndex)
{ {
SelectedSpriteListIndex = selectedIndex; SelectedSpriteListIndex = selectedIndex;

View File

@ -68,6 +68,8 @@ public:
void LetterUp(); void LetterUp();
void LetterDown(); void LetterDown();
bool IsIdle(); bool IsIdle();
unsigned int GetScrollOffsetIndex();
void SetScrollOffsetIndex(unsigned int index);
void SetSelectedIndex(int selectedIndex); void SetSelectedIndex(int selectedIndex);
ComponentItemBinding *GetSelectedCollectionItemSprite(); ComponentItemBinding *GetSelectedCollectionItemSprite();
ComponentItemBinding *GetPendingCollectionItemSprite(); ComponentItemBinding *GetPendingCollectionItemSprite();

View File

@ -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) void Page::SetMinShowTime(float value)
{ {
MinShowTime = value; MinShowTime = value;

View File

@ -63,6 +63,8 @@ public:
unsigned int GetMenuDepth(); unsigned int GetMenuDepth();
Item *GetSelectedItem(); Item *GetSelectedItem();
void RemoveSelectedItem(); void RemoveSelectedItem();
void SetScrollOffsetIndex(unsigned int i);
unsigned int GetScrollOffsetIndex();
bool IsIdle(); bool IsIdle();
bool IsMenuIdle(); bool IsMenuIdle();
bool IsHidden(); bool IsHidden();

View File

@ -307,6 +307,7 @@ void RetroFE::Run()
break; break;
case RETROFE_BACK_REQUEST: case RETROFE_BACK_REQUEST:
LastMenuOffsets[CurrentPage->GetCollectionName()] = CurrentPage->GetScrollOffsetIndex();
CurrentPage->PopCollection(); CurrentPage->PopCollection();
Config.SetCurrentCollection(CurrentPage->GetCollectionName()); Config.SetCurrentCollection(CurrentPage->GetCollectionName());
@ -419,7 +420,7 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page)
} }
if (Input.GetKeyState(UserInput::KeyCodeDown)) if (Input.GetKeyState(UserInput::KeyCodeDown))
{ {
page->SetScrolling(Page::ScrollDirectionForward); page->SetScrolling(Page::ScrollDirectionForward);
} }
} }
if (Input.GetKeyState(UserInput::KeyCodePageUp)) if (Input.GetKeyState(UserInput::KeyCodePageUp))
@ -462,6 +463,11 @@ RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page)
mp.GetMenuItems(info); mp.GetMenuItems(info);
page->PushCollection(info); page->PushCollection(info);
if(LastMenuOffsets.find(NextPageItem->GetName()) != LastMenuOffsets.end())
{
page->SetScrollOffsetIndex(LastMenuOffsets[NextPageItem->GetName()]);
}
state = RETROFE_NEXT_PAGE_REQUEST; state = RETROFE_NEXT_PAGE_REQUEST;
} }
} }

View File

@ -26,6 +26,7 @@
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <list> #include <list>
#include <vector> #include <vector>
#include <map>
class CollectionInfo; class CollectionInfo;
class Configuration; class Configuration;
@ -78,5 +79,6 @@ private:
Item *NextPageItem; Item *NextPageItem;
FontCache FC; FontCache FC;
AttractMode Attract; AttractMode Attract;
std::map<std::string, unsigned int> LastMenuOffsets;
}; };