diff --git a/loader/src/ui/internal/list/ModListLayer.cpp b/loader/src/ui/internal/list/ModListLayer.cpp index 3a5cf1d3..ae936bed 100644 --- a/loader/src/ui/internal/list/ModListLayer.cpp +++ b/loader/src/ui/internal/list/ModListLayer.cpp @@ -444,13 +444,18 @@ void ModListLayer::createSearchControl() { this->addChild(m_searchInput); } -void ModListLayer::reloadList(std::optional const& query) { +void ModListLayer::reloadList(bool keepScroll, std::optional const& query) { auto winSize = CCDirector::sharedDirector()->getWinSize(); if (query) { m_query = query.value(); } + float scroll = 0.0f; + if (keepScroll && m_list) { + scroll = m_list->m_listView->m_tableView->m_contentLayer->getPositionY(); + } + // set search query m_query.keywords = m_searchInput && @@ -489,6 +494,12 @@ void ModListLayer::reloadList(std::optional const& query) { m_listLabel->setVisible(false); } + if (keepScroll) { + list->m_tableView->m_contentLayer->setPosition( + { 0.0f, scroll } + ); + } + // update index if needed if (g_tab == ModListType::Download && !Index::get()->hasTriedToUpdate()) { m_listLabel->setVisible(true); @@ -686,7 +697,7 @@ void ModListLayer::keyDown(enumKeyCodes key) { } void ModListLayer::textChanged(CCTextInputNode* input) { - this->reloadList(); + this->reloadList(false); } // Constructors etc. diff --git a/loader/src/ui/internal/list/ModListLayer.hpp b/loader/src/ui/internal/list/ModListLayer.hpp index 648e8309..0afa2839 100644 --- a/loader/src/ui/internal/list/ModListLayer.hpp +++ b/loader/src/ui/internal/list/ModListLayer.hpp @@ -94,5 +94,5 @@ public: ModListDisplay getDisplay() const; ModListQuery& getQuery(); - void reloadList(std::optional const& query = std::nullopt); + void reloadList(bool keepScroll = true, std::optional const& query = std::nullopt); }; diff --git a/loader/src/ui/internal/list/SearchFilterPopup.cpp b/loader/src/ui/internal/list/SearchFilterPopup.cpp index 61353a7e..e64ed651 100644 --- a/loader/src/ui/internal/list/SearchFilterPopup.cpp +++ b/loader/src/ui/internal/list/SearchFilterPopup.cpp @@ -175,7 +175,7 @@ void SearchFilterPopup::onPlatformToggle(CCObject* sender) { void SearchFilterPopup::onClose(CCObject* sender) { Popup::onClose(sender); - m_modLayer->reloadList(); + m_modLayer->reloadList(false); } SearchFilterPopup* SearchFilterPopup::create(ModListLayer* layer, ModListType type) {