Skip to content

Commit

Permalink
Merge pull request #420 from unectomy/stat_totals_labels
Browse files Browse the repository at this point in the history
Add show labels argument to stat_totals HUD component
  • Loading branch information
kraflab authored Nov 9, 2023
2 parents 9f90811 + 9b49b89 commit 36516ec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
7 changes: 4 additions & 3 deletions prboom2/src/dsda/exhud.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,15 @@ static int dsda_ParseHUDConfig(char** hud_config, int line_i) {
if (!strncmp(command, components[i].name, sizeof(command))) {
int x, y;
int vpt;
int component_args[4] = { 0 };
int component_args[5] = { 0 };
char alignment[16];

found = true;

count = sscanf(args, "%d %d %15s %d %d %d %d", &x, &y, alignment,
count = sscanf(args, "%d %d %15s %d %d %d %d %d", &x, &y, alignment,
&component_args[0], &component_args[1],
&component_args[2], &component_args[3]);
&component_args[2], &component_args[3],
&component_args[4]);
if (count < 3)
I_Error("Invalid hud component args \"%s\"", line);

Expand Down
38 changes: 23 additions & 15 deletions prboom2/src/dsda/hud_components/stat_totals.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
typedef struct {
dsda_text_t component;
dboolean include_kills, include_items, include_secrets;
const char* kills_format;
const char* items_format;
const char* secrets_format;
const char* label_k;
const char* label_i;
const char* label_s;
const char* stat_separator;
} local_component_t;

static local_component_t* local;
Expand Down Expand Up @@ -73,28 +74,33 @@ static void dsda_UpdateComponentText(char* str, size_t max_size) {
length += snprintf(
str,
max_size,
local->kills_format,
"%s%s%s%d/%d%s",
dsda_TextColor(dsda_tc_exhud_totals_label),
killcolor, fullkillcount, max_kill_requirement
local->label_k,
killcolor, fullkillcount, max_kill_requirement,
local->stat_separator
);
}

if (local->include_items) {
length += snprintf(
str + length,
max_size - length,
local->items_format,
"%s%s%s%d/%d%s",
dsda_TextColor(dsda_tc_exhud_totals_label),
itemcolor, players[displayplayer].itemcount, totalitems
local->label_i,
itemcolor, players[displayplayer].itemcount, totalitems,
local->stat_separator
);
}

if (local->include_secrets) {
snprintf(
str + length,
max_size - length,
local->secrets_format,
"%s%s%s%d/%d",
dsda_TextColor(dsda_tc_exhud_totals_label),
local->label_s,
secretcolor, fullsecretcount, totalsecret
);
}
Expand All @@ -109,15 +115,17 @@ void dsda_InitStatTotalsHC(int x_offset, int y_offset, int vpt, int* args, int a
local->include_secrets = args[2];

// vertical orientation
if (args[3]) {
local->kills_format = "%sK %s%d/%d\n";
local->items_format = "%sI %s%d/%d\n";
local->secrets_format = "%sS %s%d/%d";
local->stat_separator = args[3] ? "\n" : " ";

if (arg_count < 5 || args[4]) {
local->label_k = "K ";
local->label_i = "I ";
local->label_s = "S ";
}
else {
local->kills_format = "%sK %s%d/%d ";
local->items_format = "%sI %s%d/%d ";
local->secrets_format = "%sS %s%d/%d";
local->label_k = "";
local->label_i = "";
local->label_s = "";
}

if (!local->include_kills && !local->include_items && !local->include_secrets) {
Expand Down

0 comments on commit 36516ec

Please sign in to comment.