seta hud_shownames_height 15 "height of icons"
seta hud_shownames_aspect 8 "aspect ratio of total drawing area per name"
seta hud_shownames_fontsize 8 "font size"
-seta hud_shownames_mindistance 1000 "start fading alpha at this distance"
-seta hud_shownames_maxdistance 2000 "alpha is 0 at this distance"
-
+seta hud_shownames_alpha 0.7 "alpha"
+seta hud_shownames_resize 1 "enable resizing of the names, then the size cvars will correspond to the maximum size"
+seta hud_shownames_mindistance 1000 "start fading alpha/size at this distance"
+seta hud_shownames_maxdistance 2000 "alpha/size is 0 at this distance"
// scoreboard
seta scoreboard_columns default
float autocvar_hud_shownames_height;
float autocvar_hud_shownames_aspect;
float autocvar_hud_shownames_fontsize;
+float autocvar_hud_shownames_alpha;
+float autocvar_hud_shownames_resize;
float autocvar_hud_shownames_mindistance;
float autocvar_hud_shownames_maxdistance;
string autocvar_hud_skin;
// otherwise, increase alpha until 1
+ float dist;
+ dist = vlen(self.origin - view_origin);
+
float a;
- a = autocvar_hud_panel_fg_alpha;
+ a = autocvar_hud_shownames_alpha;
if(self.alpha)
a *= self.alpha;
if(autocvar_hud_shownames_maxdistance)
{
- float dist;
- dist = vlen(self.origin - view_origin);
-
+ if(dist >= autocvar_hud_shownames_maxdistance)
+ return;
a *= ((autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance) - max(0, dist - autocvar_hud_shownames_mindistance)) / (autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance);
}
+ float resize;
+ resize = 1;
+ if(autocvar_hud_shownames_resize) // limit resize so its never smaller than 0.5... gets unreadable
+ resize = 0.5 + 0.5 * ((autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance) - max(0, dist - autocvar_hud_shownames_mindistance)) / (autocvar_hud_shownames_maxdistance - autocvar_hud_shownames_mindistance);
+
// draw the sprite image
vector o;
o = project_3d_to_2d(self.origin);
mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_height;
myPos = o - '0.5 0 0' * mySize_x - '0 1 0' * mySize_y;
- vector iconpos, iconsize;
- vector namepos;
- float namesize;
+ // size scaling
+ mySize_x *= resize;
+ mySize_y *= resize;
+
+ myPos_x += 0.5 * (mySize_x / resize - mySize_x);
+ myPos_y += (mySize_y / resize - mySize_y);
+
+ vector iconpos, iconsize; // these determine icon position/size, if any
+ vector namepos; // this is where the origin of the string
+ float namesize; // total area where we can draw the string
iconpos = myPos;
}
}
- namepos = myPos + eX * 2 * iconsize_y + eY * 0.5 * (autocvar_hud_shownames_height - autocvar_hud_shownames_fontsize);
+ namepos = myPos + eX * 2 * iconsize_y + eY * 0.5 * resize * (autocvar_hud_shownames_height - autocvar_hud_shownames_fontsize);
namesize = mySize_x - 2 * iconsize_y;
string s;
s = GetPlayerName(self.the_entnum-1);
+ drawfontscale = '1 1 0' * resize;
s = textShortenToWidth(s, namesize, '1 1 0' * autocvar_hud_shownames_fontsize, stringwidth_colors);
float width;
if (width != namesize)
namepos_x += (namesize - width) / 2;
drawcolorcodedstring(namepos, s, '1 1 0' * autocvar_hud_shownames_fontsize, a, DRAWFLAG_NORMAL);
+ drawfontscale = '1 1 0';
}
}
}