Skip to content

Commit 40862f6

Browse files
authored
Merge pull request #1030 from osm/add-scoreboard-map-name
Add scr_scoreboard_showmapname and hud_scoremapname variables
2 parents 1139945 + 652abac commit 40862f6

File tree

3 files changed

+192
-3
lines changed

3 files changed

+192
-3
lines changed

help_variables.json

+101
Original file line numberDiff line numberDiff line change
@@ -11524,6 +11524,84 @@
1152411524
"group-id": "19",
1152511525
"type": "boolean"
1152611526
},
11527+
"hud_scoremapname_align_x": {
11528+
"desc": "Sets horizontal align of scoremapname.",
11529+
"group-id": "19",
11530+
"type": "string"
11531+
},
11532+
"hud_scoremapname_align_y": {
11533+
"desc": "Sets vertical align of scoremapname.",
11534+
"group-id": "19",
11535+
"type": "string"
11536+
},
11537+
"hud_scoremapname_frame": {
11538+
"desc": "Sets frame visibility and style for scoremapname.",
11539+
"group-id": "19",
11540+
"type": "float"
11541+
},
11542+
"hud_scoremapname_frame_color": {
11543+
"desc": "Defines the color of the background of the scoremapname HUD element. See HUD manual for more info.",
11544+
"group-id": "19",
11545+
"type": "string"
11546+
},
11547+
"hud_scoremapname_item_opacity": {
11548+
"group-id": "19",
11549+
"type": "float"
11550+
},
11551+
"hud_scoremapname_order": {
11552+
"desc": "This defines the order of drawing the HUD elements. That means you can change will be drawn on top of other elements. See HUD manual for more info.",
11553+
"group-id": "19",
11554+
"type": "integer"
11555+
},
11556+
"hud_scoremapname_place": {
11557+
"desc": "Sets relative positioning for scoremapname.",
11558+
"group-id": "19",
11559+
"type": "string"
11560+
},
11561+
"hud_scoremapname_pos_x": {
11562+
"desc": "Sets horizontal position of scoremapname.",
11563+
"group-id": "19",
11564+
"type": "float"
11565+
},
11566+
"hud_scoremapname_pos_y": {
11567+
"desc": "Sets vertical position of scoremapname.",
11568+
"group-id": "19",
11569+
"type": "float"
11570+
},
11571+
"hud_scoremapname_proportional": {
11572+
"desc": "Toggles whether the scoremapname uses charset chars or TTF chars",
11573+
"group-id": "19",
11574+
"type": "boolean"
11575+
},
11576+
"hud_scoremapname_scale": {
11577+
"desc": "Scale of the scoremapname HUD element.",
11578+
"group-id": "19",
11579+
"type": "float"
11580+
},
11581+
"hud_scoremapname_style": {
11582+
"desc": "Style of the scoremapname HUD element.",
11583+
"group-id": "19",
11584+
"type": "enum",
11585+
"values": [
11586+
{
11587+
"description": "Full name, example: The Abandoned Base (dm3)",
11588+
"name": "0"
11589+
},
11590+
{
11591+
"description": "Level name, example: The Abandoned Base",
11592+
"name": "1"
11593+
},
11594+
{
11595+
"description": "Map name, example: dm3",
11596+
"name": "2"
11597+
}
11598+
]
11599+
},
11600+
"hud_scoremapname_show": {
11601+
"desc": "Toggles whether the scoremapname is displayed. It is only displayed when the scoreboard is open.",
11602+
"group-id": "19",
11603+
"type": "boolean"
11604+
},
1152711605
"hud_sigil1_align_x": {
1152811606
"desc": "Sets horizontal align of sigil 1 icon (rune)",
1152911607
"group-id": "19",
@@ -19157,6 +19235,29 @@
1915719235
}
1915819236
]
1915919237
},
19238+
"scr_scoreboard_showmapname": {
19239+
"default": "0",
19240+
"group-id": "47",
19241+
"type": "enum",
19242+
"values": [
19243+
{
19244+
"description": "Don't display the level name",
19245+
"name": "0"
19246+
},
19247+
{
19248+
"description": "Full name, example: The Abandoned Base (dm3)",
19249+
"name": "1"
19250+
},
19251+
{
19252+
"description": "Level name, example: The Abandoned Base",
19253+
"name": "2"
19254+
},
19255+
{
19256+
"description": "Map name, example: dm3",
19257+
"name": "3"
19258+
}
19259+
]
19260+
},
1916019261
"scr_scoreboard_showfrags": {
1916119262
"default": "1",
1916219263
"group-id": "47",

src/hud_gamesummary.c

+44
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,40 @@ static void SCR_Hud_GameSummary(hud_t* hud)
197197
}
198198
}
199199

