From: FruitieX Date: Wed, 13 Apr 2011 14:47:26 +0000 (+0300) Subject: support resizing the name and enable by default X-Git-Tag: xonotic-v0.5.0~278 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d2d9748f8d7b76bbec46afc99357126f85a23f14;p=xonotic%2Fxonotic-data.pk3dir.git support resizing the name and enable by default --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 68a3acb70..089c11a62 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1487,9 +1487,10 @@ seta hud_shownames_status 2 "1 = draw health/armor status of teammates, 2 = same 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 diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 50db35411..fc3c1f8e1 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -278,6 +278,8 @@ float autocvar_hud_shownames_status; 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; diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index bd3e7fd05..66391197a 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -38,18 +38,25 @@ void Draw_ShowNames() // 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); @@ -62,9 +69,16 @@ void Draw_ShowNames() 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; @@ -92,11 +106,12 @@ void Draw_ShowNames() } } - 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; @@ -105,6 +120,7 @@ void Draw_ShowNames() 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'; } } }