]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge remote branch 'origin/master' into terencehill/infinite_ammo
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index a601ce17fecb61790d133c17d9a9d76f2811eef4..f8d8a3296e9713dcc99d34b83fc52928558aa557 100644 (file)
@@ -787,7 +787,7 @@ string GetAmmoPicture(float i)
        }
 }
 
-void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
+void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected, float infinite_ammo)
 {
        float a;
        if(autocvar__hud_configure)
@@ -799,7 +799,9 @@ void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_s
                a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
 
        vector color;
-       if(a < 10)
+       if(infinite_ammo)
+               color = '0 0.5 0.75';
+       else if(a < 10)
                color = '0.7 0 0';
        else
                color = '1 1 1';
@@ -830,12 +832,12 @@ void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_s
 
     if(autocvar_hud_panel_ammo_text)
     {
-        if(a > 0)
+        if(a > 0 || infinite_ammo)
             drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
         else // "ghost" ammo count
             drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
     }
-       if(a > 0)
+       if(a > 0 || infinite_ammo)
                drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
        else // "ghost" ammo icon
                drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * mySize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
@@ -897,20 +899,23 @@ void HUD_Ammo(void)
                ammo_size_y = newSize;
        }
 
-       float i, stat_items, currently_selected;
+       float i, stat_items, currently_selected, infinite_ammo;
+       infinite_ammo = FALSE;
        if (autocvar_hud_panel_ammo_onlycurrent)
        {
                if(autocvar__hud_configure)
                {
-                       DrawAmmoItem(pos, ammo_size, 2, true); //show rockets
+                       DrawAmmoItem(pos, ammo_size, 2, true, FALSE); //show rockets
                        return;
                }
                stat_items = getstati(STAT_ITEMS);
+               if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
+                       infinite_ammo = TRUE;
                for (i = 0; i < AMMO_COUNT; ++i) {
                        currently_selected = stat_items & GetAmmoItemCode(i);
                        if (currently_selected)
                        {
-                               DrawAmmoItem(pos, ammo_size, i, true);
+                               DrawAmmoItem(pos, ammo_size, i, true, infinite_ammo);
                                return;
                        }
                }
@@ -918,9 +923,11 @@ void HUD_Ammo(void)
        }
 
        stat_items = getstati(STAT_ITEMS);
