Skip to content

Commit

Permalink
Level-stats selection settings
Browse files Browse the repository at this point in the history
Resolves #113.
  • Loading branch information
MrAlaux committed Sep 25, 2024
1 parent 2ae249b commit ad2afe1
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- **_Flip Levels_** setting [thanks @ceski-1]
- **_Allow [Weapon] Switch Interruption_** setting
- **_Message Flash_** setting
- **Level-Stats Selection** settings
- **Support for powerup-timer icons**
- Replaced `hud_stats_icons` with `hud_allow_icons` [1]
- **Support for crouching-player sprites**
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ For these settings, their CVAR names are provided alongside the _CFG-only_ label
- **_Show Powerup Timers_** setting
- **Show SSG availability in the Shotgun slot of the Arms widget** setting (CFG-only: `show_ssg`) [p.f. Crispy Doom]
- **_Level-Stats Format_** settings [i.b. Crispy Doom]
- **Level-Stats Selection** settings (CFG-only: `hud_stats_#[_map]`)
- **_Highlight Current/Pending Weapon_** setting [i.b. PSX Doom]
- **_Alternative Arms Display_** setting, to show the Chainsaw or SSG's availability on the Arms widget in place of the trivial Pistol
- **Event Timers:**
Expand Down
2 changes: 2 additions & 0 deletions src/am_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,8 @@ void AM_ChangeMode(automapmode_t mode)
AM_activateNewScale();
}
}

HU_Start();
}

//
Expand Down
2 changes: 2 additions & 0 deletions src/doomstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ int message_flash;
int show_ssg; // CFG-only
int hud_stats_format;
int hud_stats_format_map;
int hud_stats_show[NUMSHOWSTATS];
int hud_stats_show_map[NUMSHOWSTATS];
int hud_allow_icons;
int hud_highlight_weapon;
int alt_arms;
Expand Down
12 changes: 11 additions & 1 deletion src/doomstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,18 @@ enum {
};
extern int hud_stats_format;
extern int hud_stats_format_map;
extern int hud_allow_icons;

enum {
SHOWSTATS_KILLS,
SHOWSTATS_ITEMS,
SHOWSTATS_SECRETS,

NUMSHOWSTATS
};
extern int hud_stats_show[];
extern int hud_stats_show_map[];

extern int hud_allow_icons;
extern int hud_highlight_weapon;
extern int alt_arms;

Expand Down
83 changes: 64 additions & 19 deletions src/hu_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,9 +737,18 @@ void HU_Start(void)
&boom_font, colrngs[CR_GRAY],
NULL, deathmatch ? HU_widget_build_frag : HU_widget_build_keys);

// [Nugget] /---------------------------------------------------------------

const int *const showstats = (automapactive == AM_FULL) ? hud_stats_show_map : hud_stats_show;
int statslines = 0;

for (int i = 0; i < NUMSHOWSTATS; i++) { statslines += showstats[i]; }

// [Nugget] ---------------------------------------------------------------/

// create the hud monster/secret widget
HUlib_init_multiline(&w_monsec,
MULTILINE(nughud.sts_ml) ? 3 : 1, // [Nugget] NUGHUD
MULTILINE(nughud.sts_ml) ? statslines : MIN(1, statslines), // [Nugget] NUGHUD
&boom_font, colrngs[CR_GRAY],
NULL, HU_widget_build_monsec);
// [FG] in deathmatch: w_keys.builder = HU_widget_build_frag()
Expand Down Expand Up @@ -1326,6 +1335,15 @@ static void HU_widget_build_frag (void)

