Cursor positions inside folders and grouped collections are now remembered.

This commit is contained in:
Leon Styhre 2020-12-20 12:07:02 +01:00
parent 0cce86beca
commit 7fb06a5702
5 changed files with 41 additions and 2 deletions

View file

@ -56,6 +56,7 @@ Many bugs have been fixed, and numerous features that were only partially implem
* Added a gamelist info text field displaying the game count, any applied filters as well as an icon if a folder has been entered * Added a gamelist info text field displaying the game count, any applied filters as well as an icon if a folder has been entered
* Expanded the gamelist filter functionality to include completed and broken games as well as the ability to filter on game names (via free text entry) * Expanded the gamelist filter functionality to include completed and broken games as well as the ability to filter on game names (via free text entry)
* Expanded the metadata for folders and made it possible to mark them as favorites * Expanded the metadata for folders and made it possible to mark them as favorites
* Added functionality to remember cursor positions inside folders and grouped custom collections
* Added new component GuiComplexTextEditPopup to handle changes to configuration file entries and similar * Added new component GuiComplexTextEditPopup to handle changes to configuration file entries and similar
* Speed improvements and optimizations, the application now starts faster and feels more responsive * Speed improvements and optimizations, the application now starts faster and feels more responsive
* Replaced the on and off button icons with new graphics * Replaced the on and off button icons with new graphics

View file

@ -747,6 +747,11 @@ void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
bool isCurrent = (mCurrentView == it->second); bool isCurrent = (mCurrentView == it->second);
SystemData* system = it->first; SystemData* system = it->first;
FileData* cursor = view->getCursor(); FileData* cursor = view->getCursor();
// Retain the cursor history for the view.
std::vector<FileData*> cursorHistoryTemp;
it->second->copyCursorHistory(cursorHistoryTemp);
mGameListViews.erase(it); mGameListViews.erase(it);
if (reloadTheme) if (reloadTheme)
@ -761,6 +766,7 @@ void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
if (isCurrent) if (isCurrent)
mCurrentView = newView; mCurrentView = newView;
newView->populateCursorHistory(cursorHistoryTemp);
break; break;
} }
} }

View file

@ -48,6 +48,9 @@ public:
virtual FileData* getFirstGameEntry() = 0; virtual FileData* getFirstGameEntry() = 0;
virtual const std::vector<std::string>& getFirstLetterIndex() = 0; virtual const std::vector<std::string>& getFirstLetterIndex() = 0;
virtual void copyCursorHistory(std::vector<FileData*>& cursorHistory) = 0;
virtual void populateCursorHistory(std::vector<FileData*>& cursorHistory) = 0;
virtual bool input(InputConfig* config, Input input) override; virtual bool input(InputConfig* config, Input input) override;
virtual void remove(FileData* game, bool deleteFile) = 0; virtual void remove(FileData* game, bool deleteFile) = 0;
virtual void removeMedia(FileData* game) = 0; virtual void removeMedia(FileData* game) = 0;

View file

@ -18,6 +18,8 @@
#include "Sound.h" #include "Sound.h"
#include "SystemData.h" #include "SystemData.h"
#include "Log.h"
ISimpleGameListView::ISimpleGameListView( ISimpleGameListView::ISimpleGameListView(
Window* window, Window* window,
FileData* root) FileData* root)
@ -116,8 +118,25 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
NavigationSounds::getInstance()->playThemeNavigationSound(SELECTSOUND); NavigationSounds::getInstance()->playThemeNavigationSound(SELECTSOUND);
mCursorStack.push(cursor); mCursorStack.push(cursor);
populateList(cursor->getChildrenListToDisplay(), cursor); populateList(cursor->getChildrenListToDisplay(), cursor);
FileData* cursor = getCursor();
setCursor(cursor); FileData* newCursor = nullptr;
std::vector<FileData*> listEntries = cursor->getChildrenListToDisplay();
// Check if there is an entry in the cursor stack history matching any entry
// in the currect folder. If so, select that entry.
for (auto it = mCursorStackHistory.begin();
it != mCursorStackHistory.end(); it++) {
if (std::find(listEntries.begin(), listEntries.end(), *it) !=
listEntries.end()) {
newCursor = *it;
mCursorStackHistory.erase(it);
break;
}
}
// If there was no match in the cursor history, simply select the first entry.
if (!newCursor)
newCursor = getCursor();
setCursor(newCursor);
} }
} }
@ -126,6 +145,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
else if (config->isMappedTo("b", input)) { else if (config->isMappedTo("b", input)) {
ViewController::get()->cancelViewTransitions(); ViewController::get()->cancelViewTransitions();
if (mCursorStack.size()) { if (mCursorStack.size()) {
// Save the position to the cursor stack history.
mCursorStackHistory.push_back(getCursor());
NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND); NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND);
populateList(mCursorStack.top()->getParent()->getChildrenListToDisplay(), populateList(mCursorStack.top()->getParent()->getChildrenListToDisplay(),
mCursorStack.top()->getParent()); mCursorStack.top()->getParent());

View file

@ -35,6 +35,13 @@ public:
virtual const std::vector<std::string>& getFirstLetterIndex() override = 0; virtual const std::vector<std::string>& getFirstLetterIndex() override = 0;
// These functions are used to retain the folder cursor history, for instance
// during a view reload. The calling function stores the history temporarily.
void copyCursorHistory(std::vector<FileData*>& cursorHistory) override
{ cursorHistory = mCursorStackHistory; };
void populateCursorHistory(std::vector<FileData*>& cursorHistory) override
{ mCursorStackHistory = cursorHistory; };
protected: protected:
virtual std::string getQuickSystemSelectRightButton() = 0; virtual std::string getQuickSystemSelectRightButton() = 0;
virtual std::string getQuickSystemSelectLeftButton() = 0; virtual std::string getQuickSystemSelectLeftButton() = 0;
@ -49,6 +56,7 @@ protected:
std::vector<GuiComponent*> mThemeExtras; std::vector<GuiComponent*> mThemeExtras;
std::stack<FileData*> mCursorStack; std::stack<FileData*> mCursorStack;
std::vector<FileData*> mCursorStackHistory;
std::vector<std::string> mFirstLetterIndex; std::vector<std::string> mFirstLetterIndex;