]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sbar.c
currenttriangle and currentvertex no longer exist, also firstvert and firsttriangle...
[xonotic/darkplaces.git] / sbar.c
diff --git a/sbar.c b/sbar.c
index a85875dfacbf96c495623a60af416c94ccd10c89..e14b58d9074508e7a7bcec832d31ef67c9e61646 100644 (file)
--- a/sbar.c
+++ b/sbar.c
@@ -84,6 +84,9 @@ cvar_t        showfps = {CVAR_SAVE, "showfps", "0"};
 
 void Sbar_MiniDeathmatchOverlay (void);
 void Sbar_DeathmatchOverlay (void);
+void Sbar_IntermissionOverlay (void);
+void Sbar_FinaleOverlay (void);
+
 
 /*
 ===============
@@ -403,7 +406,6 @@ void Sbar_UpdateScoreboard (void)
 }
 
 
-
 /*
 ===============
 Sbar_SoloScoreboard
@@ -607,7 +609,7 @@ void Sbar_DrawFrags (void)
        int i, k, l, x, f;
        char num[12];
        scoreboard_t *s;
-       byte *c;
+       qbyte *c;
 
        Sbar_SortFrags ();
 
@@ -624,9 +626,9 @@ void Sbar_DrawFrags (void)
                        continue;
 
                // draw background
-               c = (byte *)&d_8to24table[(s->colors & 0xf0) + 8];
+               c = (qbyte *)&d_8to24table[(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), 0);
-               c = (byte *)&d_8to24table[((s->colors & 15)<<4) + 8];
+               c = (qbyte *)&d_8to24table[((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), 0);
 
                // draw number
@@ -664,14 +666,14 @@ void Sbar_DrawFace (void)
        {
                char num[12];
                scoreboard_t *s;
-               byte *c;
+               qbyte *c;
 
                s = &cl.scores[cl.viewentity - 1];
                // draw background
                Sbar_DrawPic (112, 0, rsb_teambord);
-               c = (byte *)&d_8to24table[(s->colors & 0xf0) + 8];
+               c = (qbyte *)&d_8to24table[(s->colors & 0xf0) + 8];
                DrawQ_Fill (sbar_x + 113, vid.conheight-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), 0);
-               c = (byte *)&d_8to24table[((s->colors & 15)<<4) + 8];
+               c = (qbyte *)&d_8to24table[((s->colors & 15)<<4) + 8];
                DrawQ_Fill (sbar_x + 113, vid.conheight-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), 0);
 
                // draw number
@@ -718,30 +720,51 @@ void Sbar_ShowFPS(void)
 {
        if (showfps.integer)
        {
-               static double currtime, frametimes[32];
-               double newtime, total;
+               int calc;
                char temp[32];
-               int calc, count, i;
-               static int framecycle = 0;
                float fps_x, fps_y, fps_scalex, fps_scaley;
-
-               newtime = Sys_DoubleTime();
-               frametimes[framecycle] = newtime - currtime;
-               total = 0;
-               count = 0;
-               while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
+               if (showfps.integer > 1)
+               {
+                       static double currtime, frametimes[32];
+                       double newtime, total;
+                       int count, i;
+                       static int framecycle = 0;
+
+                       newtime = Sys_DoubleTime();
+                       frametimes[framecycle] = newtime - currtime;
+                       total = 0;
+                       count = 0;
+                       while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
+                       {
+                               total += frametimes[i];
+                               count++;
+                       }
+                       framecycle++;
+                       framecycle &= 31;
+                       if (showfps.integer == 2)
+                               calc = (int) (((double) count / total) + 0.5);
+                       else // showfps 3, rapid update
+                               calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
+                       currtime = newtime;
+               }
+               else
                {
-                       total += frametimes[i];
-                       count++;
+                       static double nexttime = 0, lasttime = 0;
+                       static int framerate = 0, framecount = 0;
+                       double newtime;
+                       newtime = Sys_DoubleTime();
+                       if (newtime < nexttime)
+                               framecount++;
+                       else
+                       {
+                               framerate = (int) (framecount / (newtime - lasttime) + 0.5);
+                               lasttime = newtime;
+                               nexttime = lasttime + 0.2;
+                               framecount = 1;
+                       }
+                       calc = framerate;
                }
-               framecycle++;
-               framecycle &= 31;
-               if (showfps.integer == 1)
-                       calc = (int) (((double) count / total) + 0.5);
-               else // showfps 2, rapid update
-                       calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
                sprintf(temp, "%4i", calc);
-               currtime = newtime;
                fps_scalex = 12;
                fps_scaley = 12;
                fps_x = vid.conwidth - (fps_scalex * strlen(temp));
@@ -758,12 +781,23 @@ void Sbar_ShowFPS(void)
 Sbar_Draw
 ===============
 */
