From: BuddyFriendGuy <bfggeneral@gmail.com>
Date: Sun, 21 Apr 2019 17:20:46 +0000 (+0000)
Subject: emphasize important game info in scoreboard
X-Git-Tag: xonotic-v0.8.5~1542^2
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2054defb61de8cf08d4bde6c9093c74db72415d6;p=xonotic%2Fxonotic-data.pk3dir.git

emphasize important game info in scoreboard
add self indicator
add cvar to choose where/whether to show team size
have server info show map name
---

diff --git a/_hud_common.cfg b/_hud_common.cfg
index e31655e25..9c29d1892 100644
--- a/_hud_common.cfg
+++ b/_hud_common.cfg
@@ -117,6 +117,7 @@ seta hud_panel_scoreboard_minwidth 0.6 "minimum width of the scoreboard"
 
 seta hud_panel_scoreboard_accuracy_showdelay 2 "how long to delay displaying accuracy below the scoreboard if it's too far down"
 seta hud_panel_scoreboard_accuracy_showdelay_minpos 0.75 "delay displaying the accuracy panel only if its position is lower than this percentage of the screen height from the top"
+seta hud_panel_scoreboard_team_size_position 0 "where to show the team size (0 = do not show, 1 = left of scoreboard, 2 = right of scoreboard, and move team scores to the right)"
 
 // hud panel aliases
 alias quickmenu "cl_cmd hud quickmenu ${* ?}"
diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc
index ec0c83669..399008f20 100644
--- a/qcsrc/client/hud/panel/scoreboard.qc
+++ b/qcsrc/client/hud/panel/scoreboard.qc
@@ -33,6 +33,8 @@ float sbt_fg_alpha_self;
 bool sbt_highlight;
 float sbt_highlight_alpha;
 float sbt_highlight_alpha_self;
+int sbt_team_size_position;
+int sbt_team_size_total;
 
 // provide basic panel cvars to old clients
 // TODO remove them after a future release (0.8.2+)
@@ -57,6 +59,7 @@ float autocvar_hud_panel_scoreboard_table_highlight_alpha = 0.2;
 float autocvar_hud_panel_scoreboard_table_highlight_alpha_self = 0.4;
 float autocvar_hud_panel_scoreboard_bg_teams_color_team = 0;
 float autocvar_hud_panel_scoreboard_namesize = 15;
+float autocvar_hud_panel_scoreboard_team_size_position = 0;
 
 bool autocvar_hud_panel_scoreboard_accuracy = true;
 bool autocvar_hud_panel_scoreboard_accuracy_doublerows = false;
@@ -559,6 +562,7 @@ string sbt_field_icon2;
 vector sbt_field_icon0_rgb;
 vector sbt_field_icon1_rgb;
 vector sbt_field_icon2_rgb;