static void HU_widget_build_monsec(void)
{
// [Nugget] /---------------------------------------------------------------

const int *const showstats = (automapactive == AM_FULL) ? hud_stats_show_map : hud_stats_show;

if (!(showstats[SHOWSTATS_KILLS] || showstats[SHOWSTATS_ITEMS] || showstats[SHOWSTATS_SECRETS]))
{ return; }

// [Nugget] ---------------------------------------------------------------/

char hud_monsecstr[HU_MAXLINELENGTH];
int i;
int fullkillcount, fullitemcount, fullsecretcount;
Expand Down Expand Up @@ -1439,30 +1457,57 @@ static void HU_widget_build_monsec(void)

if (MULTILINE(nughud.sts_ml)) // [Nugget] NUGHUD
{
// [Nugget] HUD icons
// [Nugget] Stats formats from Crispy
// [Nugget] HUD icons | Stats formats from Crispy

M_snprintf(hud_monsecstr, sizeof(hud_monsecstr),
"\x1b%c%c\t\x1b%c%s", killlabelcolor, killlabel, killcolor, kill_str);
HUlib_add_string_to_cur_line(&w_monsec, hud_monsecstr);
if (showstats[SHOWSTATS_KILLS])
{
M_snprintf(hud_monsecstr, sizeof(hud_monsecstr),
"\x1b%c%c\t\x1b%c%s", killlabelcolor, killlabel, killcolor, kill_str);
HUlib_add_string_to_cur_line(&w_monsec, hud_monsecstr);
}

M_snprintf(hud_monsecstr, sizeof(hud_monsecstr),
"\x1b%c%c\t\x1b%c%s", itemlabelcolor, itemlabel, itemcolor, item_str);
HUlib_add_string_to_cur_line(&w_monsec, hud_monsecstr);
if (showstats[SHOWSTATS_ITEMS])
{
M_snprintf(hud_monsecstr, sizeof(hud_monsecstr),
"\x1b%c%c\t\x1b%c%s", itemlabelcolor, itemlabel, itemcolor, item_str);
HUlib_add_string_to_cur_line(&w_monsec, hud_monsecstr);
}

M_snprintf(hud_monsecstr, sizeof(hud_monsecstr),
"\x1b%c%c\t\x1b%c%s", secretlabelcolor, secretlabel, secretcolor, secret_str);
HUlib_add_string_to_cur_line(&w_monsec, hud_monsecstr);
if (showstats[SHOWSTATS_SECRETS])
{
M_snprintf(hud_monsecstr, sizeof(hud_monsecstr),
"\x1b%c%c\t\x1b%c%s", secretlabelcolor, secretlabel, secretcolor, secret_str);
HUlib_add_string_to_cur_line(&w_monsec, hud_monsecstr);
}
}
else
{
// [Nugget] HUD icons
// [Nugget] Stats formats from Crispy
M_snprintf(hud_monsecstr, sizeof(hud_monsecstr),
"\x1b%c%c \x1b%c%s \x1b%c%c \x1b%c%s \x1b%c%c \x1b%c%s",
killlabelcolor, killlabel, killcolor, kill_str,
itemlabelcolor, itemlabel, itemcolor, item_str,
secretlabelcolor, secretlabel, secretcolor, secret_str);
// [Nugget] HUD icons | Stats formats from Crispy

int offset = 0;

if (showstats[SHOWSTATS_KILLS])
{
offset += M_snprintf(hud_monsecstr + offset, sizeof(hud_monsecstr),
"\x1b%c%c \x1b%c%s%s",
killlabelcolor, killlabel, killcolor, kill_str,
(showstats[SHOWSTATS_ITEMS] || showstats[SHOWSTATS_SECRETS]) ? " " : "");
}

if (showstats[SHOWSTATS_ITEMS])
{
offset += M_snprintf(hud_monsecstr + offset, sizeof(hud_monsecstr),
"\x1b%c%c \x1b%c%s%s",
itemlabelcolor, itemlabel, itemcolor, item_str,
showstats[SHOWSTATS_SECRETS] ? " " : "");
}

if (showstats[SHOWSTATS_SECRETS])
{
offset += M_snprintf(hud_monsecstr + offset, sizeof(hud_monsecstr),
"\x1b%c%c \x1b%c%s",
secretlabelcolor, secretlabel, secretcolor, secret_str);
}

HUlib_add_string_to_cur_line(&w_monsec, hud_monsecstr);
}
Expand Down
46 changes: 46 additions & 0 deletions src/m_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3792,6 +3792,52 @@ default_t defaults[] = {

// [Nugget] ---------------------------------------------------------------/

// [Nugget] /---------------------------------------------------------------

{
"hud_stats_kills",
(config_t *) &hud_stats_show[SHOWSTATS_KILLS], NULL,
{1}, {0,1}, number, ss_none, wad_no,
"1 to show the kill count on the stats display"
},

{
"hud_stats_items",
(config_t *) &hud_stats_show[SHOWSTATS_ITEMS], NULL,
{1}, {0,1}, number, ss_none, wad_no,
"1 to show the item count on the stats display"
},

{
"hud_stats_secrets",
(config_t *) &hud_stats_show[SHOWSTATS_SECRETS], NULL,
{1}, {0,1}, number, ss_none, wad_no,
"1 to show the item count on the stats display"
},

{
"hud_stats_kills_map",
(config_t *) &hud_stats_show_map[SHOWSTATS_KILLS], NULL,
{1}, {0,1}, number, ss_none, wad_no,
"1 to show the kill count on the automap's stats display"
},

{
"hud_stats_items_map",
(config_t *) &hud_stats_show_map[SHOWSTATS_ITEMS], NULL,
{1}, {0,1}, number, ss_none, wad_no,
"1 to show the item count on the automap's stats display"
},

{
"hud_stats_secrets_map",
(config_t *) &hud_stats_show_map[SHOWSTATS_SECRETS], NULL,
{1}, {0,1}, number, ss_none, wad_no,
"1 to show the item count on the automap's stats display"
},

// [Nugget] ---------------------------------------------------------------/

{ // [Nugget]
"hud_allow_icons",
(config_t *) &hud_allow_icons, NULL,
Expand Down

0 comments on commit ad2afe1

Please sign in to comment.