-void DrawCrosshair(int num);
+//void DrawCrosshair(int num);
 void Sbar_Draw (void)
 {
        if (scr_con_current == vid.conheight)
                return;         // console is full screen
 
+       if (cl.intermission == 1)
+       {
+               Sbar_IntermissionOverlay();
+               return;
+       }
+       else if (cl.intermission == 2)
+       {
+               Sbar_FinaleOverlay();
+               return;
+       }
+
        sbar_y = vid.conheight - SBAR_HEIGHT;
        if (cl.gametype == GAME_DEATHMATCH)
                sbar_x = 0;
@@ -867,15 +901,10 @@ void Sbar_Draw (void)
        if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
                Sbar_MiniDeathmatchOverlay ();
 
-       if (crosshair.integer >= 1)
-               DrawCrosshair(crosshair.integer - 1);
-
-       if (cl.intermission == 1)
-               Sbar_IntermissionOverlay();
-       else if (cl.intermission == 2)
-               Sbar_FinaleOverlay();
-
        Sbar_ShowFPS();
+
+//     if (crosshair.integer >= 1)
+//             DrawCrosshair(crosshair.integer - 1);
 }
 
 //=============================================================================
@@ -892,7 +921,7 @@ void Sbar_DeathmatchOverlay (void)
        int i, k, l, x, y, total, n, minutes, tens, units, fph;
        char num[128];
        scoreboard_t *s;
-       byte *c;
+       qbyte *c;
 
        pic = Draw_CachePic ("gfx/ranking.lmp");
        DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1, 0);
@@ -903,7 +932,7 @@ void Sbar_DeathmatchOverlay (void)
 // draw the text
        l = scoreboardlines;
 
-       x = ((vid.conwidth - 320)>>1) - 140;
+       x = (vid.conwidth - 280)>>1;
        y = 40;
        for (i = 0;i < l;i++)
        {
@@ -913,10 +942,10 @@ void Sbar_DeathmatchOverlay (void)
                        continue;
 
        // draw background
-               c = (byte *)&d_8to24table[(s->colors & 0xf0) + 8];
-               DrawQ_Fill ( x, y+1, 88, 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), 0);
-               c = (byte *)&d_8to24table[((s->colors & 15)<<4) + 8];
-               DrawQ_Fill ( x, y+4, 88, 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), 0);
+               c = (qbyte *)&d_8to24table[(s->colors & 0xf0) + 8];
+               DrawQ_Fill ( x + 8, y+1, 88, 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), 0);
+               c = (qbyte *)&d_8to24table[((s->colors & 15)<<4) + 8];
+               DrawQ_Fill ( x + 8, y+4, 88, 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), 0);
 
                total = cl.time - s->entertime;
                minutes = (int)total/60;
@@ -930,7 +959,7 @@ void Sbar_DeathmatchOverlay (void)
 
                // put it together
                sprintf (num, "%c %4i:%4i %4i:%c%c %s", k == cl.viewentity - 1 ? 12 : ' ', (int) s->frags, fph, minutes, tens, units, s->name);
-               DrawQ_String(x - 8, y, num, 0, 8, 8, 1, 1, 1, 1, 0);
+               DrawQ_String(x, y, num, 0, 8, 8, 1, 1, 1, 1, 0);
 
                y += 8;
        }
@@ -947,7 +976,7 @@ void Sbar_MiniDeathmatchOverlay (void)
        int i, l, k, x, y, fph, numlines;
        char num[128];
        scoreboard_t *s;
-       byte *c;
+       qbyte *c;
 
        if (vid.conwidth < 512 || !sb_lines)
                return;
@@ -986,9 +1015,9 @@ void Sbar_MiniDeathmatchOverlay (void)
                        continue;
 
                // draw background
-               c = (byte *)&d_8to24table[(s->colors & 0xf0) + 8];
+               c = (qbyte *)&d_8to24table[(s->colors & 0xf0) + 8];
                DrawQ_Fill ( x, y+1, 72, 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), 0);
-               c = (byte *)&d_8to24table[((s->colors & 15)<<4) + 8];
+               c = (qbyte *)&d_8to24table[((s->colors & 15)<<4) + 8];
                DrawQ_Fill ( x, y+4, 72, 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), 0);
 
                fph = (cl.time - s->entertime) ? (int) ((float) s->frags * 3600.0 / (cl.time - s->entertime)) : 0;
@@ -1020,11 +1049,11 @@ void Sbar_IntermissionOverlay (void)
                return;
        }
 
-       sbar_x = 0;
-       sbar_y = 0;
+       sbar_x = (vid.conwidth - 320) >> 1;
+       sbar_y = (vid.conheight - 200) >> 1;
 
-       DrawQ_Pic (64, 24, "gfx/complete.lmp", 0, 0, 1, 1, 1, 1, 0);
-       DrawQ_Pic (0, 56, "gfx/inter.lmp", 0, 0, 1, 1, 1, 1, 0);
+       DrawQ_Pic (sbar_x + 64, sbar_y + 24, "gfx/complete.lmp", 0, 0, 1, 1, 1, 1, 0);
+       DrawQ_Pic (sbar_x + 0, sbar_y + 56, "gfx/inter.lmp", 0, 0, 1, 1, 1, 1, 0);
 
 // time
        dig = cl.completed_time/60;
@@ -1058,3 +1087,4 @@ void Sbar_FinaleOverlay (void)
        pic = Draw_CachePic ("gfx/finale.lmp");
        DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1, 0);
 }
+