+string sbt_font_self;
 string Scoreboard_GetName(entity pl)
 {
 	if(ready_waiting && pl.ready)
@@ -837,6 +841,11 @@ void Scoreboard_DrawItem(vector item_pos, vector rgb, entity pl, bool is_self, i
 	float fg_alpha = (is_self ? sbt_fg_alpha_self : sbt_fg_alpha);
 
 	vector pos = item_pos;
+	// put a "self indicator" beside the self row
+	sbt_font_self = "◀"; // unicode U+25C0 (black left-pointing triangle)
+	if (is_self)
+		drawstring(pos+eX*(panel_size.x+.5*hud_fontsize.x)+eY, sbt_font_self, vec2(hud_fontsize.x, hud_fontsize.y), rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
+
 	pos.x += hud_fontsize.x * 0.5;
 	pos.y += (1.25 - 1) / 2 * hud_fontsize.y; // center text vertically
 	vector tmp = '0 0 0';
@@ -1047,7 +1056,7 @@ vector Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)
 	panel_size.y += panel_bg_padding * 2;
 	HUD_Panel_DrawBg();
 
-	vector end_pos = panel_pos + eY * (panel_size.y + hud_fontsize.y);
+	vector end_pos = panel_pos + eY * (panel_size.y + 0.5* hud_fontsize.y);
 	if(panel.current_panel_bg != "0")
 		end_pos.y += panel_bg_border * 2;
 
@@ -1565,6 +1574,7 @@ void Scoreboard_Draw()
 	sbt_highlight_alpha_self = autocvar_hud_panel_scoreboard_table_highlight_alpha_self * panel_fg_alpha;
 	sbt_fg_alpha = autocvar_hud_panel_scoreboard_table_fg_alpha * panel_fg_alpha;
 	sbt_fg_alpha_self = autocvar_hud_panel_scoreboard_table_fg_alpha_self * panel_fg_alpha;
+	sbt_team_size_position = autocvar_hud_panel_scoreboard_team_size_position;
 
 	// don't overlap with con_notify
 	if(!autocvar__hud_configure)
@@ -1582,17 +1592,84 @@ void Scoreboard_Draw()
 	string str;
 	vector str_pos;
 
-	// Heading
-	vector sb_heading_fontsize;
-	sb_heading_fontsize = hud_fontsize * 2;
+	vector sb_gameinfo_type_fontsize, sb_gameinfo_detail_fontsize;
+
+	// Begin of Game Info Section
+	sb_gameinfo_type_fontsize = hud_fontsize * 2.5;
+	sb_gameinfo_detail_fontsize = hud_fontsize * 1.3;
+
+	// Game Info: Game Type
+	str = MapInfo_Type_ToText(gametype);
 	draw_beginBoldFont();
-	drawstring(pos + eX * panel_bg_padding, _("Scoreboard"), sb_heading_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+	drawcolorcodedstring(pos + '0.5 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_type_fontsize)), str, sb_gameinfo_type_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
 	draw_endBoldFont();
 
-	pos.y += sb_heading_fontsize.y;
+	// Game Info: Game Detail
+	float tl, fl, ll;
+	str = ""; // optionally "^7Limits: "
+	tl = STAT(TIMELIMIT);
+	fl = STAT(FRAGLIMIT);
+	ll = STAT(LEADLIMIT);
+	if(tl > 0)
+		str = strcat(str, sprintf(_("^3%1.0f minutes"), tl));
+	if(!ISGAMETYPE(LMS))
+	{
+		if(fl > 0)
+		{
+			if(tl > 0)
+				str = strcat(str, "^7 / "); // delimiter
+			if(teamplay)
+			{
+				str = strcat(str, sprintf(_("^5%s %s"), ScoreString(teamscores_flags(ts_primary), fl),
+					(teamscores_label(ts_primary) == "score")   ? CTX(_("SCO^points")) :
+					(teamscores_label(ts_primary) == "fastest") ? CTX(_("SCO^is beaten")) :
+					TranslateScoresLabel(teamscores_label(ts_primary))));
+			}
+			else
+			{
+				str = strcat(str, sprintf(_("^5%s %s"), ScoreString(scores_flags(ps_primary), fl),
+					(scores_label(ps_primary) == "score")   ? CTX(_("SCO^points")) :
+					(scores_label(ps_primary) == "fastest") ? CTX(_("SCO^is beaten")) :
+					TranslateScoresLabel(scores_label(ps_primary))));
+			}
+		}
+		if(ll > 0)
+		{
+			if(tl > 0 || fl > 0)
+				str = strcat(str, "^7 / "); // delimiter
+			if(teamplay)
+			{
+				str = strcat(str, sprintf(_("^2+%s %s"), ScoreString(teamscores_flags(ts_primary), ll),
+					(teamscores_label(ts_primary) == "score")   ? CTX(_("SCO^points")) :
+					(teamscores_label(ts_primary) == "fastest") ? CTX(_("SCO^is beaten")) :
+					TranslateScoresLabel(teamscores_label(ts_primary))));
+			}
+			else
+			{
+				str = strcat(str, sprintf(_("^2+%s %s"), ScoreString(scores_flags(ps_primary), ll),
+					(scores_label(ps_primary) == "score")   ? CTX(_("SCO^points")) :
+					(scores_label(ps_primary) == "fastest") ? CTX(_("SCO^is beaten")) :
+					TranslateScoresLabel(scores_label(ps_primary))));
+			}
+		}
+	}
+
+	pos.y += sb_gameinfo_type_fontsize.y;
+	drawcolorcodedstring(pos + '1 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_detail_fontsize)), str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align right
+	// map name
+	str = sprintf(_("^7Map: ^2%s"), shortmapname);
+	drawcolorcodedstring(pos, str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align left
+	// End of Game Info Section
+
+	pos.y += sb_gameinfo_detail_fontsize.y + hud_fontsize.y * 0.3; // space between Game Info Section and score table
 	if(panel.current_panel_bg != "0")
 		pos.y += panel_bg_border;
 
+	// calculate team size total (sum of all team sizes)
+	sbt_team_size_total = 0;
+	for(tm = teams.sort_next; tm; tm = tm.sort_next)
+		sbt_team_size_total += tm.team_size;
+
 	// Draw the scoreboard
 	float scale = autocvar_hud_panel_scoreboard_table_bg_scale;
 	if(scale <= 0)
@@ -1602,9 +1679,31 @@ void Scoreboard_Draw()
 	if(teamplay)
 	{
 		vector panel_bg_color_save = panel_bg_color;
-		vector team_score_baseoffset = eY * hud_fontsize.y - eX * hud_fontsize.x * 0.5;
-		if(panel.current_panel_bg != "0")
-			team_score_baseoffset.x -= panel_bg_border;
+		vector team_score_baseoffset;
+		vector team_size_baseoffset;
+		if (sbt_team_size_position != 1) // team size not on left
+		{
+			// put team score to the left of scoreboard (and team size to the right)
+			team_score_baseoffset = eY * hud_fontsize.y - eX * hud_fontsize.x * 0.5;
+			team_size_baseoffset = eY * hud_fontsize.y + eX * hud_fontsize.x * 0.5;
+			if(panel.current_panel_bg != "0")
+			{
+				team_score_baseoffset.x -= panel_bg_border;
+				team_size_baseoffset.x += panel_bg_border;
+			}
+		}
+		else
+		{
+			// put team score to the right of scoreboard (and team size to the left)
+			team_score_baseoffset = eY * hud_fontsize.y + eX * hud_fontsize.x * 0.5;
+			team_size_baseoffset = eY * hud_fontsize.y - eX * hud_fontsize.x * 0.5;
+			if(panel.current_panel_bg != "0")
+			{
+				team_score_baseoffset.x += panel_bg_border;
+				team_size_baseoffset.x -= panel_bg_border;
+			}
+		}
+
 		for(tm = teams.sort_next; tm; tm = tm.sort_next)
 		{
 			if(tm.team == NUM_SPECTATOR)
@@ -1615,13 +1714,56 @@ void Scoreboard_Draw()
 			draw_beginBoldFont();
 			vector rgb = Team_ColorRGB(tm.team);
 			str = ftos(tm.(teamscores(ts_primary)));
-			str_pos = pos + team_score_baseoffset - eX * stringwidth(str, false, hud_fontsize * 1.5);
+			if (sbt_team_size_position != 1) // team size not on left
+			{
+				// team score on the left (default)
+				str_pos = pos + team_score_baseoffset - eX * stringwidth(str, false, hud_fontsize * 1.5);
+			}
+			else
+			{
+				// team score on the right
+				str_pos = pos + team_score_baseoffset + eX * (panel_size.x + hud_fontsize.x * 1.5);
+			}
 			drawstring(str_pos, str, hud_fontsize * 1.5, rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
 
+			// team size (if set to show on the side)
+			if (sbt_team_size_position != 0) // team size not off
+			{
+				// calculate the starting position for the whole team size info string
+				str = sprintf("%d/%d", tm.team_size, sbt_team_size_total);
+				if (sbt_team_size_position == 1)
+				{
+					// team size on the left
+					str_pos = pos + team_size_baseoffset - eX * stringwidth(str, false, hud_fontsize * 1.5);
+				}
+				else
+				{
+					// team size on the right
+					str_pos = pos + team_size_baseoffset + eX * (panel_size.x + hud_fontsize.x * 1.5);
+				}
+				str = sprintf("%d", tm.team_size);
+				drawstring(str_pos, str, hud_fontsize * 1.5, rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
+				str_pos += eX * stringwidth(str, true, hud_fontsize * 1.5) + eY * hud_fontsize.y * .5;
+				str = sprintf("/%d", sbt_team_size_total);
+				drawstring(str_pos, str, hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+			}
+
+
+			// secondary score, e.g. keyhunt
 			if(ts_primary != ts_secondary)
 			{
 				str = ftos(tm.(teamscores(ts_secondary)));
-				str_pos = pos + team_score_baseoffset - vec2(stringwidth(str, false, hud_fontsize), hud_fontsize.y * 1.5);
+				if (sbt_team_size_position != 1) // team size not on left
+				{
+					// left
+					str_pos = pos + team_score_baseoffset - vec2(stringwidth(str, false, hud_fontsize), hud_fontsize.y * -1.5);
+				}
+				else
+				{
+					// right
+					str_pos = pos + team_score_baseoffset + vec2(panel_size.x + hud_fontsize.x * 1.5, hud_fontsize.y * 1.5);
+				}
+
 				drawstring(str_pos, str, hud_fontsize, rgb, panel_fg_alpha, DRAWFLAG_NORMAL);
 			}
 			draw_endBoldFont();
@@ -1682,63 +1824,6 @@ void Scoreboard_Draw()
 		}
 	}
 
-	// Print info string
-	float tl, fl, ll;
-	str = sprintf(_("playing ^3%s^7 on ^2%s^7"), MapInfo_Type_ToText(gametype), shortmapname);
-	tl = STAT(TIMELIMIT);
-	fl = STAT(FRAGLIMIT);
-	ll = STAT(LEADLIMIT);
-	if(ISGAMETYPE(LMS))
-	{
-		if(tl > 0)
-			str = strcat(str, sprintf(_(" for up to ^1%1.0f minutes^7"), tl));
-	}
-	else
-	{
-		if(tl > 0)
-			str = strcat(str, sprintf(_(" for up to ^1%1.0f minutes^7"), tl));
-		if(fl > 0)
-		{
-			if(tl > 0)
-				str = strcat(str, _(" or"));
-			if(teamplay)
-			{
-				str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(teamscores_flags(ts_primary), fl),
-					(teamscores_label(ts_primary) == "score")   ? CTX(_("SCO^points")) :
-					(teamscores_label(ts_primary) == "fastest") ? CTX(_("SCO^is beaten")) :
-					TranslateScoresLabel(teamscores_label(ts_primary))));
-			}
-			else
-			{
-				str = strcat(str, sprintf(_(" until ^3%s %s^7"), ScoreString(scores_flags(ps_primary), fl),
-					(scores_label(ps_primary) == "score")   ? CTX(_("SCO^points")) :
-					(scores_label(ps_primary) == "fastest") ? CTX(_("SCO^is beaten")) :
-					TranslateScoresLabel(scores_label(ps_primary))));
-			}
-		}
-		if(ll > 0)
-		{
-			if(tl > 0 || fl > 0)
-				str = strcat(str, _(" or"));
-			if(teamplay)
-			{
-				str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(teamscores_flags(ts_primary), ll),
-					(teamscores_label(ts_primary) == "score")   ? CTX(_("SCO^points")) :
-					(teamscores_label(ts_primary) == "fastest") ? CTX(_("SCO^is beaten")) :
-					TranslateScoresLabel(teamscores_label(ts_primary))));
-			}
-			else
-			{
-				str = strcat(str, sprintf(_(" until a lead of ^3%s %s^7"), ScoreString(scores_flags(ps_primary), ll),
-					(scores_label(ps_primary) == "score")   ? CTX(_("SCO^points")) :
-					(scores_label(ps_primary) == "fastest") ? CTX(_("SCO^is beaten")) :
-					TranslateScoresLabel(scores_label(ps_primary))));
-			}
-		}
-	}
-
-	pos.y += 1.2 * hud_fontsize.y;
-	drawcolorcodedstring(pos + '0.5 0 0' * (panel_size.x - stringwidth(str, true, hud_fontsize)), str, hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
 
 	// print information about respawn status
 	float respawn_time = STAT(RESPAWN_TIME);
diff --git a/qcsrc/menu/xonotic/dialog_settings_game_hud.qc b/qcsrc/menu/xonotic/dialog_settings_game_hud.qc
index 88fba8dd0..0fb475563 100644
--- a/qcsrc/menu/xonotic/dialog_settings_game_hud.qc
+++ b/qcsrc/menu/xonotic/dialog_settings_game_hud.qc
@@ -55,8 +55,15 @@ void XonoticGameHUDSettingsTab_fill(entity me)
 		me.TD(me, 1, 3, e = makeXonoticCheckBox(0, "hud_panel_scoreboard_respawntime_decimals", _("Show decimals in respawn countdown")));
 	me.TR(me);
 		me.TD(me, 1, 3, e = makeXonoticCheckBox(0, "hud_panel_scoreboard_accuracy", _("Show accuracy underneath scoreboard")));
-
 	me.TR(me);
+		me.TD(me, 1, 1, e = makeXonoticTextLabel(0, _("Show team sizes:")));
+		me.TD(me, 1, 2, e = makeXonoticTextSlider_T("hud_panel_scoreboard_team_size_position", _("Team size position: Off=do not show; Left=on the left side of the scoreboard and move team scores to the right; Right=on the right of the scoreboard")));
+			e.addValue(e, _("Left"), "1");
+			e.addValue(e, _("Off"), "0");
+			e.addValue(e, _("Right"), "2");
+			e.configureXonoticTextSliderValues(e);
+
+	//me.TR(me);
 	me.TR(me);
 		me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Waypoints")));
 	me.TR(me);
diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc
index 41331541b..6f3fca9fc 100644
--- a/qcsrc/server/client.qc
+++ b/qcsrc/server/client.qc
@@ -1034,6 +1034,7 @@ string getwelcomemessage(entity this)
 
 	string versionmessage = GetClientVersionMessage(this);
 	string s = strcat(versionmessage, "^8\n^8\nmatch type is ^1", gamemode_name, "^8\n");
+	s = strcat(s, "^8\nCurrent map: ^2", GetMapname(), "^8\n");
 
 	if(modifications != "")
 		s = strcat(s, "^8\nactive modifications: ^3", modifications, "^8\n");