From a9cce769d5d507efeaee6b853c65bbc857ef6b5a Mon Sep 17 00:00:00 2001 From: ConfiG Date: Thu, 10 Aug 2023 23:35:55 +0300 Subject: [PATCH] fix index ui with show installed filter on --- loader/src/ui/internal/info/ModInfoPopup.cpp | 2 ++ loader/src/ui/internal/list/ModListCell.cpp | 6 ++++-- loader/src/ui/internal/list/ModListLayer.cpp | 8 +++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/loader/src/ui/internal/info/ModInfoPopup.cpp b/loader/src/ui/internal/info/ModInfoPopup.cpp index 92068f44..ea77de18 100644 --- a/loader/src/ui/internal/info/ModInfoPopup.cpp +++ b/loader/src/ui/internal/info/ModInfoPopup.cpp @@ -686,6 +686,8 @@ bool IndexItemInfoPopup::init(IndexItemHandle item, ModListLayer* list) { if (!ModInfoPopup::init(item->getMetadata(), list)) return false; + if (item->isInstalled()) return true; + m_installBtnSpr = IconButtonSprite::create( "GE_button_01.png"_spr, CCSprite::createWithSpriteFrameName("install.png"_spr), diff --git a/loader/src/ui/internal/list/ModListCell.cpp b/loader/src/ui/internal/list/ModListCell.cpp index c9fcdf8f..25e026de 100644 --- a/loader/src/ui/internal/list/ModListCell.cpp +++ b/loader/src/ui/internal/list/ModListCell.cpp @@ -387,9 +387,11 @@ bool IndexItemCell::init( m_item = item; - this->setupInfo(item->getMetadata(), item->getTags().size(), display, item->isInstalled()); + bool justInstalled = item->isInstalled() && !Loader::get()->isModInstalled(item->getMetadata().getID()); - if (item->isInstalled()) { + this->setupInfo(item->getMetadata(), item->getTags().size(), display, justInstalled); + + if (justInstalled) { auto restartSpr = ButtonSprite::create("Restart", "bigFont.fnt", "GJ_button_03.png", .8f); restartSpr->setScale(.65f); diff --git a/loader/src/ui/internal/list/ModListLayer.cpp b/loader/src/ui/internal/list/ModListLayer.cpp index 8a768c65..8bb873a3 100644 --- a/loader/src/ui/internal/list/ModListLayer.cpp +++ b/loader/src/ui/internal/list/ModListLayer.cpp @@ -136,7 +136,7 @@ static std::optional queryMatch(ModListQuery const& query, IndexItemHandle static std::optional queryMatch(ModListQuery const& query, InvalidGeodeFile const& info) { // if any explicit filters were provided, no match - if (query.tags.size() || query.keywords.has_value()) { + if (!query.tags.empty() || query.keywords.has_value()) { return std::nullopt; } return 0; @@ -162,9 +162,11 @@ CCArray* ModListLayer::createModCells(ModListType type, ModListQuery const& quer // newly installed for (auto const& item : Index::get()->getItems()) { - if (!item->isInstalled()) + if (!item->isInstalled() || + Loader::get()->isModInstalled(item->getMetadata().getID())) continue; - if (auto match = queryMatch(query, item)) { + // match the same as other installed mods + if (auto match = queryMatchKeywords(query, item->getMetadata())) { auto cell = IndexItemCell::create(item, this, m_display, this->getCellSize()); sorted.insert({ match.value(), cell }); }