200+
static void SCR_HUD_DrawScoreMapName(hud_t *hud) {
201+
static cvar_t *proportional = NULL, *scale, *style;
202+
int w, h, x, y;
203+
char str[256];
204+
205+
if (proportional == NULL)
206+
{
207+
proportional = HUD_FindVar(hud, "proportional");
208+
scale = HUD_FindVar(hud, "scale");
209+
style = HUD_FindVar(hud, "style");
210+
}
211+
212+
switch (style->integer)
213+
{
214+
case 1:
215+
snprintf(str, sizeof(str), "%s", cl.levelname);
216+
break;
217+
case 2:
218+
snprintf(str, sizeof(str), "%s", host_mapname.string);
219+
break;
220+
default:
221+
snprintf(str, sizeof(str), "%s (%s)", cl.levelname, host_mapname.string);
222+
break;
223+
}
224+
225+
w = Draw_StringLengthColors(str, -1, scale->value, proportional->integer);
226+
h = scale->value * 8;
227+
228+
if (!HUD_PrepareDraw(hud, w, h, &x, &y))
229+
return;
230+
231+
Draw_SString(x, y, str, scale->value, proportional->integer);
232+
}
233+
200234
void GameSummary_HudInit(void)
201235
{
202236
HUD_Register(
@@ -213,4 +247,14 @@ void GameSummary_HudInit(void)
213247
"proportional", "0",
214248
NULL
215249
);
250+
251+
HUD_Register(
252+
"scoremapname", NULL, "Shows map name on the scoreboard",
253+
HUD_NO_DRAW | HUD_ON_INTERMISSION | HUD_ON_SCORES | HUD_ON_FINALE, ca_disconnected, 8, SCR_HUD_DrawScoreMapName,
254+
"0", "screen", "right", "bottom", "0", "-10", "0", "0 0 0", NULL,
255+
"style", "0",
256+
"proportional", "0",
257+
"scale", "1",
258+
NULL
259+
);
216260
}

src/sbar.c

+47-3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ cvar_t scr_scoreboard_wipeout = {"scr_scoreboard_wipeout", "1"};
144144
cvar_t scr_scoreboard_classic = {"scr_scoreboard_classic", "0"};
145145
cvar_t scr_scoreboard_highlightself = {"scr_scoreboard_highlightself", "1"};
146146
cvar_t scr_scoreboard_showclock = {"scr_scoreboard_showclock", "0"};
147+
cvar_t scr_scoreboard_showmapname = {"scr_scoreboard_showmapname", "0"};
147148

148149
// VFrags: only draw the frags for the first player when using mvinset
149150
#define MULTIVIEWTHISPOV() ((!cl_multiview.value) || (cl_mvinset.value && CL_MultiviewCurrentView() == 1))
@@ -336,6 +337,7 @@ void Sbar_Init(void)
336337
Cvar_Register(&scr_scoreboard_classic);
337338
Cvar_Register(&scr_scoreboard_highlightself);
338339
Cvar_Register(&scr_scoreboard_showclock);
340+
Cvar_Register(&scr_scoreboard_showmapname);
339341

340342
Cvar_ResetCurrentGroup();
341343

@@ -1217,6 +1219,8 @@ void Sbar_SoloScoreboard (void)
12171219
{
12181220
char str[256];
12191221
int len;
1222+
int clock_y;
1223+
int mapname_y;
12201224

12211225
if (cl.gametype == GAME_COOP)
12221226
{
@@ -1236,10 +1240,50 @@ void Sbar_SoloScoreboard (void)
12361240
len = strlen (str);
12371241
Sbar_DrawString (160 - len*4, 4, str);
12381242
}
1239-
else if (scr_scoreboard_showclock.value)
1243+
else
12401244
{
1241-
strlcpy(str, SCR_GetTimeString(TIMETYPE_CLOCK, "%H:%M:%S"), sizeof(str));
1242-
Sbar_DrawString(160 - (strlen(str)*4), -10, str);
1245+
if ((scr_scoreboard_showclock.integer && !scr_scoreboard_showmapname.integer))
1246+
{
1247+
clock_y = -10;
1248+
}
1249+
else if (!scr_scoreboard_showclock.integer && scr_scoreboard_showmapname.integer)
1250+
{
1251+
mapname_y = -10;
1252+
}
1253+
else if (scr_scoreboard_showclock.integer && scr_scoreboard_showmapname.integer == 3)
1254+
{
1255+
clock_y = 2;
1256+
mapname_y = -10;
1257+
}
1258+
else
1259+
{
1260+
clock_y = -10;
1261+
mapname_y = 2;
1262+
}
1263+
1264+
if (scr_scoreboard_showclock.integer)
1265+
{
1266+
snprintf(str, sizeof(str), "%s", SCR_GetTimeString(TIMETYPE_CLOCK, "%H:%M:%S"));
1267+
Sbar_DrawString(160 - strlen(str) * 4, clock_y, str);
1268+
}
1269+
1270+
if (scr_scoreboard_showmapname.integer)
1271+
{
1272+
switch (scr_scoreboard_showmapname.integer)
1273+
{
1274+
case 2:
1275+
snprintf(str, sizeof(str), "%s", cl.levelname);
1276+
break;
1277+
case 3:
1278+
snprintf(str, sizeof(str), "%s", host_mapname.string);
1279+
break;
1280+
default:
1281+
snprintf(str, sizeof(str), "%s (%s)", cl.levelname, host_mapname.string);
1282+
break;
1283+
}
1284+
1285+
Sbar_DrawString (160 - strlen(str) * 4, mapname_y, str);
1286+
}
12431287
}
12441288
}
12451289

0 commit comments

Comments
 (0)