]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
- Fix hud_panel_weapons_accuracy usage that was considered always true
authorterencehill <piuntn@gmail.com>
Thu, 30 Sep 2010 14:29:26 +0000 (16:29 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 30 Sep 2010 14:29:26 +0000 (16:29 +0200)
- Initialize accuracy levels only when the cvar hud_panel_weapons_accuracy_color_levels changes, not at every frame
- Show accuracy stats data without colors on the scoreboard if hud_panel_weapons_accuracy_color_levels is "", instead of not showing at all the whole accuracy panel

defaultXonotic.cfg
qcsrc/client/View.qc
qcsrc/client/hud.qc
qcsrc/client/hud.qh
qcsrc/client/scoreboard.qc

index d3e5f56e654e60de0db8576b7c5262645556bfcf..0ec3e06960eca863312832270bf3c3bbe3b20b77 100644 (file)
@@ -1383,7 +1383,7 @@ seta scoreboard_columns default
 seta scoreboard_border_thickness 1 "scoreboard border thickness"
 seta scoreboard_accuracy_border_thickness 1 "accuracy stats border thickness"
 seta scoreboard_accuracy_doublerows 0 "use two rows instead of one"
-seta scoreboard_accuracy 1 "0 = no weapon accuracy stats panel on scoreboard"
+seta scoreboard_accuracy 1 "show accuracy stats panel on scoreboard"
 seta scoreboard_color_bg_r 0 "red color component of the HUD background"
 seta scoreboard_color_bg_g 0.25 "green color component of the HUD background"
 seta scoreboard_color_bg_b 0.17 "blue color component of the HUD background"
index 829eeb70141161a8cee53a346d8dc5da85f1244e..111db52e1696c40a6b20e22265fd5eb5db20a3ab 100644 (file)
@@ -1200,9 +1200,11 @@ void CSQC_common_hud(void)
                case HUD_NORMAL:
                        // do some accuracy var caching
                        float i;
+                       if(cvar_string("hud_panel_weapons_accuracy_color_levels") != acc_color_levels)
                        if(!(gametype == GAME_RACE || gametype == GAME_CTS))
                        {
-                               acc_levels = tokenize(cvar_string("hud_panel_weapons_accuracy_color_levels"));
+                               acc_color_levels = cvar_string("hud_panel_weapons_accuracy_color_levels");
+                               acc_levels = tokenize(acc_color_levels);
                                if (acc_levels > MAX_ACCURACY_LEVELS)
                                        acc_levels = MAX_ACCURACY_LEVELS;
 
index 3a9be97bbf3843ce412df23df0d0f108bb4ca7a6..906a0192847b7010c893c121420a715fb5610e9b 100644 (file)
@@ -1657,6 +1657,10 @@ void HUD_Weapons(void)
        vector wpnpos;
        vector wpnsize;
 
+       float show_accuracy;
+       if(autocvar_hud_panel_weapons_accuracy && acc_levels)
+               show_accuracy = true;
+
        for(i = 0; i < weapon_cnt; ++i)
        {
                wpnpos = panel_pos + eX * column * panel_size_x*(1/columns) + eY * row * panel_size_y*(1/rows);
@@ -1670,7 +1674,7 @@ void HUD_Weapons(void)
                        drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
 
                // draw the weapon accuracy
-               if(acc_levels)
+               if(show_accuracy)
                {
                        float weapon_hit, weapon_damage;
                        weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
index 371dd64b79f6252bb0c4f50cdb4436337fff25ff..1754dcb58a1afdec16f3c2eaf126b0e799e0d1a0 100644 (file)
@@ -22,6 +22,7 @@ float weapon_fired[WEP_MAXCOUNT];
 #define MAX_ACCURACY_LEVELS 10
 float acc_lev[MAX_ACCURACY_LEVELS];
 float acc_levels;
+string acc_color_levels;
 
 float complain_weapon;
 string complain_weapon_name;
index 76b19a54c50c99a94d7942951edf430ab380d626..0149f9d9665f92ff9d8491428989dc33412fc78e 100644 (file)
@@ -947,6 +947,9 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        if(getstati(STAT_SWITCHWEAPON) == WEP_MINSTANEX)
                g_minstagib = 1; // TODO: real detection for minstagib?
 
+       if (!acc_levels)
+               rgb = '1 1 1';
+
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
                self = get_weaponinfo(i);
@@ -986,17 +989,20 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                                weapon_stats = floor(100 * weapon_hit / weapon_damage);
                        }
 
-                       // find the max level lower than weapon_stats
-                       float j;
-                       j = acc_levels-1;
-                       while ( j && weapon_stats < acc_lev[j] )
-                               --j;
-
-                       // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
-                       float factor;
-                       factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
-                       rgb = acc_color(j);
-                       rgb = rgb + factor * (acc_color(j+1) - rgb);
+                       if (acc_levels)
+                       {
+                               // find the max level lower than weapon_stats
+                               float j;
+                               j = acc_levels-1;
+                               while ( j && weapon_stats < acc_lev[j] )
+                                       --j;
+
+                               // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
+                               float factor;
+                               factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
+                               rgb = acc_color(j);
+                               rgb = rgb + factor * (acc_color(j+1) - rgb);
+                       }
 
                        drawstring(pos + '1 0 0' * padding + '0 1 0' * height * (2/3), s, '1 1 0' * fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
                }