]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Code to support icons which are shown with an "incorporated" bar indicating the pps...
authorterencehill <piuntn@gmail.com>
Wed, 28 Jul 2010 20:25:55 +0000 (22:25 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 28 Jul 2010 20:25:55 +0000 (22:25 +0200)
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.

12 files changed:
defaultXonotic.cfg
gfx/hud/old/dom_icon_blue-highlighted.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_blue.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_pink-highlighted.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_pink.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_red-highlighted.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_red.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_yellow-highlighted.tga [new file with mode: 0644]
gfx/hud/old/dom_icon_yellow.tga [new file with mode: 0644]
qcsrc/client/hud.qc
qcsrc/server/cl_client.qc
qcsrc/server/domination.qc

index 2e5b56cd14fccfd30703d33850cd912f2858c744..bd0b2b97b30a8f03d369377e7941f4107531f0bb 100644 (file)
@@ -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 (file)
index 0000000..a1ee2f0
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 (file)
index 0000000..9524e70
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 (file)
index 0000000..748e2ad
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 (file)
index 0000000..504c849
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 (file)
index 0000000..fcfef52
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 (file)
index 0000000..bedc8bb
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 (file)
index 0000000..02e7fb8
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 (file)
index 0000000..ef8fa8d
Binary files /dev/null and b/gfx/hud/old/dom_icon_yellow.tga differ
index 487e4f6d49582c3a6c100f6a6480df25df6baa21..caf9d1bc52fb0221042243ef6247773e37ddb62b 100644 (file)
@@ -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)
index 4ef2bd4f48ca8ca102fc45df1a5f2877e285b7b7..7c7bb46c9a55be15b8804883bd10ea26393e73eb 100644 (file)
@@ -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();
 }
index d0bffa1c4682cf38e5b4269a95244641a901fb99..578a440990d25045755d6a4afe23fa723b9f5cd0 100644 (file)
@@ -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");