+       if (stat_items & IT_UNLIMITED_WEAPON_AMMO)
+               infinite_ammo = TRUE;
        for (i = 0; i < AMMO_COUNT; ++i) {
                currently_selected = stat_items & GetAmmoItemCode(i);
-               DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected);
+               DrawAmmoItem(pos + eX * column * (ammo_size_x + offset_x) + eY * row * (ammo_size_y + offset_y), ammo_size, i, currently_selected, infinite_ammo);
                ++row;
                if(row >= rows)
                {
@@ -1839,7 +1846,7 @@ void HUD_Centerprint(string s1, string s2, float type, float msg)
        gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
        if(msg == MSG_SUICIDE) {
                if (type == DEATH_TEAMCHANGE) {
-                       centerprint(strcat(sprintf(_("You are now on: %s"), s1)));
+                       centerprint(sprintf(_("You are now on: %s"), s1));
                } else if (type == DEATH_AUTOTEAMCHANGE) {
                        centerprint(sprintf(_("You have been moved into a different team to improve team balance\nYou are now on: %s"), s1));
                } else if (type == DEATH_CAMP) {
@@ -1873,9 +1880,9 @@ void HUD_Centerprint(string s1, string s2, float type, float msg)
        } else if(msg == MSG_KILL) {
                if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
                        if(gentle) {
-                               centerprint(strcat(sprintf(_("^1Moron! You went against ^7%s^1, a team mate!"), s1)));
+                               centerprint(sprintf(_("^1Moron! You went against ^7%s^1, a team mate!"), s1));
                        } else {
-                               centerprint(strcat(sprintf(_("^1Moron! You fragged ^7%s^1, a team mate!"), s1)));
+                               centerprint(sprintf(_("^1Moron! You fragged ^7%s^1, a team mate!"), s1));
                        }
                } else if (type == KILL_FIRST_BLOOD) {
                        if(gentle) {
@@ -2948,7 +2955,7 @@ void HUD_VoteWindow(void)
        pos = panel_pos;
        mySize = panel_size;
 
-       a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
+       a = vote_alpha * (vote_highlighted ? autocvar_hud_panel_vote_alreadyvoted_alpha : 1);
        HUD_Panel_DrawBg(a);
        a = panel_fg_alpha * a;
 
@@ -2999,7 +3006,7 @@ void HUD_VoteWindow(void)
                drawsetcliparea(pos_x, pos_y, mySize_x * 0.5, mySize_y);
                drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
-       else if(vote_highlighted == 2) {
+       else if(vote_highlighted == -1) {
                drawsetcliparea(pos_x + 0.5 * mySize_x, pos_y, mySize_x * 0.5, mySize_y);
                drawpic_skin(pos + eY * (5/8) * mySize_y, "voteprogress_voted", eX * mySize_x + eY * (3/8) * mySize_y, '1 1 1', a, DRAWFLAG_NORMAL);
        }
@@ -3018,10 +3025,6 @@ void HUD_VoteWindow(void)
        }
 
        drawresetcliparea();
-
-       if(!vote_active) {
-               vote_highlighted = 0;
-       }
 }
 
 // Mod icons panel (#10)
@@ -4130,7 +4133,8 @@ void HUD_Physics(void)
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_physics) return;
-               if(spectatee_status == -1 && autocvar_hud_panel_physics < 2) return;
+               if(spectatee_status == -1 && (autocvar_hud_panel_physics == 1 || autocvar_hud_panel_physics == 3)) return;
+               if(autocvar_hud_panel_physics == 3 && !(gametype == GAME_RACE || gametype == GAME_CTS)) return;
        }
        else
                hud_configure_active_panel = HUD_PANEL_PHYSICS;
@@ -4347,8 +4351,11 @@ void HUD_Physics(void)
                drawstring_aspect(panel_pos + acceleration_offset, strcat(ftos_decimals(acceleration, 2), "g"), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 }
 
+// CenterPrint (#16)
+//
 #define CENTERPRINT_MAX_MSGS 10
 #define CENTERPRINT_MAX_ENTRIES 50
+#define CENTERPRINT_SPACING 0.7
 float cpm_index;
 string centerprint_messages[CENTERPRINT_MAX_MSGS];
 float centerprint_msgID[CENTERPRINT_MAX_MSGS];
@@ -4437,9 +4444,6 @@ void centerprint(string strMessage)
        centerprint_generic(0, strMessage, autocvar_hud_panel_centerprint_time, 0);
 }
 
-// CenterPrint (#16)
-//
-float hud_configure_cp_generation_time;
 void reset_centerprint_messages(void)
 {
        float i;
@@ -4450,16 +4454,17 @@ void reset_centerprint_messages(void)
                centerprint_msgID[i] = 0;
                if(centerprint_messages[i])
                        strunzone(centerprint_messages[i]);
-               centerprint_messages[i] = strzone("");
+               centerprint_messages[i] = string_null;
        }
 }
+float hud_configure_cp_generation_time;
 void HUD_CenterPrint (void)
 {
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_centerprint) return;
 
-               if (hud_configure_prev)
+               if (hud_configure_prev && hud_configure_prev != -1)
                        reset_centerprint_messages();
        }
        else
@@ -4515,12 +4520,12 @@ void HUD_CenterPrint (void)
        // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
        // height = panel_size_y/entries;
        // fontsize = '1 1 0' * height;
-       height = vid_conheight/40 * autocvar_hud_panel_centerprint_fontscale;
+       height = vid_conheight/50 * autocvar_hud_panel_centerprint_fontscale;
        fontsize = '1 1 0' * height;
        entries = bound(1, floor(panel_size_y/height), CENTERPRINT_MAX_ENTRIES);
 
        float i, j, k, n;
