]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge remote branch 'origin/fruitiex/newpanelhud'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index db423eb8718a10686b9962c78c0ce285d004438f..357f8a0e3502a726436461bc9163bf0b861e459f 100644 (file)
@@ -284,10 +284,9 @@ void HUD_DrawCenterPrint (void)
 
        sz = 0.8 + (a / 5);
 
-       if(centerprint_num * cvar("scr_centersize") > 24 && HUD_WouldDrawScoreboard()) // 24 = height of Scoreboard text
-       {
+       if(centerprint_num * cvar("scr_centersize") > 24 && scoreboard_active) // 24 = height of Scoreboard text
                centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
-       }
+
        pos = centerprint_start;
        for (i=0; i<centerprint_num; i = i + 1)
        {
@@ -902,8 +901,6 @@ float prevMouseClicked; // previous state
 float prevMouseClickedTime; // time during previous mouse click, to check for doubleclicks
 vector prevMouseClickedPos; // pos during previous mouse click, to check for doubleclicks
 
-float menu_enabled;
-float menu_enabled_time;
 float pressed_key_time;
 void HUD_Panel_Arrow_Action(float nPrimary)
 {
@@ -1059,7 +1056,6 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
        {
                if (bInputType == 1)
                        return true;
-               disable_menu_alphacheck = 1;
                menu_enabled = 1;
                menu_enabled_time = time;
                localcmd("menu_showhudexit\n");
@@ -1322,18 +1318,22 @@ vector prev_pos, prev_size;
 void HUD_Panel_Mouse()
 {
        // TODO: needs better check... is there any float that contains the current state of the menu? _menu_alpha isn't apparently updated the frame the menu gets enabled
-       if (menu_enabled == 0) // menu dialog closed, enable normal alpha stuff again
-               disable_menu_alphacheck = 0;
        if (autocvar__menu_alpha == 0 && time - menu_enabled_time > 0.5)
                menu_enabled = 0;
 
        /*
-       print("Disable menu_alphacheck: ", ftos(disable_menu_alphacheck), "\n");
+       print("menu_enabled: ", ftos(menu_enabled), "\n");
        print("Highlighted: ", ftos(highlightedPanel), "\n");
        print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
        */
 
-       if(mouseClicked == 0 && disable_menu_alphacheck != 2 && highlightedPanel >= 0) { // don't reset these variables in disable_menu_alphacheck mode 2!
+       // instantly hide the editor cursor if we open the HUDExit dialog
+       // as hud_fade_alpha doesn't decrease to 0 in this case
+       // TODO: find a way to fade the cursor out even in this case
+       if(menu_enabled == 1 || (menu_enabled == 2 && !hud_fade_alpha))
+               return;
+
+       if(mouseClicked == 0 && menu_enabled != 2 && highlightedPanel >= 0) { // don't reset these variables in menu_enabled mode 2!
                highlightedPanel = -1;
                highlightedAction = 0;
        }
@@ -1396,8 +1396,7 @@ void HUD_Panel_Mouse()
                if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
                {
                        mouseClicked = 0; // to prevent spam, I guess.
-                       disable_menu_alphacheck = 2;
-                       menu_enabled = 1;
+                       menu_enabled = 2;
                        menu_enabled_time = time;
                        HUD_Panel_GetName(highlightedPanel)
                        localcmd("menu_showhudoptions ", panel_name, "\n");
@@ -1419,13 +1418,13 @@ void HUD_Panel_Mouse()
        cursorsize = '32 32 0';
 
        if(highlightcheck == 0)
-               drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
+               drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
        else if(highlightcheck == 1)
-               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
+               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_move.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
        else if(highlightcheck == 2)
-               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
+               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
        else
-               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', 1, DRAWFLAG_NORMAL);
+               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), '32 32 0', '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
 
        prevMouseClicked = mouseClicked;
 }
@@ -1478,6 +1477,7 @@ float GetAmmoTypeForWep(float i)
                case WEP_UZI: return 1;
                case WEP_CAMPINGRIFLE: return 1;
                case WEP_GRENADE_LAUNCHER: return 2;
+               case WEP_MINE_LAYER: return 2;
                case WEP_ELECTRO: return 3;
                case WEP_CRYLINK: return 3;
                case WEP_HLAC: return 3;
@@ -1614,305 +1614,309 @@ void HUD_Weapons(void)
                heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
        }
 
-               HUD_Panel_DrawBg(1);
-               if(panel_bg_padding)
-               {
-                       panel_pos += '1 1 0' * panel_bg_padding;
-                       panel_size -= '2 2 0' * panel_bg_padding;
-               }
+       HUD_Panel_DrawBg(1);
+       if(panel_bg_padding)
+       {
+               panel_pos += '1 1 0' * panel_bg_padding;
+               panel_size -= '2 2 0' * panel_bg_padding;
+       }
 
-               // hits
-               weapon_stats = getstati(STAT_DAMAGE_HITS);
-               weapon_number = weapon_stats & 63;
-               weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
-               // fired
-               weapon_stats = getstati(STAT_DAMAGE_FIRED);
-               weapon_number = weapon_stats & 63;
-               weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
+       // hits
+       weapon_stats = getstati(STAT_DAMAGE_HITS);
+       weapon_number = weapon_stats & 63;
+       weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
+       // fired
+       weapon_stats = getstati(STAT_DAMAGE_FIRED);
+       weapon_number = weapon_stats & 63;
+       weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
 
-               if(cvar_or("hud_panel_weapons_fade", 1))
-               {
-                       fade = 3.2 - 2 * (time - weapontime);
-                       fade = bound(0.7, fade, 1);
-               }
-               else
-                       fade = 1;
+       if(cvar_or("hud_panel_weapons_fade", 1))
+       {
+               fade = 3.2 - 2 * (time - weapontime);
+               fade = bound(0.7, fade, 1);
+       }
+       else
+               fade = 1;
 
-               HUD_Weapons_Clear();
+       HUD_Weapons_Clear();
 
-               float rows, columns;
-               rows = panel_size_y/panel_size_x;
-               rows = bound(1, floor((sqrt(4 * autocvar_hud_panel_weapons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
+       float rows, columns;
+       rows = panel_size_y/panel_size_x;
+       rows = bound(1, floor((sqrt(4 * autocvar_hud_panel_weapons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
 
-               columns = ceil(WEP_COUNT/rows);
-               float row, column;
+       columns = ceil(WEP_COUNT/rows);
+       float row, column;
 
-               float a, type, fullammo;
-               float when;
-               when = autocvar_hud_panel_weapons_complainbubble_time;
-               float fadetime;
-               fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
+       float a, type, fullammo;
+       float when;
+       when = autocvar_hud_panel_weapons_complainbubble_time;
+       float fadetime;
+       fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
 
-               vector color;
-               vector wpnpos;
-               vector wpnsize;
+       vector color;
+       vector wpnpos;
+       vector wpnsize;
 
-               for(i = 0; i < weapon_cnt; ++i)
-               {
-                       wpnpos = panel_pos + eX * column * panel_size_x*(1/columns) + eY * row * panel_size_y*(1/rows);
-                       wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
+       float show_accuracy;
+       if(autocvar_hud_panel_weapons_accuracy && acc_levels)
+               show_accuracy = true;
 
-                       self = weaponorder[i];
-                       weapid = self.impulse;
+       for(i = 0; i < weapon_cnt; ++i)
+       {
+               wpnpos = panel_pos + eX * column * panel_size_x*(1/columns) + eY * row * panel_size_y*(1/rows);
+               wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
+
+               self = weaponorder[i];
+               weapid = self.impulse;
 
-                       // draw background behind currently selected weapon
-                       if(self.weapon == activeweapon)
-                               drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
+               // draw background behind currently selected weapon
+               if(self.weapon == activeweapon)
+                       drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
 
-                       // draw the weapon accuracy
-                       if(acc_levels)
+               // draw the weapon accuracy
+               if(show_accuracy)
+               {
+                       float weapon_hit, weapon_damage;
+                       weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
+                       if(weapon_damage)
                        {
-                               float weapon_hit, weapon_damage;
-                               weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
-                               if(weapon_damage)
-                               {
-                                       weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
-                                       weapon_stats = floor(100 * weapon_hit / weapon_damage);
-                               }
+                               weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
+                               weapon_stats = floor(100 * weapon_hit / weapon_damage);
+                       }
 
-                               // find the max level lower than weapon_stats
-                               float j;
-                               j = acc_levels-1;
-                               while ( j && weapon_stats < acc_lev[j] )
-                                       --j;
+                       // find the max level lower than weapon_stats
+                       float j;
+                       j = acc_levels-1;
+                       while ( j && weapon_stats < acc_lev[j] )
+                               --j;
 
-                               // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
-                               float factor;
-                               factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
-                               color = acc_color(j);
-                               color = color + factor * (acc_color(j+1) - color);
+                       // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
+                       float factor;
+                       factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
+                       color = acc_color(j);
+                       color = color + factor * (acc_color(j+1) - color);
 
-                               if(weapon_damage)
-                                       drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
-                       }
+                       if(weapon_damage)
+                               drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+               }
 
-                       // draw the weapon icon
-                       if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
-                       {
-                               drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
+               // draw the weapon icon
+               if((self.impulse >= 0) && (getstati(STAT_WEAPONS) & self.weapons))
+               {
+                       drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL);
+
+                       if(autocvar_hud_panel_weapons_label == 1) // weapon number
+                               drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       else if(autocvar_hud_panel_weapons_label == 2) // bind
+                               drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 
-                               if(autocvar_hud_panel_weapons_label == 1) // weapon number
-                                       drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                               else if(autocvar_hud_panel_weapons_label == 2) // bind
-                                       drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       // draw ammo status bar
+                       if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
+                       {
+                               a = 0;
+                               type = GetAmmoTypeForWep(weapid);
+                               if(type != -1)
+                                       a = getstati(GetAmmoStat(type)); // how much ammo do we have?
 
-                               // draw ammo status bar
-                               if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
+                               if(a > 0)
                                {
-                                       a = 0;
-                                       type = GetAmmoTypeForWep(weapid);
-                                       if(type != -1)
-                                               a = getstati(GetAmmoStat(type)); // how much ammo do we have?
+                                       switch(type) {
+                                               case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
+                                               case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
+                                               case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
+                                               case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
+                                               case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
+                                               default: fullammo = 60;
+                                       }
 
-                                       if(a > 0)
+                                       vector barsize;
+                                       vector barpos;
+                                       if(wpnsize_x/wpnsize_y > autocvar_hud_panel_weapons_aspect)
+                                       {
+                                               barsize_x = autocvar_hud_panel_weapons_aspect * wpnsize_y;
+                                               barsize_y = wpnsize_y;
+
+                                               barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
+                                               barpos_y = wpnpos_y;
+                                       }
+                                       else
                                        {
-                                               switch(type) {
-                                                       case 0: fullammo = autocvar_hud_panel_weapons_ammo_full_shells; break;
-                                                       case 1: fullammo = autocvar_hud_panel_weapons_ammo_full_nails; break;
-                                                       case 2: fullammo = autocvar_hud_panel_weapons_ammo_full_rockets; break;
-                                                       case 3: fullammo = autocvar_hud_panel_weapons_ammo_full_cells; break;
-                                                       case 4: fullammo = autocvar_hud_panel_weapons_ammo_full_fuel; break;
-                                                       default: fullammo = 60;
-                                               }
-
-                                               vector barsize;
-                                               vector barpos;
-                                               if(wpnsize_x/wpnsize_y > autocvar_hud_panel_weapons_aspect)
-                                               {
-                                                       barsize_x = autocvar_hud_panel_weapons_aspect * wpnsize_y;
-                                                       barsize_y = wpnsize_y;
-
-                                                       barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
-                                                       barpos_y = wpnpos_y;
-                                               }
-                                               else
-                                               {
-                                                       barsize_y = 1/autocvar_hud_panel_weapons_aspect * wpnsize_x;
-                                                       barsize_x = wpnsize_x;
-
-                                                       barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
-                                                       barpos_x = wpnpos_x;
-                                               }
-
-                                               drawsetcliparea(
-                                                       barpos_x,
-                                                       barpos_y,
-                                                       barsize_x * bound(0, a/fullammo, 1),
-                                                       barsize_y);
-                                               drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_panel_weapons_ammo_color, panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha, DRAWFLAG_NORMAL);
-                                               drawresetcliparea();
+                                               barsize_y = 1/autocvar_hud_panel_weapons_aspect * wpnsize_x;
+                                               barsize_x = wpnsize_x;
+
+                                               barpos_y = wpnpos_y + (wpnsize_y - barsize_y) / 2;
+                                               barpos_x = wpnpos_x;
                                        }
+
+                                       drawsetcliparea(
+                                               barpos_x,
+                                               barpos_y,
+                                               barsize_x * bound(0, a/fullammo, 1),
+                                               barsize_y);
+                                       drawpic_aspect_skin(wpnpos, "weapon_ammo", wpnsize, autocvar_hud_panel_weapons_ammo_color, panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha, DRAWFLAG_NORMAL);
+                                       drawresetcliparea();
                                }
                        }
+               }
 
-                       // draw a "ghost weapon icon" if you don't have the weapon
-                       else
+               // draw a "ghost weapon icon" if you don't have the weapon
+               else
+               {
+                       drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
+               }
+
+               // draw the complain message
+               if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
+               {
+                       if(fadetime)
                        {
-                               drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '0 0 0', panel_fg_alpha * 0.5, DRAWFLAG_NORMAL);
+                               if(complain_weapon_time + when > time)
+                                       a = 1;
+                               else
+                                       a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
                        }
-
-                       // draw the complain message
-                       if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
+                       else
                        {
-                               if(fadetime)
-                               {
-                                       if(complain_weapon_time + when > time)
-                                               a = 1;
-                                       else
-                                               a = bound(0, (complain_weapon_time + when + fadetime - time) / fadetime, 1);
-                               }
+                               if(complain_weapon_time + when > time)
+                                       a = 1;
                                else
-                               {
-                                       if(complain_weapon_time + when > time)
-                                               a = 1;
-                                       else
-                                               a = 0;
-                               }
-
-                               string s;
-                               if(complain_weapon_type == 0) {
-                                       s = "Out of ammo";
-                                       color = autocvar_hud_panel_weapons_complainbubble_color_outofammo;
-                               }
-                               else if(complain_weapon_type == 1) {
-                                       s = "Don't have";
-                                       color = autocvar_hud_panel_weapons_complainbubble_color_donthave;
-                               }
-                               else {
-                                       s = "Unavailable";
-                                       color = autocvar_hud_panel_weapons_complainbubble_color_unavailable;
-                               }
-                               drawpic_aspect_skin(wpnpos + '1 1 0' * autocvar_hud_panel_weapons_complainbubble_padding, "weapon_complainbubble", wpnsize - '2 2 0' * autocvar_hud_panel_weapons_complainbubble_padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
-                               drawstring_aspect(wpnpos + '1 1 0' * autocvar_hud_panel_weapons_complainbubble_padding, s, wpnsize - '2 2 0' * autocvar_hud_panel_weapons_complainbubble_padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                                       a = 0;
                        }
 
-                       ++row;
-                       if(row >= rows)
-                       {
-                               row = 0;
-                               ++column;
+                       string s;
+                       if(complain_weapon_type == 0) {
+                               s = "Out of ammo";
+                               color = autocvar_hud_panel_weapons_complainbubble_color_outofammo;
                        }
+                       else if(complain_weapon_type == 1) {
+                               s = "Don't have";
+                               color = autocvar_hud_panel_weapons_complainbubble_color_donthave;
+                       }
+                       else {
+                               s = "Unavailable";
+                               color = autocvar_hud_panel_weapons_complainbubble_color_unavailable;
+                       }
+                       drawpic_aspect_skin(wpnpos + '1 1 0' * autocvar_hud_panel_weapons_complainbubble_padding, "weapon_complainbubble", wpnsize - '2 2 0' * autocvar_hud_panel_weapons_complainbubble_padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(wpnpos + '1 1 0' * autocvar_hud_panel_weapons_complainbubble_padding, s, wpnsize - '2 2 0' * autocvar_hud_panel_weapons_complainbubble_padding, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
                }
 
-       }
-
-       // Ammo (#1)
-       //
-       // TODO: macro
-       float GetAmmoItemCode(float i)
-       {
-               switch(i)
+               ++row;
+               if(row >= rows)
                {
-                       case 0: return IT_SHELLS;
-                       case 1: return IT_NAILS;
-                       case 2: return IT_ROCKETS;
-                       case 3: return IT_CELLS;
-                       case 4: return IT_FUEL;
-                       default: return -1;
+                       row = 0;
+                       ++column;
                }
        }
 
-       string GetAmmoPicture(float i)
+}
+
+// Ammo (#1)
+//
+// TODO: macro
+float GetAmmoItemCode(float i)
+{
+       switch(i)
        {
-               switch(i)
-               {
-                       case 0: return "ammo_shells";
-                       case 1: return "ammo_bullets";
-                       case 2: return "ammo_rockets";
-                       case 3: return "ammo_cells";
-                       case 4: return "ammo_fuel";
-                       default: return "";
-               }
+               case 0: return IT_SHELLS;
+               case 1: return IT_NAILS;
+               case 2: return IT_ROCKETS;
+               case 3: return IT_CELLS;
+               case 4: return IT_FUEL;
+               default: return -1;
        }
+}
 
-       void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
+string GetAmmoPicture(float i)
+{
+       switch(i)
        {
-               float a;
-               a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
-               if(autocvar__hud_configure)
-                       a = 100;
-
-               vector color;
-               if(a < 10)
-                       color = '0.7 0 0';
-               else
-                       color = '1 1 1';
-
-               float alpha;
-               if(currently_selected)
-                       alpha = 1;
-               else
-                       alpha = 0.7;
+               case 0: return "ammo_shells";
+               case 1: return "ammo_bullets";
+               case 2: return "ammo_rockets";
+               case 3: return "ammo_cells";
+               case 4: return "ammo_fuel";
+               default: return "";
+       }
+}
 
-               vector newSize, newPos;
-               if(mySize_x/mySize_y > 3)
-               {
-                       newSize_x = 3 * mySize_y;
-                       newSize_y = mySize_y;
+void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_selected)
+{
+       float a;
+       a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
+       if(autocvar__hud_configure)
+               a = 100;
 
-                       newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
-                       newPos_y = myPos_y;
-               }
-               else
-               {
-                       newSize_y = 1/3 * mySize_x;
-                       newSize_x = mySize_x;
+       vector color;
+       if(a < 10)
+               color = '0.7 0 0';
+       else
+               color = '1 1 1';
 
-                       newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
-                       newPos_x = myPos_x;
-               }
+       float alpha;
+       if(currently_selected)
+               alpha = 1;
+       else
+               alpha = 0.7;
 
-               vector picpos, numpos;
-               if(autocvar_hud_panel_ammo_iconalign)
-               {
-                       numpos = newPos;
-                       picpos = newPos + eX * 2 * newSize_y;
-               }
-               else
-               {
-                       numpos = newPos + eX * newSize_y;
-                       picpos = newPos;
-               }
+       vector newSize, newPos;
+       if(mySize_x/mySize_y > 3)
+       {
+               newSize_x = 3 * mySize_y;
+               newSize_y = mySize_y;
 
-               if (currently_selected)
-                       drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               newPos_x = myPos_x + (mySize_x - newSize_x) / 2;
+               newPos_y = myPos_y;
+       }
+       else
+       {
+               newSize_y = 1/3 * mySize_x;
+               newSize_x = mySize_x;
 
-               drawfont = hud_bigfont;
-               if(a > 0)
-                       drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
-               else // "ghost" ammo count
-                       drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
-               drawfont = hud_font;
-               if(a > 0)
-                       drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
-               else // "ghost" ammo icon
-                       drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
+               newPos_y = myPos_y + (mySize_y - newSize_y) / 2;
+               newPos_x = myPos_x;
        }
 
-       void HUD_Ammo(void)
+       vector picpos, numpos;
+       if(autocvar_hud_panel_ammo_iconalign)
        {
-               if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
-                       return;
+               numpos = newPos;
+               picpos = newPos + eX * 2 * newSize_y;
+       }
+       else
+       {
+               numpos = newPos + eX * newSize_y;
+               picpos = newPos;
+       }
 
-               active_panel = HUD_PANEL_AMMO;
-               HUD_Panel_UpdateCvars(ammo);
-               float i, currently_selected;
+       if (currently_selected)
+               drawpic_aspect_skin(newPos, "ammo_current_bg", newSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 
-               vector pos, mySize;
-               pos = panel_pos;
-               mySize = panel_size;
+       drawfont = hud_bigfont;
+       if(a > 0)
+               drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
+       else // "ghost" ammo count
+               drawstring_aspect(numpos, ftos(a), eX * (2/3) * newSize_x + eY * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
+       drawfont = hud_font;
+       if(a > 0)
+               drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
+       else // "ghost" ammo icon
+               drawpic_aspect_skin(picpos, GetAmmoPicture(itemcode), '1 1 0' * newSize_y, '0 0 0', panel_fg_alpha * alpha * 0.5, DRAWFLAG_NORMAL);
+}
+
+void HUD_Ammo(void)
+{
+       if(!autocvar_hud_panel_ammo && !autocvar__hud_configure)
+               return;
+
+       active_panel = HUD_PANEL_AMMO;
+       HUD_Panel_UpdateCvars(ammo);
+       float i, currently_selected;
+
+       vector pos, mySize;
+       pos = panel_pos;
+       mySize = panel_size;
 
-               HUD_Panel_DrawBg(1);
+       HUD_Panel_DrawBg(1);
        if(panel_bg_padding)
        {
                pos += '1 1 0' * panel_bg_padding;
@@ -2255,12 +2259,10 @@ void HUD_HealthArmor(void)
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
-       float armor, health;
+       float armor, health, fuel;
        armor = getstati(STAT_ARMOR);
        health = getstati(STAT_HEALTH);
-
-       float fuel;
-       fuel = getstati(GetAmmoStat(4)); // how much fuel do we have?
+       fuel = getstati(STAT_FUEL);
 
        if(autocvar__hud_configure)
        {
@@ -2754,7 +2756,11 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                } else if (type == DEATH_CUSTOM) {
                        HUD_KillNotify_Push(s1, s2, 1, DEATH_CUSTOM);
                        if(alsoprint)
-                               print ("^1",s2, "^1 ", s1, "\n");
+                               print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
+               } else if (type == DEATH_HURTTRIGGER) {
+                       HUD_KillNotify_Push(s1, s2, 1, DEATH_HURTTRIGGER);
+                       if(alsoprint)
+                               print("^1", sprintf(s3, strcat(s2, "^1"), strcat(s1, "^1")), "\n");
                } else {
                        HUD_KillNotify_Push(s1, s2, 1, DEATH_GENERIC);
                        if(alsoprint)
@@ -2859,11 +2865,11 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                } else if (type == DEATH_CUSTOM) {
                        HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
                        if(alsoprint)
-                               print ("^1",s1, "^1 ", s2, "\n");
+                               print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
                } else if (type == DEATH_HURTTRIGGER) {
                        HUD_KillNotify_Push(s1, "", 0, DEATH_HURTTRIGGER);
                        if(alsoprint)
-                               print ("^1",s1, "^1 was in the wrong place\n");
+                               print("^1", sprintf(s2, strcat(s1, "^1")), "\n");
                } else if(type == DEATH_TOUCHEXPLODE) {
                        HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
                        if(alsoprint)
@@ -4237,16 +4243,31 @@ void HUD_Mod_Race(vector pos, vector mySize)
                crecordtime_prev = t;
                crecordtime_change_time = time;
        }
+
+       vector textPos, medalPos;
+       float squareSize;
+       if(mySize_x > mySize_y) {
+               // text on left side
+               squareSize = min(mySize_y, mySize_x/2);
+               textPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eY * 0.5 * (mySize_y - squareSize);
+               medalPos = pos + eX * 0.5 * max(0, mySize_x/2 - squareSize) + eX * 0.5 * mySize_x + eY * 0.5 * (mySize_y - squareSize);
+       } else {
+               // text on top
+               squareSize = min(mySize_x, mySize_y/2);
+               textPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eX * 0.5 * (mySize_x - squareSize);;
+               medalPos = pos + eY * 0.5 * max(0, mySize_y/2 - squareSize) + eY * 0.5 * mySize_y + eX * 0.5 * (mySize_x - squareSize);
+       }
+
        f = time - crecordtime_change_time;
 
        if (f > 1) {
-               drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
        } else {
-               drawstring_aspect(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect_expanding(pos, "Personal best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
-               drawstring_aspect_expanding(pos + eY * 0.25 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
+               drawstring_aspect(textPos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(textPos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect_expanding(pos, "Personal best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
+               drawstring_aspect_expanding(pos + eY * 0.25 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
        }
 
        // server record
@@ -4258,13 +4279,13 @@ void HUD_Mod_Race(vector pos, vector mySize)
        f = time - srecordtime_change_time;
 
        if (f > 1) {
-               drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
        } else {
-               drawstring_aspect(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-               drawstring_aspect_expanding(pos + eY * 0.5 * mySize_y, "Server best", eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
-               drawstring_aspect_expanding(pos + eY * 0.75 * mySize_y, TIME_ENCODED_TOSTRING(t), eX * 0.5 * mySize_x + eY * 0.25 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
+               drawstring_aspect(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect_expanding(textPos + eY * 0.5 * squareSize, "Server best", eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
+               drawstring_aspect_expanding(textPos + eY * 0.75 * squareSize, TIME_ENCODED_TOSTRING(t), eX * squareSize + eY * 0.25 * squareSize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, f);
        }
 
        if (race_status != race_status_prev || race_status_name != race_status_name_prev) {
@@ -4275,13 +4296,12 @@ void HUD_Mod_Race(vector pos, vector mySize)
                race_status_name_prev = strzone(race_status_name);
        }
 
-       pos_x += mySize_x/2;
        // race "awards"
        float a;
        a = bound(0, race_status_time - time, 1);
 
        string s;
-       s = textShortenToWidth(race_status_name, mySize_y, '1 1 0' * 0.1 * mySize_y, stringwidth_colors);
+       s = textShortenToWidth(race_status_name, squareSize, '1 1 0' * 0.1 * squareSize, stringwidth_colors);
 
        float rank;
        if(race_status > 0)
@@ -4290,27 +4310,27 @@ void HUD_Mod_Race(vector pos, vector mySize)
        rankname = race_PlaceName(rank);
 
        vector namepos;
-       namepos = pos + '0.5 0.9 0' * mySize_y - eX * stringwidth(s, TRUE, '1 1 0' * 0.1 * mySize_y);
+       namepos = medalPos + '0 0.8 0' * squareSize;
        vector rankpos;
-       rankpos = pos + '0.5 0.25 0' * mySize_y - eX * stringwidth(rankname, TRUE, '1 1 0' * 0.15 * mySize_y);
+       rankpos = medalPos + '0 0.15 0' * squareSize;
 
        if(race_status == 0)
-               drawpic_aspect_skin(pos, "race_newfail", '1 1 0' * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(medalPos, "race_newfail", '1 1 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
        else if(race_status == 1) {
-               drawpic_aspect_skin(pos, "race_newtime", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
-               drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
-               drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newtime", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
+               drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+               drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
        } else if(race_status == 2) {
                if(race_status_name == GetPlayerName(player_localentnum -1) || !race_myrank || race_myrank < rank)
-                       drawpic_aspect_skin(pos, "race_newrankgreen", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                       drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankgreen", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
                else
-                       drawpic_aspect_skin(pos, "race_newrankyellow", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
-               drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
-               drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
+                       drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrankyellow", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
+               drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+               drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
        } else if(race_status == 3) {
-               drawpic_aspect_skin(pos, "race_newrecordserver", '1 1 0' * 0.9 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
-               drawcolorcodedstring(namepos, s, '1 1 0' * 0.1 * mySize_y, panel_fg_alpha * a, DRAWFLAG_NORMAL);
-               drawstring(rankpos, rankname, '1 1 0' * 0.15 * mySize_y, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(medalPos + '0.1 0 0' * squareSize, "race_newrecordserver", '1 1 0' * 0.8 * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
+               drawcolorcodedstring_aspect(namepos, s, '1 0.2 0' * squareSize, panel_fg_alpha * a, DRAWFLAG_NORMAL);
+               drawstring_aspect(rankpos, rankname, '1 0.15 0' * squareSize, '1 1 1', panel_fg_alpha * a, DRAWFLAG_NORMAL);
        }
 
        if (race_status_time - time <= 0) {
@@ -4524,29 +4544,32 @@ void HUD_EngineInfo(void)
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
+       float currentTime = gettime(GETTIME_REALTIME);
        if(cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage"))
        {
-               frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + frametime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
+               float currentframetime = currentTime - prevfps_time;
+               frametimeavg = (frametimeavg + frametimeavg1 + frametimeavg2 + currentframetime)/4; // average three frametimes into framecounter for slightly more stable fps readings :P
                frametimeavg2 = frametimeavg1;
                frametimeavg1 = frametimeavg;
                
                float weight;
                weight = cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_new_weight");
-               if(frametime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter.
+               if(currentframetime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter.
                {
-                       if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant
-                               prevfps = (1/frametime);
+                       if(fabs(prevfps - (1/frametimeavg)) > prevfps * cvar("hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/currentframetime) to make big updates instant
+                               prevfps = (1/currentframetime);
                        prevfps = (1 - weight) * prevfps + weight * (1/frametimeavg); // framecounter just used so there's no need for a new variable, think of it as "frametime average"
                }
+               prevfps_time = currentTime;
        }
        else
        {
                framecounter += 1;
-               if(time - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
+               if(currentTime - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
                {
-                       prevfps = framecounter/cvar("hud_panel_engineinfo_framecounter_time");
+                       prevfps = framecounter/(currentTime - prevfps_time);
                        framecounter = 0;
-                       prevfps_time = time;
+                       prevfps_time = currentTime;
                }
        }
 
@@ -4790,11 +4813,11 @@ void HUD_ShowSpeed(void)
        pos = (vid_conheight - numsize_y) * cvar("cl_showspeed_position");
 
        drawfont = hud_bigfont;
-       drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawstringcenter(eX + pos * eY, speed, numsize, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
 
        if (cvar("cl_showspeed_z") == 1) {
                zspeed = strcat(ftos(fabs(floor( pmove_vel_z * conversion_factor + 0.5 ))), unit);
-               drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstringcenter(eX + pos * eY + numsize_y * eY, zspeed, numsize * 0.5, '1 1 1', autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
        }
 
        drawfont = hud_font;
@@ -4822,6 +4845,8 @@ void HUD_ShowAcceleration(void)
        f = bound(0, f * 10, 1);
        acc_avg = acc_avg * (1 - f) + acceleration * f;
        acceleration = acc_avg / getstatf(STAT_MOVEVARS_MAXSPEED);
+       if (acceleration == 0)
+               return;
 
        pos = top - sz/2 * eY + (cvar("cl_showacceleration_position") * vid_conheight) * eY;
 
@@ -4831,18 +4856,16 @@ void HUD_ShowAcceleration(void)
        if (cvar("cl_showacceleration_color_custom"))
                rgb = stov(cvar_string("cl_showacceleration_color"));
        else {
-               rgb = '1 1 1';
-               if (acceleration < 0) {
+               if (acceleration < 0)
                        rgb = '1 .5 .5' - '0 .5 .5' * bound(0, -acceleration * 0.2, 1);
-               } else if (acceleration > 0) {
+               else
                        rgb = '.5 1 .5' - '.5 0 .5' * bound(0, +acceleration * 0.2, 1);
-               }
        }
 
        if (acceleration > 0)
-               HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
-       else if (acceleration < 0)
-               HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha, DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
+       else
+               HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * autocvar_hud_panel_fg_alpha * hud_fade_alpha, DRAWFLAG_NORMAL);
 }
 
 void HUD_Reset (void)
@@ -4893,7 +4916,7 @@ void HUD_Main (void)
        hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
 
        // global hud alpha fade
-       if(disable_menu_alphacheck == 1)
+       if(menu_enabled == 1)
                hud_fade_alpha = 1;
        else
                hud_fade_alpha = (1 - autocvar__menu_alpha);
@@ -4906,11 +4929,10 @@ void HUD_Main (void)
        else if(autocvar__menu_alpha == 0 && scoreboard_fade_alpha == 0)
                hud_fade_alpha = 1;
 
-       hud_border_thickness = bound(0, cvar("hud_border_thickness"), 5);
-       hud_accuracy_border_thickness = bound(0, cvar_or("hud_accuracy_border_thickness", 1), 5);
-
        hud_fontsize = HUD_GetFontsize("hud_fontsize");
-       hud_fontsize_spec = HUD_GetFontsize("hud_fontsize_spec");
+
+       if(!autocvar__hud_configure && !hud_fade_alpha)
+               return;
 
        // Drawing stuff
 
@@ -4930,29 +4952,29 @@ void HUD_Main (void)
                }
        }
 
-       float f;
-       vector color;
-       if((teamplay) && autocvar_hud_dock_color_team) {
-               f = stof(getplayerkey(player_localentnum - 1, "colors"));
-               color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
-       }
-       else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && autocvar_hud_dock_color_team) {
-               color = '1 0 0' * autocvar_hud_dock_color_team;
-       }
-       else if(autocvar_hud_dock_color == "shirt") {
-               f = stof(getplayerkey(player_localentnum - 1, "colors"));
-               color = colormapPaletteColor(floor(f / 16), 0);
-       }
-       else if(autocvar_hud_dock_color == "pants") {
-               f = stof(getplayerkey(player_localentnum - 1, "colors"));
-               color = colormapPaletteColor(mod(f, 16), 1);
-       }
-       else
-               color = stov(autocvar_hud_dock_color);
-
        // draw the dock
        if(autocvar_hud_dock != "" && autocvar_hud_dock != "0")
        {
+               float f;
+               vector color;
+               if((teamplay) && autocvar_hud_dock_color_team) {
+                       f = stof(getplayerkey(player_localentnum - 1, "colors"));
+                       color = colormapPaletteColor(mod(f, 16), 1) * autocvar_hud_dock_color_team;
+               }
+               else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && autocvar_hud_dock_color_team) {
+                       color = '1 0 0' * autocvar_hud_dock_color_team;
+               }
+               else if(autocvar_hud_dock_color == "shirt") {
+                       f = stof(getplayerkey(player_localentnum - 1, "colors"));
+                       color = colormapPaletteColor(floor(f / 16), 0);
+               }
+               else if(autocvar_hud_dock_color == "pants") {
+                       f = stof(getplayerkey(player_localentnum - 1, "colors"));
+                       color = colormapPaletteColor(mod(f, 16), 1);
+               }
+               else
+                       color = stov(autocvar_hud_dock_color);
+
                string pic;
                pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
                if(precache_pic(pic) == "") {
@@ -4996,5 +5018,6 @@ void HUD_Main (void)
        hud_configure_prev = autocvar__hud_configure;
 
        if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again
-               disable_menu_alphacheck = 0;
+               if (menu_enabled)
+                       menu_enabled = 0;
 }