Merge pull request #874 from Gemba/fix_lrlb_paging_cursor_misplaced_lastplayed

Fix cursor overrun in last played collection when LR/LB paging is used
This commit is contained in:
pjft 2024-04-22 22:31:58 +01:00 committed by GitHub
commit 4a064a2130
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 8 deletions

View file

@ -1,5 +1,6 @@
#include "CollectionSystemManager.h"
#include "components/TextListComponent.h"
#include "guis/GuiInfoPopup.h"
#include "utils/FileSystemUtil.h"
#include "utils/StringUtil.h"
@ -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);

View file

@ -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");

View file

@ -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
}
});
}

View file

@ -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;
@ -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++)
{
@ -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

View file

@ -28,7 +28,7 @@ public:
// 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();