From 485b995196ba7158aea4c60b9487afc14b894171 Mon Sep 17 00:00:00 2001 From: Gemba Date: Sun, 14 Apr 2024 18:17:07 +0200 Subject: [PATCH] Fix for cursor overrun in last played collection when LR/LB paging is active and fix cursor placement when changing theme with a smaller/larger gamelist viewport. --- es-app/src/CollectionSystemManager.cpp | 3 +++ es-app/src/components/TextListComponent.h | 5 +++++ es-app/src/guis/GuiMenu.cpp | 3 +-- es-app/src/views/ViewController.cpp | 12 +++++++----- es-app/src/views/ViewController.h | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/es-app/src/CollectionSystemManager.cpp b/es-app/src/CollectionSystemManager.cpp index 610e626752..a040a8e4e7 100644 --- a/es-app/src/CollectionSystemManager.cpp +++ b/es-app/src/CollectionSystemManager.cpp @@ -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::REFRESH_LIST_CURSOR_POS); } else ViewController::get()->onFileChanged(rootFolder, FILE_SORTED); diff --git a/es-app/src/components/TextListComponent.h b/es-app/src/components/TextListComponent.h index 1c9080674a..2250769d30 100644 --- a/es-app/src/components/TextListComponent.h +++ b/es-app/src/components/TextListComponent.h @@ -392,6 +392,11 @@ void TextListComponent::onCursorChanged(const CursorState& state) template void TextListComponent::applyTheme(const std::shared_ptr& 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"); diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 09f377e0d9..b3150db4a5 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -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 } }); } diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index c0a348349c..3d5079acec 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -555,7 +555,7 @@ void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme) } -void ViewController::reloadAll() +void ViewController::reloadAll(bool themeChanged) { // clear all gamelistviews std::map 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 diff --git a/es-app/src/views/ViewController.h b/es-app/src/views/ViewController.h index 0a8696d0a3..13a9a0c7a0 100644 --- a/es-app/src/views/ViewController.h +++ b/es-app/src/views/ViewController.h @@ -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();