Skip to content

Commit

Permalink
Merge PR 'Use the text from modinfo.txt as the mod menu entry'
Browse files Browse the repository at this point in the history
Copies the text from the `modinfo.txt` into the name field for the mod
list entry. If there is no text the mod directory name is used as
before.

![image](https://github.com/DarkPlacesEngine/darkplaces/assets/424218/b6b5da57-7590-407e-920c-21bca23ef2bb)

Fixes Alkaline 1.2 failing to appear in the mod list (its dir is
`alk1.2`).

See DarkPlacesEngine/DarkPlaces#168

---------

Signed-off-by: bones_was_here <[email protected]>
Co-authored-by: bones_was_here <[email protected]>
  • Loading branch information
hemebond and bones-was-here authored Apr 21, 2024
1 parent 1f4743e commit 3848c33
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -4524,7 +4524,7 @@ typedef struct modlist_entry_s
qbool loaded; // used to determine whether this entry is loaded and running
int enabled; // index to array of modlist_enabled

// name of the modification, this is (will...be) displayed on the menu entry
// name of the modification, this is displayed on the menu entry
char name[128];
// directory where we will find it
char dir[MAX_QPATH];
Expand All @@ -4549,8 +4549,7 @@ static void ModList_RebuildList(void)
modlist_numenabled = fs_numgamedirs;
for (i = 0;i < list.numstrings && modlist_count < MODLIST_TOTALSIZE;i++)
{
// quickly skip names with dot characters - generally these are files, not directories
if (strchr(list.strings[i], '.')) continue;
int desc_len;

// reject any dirs that are part of the base game
if (gamedirname1 && !strcasecmp(gamedirname1, list.strings[i])) continue;
Expand All @@ -4562,6 +4561,14 @@ static void ModList_RebuildList(void)
description = FS_CheckGameDir(list.strings[i]);
if (description == NULL || description == fs_checkgamedir_missing) continue;

desc_len = min(strlen(description), sizeof(modlist[modlist_count].name));
for (j = 0; j < desc_len; ++j)
if (!ISWHITESPACE(description[j]))
{
dp_strlcpy(modlist[modlist_count].name, description, sizeof(modlist[modlist_count].name));
break;
}

dp_strlcpy (modlist[modlist_count].dir, list.strings[i], sizeof(modlist[modlist_count].dir));
//check currently loaded mods
modlist[modlist_count].loaded = false;
Expand Down Expand Up @@ -4681,8 +4688,10 @@ static void M_ModList_Draw (void)
{
for (n = start;n < end;n++)
{
const char *item_label = (modlist[n].name[0] != '\0') ? modlist[n].name : modlist[n].dir;

DrawQ_Pic(menu_x + 40, menu_y + y, NULL, 360, 8, n == modlist_cursor ? (0.5 + 0.2 * sin(host.realtime * M_PI)) : 0, 0, 0, 0.5, 0);
M_ItemPrint(80, y, modlist[n].dir, true);
M_ItemPrint(80, y, item_label, true);
M_DrawCheckbox(48, y, modlist[n].loaded);
y +=8;
}
Expand Down

0 comments on commit 3848c33

Please sign in to comment.