Skip to content

Commit

Permalink
Merge pull request RetroPie#874 from Gemba/fix_lrlb_paging_cursor_mis…
Browse files Browse the repository at this point in the history
…placed_lastplayed

Fix cursor overrun in last played collection when LR/LB paging is used
  • Loading branch information
pjft authored Apr 22, 2024
2 parents 95ba158 + 485b995 commit 4a064a2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
3 changes: 3 additions & 0 deletions es-app/src/CollectionSystemManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "CollectionSystemManager.h"

#include "components/TextListComponent.h"
#include "guis/GuiInfoPopup.h"
#include "utils/FileSystemUtil.h"
#include "utils/StringUtil.h"
Expand Down Expand Up @@ -284,6 +285,8 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS
{
trimCollectionCount(rootFolder, LAST_PLAYED_MAX, false);
ViewController::get()->onFileChanged(rootFolder, FILE_METADATA_CHANGED);
// Force re-calculation of cursor position
ViewController::get()->getGameListView(curSys)->setViewportTop(TextListComponent<FileData>::REFRESH_LIST_CURSOR_POS);
}
else
ViewController::get()->onFileChanged(rootFolder, FILE_SORTED);
Expand Down
5 changes: 5 additions & 0 deletions es-app/src/components/TextListComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ void TextListComponent<T>::onCursorChanged(const CursorState& state)
template <typename T>
void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view, const std::string& element, unsigned int properties)
{
if(Settings::getInstance()->getBool("UseFullscreenPaging"))
{
mViewportTop = REFRESH_LIST_CURSOR_POS;
}

GuiComponent::applyTheme(theme, view, element, properties);

const ThemeData::ThemeElement* elem = theme->getElement(view, element, "textlist");
Expand Down
3 changes: 1 addition & 2 deletions es-app/src/guis/GuiMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ void GuiMenu::openUISettings()
{
Scripting::fireEvent("theme-changed", theme_set->getSelected(), oldTheme);
CollectionSystemManager::get()->updateSystemsList();
ViewController::get()->goToStart();
ViewController::get()->reloadAll(); // TODO - replace this with some sort of signal-based implementation
ViewController::get()->reloadAll(true); // TODO - replace this with some sort of signal-based implementation
}
});
}
Expand Down
12 changes: 7 additions & 5 deletions es-app/src/views/ViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)

}

void ViewController::reloadAll()
void ViewController::reloadAll(bool themeChanged)
{
// clear all gamelistviews
std::map<SystemData*, FileData*> cursorMap;
Expand All @@ -567,7 +567,6 @@ void ViewController::reloadAll()
}
mGameListViews.clear();


// load themes, create gamelistviews and reset filters
for(auto it = cursorMap.cbegin(); it != cursorMap.cend(); it++)
{
Expand All @@ -576,10 +575,13 @@ void ViewController::reloadAll()
getGameListView(it->first)->setCursor(it->second);
}

// restore index of first list item on display
for(auto it = viewportTopMap.cbegin(); it != viewportTopMap.cend(); it++)
if(!themeChanged || !Settings::getInstance()->getBool("UseFullscreenPaging"))
{
getGameListView(it->first)->setViewportTop(it->second);
// restore index of first list item on display
for(auto it = viewportTopMap.cbegin(); it != viewportTopMap.cend(); it++)
{
getGameListView(it->first)->setViewportTop(it->second);
}
}

// Rebuild SystemListView
Expand Down
2 changes: 1 addition & 1 deletion es-app/src/views/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ViewController : public GuiComponent
// the current gamelist view (as it may change to be detailed).
void reloadGameListView(IGameListView* gamelist, bool reloadTheme = false);
inline void reloadGameListView(SystemData* system, bool reloadTheme = false) { reloadGameListView(getGameListView(system).get(), reloadTheme); }
void reloadAll(); // Reload everything with a theme. Used when the "ThemeSet" setting changes.
void reloadAll(bool themeChanged = false); // Reload everything with a theme. When the "ThemeSet" setting changes, themeChanged is true.

// Navigation.
void goToNextGameList();
Expand Down

0 comments on commit 4a064a2

Please sign in to comment.