implement vertical option for monsec and coord widgets

* fix memory leak (clang-tidy warning)
This commit is contained in:
Roman Fomin 2025-01-30 16:01:39 +07:00 committed by GitHub
parent c3c3bcb7dc
commit bb74e0584c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 433 additions and 391 deletions

View File

@ -911,12 +911,13 @@
"widget":
{
"x": 2,
"y": 152,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -931,7 +932,7 @@
"widget":
{
"x": 2,
"y": 144,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -942,34 +943,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 152,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -985,7 +958,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},
@ -1752,12 +1752,13 @@
"widget":
{
"x": 2,
"y": 147,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -1772,7 +1773,7 @@
"widget":
{
"x": 2,
"y": 139,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -1783,34 +1784,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 147,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -1826,7 +1799,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},
@ -2795,12 +2795,13 @@
"widget":
{
"x": 2,
"y": 152,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -2815,7 +2816,7 @@
"widget":
{
"x": 2,
"y": 144,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -2826,34 +2827,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 152,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -2869,7 +2842,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},
@ -3085,12 +3085,13 @@
"widget":
{
"x": 2,
"y": 184,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -3105,7 +3106,7 @@
"widget":
{
"x": 2,
"y": 176,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -3116,34 +3117,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 184,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -3159,7 +3132,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},

View File

@ -911,12 +911,13 @@
"widget":
{
"x": 2,
"y": 152,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -931,7 +932,7 @@
"widget":
{
"x": 2,
"y": 144,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -942,34 +943,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 152,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -985,7 +958,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},
@ -1752,12 +1752,13 @@
"widget":
{
"x": 2,
"y": 147,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -1772,7 +1773,7 @@
"widget":
{
"x": 2,
"y": 139,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -1783,34 +1784,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 147,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -1826,7 +1799,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},
@ -2795,12 +2795,13 @@
"widget":
{
"x": 2,
"y": 152,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -2815,7 +2816,7 @@
"widget":
{
"x": 2,
"y": 144,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -2826,34 +2827,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 152,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -2869,7 +2842,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},
@ -3085,12 +3085,13 @@
"widget":
{
"x": 2,
"y": 184,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -3105,7 +3106,7 @@
"widget":
{
"x": 2,
"y": 176,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -3116,34 +3117,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 184,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -3159,7 +3132,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},

View File

@ -911,12 +911,13 @@
"widget":
{
"x": 2,
"y": 152,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -931,7 +932,7 @@
"widget":
{
"x": 2,
"y": 144,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -942,34 +943,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 152,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -985,7 +958,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},
@ -1752,12 +1752,13 @@
"widget":
{
"x": 2,
"y": 147,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -1772,7 +1773,7 @@
"widget":
{
"x": 2,
"y": 139,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -1783,34 +1784,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 147,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -1826,7 +1799,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},
@ -2795,12 +2795,13 @@
"widget":
{
"x": 2,
"y": 152,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -2815,7 +2816,7 @@
"widget":
{
"x": 2,
"y": 144,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -2826,34 +2827,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 152,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -2869,7 +2842,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},
@ -3085,12 +3085,13 @@
"widget":
{
"x": 2,
"y": 184,
"y": 8,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 0,
"font": "Digits",
"vertical": true,
"conditions":
[
{
@ -3105,7 +3106,7 @@
"widget":
{
"x": 2,
"y": 176,
"y": 40,
"alignment": 16,
"tranmap": null,
"translation": null,
@ -3116,34 +3117,6 @@
{
"condition": 19,
"param": 3
},
{
"condition": 20,
"param": 0
}
],
"children": null
}
},
{
"widget":
{
"x": 2,
"y": 184,
"alignment": 16,
"tranmap": null,
"translation": null,
"type": 1,
"font": "Digits",
"conditions":
[
{
"condition": 19,
"param": 3
},
{
"condition": 21,
"param": 0
}
],
"children": null
@ -3159,7 +3132,34 @@
"translation": null,
"type": 2,
"font": "Digits",
"conditions": null,
"conditions":
[
{
"condition": 19,
"param": 4
}
],
"children": null
}
},
{
"widget":
{
"x": 256,
"y": 8,
"alignment": 32,
"tranmap": null,
"translation": null,
"type": 2,
"font": "Digits",
"vertical": true,
"conditions":
[
{
"condition": 19,
"param": 3
}
],
"children": null
}
},

View File

@ -216,6 +216,16 @@ static boolean ParseSbarElemType(json_t *json, sbarelementtype_t type,
widget->duration =
JS_GetNumberValue(json, "duration") * TICRATE;
break;
case sbw_monsec:
case sbw_coord:
{
json_t *vertical = JS_GetObject(json, "vertical");
if (JS_IsBoolean(vertical))
{
widget->vertical = JS_GetBoolean(vertical);
}
}
break;
default:
break;
}
@ -519,6 +529,7 @@ sbardef_t *ST_ParseSbarDef(void)
json = JS_Open("SBHUDDEF", "hud", (version_t){1, 0, 0});
if (json == NULL)
{
free(out);
return NULL;
}

View File

@ -204,6 +204,8 @@ typedef struct sbe_widget_s
int duration;
int duration_left;
boolean vertical;
} sbe_widget_t;
struct sbarelem_s

View File

@ -717,15 +717,31 @@ static void UpdateCoord(sbe_widget_t *widget, player_t *player)
// killough 10/98: allow coordinates to display non-following pointer
AM_Coordinates(player->mo, &x, &y, &z);
static char string[80];
// jff 2/16/98 output new coord display
M_snprintf(string, sizeof(string),
"\x1b%cX " GRAY_S "%d \x1b%cY " GRAY_S "%d \x1b%cZ " GRAY_S "%d",
'0' + hudcolor_xyco, x >> FRACBITS, '0' + hudcolor_xyco,
y >> FRACBITS, '0' + hudcolor_xyco, z >> FRACBITS);
ST_AddLine(widget, string);
if (!widget->vertical)
{
static char string[80];
// jff 2/16/98 output new coord display
M_snprintf(string, sizeof(string),
"\x1b%cX " GRAY_S "%d \x1b%cY " GRAY_S "%d \x1b%cZ " GRAY_S "%d",
'0' + hudcolor_xyco, x >> FRACBITS, '0' + hudcolor_xyco,
y >> FRACBITS, '0' + hudcolor_xyco, z >> FRACBITS);
ST_AddLine(widget, string);
}
else
{
static char string1[16];
M_snprintf(string1, sizeof(string1), "\x1b%cX " GRAY_S "%d",
'0' + hudcolor_xyco, x >> FRACBITS);
ST_AddLine(widget, string1);
static char string2[16];
M_snprintf(string2, sizeof(string2), "\x1b%cY " GRAY_S "%d",
'0' + hudcolor_xyco, y >> FRACBITS);
ST_AddLine(widget, string2);
static char string3[16];
M_snprintf(string3, sizeof(string3), "\x1b%cZ " GRAY_S "%d",
'0' + hudcolor_xyco, z >> FRACBITS);
ST_AddLine(widget, string3);
}
}
typedef enum
@ -788,8 +804,6 @@ static void UpdateMonSec(sbe_widget_t *widget)
ForceDoomFont(widget);
static char string[120];
const int cr_blue = (widget->font == stcfnt) ? CR_BLUE2 : CR_BLUE1;
int fullkillcount = 0;
@ -829,13 +843,28 @@ static void UpdateMonSec(sbe_widget_t *widget)
StatsFormatFunc(item_str, sizeof(item_str), fullitemcount, totalitems);
StatsFormatFunc(secret_str, sizeof(secret_str), fullsecretcount, totalsecret);
M_snprintf(string, sizeof(string),
RED_S "K \x1b%c%s " RED_S "I \x1b%c%s " RED_S "S \x1b%c%s",
killcolor, kill_str,
itemcolor, item_str,
secretcolor, secret_str);
ST_AddLine(widget, string);
if (!widget->vertical)
{
static char string[80];
M_snprintf(string, sizeof(string),
RED_S "K \x1b%c%s " RED_S "I \x1b%c%s " RED_S "S \x1b%c%s",
killcolor, kill_str,
itemcolor, item_str,
secretcolor, secret_str);
ST_AddLine(widget, string);
}
else
{
static char string1[16];
M_snprintf(string1, sizeof(string1), RED_S "K \x1b%c%s", killcolor, kill_str);
ST_AddLine(widget, string1);
static char string2[16];
M_snprintf(string2, sizeof(string2), RED_S "I \x1b%c%s", itemcolor, item_str);
ST_AddLine(widget, string2);
static char string3[16];
M_snprintf(string3, sizeof(string3), RED_S "S \x1b%c%s", secretcolor, secret_str);
ST_AddLine(widget, string3);
}
}
static void UpdateDM(sbe_widget_t *widget)
@ -1228,7 +1257,7 @@ void ST_BindHUDVariables(void)
M_BindBool("hud_time_use", &hud_time_use, NULL, false, ss_stat, wad_no,
"Show split time when pressing the use-button");
M_BindNum("hud_widget_font", &hud_widget_font, NULL,
HUD_WIDGET_OFF, HUD_WIDGET_OFF, HUD_WIDGET_ALWAYS,
HUD_WIDGET_AUTOMAP, HUD_WIDGET_OFF, HUD_WIDGET_ALWAYS,
ss_stat, wad_no,
"Use standard Doom font for widgets (1 = On automap; 2 = On HUD; 3 "
"= Always)");