Automatically categorize CS mods

This commit is contained in:
Agent X 2024-12-13 20:13:43 -05:00
parent 7b8cb0254f
commit 4908f4bdcf
2 changed files with 9 additions and 4 deletions

View file

@ -25,7 +25,7 @@ static struct DjuiText* sTooltip = NULL;
static struct DjuiPaginated* sModPaginated = NULL;
static struct DjuiButton* sBackButton = NULL;
static struct DjuiButton* sRefreshButton = NULL;
unsigned int selectedCategory = MOD_CATEGORY_ALL;
static unsigned int sSelectedCategory = MOD_CATEGORY_ALL;
static bool sWarned = false;
struct ThreadHandle gModRefreshThread = { 0 };
@ -135,7 +135,7 @@ void djui_panel_host_mods_add_mods(struct DjuiBase* layoutBase) {
for (int i = 0; i < gLocalMods.entryCount; i++) {
struct Mod* mod = gLocalMods.entries[i];
char* category = mod->category != NULL ? mod->category : mod->incompatible;
switch (selectedCategory) {
switch (sSelectedCategory) {
case MOD_CATEGORY_ALL: { break; }
case MOD_CATEGORY_MISC: {
bool doContinue = false;
@ -151,7 +151,7 @@ void djui_panel_host_mods_add_mods(struct DjuiBase* layoutBase) {
break;
}
default: {
if (!category || !strstr(category, sCategories[selectedCategory].category)) {
if (!category || !strstr(category, sCategories[sSelectedCategory].category)) {
continue;
}
break;
@ -224,7 +224,7 @@ void djui_panel_host_mods_create(struct DjuiBase* caller) {
for (int i = 0; i < numCategories; i++) {
categoryChoices[i] = djui_language_get("HOST_MOD_CATEGORIES", sCategories[i].langKey);
}
djui_selectionbox_create(body, DLANG(HOST_MODS, CATEGORIES), categoryChoices, numCategories, &selectedCategory, djui_panel_on_categories_change);
djui_selectionbox_create(body, DLANG(HOST_MODS, CATEGORIES), categoryChoices, numCategories, &sSelectedCategory, djui_panel_on_categories_change);
struct DjuiPaginated* paginated = djui_paginated_create(body, 8);
paginated->showMaxCount = true;
sModLayout = paginated->layout;

View file

@ -547,6 +547,11 @@ bool mod_load(struct Mods* mods, char* basePath, char* modName) {
mod->name = strdup(modName);
}
// set category
if ((mod->category == NULL) && (strlen(mod->name) > 5) && (strncmp(mod->name, "[CS] ", 5) == 0)) {
mod->category = strdup("cs");
}
// print
// LOG_INFO(" %s", mod->name);
for (int i = 0; i < mod->fileCount; i++) {