mirror of
https://github.com/geode-sdk/geode.git
synced 2025-04-24 05:14:40 -04:00
support for sorting by category (seems like makeMenuSelector is causing
crashes, will have to look into that)
This commit is contained in:
parent
1599a6ca04
commit
67a88d7ffc
5 changed files with 32 additions and 7 deletions
loader
include/Geode/utils
launcher/windows
src/ui/internal/list
|
@ -396,9 +396,7 @@ namespace geode::cocos {
|
|||
if (m_assigned) {
|
||||
return m_lambda(std::forward<Args>(args)...);
|
||||
} else {
|
||||
if constexpr (!std::is_void_v<Ret>) {
|
||||
return Ret();
|
||||
}
|
||||
return Ret();
|
||||
}
|
||||
}
|
||||
void assign(F&& func) {
|
||||
|
|
|
@ -12,4 +12,4 @@ add_custom_command(
|
|||
DEPENDS $<TARGET_FILE:proxy_loader>
|
||||
VERBATIM
|
||||
TARGET proxy_loader
|
||||
)
|
||||
)
|
||||
|
|
|
@ -394,6 +394,17 @@ bool ModListView::filter(IndexItem const& item, ModListQuery const& query) {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (query.m_categories.size()) {
|
||||
bool found = false;
|
||||
for (auto& cat : query.m_categories) {
|
||||
if (item.m_categories.count(cat)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (auto& plat : query.m_platforms) {
|
||||
if (item.m_download.m_platforms.count(plat)) {
|
||||
return filter(item.m_info, query);
|
||||
|
|
|
@ -102,6 +102,7 @@ struct ModListQuery {
|
|||
int m_searchFlags = ALL_FLAGS;
|
||||
bool m_showInstalled = false;
|
||||
std::unordered_set<PlatformID> m_platforms { GEODE_PLATFORM_TARGET };
|
||||
std::unordered_set<std::string> m_categories {};
|
||||
};
|
||||
|
||||
class ModListView : public CustomListView {
|
||||
|
|
|
@ -86,11 +86,26 @@ bool SearchFilterPopup::setup(ModListLayer* layer, ModListType type) {
|
|||
for (auto& category : Index::get()->getCategories()) {
|
||||
this->addToggle(
|
||||
category.c_str(),
|
||||
nullptr,
|
||||
false,
|
||||
makeMenuSelector([this](CCMenuItemToggler* toggle) {
|
||||
// seems like C++ generates the same lambda if you try to
|
||||
// capture category so all toggles will use the same one
|
||||
// which is not wanted
|
||||
try {
|
||||
if (!toggle->isToggled()) {
|
||||
m_modLayer->m_query.m_categories.insert(
|
||||
static_cast<CCString*>(toggle->getUserObject())->getCString()
|
||||
);
|
||||
} else {
|
||||
m_modLayer->m_query.m_categories.erase(
|
||||
static_cast<CCString*>(toggle->getUserObject())->getCString()
|
||||
);
|
||||
}
|
||||
} catch(...) {}
|
||||
}),
|
||||
m_modLayer->m_query.m_categories.count(category),
|
||||
0,
|
||||
pos
|
||||
);
|
||||
)->setUserObject(CCString::create(category));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue