From f90461fbb7c2479ef610dbdd81c92b0b56917359 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:36:02 +0200 Subject: [PATCH] make sure mods are aligned to the top on grid view --- loader/src/ui/mods/list/ModList.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/loader/src/ui/mods/list/ModList.cpp b/loader/src/ui/mods/list/ModList.cpp index 123b1ac1..7863d99b 100644 --- a/loader/src/ui/mods/list/ModList.cpp +++ b/loader/src/ui/mods/list/ModList.cpp @@ -15,9 +15,9 @@ static size_t getDisplayPageSize(ModListSource* src, ModListDisplay display) { $execute { listenForSettingChanges("infinite-local-mods-list", [](bool value) { - InstalledModListSource::get(InstalledModListType::All)->reset(); - InstalledModListSource::get(InstalledModListType::OnlyErrors)->reset(); - InstalledModListSource::get(InstalledModListType::OnlyOutdated)->reset(); + InstalledModListSource::get(InstalledModListType::All)->clearCache(); + InstalledModListSource::get(InstalledModListType::OnlyErrors)->clearCache(); + InstalledModListSource::get(InstalledModListType::OnlyOutdated)->clearCache(); // Updates is technically a server mod list :-) So I left it out here }); } @@ -601,6 +601,16 @@ void ModList::updateDisplay(ModListDisplay display) { ); } + // Make sure list isn't too small + // NOTE: Do NOT call `updateLayout` on m_list, it'll undo this! + if (m_list->m_contentLayer->getContentHeight() < m_list->getContentHeight()) { + auto diff = m_list->getContentHeight() - m_list->m_contentLayer->getContentHeight(); + m_list->m_contentLayer->setContentHeight(m_list->getContentHeight()); + for (auto child : CCArrayExt(m_list->m_contentLayer->getChildren())) { + child->setPositionY(child->getPositionY() + diff); + } + } + // Preserve relative scroll position m_list->m_contentLayer->setPositionY(( m_list->m_contentLayer->getContentHeight() - m_list->getContentHeight()