]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
argh fix typo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index ab9e6540e9d8305e0744714c05484a6e1fbc5926..3bb094a2d88629e3e4d39d27494d16a95610f6c6 100644 (file)
@@ -265,7 +265,7 @@ void centerprint(string strMessage)
        float i, j, n, hcount;
        string s;
 
-       centerprint_fontsize = Sbar_GetFontsize("scr_centersize");
+       centerprint_fontsize = HUD_GetFontsize("scr_centersize");
 
        centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
 
@@ -571,6 +571,9 @@ vector HUD_Panel_CheckLimitSize(float id, vector mySize)
                case 5: 
                        mySize_x = max(mySize_y * 2, mySize_x); // at least 2 * height
                        break;
+               case 8: 
+                       mySize_y = (1/4) * mySize_x; // 1/4 * width
+                       break;
                case 9: 
                        mySize_y = (1/4) * mySize_x; // 1/4 * width
                        break;
@@ -1401,7 +1404,7 @@ void HUD_HealthArmor(void)
 
                        if (x > 0)
                        {
-                               drawpic(pos, "gfx/hud/statusbar", eX * 0.5 * mySize_x * min(1, x/200) + eY * mySize_y, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                               drawpic(pos, "gfx/hud/statuhud", eX * 0.5 * mySize_x * min(1, x/200) + eY * mySize_y, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
                                if (x > 45)
                                        drawpic(pos, "gfx/hud/sb_armor", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                                else
@@ -1411,7 +1414,7 @@ void HUD_HealthArmor(void)
 
                        // health
                        x = health;
-                       drawpic(pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, x/200), "gfx/hud/statusbar", eX * 0.5 * mySize_x * min(1, x/200) + eY * mySize_y, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                       drawpic(pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, x/200), "gfx/hud/statuhud", eX * 0.5 * mySize_x * min(1, x/200) + eY * mySize_y, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
                        drawpic(pos + eX * mySize_x - eX * mySize_y, "gfx/hud/sb_health", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                        HUD_DrawXNum_Colored(pos + eX * mySize_x - eX * 2.5 * mySize_y + eY * 0.25 * mySize_y, x, 3, 0.5 * mySize_y, hud_alpha_fg);
                }
@@ -1423,7 +1426,7 @@ void HUD_HealthArmor(void)
 
                        if (x > 0)
                        {
-                               drawpic(pos + eY * mySize_y - eY * mySize_y * min(1, x/200), "gfx/hud/statusbar", eX * 0.5 * mySize_x + eY * mySize_y * min(1, x/200), HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                               drawpic(pos + eY * mySize_y - eY * mySize_y * min(1, x/200), "gfx/hud/statuhud", eX * 0.5 * mySize_x + eY * mySize_y * min(1, x/200), HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
                                if (x > 45)
                                        drawpic(pos + eX * 0.4 * mySize_y, "gfx/hud/sb_armor", '0.7 0.7 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                                else
@@ -1435,7 +1438,7 @@ void HUD_HealthArmor(void)
                        x = health;
                        numbers = strlen(ftos(x));
 
-                       drawpic(pos + eX * 0.5 * mySize_x + eY * mySize_y - eY * mySize_y * min(1, x/200), "gfx/hud/statusbar", eX * 0.5 * mySize_x + eY * mySize_y * min(1, x/200), HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                       drawpic(pos + eX * 0.5 * mySize_x + eY * mySize_y - eY * mySize_y * min(1, x/200), "gfx/hud/statuhud", eX * 0.5 * mySize_x + eY * mySize_y * min(1, x/200), HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
                        drawpic(pos + eX * mySize_x - eX * 1.1 * mySize_y, "gfx/hud/sb_health", '0.7 0.7 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                        HUD_DrawXNum_Colored(pos + eX * mySize_x - eX * numbers * 0.5 * mySize_y + eY * 0.55 * mySize_y, x, numbers, 0.5 * mySize_y, hud_alpha_fg);
                }
@@ -1447,7 +1450,7 @@ void HUD_HealthArmor(void)
 
                        if (x > 0)
                        {
-                               drawpic(pos, "gfx/hud/statusbar", eX * mySize_x * min(1, x/200) + eY * 0.5 * mySize_y, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                               drawpic(pos, "gfx/hud/statuhud", eX * mySize_x * min(1, x/200) + eY * 0.5 * mySize_y, HUD_Panel_GetProgressBarColor("armor"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
                                if (x > 45)
                                        drawpic(pos, "gfx/hud/sb_armor", '0.5 0.5 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                                else
@@ -1459,7 +1462,7 @@ void HUD_HealthArmor(void)
                        x = health;
                        numbers = strlen(ftos(x));
 
-                       drawpic(pos + eY * 0.5 * mySize_y, "gfx/hud/statusbar", eX * mySize_x * min(1, x/200) + eY * 0.5 * mySize_y, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                       drawpic(pos + eY * 0.5 * mySize_y, "gfx/hud/statuhud", eX * mySize_x * min(1, x/200) + eY * 0.5 * mySize_y, HUD_Panel_GetProgressBarColor("health"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
                        drawpic(pos + eY * 0.5 * mySize_y, "gfx/hud/sb_health", '0.5 0.5 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                        HUD_DrawXNum_Colored(pos + eX * 0.5 * mySize_y + eY * 0.5 * mySize_y, x, numbers, 0.5 * mySize_y, hud_alpha_fg);
                }
@@ -1553,11 +1556,18 @@ void HUD_RaceTimer (void) {
        if(HUD_Panel_GetBgActive(8))
                draw_BorderPicture(pos - '1 1 0' * marigin, "gfx/hud/border", mySize + '1 1 0' * 2 * marigin, color, hud_alpha_bg, '1 1 0' * (marigin/MARIGIN_MULTIPLIER));
 
-       drawfont = sbar_bigfont;
+       drawfont = hud_bigfont;
        float a, t;
        string s, forcetime;
 
-       if(race_checkpointtime)
+       if(cvar("_hud_configure"))
+       {
+               s = "0:13:37";
+               drawstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, FALSE, '0.75 0.75 0' * mySize_y), s, '0.75 0.75 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
+               s = "^1Intermediate 1 (+15.42)";
+               drawcolorcodedstring(pos + eX * 0.5 * mySize_x - '0.5 0 0' * stringwidth(s, TRUE, '1 1 0' * 0.25 * mySize_y) + eY * 0.75 * mySize_y, s, '1 1 0' * 0.25 * mySize_y, hud_alpha_fg, DRAWFLAG_NORMAL);
+       }
+       else if(race_checkpointtime)
        {
                a = bound(0, 2 - (time - race_checkpointtime), 1);
                s = "";
@@ -1657,7 +1667,7 @@ void HUD_RaceTimer (void) {
                }
        }
 
-       drawfont = sbar_font;
+       drawfont = hud_font;
 }
 
 // Notification area (#4)
@@ -1678,17 +1688,17 @@ void HUD_Notify (void)
        entity tm;
        if(spectatee_status && !intermission)
        {
-               drawfont = sbar_bigfont;
+               drawfont = hud_bigfont;
                if(spectatee_status == -1)
                        s = "^1Observing";
                else
                        s = GetPlayerName(spectatee_status - 1);
                // spectated player name between HUD and chat area, aligned to the left
                pos_x = 0;
-               pos_y = - 50 - sbar_fontsize_spec_y;
-               s = textShortenToWidth(s, vid_conwidth/2.5, sbar_fontsize_spec, stringwidth_colors);
-               drawcolorcodedstring(pos, s, sbar_fontsize_spec, hud_alpha_fg, DRAWFLAG_NORMAL);
-               drawfont = sbar_font;
+               pos_y = - 50 - hud_fontsize_spec_y;
+               s = textShortenToWidth(s, vid_conwidth/2.5, hud_fontsize_spec, stringwidth_colors);
+               drawcolorcodedstring(pos, s, hud_fontsize_spec, hud_alpha_fg, DRAWFLAG_NORMAL);
+               drawfont = hud_font;
 
                // spectator text in the upper right corner
                if(spectatee_status == -1)
@@ -1824,6 +1834,14 @@ void HUD_VoteWindow(void)
        else
                vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
 
+       if(cvar("_hud_configure"))
+       {
+               vote_alpha = 1;
+               vote_yescount = 3;
+               vote_nocount = 2;
+               vote_needed = 4;
+       }
+
        if(HUD_Panel_GetBgActive(9))
                draw_BorderPicture(pos - '1 1 0' * marigin, "gfx/hud/border", mySize + '1 1 0' * 2 * marigin, color, hud_alpha_bg * vote_alpha, '1 1 0' * (marigin/MARIGIN_MULTIPLIER));
 
@@ -1835,6 +1853,8 @@ void HUD_VoteWindow(void)
                s = "A vote has been called for: ";
                drawstring(pos + '0.5 0 0' * mySize_x + '0 0.1 0' * mySize_y - eX * stringwidth(s, FALSE, '1 1 0' * 0.5 * mySize_y*(1/5)), s, '1 1 0' * mySize_y*(1/5), '1 1 1', a * hud_alpha_fg, DRAWFLAG_NORMAL);
                s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '10 0 0', stringwidth_colors);
+               if(cvar("_hud_configure"))
+                       s = "Configure the HUD";
                drawcolorcodedstring(pos + '0.52 0 0' * mySize_x + '0 0.3 0' * mySize_y - eX * stringwidth(s, FALSE, '1 1 0' * 0.5 * mySize_y*(1/6)), s, '1 1 0' * mySize_y*(1/6), a * hud_alpha_fg, DRAWFLAG_NORMAL);
 
                // print the yes/no counts
@@ -2289,7 +2309,7 @@ void CSQC_race_hud(void)
        if not((scores_flags[ps_primary] & SFL_TIME) && !teamplay) // race/cts record display on HUD
                return; // no records in the actual race
 
-       drawfont = sbar_bigfont;
+       drawfont = hud_bigfont;
        vector pos;
        pos_x = 2;
        pos_y = vid_conheight - 48;
@@ -2302,8 +2322,15 @@ void CSQC_race_hud(void)
                rr = RACE_RECORD;
        t = stof(db_get(ClientProgsDB, strcat(shortmapname, rr, "time")));
 
-       if(score && score < t || !t)
+       if(score && (score < t || !t)) {
                db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
+               if(cvar("cl_autodemo_delete_keeprecords"))
+               {
+                       f = cvar("cl_autodemo_delete");
+                       f &~= 1;
+                       cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
+               }
+       }
 
        if(t != crecordtime_prev) {
                crecordtime_prev = t;
@@ -2339,7 +2366,7 @@ void CSQC_race_hud(void)
                drawstring_expanding(pos, "Server best ", '10 10 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL, f);
                drawstring_expanding(pos + '0 10 0', TIME_ENCODED_TOSTRING(t),'14 14 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL, f);
        }
-       drawfont = sbar_font;
+       drawfont = hud_font;
 }
 
 // Timer (#5)
@@ -2434,7 +2461,7 @@ void HUD_Radar(void)
        if(HUD_Panel_GetBgActive(6))
                draw_BorderPicture(pos - '1 1 0' * marigin, "gfx/hud/border", mySize + '1 1 0' * 2 * marigin, color, hud_alpha_bg, '1 1 0' * (marigin/MARIGIN_MULTIPLIER));
 
-       local float color1, color2; // color already declared as a global in sbar.qc
+       local float color1, color2; // color already declared as a global in hud.qc
        local vector rgb;
        local entity tm;
        float scale2d, normalsize, bigsize;
@@ -2649,7 +2676,7 @@ void HUD_ShowSpeed(void)
        numsize_x = numsize_y = cvar("cl_showspeed_size");
        pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
 
-       drawfont = sbar_bigfont;
+       drawfont = hud_bigfont;
        drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
 
        if (cvar("cl_showspeed_z") == 1) {
@@ -2657,7 +2684,7 @@ void HUD_ShowSpeed(void)
                drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
        }
 
-       drawfont = sbar_font;
+       drawfont = hud_font;
 }
 
 vector acc_prevspeed;
@@ -2700,9 +2727,9 @@ void HUD_ShowAcceleration(void)
        }
 
        if (acceleration > 0)
-               drawpic(pos, "gfx/hud/statusbar", acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+               drawpic(pos, "gfx/hud/statuhud", acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_alpha_fg, DRAWFLAG_NORMAL);
        else if (acceleration < 0)
-               drawpic(pos + acceleration * scale * '40 0 0', "gfx/hud/statusbar", -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+               drawpic(pos + acceleration * scale * '40 0 0', "gfx/hud/statuhud", -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_alpha_fg, DRAWFLAG_NORMAL);
 }
 
 void HUD_Reset (void)
@@ -2721,8 +2748,8 @@ void HUD_Main (void)
        hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
        hud_color_bg_team = cvar("hud_color_bg_team");
 
-       sbar_fontsize = Sbar_GetFontsize("sbar_fontsize");
-       sbar_fontsize_spec = Sbar_GetFontsize("sbar_fontsize_spec");
+       hud_fontsize = HUD_GetFontsize("hud_fontsize");
+       hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
 
        if(HUD_Panel_CheckActive(0))
                HUD_WeaponIcons();
@@ -2736,6 +2763,7 @@ void HUD_Main (void)
                HUD_Notify();
        if(HUD_Panel_CheckActive(5))
                HUD_Timer();
+       // TODO hud'ify
        if(HUD_Panel_CheckActive(6))
                if(ons_showmap || cvar_string("cl_teamradar") != "0" && (cvar("cl_teamradar") == 2 || teamplay))
                        HUD_Radar();
@@ -2746,67 +2774,25 @@ void HUD_Main (void)
                        HUD_RaceTimer();
        if(HUD_Panel_CheckActive(9))
                HUD_VoteWindow();
+       // TODO hud'ify
        if(HUD_Panel_CheckActive(10))
                if(spectatee_status > 0 || cvar("cl_showpressedkeys") >= 2 || cvar("_hud_configure"))
                        HUD_DrawPressedKeys();
 
-       /* these are right now taken care of in View.qc
-       if(HUD_Panel_CheckActive(0))
+       // TODO hud_'ify these
+       if (cvar("cl_showspeed"))
                HUD_ShowSpeed();
-       if(HUD_Panel_CheckActive(0))
+       if (cvar("cl_showacceleration"))
                HUD_ShowAcceleration();
-               */
-
-       //Sbar_UpdatePlayerTeams();
-       // move this stuff to View.qc
-       if (intermission == 2) // map voting screen
-       {
-               if(sb_showaccuracy && spectatee_status != -1) {
-                       //HUD_DrawAccuracyStats();
-                       //HUD_Score();
-                       //HUD_Timer();
-               }
-               else if(sb_showscores) {
-                       //HUD_DrawScoreboard();
-                        //HUD_Score();
-                        //HUD_Timer();
-                }
-               else
-                       //HUD_FinaleOverlay();
-
-               HUD_Reset();
-       }
-       else if (sb_showscores_force || getstati(STAT_HEALTH) <= 0 || intermission == 1)
-       {
-               //if(sb_showaccuracy && spectatee_status != -1)
-                       //HUD_DrawAccuracyStats();
-               //else
-                       //HUD_DrawScoreboard();
-               //HUD_Score();
-               //HUD_Timer();
 
-               //HUD_Reset();
-       }
-       else
-       {
-               //if(sb_showaccuracy && spectatee_status != -1)
-                       //HUD_DrawAccuracyStats();
-               //else
-               //      HUD_DrawScoreboard();
-
-               // draw scores and timer
-               //HUD_Score();
-               //HUD_Timer();
-
-               // draw gametype specific icons
-               if(gametype == GAME_KEYHUNT)
-                       CSQC_kh_hud();
-               else if(gametype == GAME_CTF)
-                       CSQC_ctf_hud();
-               else if(gametype == GAME_NEXBALL)
-                       CSQC_nb_hud();
-               else if(gametype == GAME_CTS || gametype == GAME_RACE)
-                       CSQC_race_hud();
-       }
+       // TODO... well make them work in a panel etc
+       if(gametype == GAME_KEYHUNT)
+               CSQC_kh_hud();
+       else if(gametype == GAME_CTF)
+               CSQC_ctf_hud();
+       else if(gametype == GAME_NEXBALL)
+               CSQC_nb_hud();
+       else if(gametype == GAME_CTS || gametype == GAME_RACE)
+               CSQC_race_hud();
        return;
 }