]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sbar.c
video modes in menu now also set vid_pixelheight and vid_conwidth/vid_conheight
[xonotic/darkplaces.git] / sbar.c
diff --git a/sbar.c b/sbar.c
index 5137d440a4371ffbf8a393774b559a1148dd4d79..4e09cbc4da6ae69e6f3a65db77abca89c622878e 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 #include "quakedef.h"
 
-typedef struct
+typedef struct sbarpic_s
 {
        char name[32];
 }
@@ -89,12 +89,15 @@ sbarpic_t *somsb_health;
 sbarpic_t *somsb_ammo[4];
 sbarpic_t *somsb_armor[3];
 
-sbarpic_t *zymsb_crosshair_dot;
+sbarpic_t *zymsb_crosshair_center;
 sbarpic_t *zymsb_crosshair_line;
 sbarpic_t *zymsb_crosshair_health;
 sbarpic_t *zymsb_crosshair_ammo;
 sbarpic_t *zymsb_crosshair_clip;
 sbarpic_t *zymsb_crosshair_background;
+sbarpic_t *zymsb_crosshair_left1;
+sbarpic_t *zymsb_crosshair_left2;
+sbarpic_t *zymsb_crosshair_right;
 
 cvar_t showfps = {CVAR_SAVE, "showfps", "0"};
 cvar_t showtime = {CVAR_SAVE, "showtime", "0"};
@@ -144,7 +147,10 @@ void sbar_start(void)
 
        numsbarpics = 0;
 
-       if (gamemode == GAME_SOM)
+       if (gamemode == GAME_NETHERWORLD)
+       {
+       }
+       else if (gamemode == GAME_SOM)
        {
                sb_disc = Sbar_NewPic("gfx/disc");
 
@@ -185,12 +191,15 @@ void sbar_start(void)
        }
        else if (gamemode == GAME_ZYMOTIC)
        {
-               zymsb_crosshair_dot = Sbar_NewPic ("gfx/hud/crosshair_dot");
+               zymsb_crosshair_center = Sbar_NewPic ("gfx/hud/crosshair_center");
                zymsb_crosshair_line = Sbar_NewPic ("gfx/hud/crosshair_line");
                zymsb_crosshair_health = Sbar_NewPic ("gfx/hud/crosshair_health");
                zymsb_crosshair_clip = Sbar_NewPic ("gfx/hud/crosshair_clip");
                zymsb_crosshair_ammo = Sbar_NewPic ("gfx/hud/crosshair_ammo");
                zymsb_crosshair_background = Sbar_NewPic ("gfx/hud/crosshair_background");
+               zymsb_crosshair_left1 = Sbar_NewPic ("gfx/hud/crosshair_left1");
+               zymsb_crosshair_left2 = Sbar_NewPic ("gfx/hud/crosshair_left2");
+               zymsb_crosshair_right = Sbar_NewPic ("gfx/hud/crosshair_right");
        }
        else
        {
@@ -718,7 +727,7 @@ void Sbar_DrawFrags (void)
        int i, k, l, x, f;
        char num[12];
        scoreboard_t *s;
-       qbyte *c;
+       unsigned char *c;
 
        Sbar_SortFrags ();
 
@@ -733,9 +742,9 @@ void Sbar_DrawFrags (void)
                s = &cl.scores[k];
 
                // draw background
-               c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
+               c = (unsigned char *)&palette_complete[(s->colors & 0xf0) + 8];
                DrawQ_Fill (sbar_x + x + 10, sbar_y     - 23, 28, 4, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0);
-               c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
+               c = (unsigned char *)&palette_complete[((s->colors & 15)<<4) + 8];
                DrawQ_Fill (sbar_x + x + 10, sbar_y + 4 - 23, 28, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0);
 
                // draw number
@@ -772,14 +781,14 @@ void Sbar_DrawFace (void)
        {
                char num[12];
                scoreboard_t *s;
-               qbyte *c;
+               unsigned char *c;
 
                s = &cl.scores[cl.viewentity - 1];
                // draw background
                Sbar_DrawPic (112, 0, rsb_teambord);
-               c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
+               c = (unsigned char *)&palette_complete[(s->colors & 0xf0) + 8];
                DrawQ_Fill (sbar_x + 113, vid_conheight.integer-SBAR_HEIGHT+3, 22, 9, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0);
-               c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
+               c = (unsigned char *)&palette_complete[((s->colors & 15)<<4) + 8];
                DrawQ_Fill (sbar_x + 113, vid_conheight.integer-SBAR_HEIGHT+12, 22, 9, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0);
 
                // draw number
@@ -921,6 +930,26 @@ void Sbar_ShowFPS(void)
        }
 }
 
