]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sbar.c
fix Sbar_MiniDeathmatchOverlay to draw to the right of the sbar (in non-Nexuiz modes...
[xonotic/darkplaces.git] / sbar.c
diff --git a/sbar.c b/sbar.c
index f98d4de46ab15aa9be912bbbbf5c4ba465be7cd2..d62863d61efc26b80b856229ae760288b81f71b2 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -126,10 +126,7 @@ void sbar_start(void)
        sb_disc = Sbar_NewPic("gfx/disc");
 
        for (i = 0;i < 10;i++)
-       {
                sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
-               sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i));
-       }
 
        sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
        sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus");
@@ -137,7 +134,7 @@ void sbar_start(void)
        sb_colon = Sbar_NewPic ("gfx/num_colon");
        sb_slash = Sbar_NewPic ("gfx/num_slash");
 
-       //AK NEX uses its own hud
+       //AK NX uses its own hud
        if(gamemode == GAME_NEXUIZ)
        {
                sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
@@ -365,6 +362,39 @@ void Sbar_DrawNum (int x, int y, int num, int digits, int color)
 
                Sbar_DrawPic (x, y, sb_nums[color][frame]);
                x += 24;
+
+               ptr++;
+       }
+}
+
+/*
+=============
+Sbar_DrawXNum
+=============
+*/
+
+void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r, float g, float b, float a, int flags)
+{
+       char str[32], *ptr;
+       int l, frame;
+
+       l = sprintf(str, "%i", num);
+       ptr = str;
+       if (l > digits)
+               ptr += (l-digits);
+       if (l < digits)
+               x += (digits-l) * lettersize;
+
+       while (*ptr)
+       {
+               if (*ptr == '-')
+                       frame = STAT_MINUS;
+               else
+                       frame = *ptr -'0';
+
+               DrawQ_Pic (sbar_x + x, sbar_y + y, sb_nums[0][frame]->name,lettersize,lettersize,r,g,b,a,flags);
+               x += lettersize;
+
                ptr++;
        }
 }
@@ -838,13 +868,16 @@ void Sbar_Draw (void)
                sbar_y = vid.conheight - 47;
                sbar_x = (vid.conwidth - 640)/2;
 
-               if (sb_lines > 24)
-                       Sbar_DrawFrags ();
+               if (sb_lines)
+               {
+                       Sbar_DrawInventory();
+                       if (!cl.islocalgame)
+                               Sbar_DrawFrags ();
+               }
 
                if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
                {
-                       if (gamemode != GAME_GOODVSBAD2)
-                               Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
+                       Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
                        Sbar_DrawScoreboard ();
                }
                else if (sb_lines)
@@ -854,28 +887,40 @@ void Sbar_Draw (void)
                        // special items
                        if (cl.items & IT_INVULNERABILITY)
                        {
-                               Sbar_DrawNum (24, 0, 666, 3, 1);
+                               Sbar_DrawNum (36, 0, 666, 3, 1);
                                Sbar_DrawPic (0, 0, sb_disc);
                        }
 
                        // armor
-                       Sbar_DrawNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
+                       Sbar_DrawXNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, 24, 0.6,0.7,0.8,1,0);
 
                        // health
-                       Sbar_DrawNum ((154-3*24), 12, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
+                       if(cl.stats[STAT_HEALTH] > 100)
+                               Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,1,1,1,1,0);
+                       else if(cl.stats[STAT_HEALTH] <= 25 && cl.time - (int)cl.time > 0.5)
+                               Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0);
+                       else
+                               Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0);
 
-                       if (cl.items & NEX_IT_SHELLS)
-                               Sbar_DrawPic (519, 0, sb_ammo[0]);
-                       else if (cl.items & NEX_IT_BULLETS)
-                               Sbar_DrawPic (519, 0, sb_ammo[1]);
-                       else if (cl.items & NEX_IT_ROCKETS)
-                               Sbar_DrawPic (519, 0, sb_ammo[2]);
-                       else if (cl.items & NEX_IT_CELLS)
-                               Sbar_DrawPic (519, 0, sb_ammo[3]);
+                       // AK dont draw ammo for the laser
+                       if(cl.stats[STAT_ACTIVEWEAPON] != 12)
+                       {
+                               if (cl.items & NEX_IT_SHELLS)
+                                       Sbar_DrawPic (519, 0, sb_ammo[0]);
+                               else if (cl.items & NEX_IT_BULLETS)
+                                       Sbar_DrawPic (519, 0, sb_ammo[1]);
+                               else if (cl.items & NEX_IT_ROCKETS)
+                                       Sbar_DrawPic (519, 0, sb_ammo[2]);
+                               else if (cl.items & NEX_IT_CELLS)
+                                       Sbar_DrawPic (519, 0, sb_ammo[3]);
+
+                               if(cl.stats[STAT_AMMO] <= 10)
+                                       Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.7, 0,0,1,0);
+                               else
+                                       Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.6, 0.7,0.8,1,0);
 
-                       Sbar_DrawNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
+                       }
 
-                       //Sbar_DrawAlphaPic(0,0,sb_sbar_overlay,0.5);
                        DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE);
                }
        }
@@ -988,7 +1033,6 @@ void Sbar_Draw (void)
                }
        }
 
-
        if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
                Sbar_MiniDeathmatchOverlay ();
 
@@ -1051,8 +1095,18 @@ void Sbar_MiniDeathmatchOverlay (void)
        int i, x, y, numlines;
 
        // decide where to print
-       x = 324;
-       y = vid.conheight - sb_lines;
+       // AK Nex wants its scores on the upper left
+       if(gamemode == GAME_NEXUIZ)
+       {
+               x = 0;
+               y = 0;
+       }
+       else
+       {
+               x = 320;
+               y = vid.conheight - sb_lines;
+       }
+
        numlines = (vid.conheight - y) / 8;
        // give up if there isn't room
        if (x + (6 + 15) * 8 > vid.conwidth || numlines < 1)