-       float a, sz, align, current_msg_pos_y;
+       float a, sz, align, current_msg_pos_y, msg_size;
        vector pos;
        string ts;
 
@@ -4534,9 +4539,9 @@ void HUD_CenterPrint (void)
        {
                if (j == CENTERPRINT_MAX_MSGS)
                        j = 0;
-               if (centerprint_time[j] > 0 && centerprint_expire_time[j] < time)
+               if (centerprint_expire_time[j] < time)
                {
-                       if (centerprint_countdown_num[j])
+                       if (centerprint_countdown_num[j] && centerprint_time[j] > 0)
                        {
                                centerprint_countdown_num[j] = centerprint_countdown_num[j] - 1;
                                if (centerprint_countdown_num[j] == 0)
@@ -4548,8 +4553,8 @@ void HUD_CenterPrint (void)
                }
                if (centerprint_time[j] < 0 || centerprint_expire_time[j] - centerprint_fadetime > time)
                {
-                       a = 1;
-                       sz = 1;
+                       a = bound(0, (time - (centerprint_expire_time[j] - centerprint_time[j])) / centerprint_fadetime, 1);
+                       sz = 0.8 + a * (1 - 0.8);
                }
                else if (centerprint_expire_time[j] > time)
                {
@@ -4574,7 +4579,7 @@ void HUD_CenterPrint (void)
                                        if (ts != "")
                                                pos_y -= fontsize_y;
                                        else
-                                               pos_y -= fontsize_y * 0.35;
+                                               pos_y -= fontsize_y * CENTERPRINT_SPACING/2;
                                        if (pos_y < panel_pos_y) // check if the next line can be shown
                                        {
                                                drawfontscale = '1 1 0';
@@ -4585,6 +4590,7 @@ void HUD_CenterPrint (void)
                        current_msg_pos_y = pos_y; // save starting pos (first line) of the current message
                }
 
+               msg_size = pos_y;
                for(k = 0; k < n; ++k)
                {
                        getWrappedLine_remaining = argv(k);
@@ -4595,11 +4601,11 @@ void HUD_CenterPrint (void)
                                {
                                        if (align)
                                                pos_x = panel_pos_x + (panel_size_x - stringwidth(ts, TRUE, fontsize)) * align;
-                                       drawcolorcodedstring(pos + '0 1 0' * 1.5 * (1 - sz) * fontsize_y, ts, fontsize, a * panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize_y, ts, fontsize, a * panel_fg_alpha, DRAWFLAG_NORMAL);
                                        pos_y += fontsize_y;
                                }
                                else
-                                       pos_y += fontsize_y * 0.35;
+                                       pos_y += fontsize_y * CENTERPRINT_SPACING/2;
                                if (!autocvar_hud_panel_centerprint_flip && pos_y > panel_pos_y + panel_size_y - fontsize_y) // check if the next line can be shown
                                {
                                        drawfontscale = '1 1 0';
@@ -4607,17 +4613,18 @@ void HUD_CenterPrint (void)
                                }
                        }
                }
+               msg_size = pos_y - msg_size;
                if (autocvar_hud_panel_centerprint_flip)
                {
-                       pos_y = current_msg_pos_y - 0.7 * fontsize_y;
+                       pos_y = current_msg_pos_y - CENTERPRINT_SPACING * fontsize_y;
                        if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
-                               pos_y += 1.5 * fontsize_y * (1 - a*a);
+                               pos_y += (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(a));
                }
                else
                {
-                       pos_y += 0.7 * fontsize_y;
+                       pos_y += CENTERPRINT_SPACING * fontsize_y;
                        if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
-                               pos_y -= 1.5 * fontsize_y * (1 - a*a);
+                               pos_y -= (msg_size + CENTERPRINT_SPACING * fontsize_y) * (1 - sqrt(a));
                }
        }
        drawfontscale = '1 1 0';