From: LegendaryGuard Date: Sun, 4 Apr 2021 23:09:15 +0000 (+0200) Subject: Added new column of country flags in the scoreboard (for the sake of z411's request) X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b166322f2fef161a03fd8699fcb22e204211177e;p=xonotic%2Fxonotic-data.pk3dir.git Added new column of country flags in the scoreboard (for the sake of z411's request) --- diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 25fcae0fa..ffbf0868b 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -126,6 +126,7 @@ string Label_getInfo(string label, int mode) case "bctime": if (!mode) return CTX(_("SCO^bctime")); else LOG_HELP(strcat("^3", "bctime", " ^7", _("Total amount of time holding the ball in Keepaway"))); case "caps": if (!mode) return CTX(_("SCO^caps")); else LOG_HELP(strcat("^3", "caps", " ^7", _("How often a flag (CTF) or a key (KeyHunt) was captured"))); case "captime": if (!mode) return CTX(_("SCO^captime")); else LOG_HELP(strcat("^3", "captime", " ^7", _("Time of fastest capture (CTF)"))); + case "cn": if (!mode) return CTX(_("SCO^cn")); else LOG_HELP(strcat("^3", "cn", " ^7", _("Player country"))); //LegendGuard adds cn for Country column 05-04-2021 case "deaths": if (!mode) return CTX(_("SCO^deaths")); else LOG_HELP(strcat("^3", "deaths", " ^7", _("Number of deaths"))); case "destroyed": if (!mode) return CTX(_("SCO^destroyed")); else LOG_HELP(strcat("^3", "destroyed", " ^7", _("Number of keys destroyed by pushing them into void"))); case "dmg": if (!mode) return CTX(_("SCO^damage")); else LOG_HELP(strcat("^3", "dmg", " ^7", _("The total damage done"))); @@ -397,7 +398,7 @@ void Cmd_Scoreboard_Help() // otherwise the previous exclusive rule warns anyway // e.g. -teams,rc,cts,lms/kills ?+rc/kills #define SCOREBOARD_DEFAULT_COLUMNS \ -"ping pl fps name |" \ +"ping pl fps cn name |" \ " -teams,rc,cts,inv,lms/kills +ft,tdm/kills ?+rc,inv/kills" \ " -teams,lms/deaths +ft,tdm/deaths" \ " +tdm/sum" \ @@ -447,7 +448,7 @@ void Cmd_Scoreboard_SetFields(int argc) } else if(argv(2) == "all") { - string s = "ping pl name |"; // scores without a label + string s = "ping pl cn name |"; // scores without a label FOREACH(Scores, true, { if(it != ps_primary) if(it != ps_secondary) @@ -504,6 +505,7 @@ void Cmd_Scoreboard_SetFields(int argc) // fields without a label (not networked via the score system) case "ping": sbt_field[sbt_num_fields] = SP_PING; break; case "pl": sbt_field[sbt_num_fields] = SP_PL; break; + case "cn": sbt_field[sbt_num_fields] = SP_COUNTRY; break; //LegendGuard adds cn label for Country column 05-04-2021 case "name": case "nick": sbt_field[sbt_num_fields] = SP_NAME; have_name = true; break; case "|": sbt_field[sbt_num_fields] = SP_SEPARATOR; have_separator = true; break; case "kd": case "kdr": case "kdratio": sbt_field[sbt_num_fields] = SP_KDRATIO; break; @@ -625,6 +627,7 @@ vector sbt_field_rgb; string sbt_field_icon0; string sbt_field_icon1; string sbt_field_icon2; +string sbt_field_icon3; //LegendGuard adds for Country player flags 05-04-2021 vector sbt_field_icon0_rgb; vector sbt_field_icon1_rgb; vector sbt_field_icon2_rgb; @@ -634,7 +637,7 @@ string Scoreboard_GetName(entity pl) { sbt_field_icon0 = "gfx/scoreboard/player_ready"; } - /*else if(!teamplay) + else if(!teamplay) { int f = entcs_GetClientColors(pl.sv_entnum); { @@ -644,17 +647,21 @@ string Scoreboard_GetName(entity pl) sbt_field_icon2 = "gfx/scoreboard/playercolor_pants"; sbt_field_icon2_rgb = colormapPaletteColor(f % 16, 1); } - }*/ - else - { - int ccode = entcs_GetCountryCode(pl.sv_entnum); - if(ccode) - sbt_field_icon0 = strcat("gfx/flags/", ftos(ccode)); } return entcs_GetName(pl.sv_entnum); } +//LegendGuard adds GetCountrycode function 05-04-2021 +string Scoreboard_GetCountrycode(entity pl) +{ + int ccode = entcs_GetCountryCode(pl.sv_entnum); + if(ccode) + sbt_field_icon3 = strcat("gfx/flags/", ftos(ccode)); + + return ftos(entcs_GetCountryCode(pl.sv_entnum)); +} + vector getPingColor(float f) { if(f < 80) { @@ -674,6 +681,7 @@ string Scoreboard_GetField(entity pl, PlayerScoreField field) sbt_field_icon0 = ""; sbt_field_icon1 = ""; sbt_field_icon2 = ""; + sbt_field_icon3 = ""; //LegendGuard adds for Country column 05-04-2021 sbt_field_icon0_rgb = '1 1 1'; sbt_field_icon1_rgb = '1 1 1'; sbt_field_icon2_rgb = '1 1 1'; @@ -704,6 +712,13 @@ string Scoreboard_GetField(entity pl, PlayerScoreField field) tmp = bound(0, f / 0.2 + tmp / 0.04, 1); // 20% is REALLY BAD pl sbt_field_rgb = '1 0.5 0.5' - '0 0.5 0.5' * tmp; return str; + + //LegendGuard adds Country REGISTER in the switch 05-04-2021 + case SP_COUNTRY: + { + str = Scoreboard_GetCountrycode(pl); + return str; + } case SP_NAME: str = Scoreboard_GetName(pl); @@ -761,6 +776,7 @@ string Scoreboard_GetField(entity pl, PlayerScoreField field) sbt_field_rgb = '1 1 1'; return ((pl.ping == 0) ? _("N/A") : "..."); // if 0 ping, either connecting or bot (either case can't show proper score) } + //sbt_field_rgb = HUD_Get_Num_Color(fps, 200, true); sbt_field_rgb = '1 0 0' + '0 1 1' * (bound(0, fps, 60) / 60); return ftos(fps); @@ -819,6 +835,15 @@ string Scoreboard_FixColumnWidth(int i, string str) sbt_fixcolumnwidth_iconlen = f; } + //LegendGuard adds conditional for Country column 05-04-2021 + if(sbt_field_icon3 != "") + { + sz = draw_getimagesize(sbt_field_icon3); + f = sz.x / sz.y; + if(sbt_fixcolumnwidth_iconlen < f) + sbt_fixcolumnwidth_iconlen = f; + } + if(sbt_fixcolumnwidth_iconlen != 0) { sbt_fixcolumnwidth_iconlen *= hud_fontsize.y / hud_fontsize.x; // fix icon aspect @@ -982,6 +1007,8 @@ void Scoreboard_DrawItem(vector item_pos, vector rgb, entity pl, bool is_self, i drawpic(pos - tmp, sbt_field_icon1, vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y), sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); if(sbt_field_icon2 != "") drawpic(pos - tmp, sbt_field_icon2, vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y), sbt_field_icon2_rgb, fg_alpha, DRAWFLAG_NORMAL); + if(sbt_field_icon3 != "") //LegendGuard adds conditional for Country column 05-04-2021 + drawpic(pos - tmp, sbt_field_icon3, vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y), sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); } if(sbt_field[i] == SP_SEPARATOR) @@ -1016,6 +1043,8 @@ void Scoreboard_DrawItem(vector item_pos, vector rgb, entity pl, bool is_self, i drawpic(pos - tmp, sbt_field_icon1, vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y), sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); if(sbt_field_icon2 != "") drawpic(pos - tmp, sbt_field_icon2, vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y), sbt_field_icon2_rgb, fg_alpha, DRAWFLAG_NORMAL); + if(sbt_field_icon3 != "") //LegendGuard adds conditional for Country column 05-04-2021 + drawpic(pos - tmp, sbt_field_icon3, vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y), sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL); pos.x -= sbt_field_size[i] + hud_fontsize.x; } } @@ -1246,6 +1275,19 @@ void Scoreboard_Duel_DrawTable(vector pos, bool invert, entity pl, entity tm) tmp_in.y += (duel_name_fontsize.y - hud_fontsize.y) / 2; drawpic(tmp_in, sbt_field_icon0, vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y), sbt_field_icon1_rgb, panel_fg_alpha, DRAWFLAG_NORMAL); } + + //LegendGuard adds a conditional sentence for country column 05-04-2021 + // Player country icon/flag + if(sbt_field_icon3 != "") { + vector rsz = draw_getimagesize(sbt_field_icon3); + sbt_fixcolumnwidth_iconlen = rsz.x / rsz.y; + if(invert) + tmp_in.x -= hud_fontsize.x * sbt_fixcolumnwidth_iconlen + duel_name_fontsize.x * 0.5; + else + tmp_in.x += stringwidth_colors(tmp_str, duel_name_fontsize) + duel_name_fontsize.x * 0.5; + tmp_in.y += (duel_name_fontsize.y - hud_fontsize.y) / 2; + drawpic(tmp_in, sbt_field_icon3, vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y), sbt_field_icon1_rgb, panel_fg_alpha, DRAWFLAG_NORMAL); + } // Header float column_width = panel_size.x / 5; diff --git a/qcsrc/common/scores.qh b/qcsrc/common/scores.qh index 824763cc1..63e49ae5f 100644 --- a/qcsrc/common/scores.qh +++ b/qcsrc/common/scores.qh @@ -22,6 +22,7 @@ REGISTER_SP(END); REGISTER_SP(PING); REGISTER_SP(PL); +REGISTER_SP(COUNTRY); //LegendGuard adds new column for country label 05-04-2021 REGISTER_SP(NAME); REGISTER_SP(SEPARATOR);