have to commit to work elsewhere :/

This commit is contained in:
HJfod 2024-03-26 22:25:05 +02:00
parent 9953904628
commit 984cb81535
4 changed files with 12 additions and 12 deletions

View file

@ -40,7 +40,7 @@ bool ModList::init(ModListSource* src, CCSize const& size) {
m_searchInput->setCallback([this](auto const&) {
// If the source is already in memory, we can immediately update the
// search query
if (m_source->isInMemory()) {
if (m_source->isInstalledMods()) {
m_source->setQuery(m_searchInput->getString());
this->gotoPage(0);
return;
@ -89,6 +89,10 @@ bool ModList::init(ModListSource* src, CCSize const& size) {
// Do not add search menu; that's handled by onSearch
if (m_source->isInstalledMods()) {
// todo
}
// Paging
auto pageLeftMenu = CCMenu::create();

View file

@ -31,6 +31,7 @@ protected:
CCMenuItemSpriteExtra* m_pagePrevBtn;
CCMenuItemSpriteExtra* m_pageNextBtn;
Ref<CCNode> m_searchMenu;
Ref<CCNode> m_viewUpdatesMenu;
TextInput* m_searchInput;
EventListener<UpdateModListStateFilter> m_updateStateListener;
bool m_bigSize = false;

View file

@ -170,10 +170,9 @@ void ModListSource::setQuery(std::string const& query) {
}
}
bool ModListSource::isInMemory() const {
return m_provider.inMemory;
bool ModListSource::isInstalledMods() const {
return m_provider.isInstalledMods;
}
bool ModListSource::wantsRestart() const {
return m_provider.wantsRestart && m_provider.wantsRestart();
}
@ -199,7 +198,7 @@ ModListSource* ModListSource::get(ModListSourceType type) {
}
return false;
},
.inMemory = true,
.isInstalledMods = true,
}));
return inst;
} break;

View file

@ -43,7 +43,7 @@ public:
struct Provider {
ProviderPromise(*get)(server::ModsQuery&& query) = nullptr;
bool(*wantsRestart)() = nullptr;
bool inMemory = false;
bool isInstalledMods = false;
};
protected:
@ -71,12 +71,8 @@ public:
std::optional<size_t> getItemCount() const;
/**
* True if the source is already fully loaded in memory (doesn't fetch
* from a server or filesystem)
*
* Used to determine whether things like searching should update the query
* instantaniously or buffer a bit to avoid spamming unnecessary requests
* True if the source consists only of installed mods
*/
bool isInMemory() const;
bool isInstalledMods() const;
bool wantsRestart() const;
};