From f1e1075ebe75904f4b464d48e5cb05888035588e Mon Sep 17 00:00:00 2001 From: FruitieX Date: Sat, 14 May 2011 22:33:46 +0300 Subject: [PATCH] bunch of updates, statusbars instead of icons --- defaultXonotic.cfg | 10 ++++----- qcsrc/client/autocvars.qh | 2 +- qcsrc/client/shownames.qc | 45 ++++++++++----------------------------- qcsrc/server/cl_client.qc | 1 - qcsrc/server/cl_player.qc | 11 ---------- 5 files changed, 17 insertions(+), 52 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 803fdc0a9..e1ebe8b7d 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1496,11 +1496,11 @@ seta hud_contents_water_alpha 0.5 "alpha of the water color blend when inside it seta hud_contents_water_color "0.4 0.3 0.3" seta hud_shownames 1 "draw names and health/armor of nearby players" -seta hud_shownames_enemies 2 "1 = draw names of enemies you point at, 2 = draw names of all enemies in view" -seta hud_shownames_status 2 "1 = draw health/armor status of teammates, 2 = same as 1, but draw health/armor icons with a question mark on enemies in teamgames" -seta hud_shownames_height 15 "height of icons" +seta hud_shownames_enemies 2 "1 = draw names of enemies you point at (TODO), 2 = draw names of all enemies in view" +seta hud_shownames_status 1 "1 = draw health/armor status of teammates" +seta hud_shownames_statusbar_height 4 "height of status bar" seta hud_shownames_aspect 8 "aspect ratio of total drawing area per name" -seta hud_shownames_fontsize 13 "font size" +seta hud_shownames_fontsize 12 "font size" seta hud_shownames_decolorize 1 "1 = decolorize name in team games, 2 = decolorize always" 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" @@ -1508,7 +1508,7 @@ seta hud_shownames_mindistance 1000 "start fading alpha/size at this distance" seta hud_shownames_maxdistance 2500 "alpha/size is 0 at this distance" seta hud_shownames_antioverlap 1 "if two tags get too close to each other, fade out the one further away from you" seta hud_shownames_antioverlap_distance 125 "2d distance to other tag after which to fade out" -seta hud_shownames_offset 48 "offset (along z-axis) tag from player origin by this many units" +seta hud_shownames_offset 52 "offset (along z-axis) tag from player origin by this many units" // scoreboard seta scoreboard_columns default diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 5324d56ab..b2a160268 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -281,7 +281,7 @@ float autocvar_hud_showbinds_limit; float autocvar_hud_shownames; float autocvar_hud_shownames_enemies; float autocvar_hud_shownames_status; -float autocvar_hud_shownames_height; +float autocvar_hud_shownames_statusbar_height; float autocvar_hud_shownames_aspect; float autocvar_hud_shownames_fontsize; float autocvar_hud_shownames_decolorize; diff --git a/qcsrc/client/shownames.qc b/qcsrc/client/shownames.qc index 92b071ea1..f132bfa66 100644 --- a/qcsrc/client/shownames.qc +++ b/qcsrc/client/shownames.qc @@ -12,11 +12,7 @@ void Draw_ShowNames() if(self.sameteam || (!self.sameteam && autocvar_hud_shownames_enemies)) { - string temporigin; - temporigin = getplayerkey(self.the_entnum-1, "TEMPHACK_origin"); - if(temporigin == "") - return; - self.origin = stov(temporigin); + self.origin = getplayerorigin(self.the_entnum-1); self.origin_z += autocvar_hud_shownames_offset; if(!self.sameteam) @@ -97,7 +93,7 @@ void Draw_ShowNames() o_z = 0; vector myPos, mySize; - mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_height; + mySize = (eX * autocvar_hud_shownames_aspect + eY) * autocvar_hud_shownames_fontsize; myPos = o - '0.5 0 0' * mySize_x - '0 1 0' * mySize_y; // size scaling @@ -107,58 +103,39 @@ void Draw_ShowNames() 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 + float namewidth; - iconpos = myPos; + namepos = myPos; + namewidth = mySize_x; if(autocvar_hud_shownames_status && teamplay) { if(self.sameteam) { - iconsize = eX * 2 * mySize_y + eY * mySize_y; - // "ghost" backgrounds - drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL); - drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '0 0 0', a * 0.5, DRAWFLAG_NORMAL); - if(self.healthvalue > 0) { - drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.healthvalue/autocvar_hud_panel_healtharmor_maxhealth), vid_conwidth, myPos_y + iconsize_y); - drawpic_aspect_skin(iconpos, "health", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL); - } + HUD_Panel_DrawProgressBar(namepos + '0 1 0' * autocvar_hud_shownames_fontsize * resize, eX * mySize_x + eY * resize * autocvar_hud_shownames_statusbar_height, "nametag_statusbar", self.healthvalue, 0, 0, '1 0 0', a, DRAWFLAG_NORMAL); - if(self.armorvalue > 0) - { - drawsetcliparea(0, myPos_y + iconsize_y - iconsize_y * min(1, self.armorvalue/autocvar_hud_panel_healtharmor_maxarmor), vid_conwidth, myPos_y + iconsize_y); - drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor", '1 1 0' * iconsize_y, '1 1 1', a, DRAWFLAG_NORMAL); + if(self.armorvalue > 0) + HUD_Panel_DrawProgressBar(namepos + '0 1 0' * autocvar_hud_shownames_fontsize * resize + eY * resize * autocvar_hud_shownames_statusbar_height, eX * mySize_x + eY * resize * autocvar_hud_shownames_statusbar_height, "nametag_statusbar", self.armorvalue, 0, 0, '0 1 0', a, DRAWFLAG_NORMAL); } - drawresetcliparea(); - } - else if(autocvar_hud_shownames_status == 2) - { - iconsize = eX * 2 * mySize_y + eY * mySize_y; - drawpic_aspect_skin(iconpos, "health_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL); - drawpic_aspect_skin(iconpos + '0.5 0 0' * iconsize_x, "armor_unknown", '1 1 0' * iconsize_y, '0 0 0', a, DRAWFLAG_NORMAL); } } - 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); if((autocvar_hud_shownames_decolorize == 1 && teamplay) || autocvar_hud_shownames_decolorize == 2) s = playername(s, GetPlayerColor(self.the_entnum-1)); drawfontscale = '1 1 0' * resize; - s = textShortenToWidth(s, namesize, '1 1 0' * autocvar_hud_shownames_fontsize, stringwidth_colors); + s = textShortenToWidth(s, namewidth, '1 1 0' * autocvar_hud_shownames_fontsize, stringwidth_colors); float width; width = stringwidth(s, TRUE, '1 1 0' * autocvar_hud_shownames_fontsize); - if (width != namesize) - namepos_x += (namesize - width) / 2; + if (width != namewidth) + namepos_x += (namewidth - width) / 2; drawcolorcodedstring(namepos, s, '1 1 0' * autocvar_hud_shownames_fontsize, a, DRAWFLAG_NORMAL); drawfontscale = '1 1 0'; } diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 329a0f9b8..01cf67c7e 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1778,7 +1778,6 @@ void ClientConnect (void) self.shownames.owner = self; self.shownames.think = shownames_think; self.shownames.nextthink = time; - self.shownames.customizeentityforclient = shownames_customize; Net_LinkEntity(self.shownames, FALSE, 0, SendEntity_ShowNames); } diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 7bb1d6851..d7e4905e4 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -779,17 +779,6 @@ void shownames_think() self.nextthink = time; } -float shownames_customize() -{ - if(self.owner.classname == "player") // only send players, no spectators! - if(self.owner != other) // no need to spam own info - if(vlen(other.origin - self.origin) < autocvar_sv_shownames_cull_distance) // distance cull - if((teams_matter && self.owner.team == other.team) || checkpvs(self.origin, other)) - return TRUE; - - return FALSE; -} - .float muted; // to be used by prvm_edictset server playernumber muted 1 float Say(entity source, float teamsay, entity privatesay, string msgin, float floodcontrol) // message "": do not say, just test flood control -- 2.39.2