+void Sbar_DrawGauge(float x, float y, const char *picname, float width, float height, float rangey, float rangeheight, float c1, float c2, float c1r, float c1g, float c1b, float c1a, float c2r, float c2g, float c2b, float c2a, float c3r, float c3g, float c3b, float c3a, int drawflags)
+{
+       float r[5];
+       c2 = bound(0, c2, 1);
+       c1 = bound(0, c1, 1 - c2);
+       r[0] = 0;
+       r[1] = rangey + rangeheight * (c2 + c1);
+       r[2] = rangey + rangeheight * (c2);
+       r[3] = rangey;
+       r[4] = height;
+       if (r[1] > r[0])
+               DrawQ_SuperPic(x, y + r[0], picname, width, (r[1] - r[0]), 0,(r[0] / height), c3r,c3g,c3b,c3a, 1,(r[0] / height), c3r,c3g,c3b,c3a, 0,(r[1] / height), c3r,c3g,c3b,c3a, 1,(r[1] / height), c3r,c3g,c3b,c3a, drawflags);
+       if (r[2] > r[1])
+               DrawQ_SuperPic(x, y + r[1], picname, width, (r[2] - r[1]), 0,(r[1] / height), c1r,c1g,c1b,c1a, 1,(r[1] / height), c1r,c1g,c1b,c1a, 0,(r[2] / height), c1r,c1g,c1b,c1a, 1,(r[2] / height), c1r,c1g,c1b,c1a, drawflags);
+       if (r[3] > r[2])
+               DrawQ_SuperPic(x, y + r[2], picname, width, (r[3] - r[2]), 0,(r[2] / height), c2r,c2g,c2b,c2a, 1,(r[2] / height), c2r,c2g,c2b,c2a, 0,(r[3] / height), c2r,c2g,c2b,c2a, 1,(r[3] / height), c2r,c2g,c2b,c2a, drawflags);
+       if (r[4] > r[3])
+               DrawQ_SuperPic(x, y + r[3], picname, width, (r[4] - r[3]), 0,(r[3] / height), c3r,c3g,c3b,c3a, 1,(r[3] / height), c3r,c3g,c3b,c3a, 0,(r[4] / height), c3r,c3g,c3b,c3a, 1,(r[4] / height), c3r,c3g,c3b,c3a, drawflags);
+}
+
 /*
 ===============
 Sbar_Draw
@@ -941,7 +970,10 @@ void Sbar_Draw (void)
                return;
        }
 
-       if (gamemode == GAME_SOM)
+       if (gamemode == GAME_NETHERWORLD)
+       {
+       }
+       else if (gamemode == GAME_SOM)
        {
                if (sb_showscores || (cl.stats[STAT_HEALTH] <= 0 && cl_deathscoreboard.integer))
                        Sbar_DrawScoreboard ();
@@ -1066,6 +1098,25 @@ void Sbar_Draw (void)
        }
        else if (gamemode == GAME_ZYMOTIC)
        {
+#if 1
+               float scale = 64.0f / 256.0f;
+               float kickoffset[3];
+               VectorClear(kickoffset);
+               if (v_dmg_time > 0)
+               {
+                       kickoffset[0] = (v_dmg_time/v_kicktime.value*v_dmg_roll) * 10 * scale;
+                       kickoffset[1] = (v_dmg_time/v_kicktime.value*v_dmg_pitch) * 10 * scale;
+               }
+               sbar_x = (vid_conwidth.integer - 256 * scale)/2 + kickoffset[0];
+               sbar_y = (vid_conheight.integer - 256 * scale)/2 + kickoffset[1];
+               // left1 16, 48 : 126 -66
+               // left2 16, 128 : 196 -66
+               // right 176, 48 : 196 -136
+               Sbar_DrawGauge(sbar_x +  16 * scale, sbar_y +  48 * scale, zymsb_crosshair_left1->name, 64*scale,  80*scale, 78*scale,  -66*scale, cl.stats[STAT_AMMO]  * (1.0 / 200.0), cl.stats[STAT_SHELLS]  * (1.0 / 200.0), 0.8f,0.8f,0.0f,1.0f, 0.8f,0.5f,0.0f,1.0f, 0.3f,0.3f,0.3f,1.0f, DRAWFLAG_NORMAL);
+               Sbar_DrawGauge(sbar_x +  16 * scale, sbar_y + 128 * scale, zymsb_crosshair_left2->name, 64*scale,  80*scale, 68*scale,  -66*scale, cl.stats[STAT_NAILS] * (1.0 / 200.0), cl.stats[STAT_ROCKETS] * (1.0 / 200.0), 0.8f,0.8f,0.0f,1.0f, 0.8f,0.5f,0.0f,1.0f, 0.3f,0.3f,0.3f,1.0f, DRAWFLAG_NORMAL);
+               Sbar_DrawGauge(sbar_x + 176 * scale, sbar_y +  48 * scale, zymsb_crosshair_right->name, 64*scale, 160*scale, 148*scale, -136*scale, cl.stats[STAT_ARMOR]  * (1.0 / 300.0), cl.stats[STAT_HEALTH]  * (1.0 / 300.0), 0.0f,0.5f,1.0f,1.0f, 1.0f,0.0f,0.0f,1.0f, 0.3f,0.3f,0.3f,1.0f, DRAWFLAG_NORMAL);
+               DrawQ_Pic(sbar_x + 120 * scale, sbar_y + 120 * scale, zymsb_crosshair_center->name, 16 * scale, 16 * scale, 1, 1, 1, 1, DRAWFLAG_NORMAL);
+#else
                float scale = 128.0f / 256.0f;
                float healthstart, healthheight, healthstarttc, healthendtc;
                float shieldstart, shieldheight, shieldstarttc, shieldendtc;
@@ -1106,6 +1157,8 @@ void Sbar_Draw (void)
                if (ammoheight > 0)   DrawQ_SuperPic(sbar_x + 0 * scale, sbar_y + ammostart   * scale, zymsb_crosshair_ammo->name,   256 * scale, ammoheight   * scale, 0,ammostarttc,   0.8f,0.8f,0.0f,1.0f, 1,ammostarttc,   0.8f,0.8f,0.0f,1.0f, 0,ammoendtc,   0.8f,0.8f,0.0f,1.0f, 1,ammoendtc,   0.8f,0.8f,0.0f,1.0f, DRAWFLAG_NORMAL);
                if (clipheight > 0)   DrawQ_SuperPic(sbar_x + 0 * scale, sbar_y + clipstart   * scale, zymsb_crosshair_clip->name,   256 * scale, clipheight   * scale, 0,clipstarttc,   1.0f,1.0f,0.0f,1.0f, 1,clipstarttc,   1.0f,1.0f,0.0f,1.0f, 0,clipendtc,   1.0f,1.0f,0.0f,1.0f, 1,clipendtc,   1.0f,1.0f,0.0f,1.0f, DRAWFLAG_NORMAL);
                DrawQ_Pic(sbar_x + 0 * scale, sbar_y + 0 * scale, zymsb_crosshair_background->name, 256 * scale, 256 * scale, 1, 1, 1, 1, DRAWFLAG_NORMAL);
+               DrawQ_Pic(sbar_x + 120 * scale, sbar_y + 120 * scale, zymsb_crosshair_center->name, 16 * scale, 16 * scale, 1, 1, 1, 1, DRAWFLAG_NORMAL);
+#endif
        }
        else // Quake and others
        {
@@ -1242,11 +1295,11 @@ Sbar_DeathmatchOverlay
 */
 float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
 {
-       qbyte *c;
+       unsigned char *c;
        // draw colors behind score
-       c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
+       c = (unsigned char *)&palette_complete[(s->colors & 0xf0) + 8];
        DrawQ_Fill(x + 8, y+1, 32, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0);
-       c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
+       c = (unsigned char *)&palette_complete[((s->colors & 15)<<4) + 8];
        DrawQ_Fill(x + 8, y+4, 32, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha_fg.value, 0);
        // print the text
        //DrawQ_String(x, y, va("%c%4i %s", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0);