From 4908f4bdcf2f87bd5649d2a985877b962cfcbdc3 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Fri, 13 Dec 2024 20:13:43 -0500 Subject: [PATCH] Automatically categorize CS mods --- src/pc/djui/djui_panel_host_mods.c | 8 ++++---- src/pc/mods/mod.c | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pc/djui/djui_panel_host_mods.c b/src/pc/djui/djui_panel_host_mods.c index ff1708987..74390a72f 100644 --- a/src/pc/djui/djui_panel_host_mods.c +++ b/src/pc/djui/djui_panel_host_mods.c @@ -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; diff --git a/src/pc/mods/mod.c b/src/pc/mods/mod.c index 30357348c..3ee2fb8b1 100644 --- a/src/pc/mods/mod.c +++ b/src/pc/mods/mod.c @@ -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++) {