// MOVEUP::
vector sbt_field_rgb;
-string sbt_field_icon0;
-string sbt_field_icon1;
-string sbt_field_icon2;
-vector sbt_field_icon0_rgb;
-vector sbt_field_icon1_rgb;
-vector sbt_field_icon2_rgb;
+// these are drawn overlapping
+string sbt_field_icon_playercolor0;
+string sbt_field_icon_playercolor1;
+string sbt_field_icon_playercolor2;
+vector sbt_field_icon_playercolor0_rgb;
+vector sbt_field_icon_playercolor1_rgb;
+vector sbt_field_icon_playercolor2_rgb;
+// these are drawn side-by-side, next to playercolor (if present)
+string sbt_field_icon_extra0; // player_ready
+string sbt_field_icon_extra1; // player_handicap
+vector sbt_field_icon_extra0_rgb;
+vector sbt_field_icon_extra1_rgb;
string Scoreboard_GetName(entity pl)
{
- if(ready_waiting && pl.ready)
- {
- sbt_field_icon0 = "gfx/scoreboard/player_ready";
- }
- else if(!teamplay)
+ if (!teamplay)
{
int f;
// NOTE: always adding 1024 allows saving the colormap 0 as a value != 0
else
f = entcs_GetClientColors(pl.sv_entnum);
- {
- sbt_field_icon0 = "gfx/scoreboard/playercolor_base";
- sbt_field_icon1 = "gfx/scoreboard/playercolor_shirt";
- sbt_field_icon1_rgb = colormapPaletteColor(floor(f / 16), 0);
- sbt_field_icon2 = "gfx/scoreboard/playercolor_pants";
- sbt_field_icon2_rgb = colormapPaletteColor(f % 16, 1);
- }
+ sbt_field_icon_playercolor0 = "gfx/scoreboard/playercolor_base";
+ sbt_field_icon_playercolor1 = "gfx/scoreboard/playercolor_shirt";
+ sbt_field_icon_playercolor1_rgb = colormapPaletteColor(floor(f / 16), 0);
+ sbt_field_icon_playercolor2 = "gfx/scoreboard/playercolor_pants";
+ sbt_field_icon_playercolor2_rgb = colormapPaletteColor(f % 16, 1);
+ }
+ if (ready_waiting && pl.ready)
+ {
+ sbt_field_icon_extra0 = "gfx/scoreboard/player_ready";
+ }
+ if (false) // TODO
+ {
+ sbt_field_icon_extra1 = "gfx/scoreboard/player_handicap";
+ sbt_field_icon_extra1_rgb = '1 1 1';
}
return entcs_GetName(pl.sv_entnum);
}
int f;
string str;
sbt_field_rgb = '1 1 1';
- sbt_field_icon0 = "";
- sbt_field_icon1 = "";
- sbt_field_icon2 = "";
- sbt_field_icon0_rgb = '1 1 1';
- sbt_field_icon1_rgb = '1 1 1';
- sbt_field_icon2_rgb = '1 1 1';
+ sbt_field_icon_playercolor0 = "";
+ sbt_field_icon_playercolor1 = "";
+ sbt_field_icon_playercolor2 = "";
+ sbt_field_icon_extra0 = "";
+ sbt_field_icon_extra1 = "";
+ sbt_field_icon_playercolor0_rgb = '1 1 1';
+ sbt_field_icon_playercolor1_rgb = '1 1 1';
+ sbt_field_icon_playercolor2_rgb = '1 1 1';
+ sbt_field_icon_extra0_rgb = '1 1 1';
+ sbt_field_icon_extra1_rgb = '1 1 1';
int rounds_played = 0;
if (per_round)
rounds_played = pl.(scores(SP_ROUNDS_PL));
}
float sbt_fixcolumnwidth_len;
-float sbt_fixcolumnwidth_iconlen;
+float sbt_fixcolumnwidth_iconlen_playercolor;
+float sbt_fixcolumnwidth_iconlen_extra0;
+float sbt_fixcolumnwidth_iconlen_extra1;
float sbt_fixcolumnwidth_marginlen;
string Scoreboard_FixColumnWidth(int i, string str, bool init)
float f;
vector sz;
- sbt_fixcolumnwidth_iconlen = 0;
+ sbt_fixcolumnwidth_iconlen_playercolor = 0;
+ sbt_fixcolumnwidth_iconlen_extra0 = 0;
+ sbt_fixcolumnwidth_iconlen_extra1 = 0;
- if(sbt_field_icon0 != "")
+ if(sbt_field_icon_playercolor0 != "")
{
- sz = draw_getimagesize(sbt_field_icon0);
+ sz = draw_getimagesize(sbt_field_icon_playercolor0);
f = sz.x / sz.y;
- if(sbt_fixcolumnwidth_iconlen < f)
- sbt_fixcolumnwidth_iconlen = f;
+ if(sbt_fixcolumnwidth_iconlen_playercolor < f)
+ sbt_fixcolumnwidth_iconlen_playercolor = f;
}
-
- if(sbt_field_icon1 != "")
+ if(sbt_field_icon_playercolor1 != "")
{
- sz = draw_getimagesize(sbt_field_icon1);
+ sz = draw_getimagesize(sbt_field_icon_playercolor1);
f = sz.x / sz.y;
- if(sbt_fixcolumnwidth_iconlen < f)
- sbt_fixcolumnwidth_iconlen = f;
+ if(sbt_fixcolumnwidth_iconlen_playercolor < f)
+ sbt_fixcolumnwidth_iconlen_playercolor = f;
}
-
- if(sbt_field_icon2 != "")
+ if(sbt_field_icon_playercolor2 != "")
{
- sz = draw_getimagesize(sbt_field_icon2);
+ sz = draw_getimagesize(sbt_field_icon_playercolor2);
f = sz.x / sz.y;
- if(sbt_fixcolumnwidth_iconlen < f)
- sbt_fixcolumnwidth_iconlen = f;
+ if(sbt_fixcolumnwidth_iconlen_playercolor < f)
+ sbt_fixcolumnwidth_iconlen_playercolor = f;
}
-
- if(sbt_fixcolumnwidth_iconlen != 0)
+ // NOTE: extra icons (player_ready and player_handicap) are squares (32x32), so this may not be necessary
+ // simply setting sbt_fixcolumnwidth_iconlen_extra* = 1 would be equivalent
+ if(sbt_field_icon_extra0 != "")
{
- sbt_fixcolumnwidth_iconlen *= hud_fontsize.y / hud_fontsize.x; // fix icon aspect
- sbt_fixcolumnwidth_marginlen = stringwidth(" ", false, hud_fontsize);
+ sz = draw_getimagesize(sbt_field_icon_extra0);
+ sbt_fixcolumnwidth_iconlen_extra0 = sz.x / sz.y;
+ }
+ if(sbt_field_icon_extra1 != "")
+ {
+ sz = draw_getimagesize(sbt_field_icon_extra1);
+ sbt_fixcolumnwidth_iconlen_extra1 = sz.x / sz.y;
}
+
+ if(sbt_fixcolumnwidth_iconlen_playercolor != 0)
+ sbt_fixcolumnwidth_iconlen_playercolor *= hud_fontsize.y / hud_fontsize.x; // fix icon aspect
+ if(sbt_fixcolumnwidth_iconlen_extra0 != 0)
+ sbt_fixcolumnwidth_iconlen_extra0 *= hud_fontsize.y / hud_fontsize.x; // fix icon aspect
+ if(sbt_fixcolumnwidth_iconlen_extra1 != 0)
+ sbt_fixcolumnwidth_iconlen_extra1 *= hud_fontsize.y / hud_fontsize.x; // fix icon aspect
+
+ if(sbt_fixcolumnwidth_iconlen_playercolor != 0
+ || sbt_fixcolumnwidth_iconlen_extra0 != 0
+ || sbt_fixcolumnwidth_iconlen_extra1 != 0)
+ sbt_fixcolumnwidth_marginlen = stringwidth(" ", false, hud_fontsize);
else
sbt_fixcolumnwidth_marginlen = 0;
if(sbt_field[i] == SP_NAME) // name gets all remaining space
{
int j;
- float remaining_space = 0;
+ float used_space = 0;
for(j = 0; j < sbt_num_fields; ++j)
if(j != i)
if (sbt_field[i] != SP_SEPARATOR)
- remaining_space += sbt_field_size[j] + hud_fontsize.x;
- sbt_field_size[i] = max(sbt_field_title_width[i], panel_size.x - remaining_space);
-
- if (sbt_fixcolumnwidth_iconlen != 0)
- remaining_space += sbt_fixcolumnwidth_marginlen + sbt_fixcolumnwidth_iconlen * hud_fontsize.x;
- float namesize = max(sbt_field_title_width[i], panel_size.x - remaining_space);
+ used_space += sbt_field_size[j] + hud_fontsize.x;
+ sbt_field_size[i] = max(sbt_field_title_width[i], panel_size.x - used_space);
+
+ used_space += sbt_fixcolumnwidth_marginlen
+ + hud_fontsize.x * sbt_fixcolumnwidth_iconlen_playercolor
+ + hud_fontsize.x * sbt_fixcolumnwidth_iconlen_extra0
+ + hud_fontsize.x * sbt_fixcolumnwidth_iconlen_extra1;
+ float namesize = max(sbt_field_title_width[i], panel_size.x - used_space);
str = textShortenToWidth(str, namesize, hud_fontsize, stringwidth_colors);
sbt_fixcolumnwidth_len = stringwidth(str, true, hud_fontsize);
- max_namesize = max(sbt_field_title_width[i], vid_conwidth - remaining_space);
+ max_namesize = max(sbt_field_title_width[i], vid_conwidth - used_space);
}
else
{
sbt_fixcolumnwidth_len = stringwidth(str, false, hud_fontsize);
}
- f = sbt_fixcolumnwidth_len + sbt_fixcolumnwidth_marginlen + sbt_fixcolumnwidth_iconlen * hud_fontsize.x;
+ f = sbt_fixcolumnwidth_len + sbt_fixcolumnwidth_marginlen
+ + hud_fontsize.x * sbt_fixcolumnwidth_iconlen_playercolor
+ + hud_fontsize.x * sbt_fixcolumnwidth_iconlen_extra0
+ + hud_fontsize.x * sbt_fixcolumnwidth_iconlen_extra1;
if(sbt_field_size[i] < f)
sbt_field_size[i] = f;
pos.x += hud_fontsize.x * 0.5;
pos.y += (1.25 - 1) / 2 * hud_fontsize.y; // center text vertically
vector tmp = '0 0 0';
+ vector icon_sz;
int i;
PlayerScoreField field;
for(i = 0; i < sbt_num_fields; ++i)
pos.x += sbt_field_size[i] + hud_fontsize.x;
if(field == SP_NAME) {
- tmp.x = sbt_field_size[i] - hud_fontsize.x * sbt_fixcolumnwidth_iconlen - sbt_fixcolumnwidth_marginlen + hud_fontsize.x;
+ tmp.x = sbt_field_size[i] - sbt_fixcolumnwidth_marginlen + hud_fontsize.x
+ - hud_fontsize.x * sbt_fixcolumnwidth_iconlen_playercolor
+ - hud_fontsize.x * sbt_fixcolumnwidth_iconlen_extra0
+ - hud_fontsize.x * sbt_fixcolumnwidth_iconlen_extra1;
drawcolorcodedstring(pos - tmp, str, hud_fontsize, fg_alpha, DRAWFLAG_NORMAL);
} else {
tmp.x = sbt_fixcolumnwidth_len + hud_fontsize.x;
}
tmp.x = sbt_field_size[i] + hud_fontsize.x;
- if(sbt_field_icon0 != "")
- drawpic(pos - tmp, sbt_field_icon0, vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y), sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL);
- if(sbt_field_icon1 != "")
- 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);
+ icon_sz = vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen_playercolor, hud_fontsize.y);
+ if(sbt_field_icon_playercolor0 != "")
+ drawpic(pos - tmp, sbt_field_icon_playercolor0, icon_sz, sbt_field_icon_playercolor1_rgb, fg_alpha, DRAWFLAG_NORMAL);
+ if(sbt_field_icon_playercolor1 != "")
+ drawpic(pos - tmp, sbt_field_icon_playercolor1, icon_sz, sbt_field_icon_playercolor1_rgb, fg_alpha, DRAWFLAG_NORMAL);
+ if(sbt_field_icon_playercolor2 != "")
+ drawpic(pos - tmp, sbt_field_icon_playercolor2, icon_sz, sbt_field_icon_playercolor2_rgb, fg_alpha, DRAWFLAG_NORMAL);
+ tmp.x -= icon_sz.x;
+ if(sbt_field_icon_extra0 != "")
+ {
+ icon_sz.x = hud_fontsize.x * sbt_fixcolumnwidth_iconlen_extra0;
+ drawpic(pos - tmp, sbt_field_icon_extra0, icon_sz, sbt_field_icon_extra0_rgb, fg_alpha, DRAWFLAG_NORMAL);
+ tmp.x -= icon_sz.x;
+ }
+ if(sbt_field_icon_extra1 != "")
+ {
+ icon_sz.x = hud_fontsize.x * sbt_fixcolumnwidth_iconlen_extra1;
+ drawpic(pos - tmp, sbt_field_icon_extra1, icon_sz, sbt_field_icon_extra1_rgb, fg_alpha, DRAWFLAG_NORMAL);
+ }
}
if(sbt_field[i] == SP_SEPARATOR)
}
tmp.x = sbt_field_size[i];
- if(sbt_field_icon0 != "")
- drawpic(pos - tmp, sbt_field_icon0, vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen, hud_fontsize.y), sbt_field_icon1_rgb, fg_alpha, DRAWFLAG_NORMAL);
- if(sbt_field_icon1 != "")
- 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);
+ icon_sz = vec2(hud_fontsize.x * sbt_fixcolumnwidth_iconlen_playercolor, hud_fontsize.y);
+ if(sbt_field_icon_playercolor0 != "")
+ drawpic(pos - tmp, sbt_field_icon_playercolor0, icon_sz, sbt_field_icon_playercolor1_rgb, fg_alpha, DRAWFLAG_NORMAL);
+ if(sbt_field_icon_playercolor1 != "")
+ drawpic(pos - tmp, sbt_field_icon_playercolor1, icon_sz, sbt_field_icon_playercolor1_rgb, fg_alpha, DRAWFLAG_NORMAL);
+ if(sbt_field_icon_playercolor2 != "")
+ drawpic(pos - tmp, sbt_field_icon_playercolor2, icon_sz, sbt_field_icon_playercolor2_rgb, fg_alpha, DRAWFLAG_NORMAL);
+ tmp.x -= icon_sz.x;
+ if(sbt_field_icon_extra0 != "")
+ {
+ icon_sz.x = hud_fontsize.x * sbt_fixcolumnwidth_iconlen_extra0;
+ drawpic(pos - tmp, sbt_field_icon_extra0, icon_sz, sbt_field_icon_extra0_rgb, fg_alpha, DRAWFLAG_NORMAL);
+ tmp.x -= icon_sz.x;
+ }
+ if(sbt_field_icon_extra1 != "")
+ {
+ icon_sz.x = hud_fontsize.x * sbt_fixcolumnwidth_iconlen_extra1;
+ drawpic(pos - tmp, sbt_field_icon_extra1, icon_sz, sbt_field_icon_extra1_rgb, fg_alpha, DRAWFLAG_NORMAL);
+ }
pos.x -= sbt_field_size[i] + hud_fontsize.x;
}
}