From: terencehill Date: Wed, 28 Jul 2010 20:25:55 +0000 (+0200) Subject: Code to support icons which are shown with an "incorporated" bar indicating the pps... X-Git-Tag: xonotic-v0.5.0~348^2~6^2~10 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6e04cb95750423d62110e01c5efc56cf0e127293;p=xonotic%2Fxonotic-data.pk3dir.git Code to support icons which are shown with an "incorporated" bar indicating the pps percentage. Add a set of dom icons, I hope I did something decent... surely as they are they don't fit luminos' style so I've put them only in the nexuiz skin. Rename hud_panel_modicons_dom_pps to hud_panel_modicons_dom_layout and add it to defaultXonotic.cfg 3 possible layouts: 0) only icons 1) icons and percentage of average pps (points per second) 2) icons and average pps The whole code is now cleaner. --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 2e5b56cd1..bd0b2b97b 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1357,6 +1357,8 @@ seta hud_panel_weapons_ammo_full_fuel 100 "show 100% of the status bar at this a seta hud_panel_notify_time 10 "time that a new entry stays until it fades out" seta hud_panel_notify_fadetime 3 "fade out time" +seta hud_panel_modicons_dom_layout 0 "3 possible layouts: 0) only icons; 1) icons and percentage of average pps (points per second); 2) icons and average pps" + seta hud_panel_timer_increment 0 "show elapsed time instead of remaining time" seta hud_panel_radar_scale 4096 "distance you can see on the team radar" diff --git a/gfx/hud/old/dom_icon_blue-highlighted.tga b/gfx/hud/old/dom_icon_blue-highlighted.tga new file mode 100644 index 000000000..a1ee2f019 Binary files /dev/null and b/gfx/hud/old/dom_icon_blue-highlighted.tga differ diff --git a/gfx/hud/old/dom_icon_blue.tga b/gfx/hud/old/dom_icon_blue.tga new file mode 100644 index 000000000..9524e70c6 Binary files /dev/null and b/gfx/hud/old/dom_icon_blue.tga differ diff --git a/gfx/hud/old/dom_icon_pink-highlighted.tga b/gfx/hud/old/dom_icon_pink-highlighted.tga new file mode 100644 index 000000000..748e2adab Binary files /dev/null and b/gfx/hud/old/dom_icon_pink-highlighted.tga differ diff --git a/gfx/hud/old/dom_icon_pink.tga b/gfx/hud/old/dom_icon_pink.tga new file mode 100644 index 000000000..504c849e4 Binary files /dev/null and b/gfx/hud/old/dom_icon_pink.tga differ diff --git a/gfx/hud/old/dom_icon_red-highlighted.tga b/gfx/hud/old/dom_icon_red-highlighted.tga new file mode 100644 index 000000000..fcfef5276 Binary files /dev/null and b/gfx/hud/old/dom_icon_red-highlighted.tga differ diff --git a/gfx/hud/old/dom_icon_red.tga b/gfx/hud/old/dom_icon_red.tga new file mode 100644 index 000000000..bedc8bb41 Binary files /dev/null and b/gfx/hud/old/dom_icon_red.tga differ diff --git a/gfx/hud/old/dom_icon_yellow-highlighted.tga b/gfx/hud/old/dom_icon_yellow-highlighted.tga new file mode 100644 index 000000000..02e7fb8ce Binary files /dev/null and b/gfx/hud/old/dom_icon_yellow-highlighted.tga differ diff --git a/gfx/hud/old/dom_icon_yellow.tga b/gfx/hud/old/dom_icon_yellow.tga new file mode 100644 index 000000000..ef8fa8def Binary files /dev/null and b/gfx/hud/old/dom_icon_yellow.tga differ diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 487e4f6d4..caf9d1bc5 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4097,86 +4097,82 @@ void HUD_Mod_Race(vector pos, vector mySize) drawfont = hud_font; } -void DrawDomCP(vector myPos, vector mySize, float i) +void DrawDomItem(vector myPos, vector mySize, float aspect_ratio, float i) { - float stat; + float stat, pps_ratio; + string pic; vector color; switch(i) { case 0: stat = getstatf(STAT_DOM_PPS_RED); + pic = "dom_icon_red"; color = '1 0 0'; break; case 1: stat = getstatf(STAT_DOM_PPS_BLUE); + pic = "dom_icon_blue"; color = '0 0 1'; break; case 2: stat = getstatf(STAT_DOM_PPS_YELLOW); + pic = "dom_icon_yellow"; color = '1 1 0'; break; case 3: stat = getstatf(STAT_DOM_PPS_PINK); + pic = "dom_icon_pink"; color = '1 0 1'; } + pps_ratio = stat / getstatf(STAT_DOM_TOTAL_PPS); - vector newSize, newPos; - if(mySize_x/mySize_y > 3) + if(mySize_x/mySize_y > aspect_ratio) { - newSize_x = 3 * mySize_y; - newSize_y = mySize_y; - - newPos_x = myPos_x + (mySize_x - newSize_x) / 2; - newPos_y = myPos_y; + i = aspect_ratio * mySize_y; + myPos_x = myPos_x + (mySize_x - i) / 2; + mySize_x = i; } else { - newSize_y = 1/3 * mySize_x; - newSize_x = mySize_x; - - newPos_y = myPos_y + (mySize_y - newSize_y) / 2; - newPos_x = myPos_x; + i = 1/aspect_ratio * mySize_x; + myPos_y = myPos_y + (mySize_y - i) / 2; + mySize_y = i; } - vector picpos, numpos; - numpos = newPos + eX * newSize_y; - /* - if(autocvar_hud_panel_modicons_iconalign) + if (cvar("hud_panel_modicons_dom_layout")) // show text too { - numpos = newPos; - picpos = newPos + eX * 2 * newSize_y; + //draw the text + drawfont = hud_bigfont; + color *= 0.5 + pps_ratio * (1 - 0.5); // half saturated color at min, full saturated at max + if (cvar("hud_panel_modicons_dom_layout") == 2) // average pps + drawstring_aspect(myPos + eX * mySize_y, ftos_decimals(stat, 2), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL); + else // percentage of average pps + drawstring_aspect(myPos + eX * mySize_y, strcat( ftos(floor(pps_ratio*100 + 0.5)), "%" ), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL); + drawfont = hud_font; } - else + + //draw the icon + drawpic_aspect_skin(myPos, pic, '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + if (stat > 0) { - numpos = newPos + eX * newSize_y; - picpos = newPos; + drawsetcliparea(myPos_x, myPos_y + mySize_y * (1 - pps_ratio), mySize_y, mySize_y * pps_ratio); + drawpic_aspect_skin(myPos, strcat(pic, "-highlighted"), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawresetcliparea(); } - */ - - drawfont = hud_bigfont; - if (cvar("hud_panel_modicons_dom_pps")) // average pps - drawstring_aspect(numpos, ftos_decimals(stat, 2), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL); - else // percentage of average pps - drawstring_aspect(numpos, strcat(ftos_decimals(stat*100 / getstatf(STAT_DOM_TOTAL_PPS), 0), "%"), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha, DRAWFLAG_NORMAL); - drawfont = hud_font; - - // TODO draw controlpoints icons with a bar - // representing the percentage of average pps - // and maybe show smaller strings } void HUD_Mod_Dom(vector myPos, vector mySize) { - print("test ", ftos(cvar("aaa")), "\n"); entity tm; float teams_count; for(tm = teams.sort_next; tm; tm = tm.sort_next) if(tm.team != COLOR_SPECTATOR) ++teams_count; - float rows, columns; + float rows, columns, aspect_ratio; rows = mySize_y/mySize_x; - rows = bound(1, floor((sqrt((4 * 1 * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count); + aspect_ratio = (cvar("hud_panel_modicons_dom_layout")) ? 3 : 1; + rows = bound(1, floor((sqrt((4 * aspect_ratio * teams_count + rows) * rows) + rows + 0.5) / 2), teams_count); columns = ceil(teams_count/rows); drawfont = hud_bigfont; @@ -4188,7 +4184,7 @@ void HUD_Mod_Dom(vector myPos, vector mySize) pos = myPos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows); size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows); - DrawDomCP(pos, size, i); + DrawDomItem(pos, size, aspect_ratio, i); ++row; if(row >= rows) diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 4ef2bd4f4..7c7bb46c9 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1379,8 +1379,7 @@ void DecodeLevelParms (void); .float uid_kicktime; .string uid; #endif -float total_pps; -.float dom_total_pps; +void set_dom_state(entity e, float connecting); void ClientConnect (void) { float t; @@ -1588,7 +1587,7 @@ void ClientConnect (void) send_CSQC_teamnagger(); if (g_domination) - self.dom_total_pps = total_pps; + set_dom_state(self, TRUE); CheatInitClient(); } diff --git a/qcsrc/server/domination.qc b/qcsrc/server/domination.qc index d0bffa1c4..578a44099 100644 --- a/qcsrc/server/domination.qc +++ b/qcsrc/server/domination.qc @@ -24,15 +24,25 @@ float g_domination_point_rate; .entity sprite; .float captime; -// pps (points per second) +// pps: points per second +.float dom_total_pps; .float dom_pps_red; .float dom_pps_blue; -.float dom_pps_pink; .float dom_pps_yellow; +.float dom_pps_pink; +float total_pps; float pps_red; float pps_blue; -float pps_pink; float pps_yellow; +float pps_pink; +void set_dom_state(entity e, float connecting) +{ + if(connecting) e.dom_total_pps = total_pps; + e.dom_pps_red = pps_red; + e.dom_pps_blue = pps_blue; + if(c3 >= 0) e.dom_pps_yellow = pps_yellow; + if(c4 >= 0) e.dom_pps_pink = pps_pink; +} void() dom_controlpoint_setup; @@ -151,14 +161,8 @@ void dompoint_captured () WaypointSprite_UpdateSprites(self.sprite, "dom-pink", "", ""); } - entity player; - FOR_EACH_CLIENT(player) - { - player.dom_pps_red = pps_red; - player.dom_pps_blue = pps_blue; - player.dom_pps_yellow = pps_yellow; - player.dom_pps_pink = pps_pink; - } + FOR_EACH_CLIENT(head) + set_dom_state(head, FALSE); WaypointSprite_UpdateTeamRadar(self.sprite, RADARICON_DOMPOINT, colormapPaletteColor(self.goalentity.team - 1, 0)); WaypointSprite_Ping(self.sprite); @@ -698,11 +702,11 @@ void dom_init() precache_sound("domination/claim.wav"); InitializeEntity(world, dom_delayedinit, INITPRIO_GAMETYPE); - addstat(STAT_DOM_TOTAL_PPS , AS_FLOAT, dom_total_pps); - addstat(STAT_DOM_PPS_RED , AS_FLOAT, dom_pps_red); - addstat(STAT_DOM_PPS_BLUE , AS_FLOAT, dom_pps_blue); - addstat(STAT_DOM_PPS_PINK , AS_FLOAT, dom_pps_pink); - addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow); + addstat(STAT_DOM_TOTAL_PPS, AS_FLOAT, dom_total_pps); + addstat(STAT_DOM_PPS_RED, AS_FLOAT, dom_pps_red); + addstat(STAT_DOM_PPS_BLUE, AS_FLOAT, dom_pps_blue); + if(c3 >= 0) addstat(STAT_DOM_PPS_YELLOW, AS_FLOAT, dom_pps_yellow); + if(c4 >= 0) addstat(STAT_DOM_PPS_PINK, AS_FLOAT, dom_pps_pink); g_domination_point_rate = cvar("g_domination_point_rate"); g_domination_point_amt = cvar("g_domination_point_amt");