]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Progress bar: fix alpha multiplied by panel_fg_alpha twice
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 82f080241ec829e16518a57aeda26ab130750042..2de02e066a6fe561ca256f8056a0367413e9714f 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)
        {
@@ -413,115 +412,124 @@ HUD panels
 ==================
 */
 
+#define HUD_Write(s) fputs(fh, s)
+// q: quoted, n: not quoted
+#define HUD_Write_Cvar_n(cvar) HUD_Write(strcat("seta ", cvar, " ", cvar_string(cvar), "\n"))
+#define HUD_Write_Cvar_q(cvar) HUD_Write(strcat("seta ", cvar, " \"", cvar_string(cvar), "\"\n"))
+#define HUD_Write_PanelCvar_n(cvar_suf) HUD_Write_Cvar_n(strcat("hud_panel_", panel_name, cvar_suf))
+#define HUD_Write_PanelCvar_q(cvar_suf) HUD_Write_Cvar_q(strcat("hud_panel_", panel_name, cvar_suf))
 // Save the config
 void HUD_Panel_ExportCfg(string cfgname)
 {
        float fh;
-       fh = fopen(strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg"), FILE_WRITE);
+       string filename = strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg");
+       fh = fopen(filename, FILE_WRITE);
        if(fh >= 0)
        {
-               fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_panel_bg \"", cvar_string("hud_panel_bg"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_panel_bg_color \"", cvar_string("hud_panel_bg_color"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_panel_bg_color_team \"", cvar_string("hud_panel_bg_color_team"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_panel_bg_alpha \"", cvar_string("hud_panel_bg_alpha"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_panel_bg_border \"", cvar_string("hud_panel_bg_border"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_panel_bg_padding \"", cvar_string("hud_panel_bg_padding"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_panel_fg_alpha \"", cvar_string("hud_panel_fg_alpha"), "\"", "\n"));
-               fputs(fh, "\n");
-
-               fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_dock_color_team \"", cvar_string("hud_dock_color_team"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_dock_alpha \"", cvar_string("hud_dock_alpha"), "\"", "\n"));
-               fputs(fh, "\n");
-
-               fputs(fh, strcat("seta hud_progressbar_alpha \"", cvar_string("hud_progressbar_alpha"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_progressbar_strength_color \"", cvar_string("hud_progressbar_strength_color"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_progressbar_shield_color \"", cvar_string("hud_progressbar_shield_color"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_progressbar_health_color \"", cvar_string("hud_progressbar_health_color"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_progressbar_armor_color \"", cvar_string("hud_progressbar_armor_color"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_progressbar_fuel_color \"", cvar_string("hud_progressbar_fuel_color"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_progressbar_nexball_color \"", cvar_string("hud_progressbar_nexball_color"), "\"", "\n"));
-               fputs(fh, "\n");
-
-               fputs(fh, strcat("seta _hud_panelorder \"", cvar_string("_hud_panelorder"), "\"", "\n"));
-               fputs(fh, "\n");
-
-               fputs(fh, strcat("seta hud_configure_grid \"", cvar_string("hud_configure_grid"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_configure_grid_xsize \"", cvar_string("hud_configure_grid_xsize"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_configure_grid_ysize \"", cvar_string("hud_configure_grid_ysize"), "\"", "\n"));
-               fputs(fh, "\n");
-
-               fputs(fh, strcat("seta scr_centerpos \"", cvar_string("scr_centerpos"), "\"", "\n"));
-               fputs(fh, "\n");
+               HUD_Write_Cvar_q("hud_skin");
+               HUD_Write_Cvar_q("hud_panel_bg");
+               HUD_Write_Cvar_q("hud_panel_bg_color");
+               HUD_Write_Cvar_q("hud_panel_bg_color_team");
+               HUD_Write_Cvar_q("hud_panel_bg_alpha");
+               HUD_Write_Cvar_q("hud_panel_bg_border");
+               HUD_Write_Cvar_q("hud_panel_bg_padding");
+               HUD_Write_Cvar_q("hud_panel_fg_alpha");
+               HUD_Write("\n");
+
+               HUD_Write_Cvar_q("hud_dock");
+               HUD_Write_Cvar_q("hud_dock_color");
+               HUD_Write_Cvar_q("hud_dock_color_team");
+               HUD_Write_Cvar_q("hud_dock_alpha");
+               HUD_Write("\n");
+
+               HUD_Write_Cvar_q("hud_progressbar_alpha");
+               HUD_Write_Cvar_q("hud_progressbar_strength_color");
+               HUD_Write_Cvar_q("hud_progressbar_shield_color");
+               HUD_Write_Cvar_q("hud_progressbar_health_color");
+               HUD_Write_Cvar_q("hud_progressbar_armor_color");
+               HUD_Write_Cvar_q("hud_progressbar_fuel_color");
+               HUD_Write_Cvar_q("hud_progressbar_nexball_color");
+               HUD_Write("\n");
+
+               HUD_Write_Cvar_q("_hud_panelorder");
+               HUD_Write("\n");
+
+               HUD_Write_Cvar_q("hud_configure_grid");
+               HUD_Write_Cvar_q("hud_configure_grid_xsize");
+               HUD_Write_Cvar_q("hud_configure_grid_ysize");
+               HUD_Write("\n");
+
+               HUD_Write_Cvar_q("scr_centerpos");
+               HUD_Write("\n");
 
                // common cvars for all panels
                float i;
                for (i = 0; i < HUD_PANEL_NUM; ++i)
                {
-                       HUD_Panel_GetName(i)
-
-                       fputs(fh, strcat("seta hud_panel_", panel_name, " ", cvar_string(strcat("hud_panel_", panel_name)), "\n"));
-                       fputs(fh, strcat("seta hud_panel_", panel_name, "_pos \"", cvar_string(strcat("hud_panel_", panel_name, "_pos")), "\"", "\n"));
-                       fputs(fh, strcat("seta hud_panel_", panel_name, "_size \"", cvar_string(strcat("hud_panel_", panel_name, "_size")), "\"", "\n"));
-                       fputs(fh, strcat("seta hud_panel_", panel_name, "_bg \"", cvar_string(strcat("hud_panel_", panel_name, "_bg")), "\"", "\n"));
-                       fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color")), "\"", "\n"));
-                       fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_color_team \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_color_team")), "\"", "\n"));
-                       fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_alpha")), "\"", "\n"));
-                       fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_border \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_border")), "\"", "\n"));
-                       fputs(fh, strcat("seta hud_panel_", panel_name, "_bg_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_bg_padding")), "\"", "\n"));
+                       HUD_Panel_GetName(i);
+
+                       HUD_Write_PanelCvar_n("");
+                       HUD_Write_PanelCvar_q("_pos");
+                       HUD_Write_PanelCvar_q("_size");
+                       HUD_Write_PanelCvar_q("_bg");
+                       HUD_Write_PanelCvar_q("_bg_color");
+                       HUD_Write_PanelCvar_q("_bg_color_team");
+                       HUD_Write_PanelCvar_q("_bg_alpha");
+                       HUD_Write_PanelCvar_q("_bg_border");
+                       HUD_Write_PanelCvar_q("_bg_padding");
                        switch(i) {
                                case HUD_PANEL_WEAPONS:
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_padding \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_padding")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_outofammo \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_outofammo")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_donthave \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_donthave")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_complainbubble_color_unavailable \"", cvar_string(strcat("hud_panel_", panel_name, "_complainbubble_color_unavailable")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_color \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_color")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_ammo_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_ammo_alpha")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
+                                       HUD_Write_PanelCvar_q("_complainbubble");
+                                       HUD_Write_PanelCvar_q("_complainbubble_padding");
+                                       HUD_Write_PanelCvar_q("_complainbubble_color_outofammo");
+                                       HUD_Write_PanelCvar_q("_complainbubble_color_donthave");
+                                       HUD_Write_PanelCvar_q("_complainbubble_color_unavailable");
+                                       HUD_Write_PanelCvar_q("_ammo_color");
+                                       HUD_Write_PanelCvar_q("_ammo_alpha");
+                                       HUD_Write_PanelCvar_q("_aspect");
                                        break;
                                case HUD_PANEL_AMMO:
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_onlycurrent \"", cvar_string(strcat("hud_panel_", panel_name, "_onlycurrent")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
+                                       HUD_Write_PanelCvar_q("_onlycurrent");
+                                       HUD_Write_PanelCvar_q("_iconalign");
                                        break;
                                case HUD_PANEL_POWERUPS:
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
+                                       HUD_Write_PanelCvar_q("_flip");
+                                       HUD_Write_PanelCvar_q("_iconalign");
+                                       HUD_Write_PanelCvar_q("_baralign");
+                                       HUD_Write_PanelCvar_q("_progressbar");
                                        break;
                                case HUD_PANEL_HEALTHARMOR:
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_iconalign \"", cvar_string(strcat("hud_panel_", panel_name, "_iconalign")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_baralign \"", cvar_string(strcat("hud_panel_", panel_name, "_baralign")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_progressbar \"", cvar_string(strcat("hud_panel_", panel_name, "_progressbar")), "\"", "\n"));
+                                       HUD_Write_PanelCvar_q("_flip");
+                                       HUD_Write_PanelCvar_q("_iconalign");
+                                       HUD_Write_PanelCvar_q("_baralign");
+                                       HUD_Write_PanelCvar_q("_progressbar");
                                        break;
                                case HUD_PANEL_NOTIFY:
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_print \"", cvar_string(strcat("hud_panel_", panel_name, "_print")), "\"", "\n"));
+                                       HUD_Write_PanelCvar_q("_flip");
+                                       HUD_Write_PanelCvar_q("_print");
                                        break;
                                case HUD_PANEL_RADAR:
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_foreground_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_foreground_alpha")), "\"", "\n"));
+                                       HUD_Write_PanelCvar_q("_foreground_alpha");
                                        break;
                                case HUD_PANEL_VOTE:
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_alreadyvoted_alpha \"", cvar_string(strcat("hud_panel_", panel_name, "_alreadyvoted_alpha")), "\"", "\n"));
+                                       HUD_Write_PanelCvar_q("_alreadyvoted_alpha");
                                        break;
                                case HUD_PANEL_PRESSEDKEYS:
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_aspect \"", cvar_string(strcat("hud_panel_", panel_name, "_aspect")), "\"", "\n"));
+                                       HUD_Write_PanelCvar_q("_aspect");
                                        break;
                                case HUD_PANEL_INFOMESSAGES:
-                                       fputs(fh, strcat("seta hud_panel_", panel_name, "_flip \"", cvar_string(strcat("hud_panel_", panel_name, "_flip")), "\"", "\n"));
+                                       HUD_Write_PanelCvar_q("_flip");
                                        break;
                        }
-                       fputs(fh, "\n");
+                       HUD_Write("\n");
                }
-               fputs(fh, strcat("menu_restart", "\n")); // force a menu update when execing config, so that the dialogs are updated
+               HUD_Write("menu_sync\n"); // force the menu to reread the cvars, so that the dialogs are updated
 
-               print("^2Successfully exported to hud_", autocvar_hud_skin, "_", cfgname, ".cfg! (Note: It's saved in data/data/)\n");
+               print("^2Successfully exported to ", filename, "! (Note: It's saved in data/data/)\n");
+               fclose(fh);
        }
-       fclose(fh);
+       else
+               print("^1Couldn't write to ", filename, "\n");
 }
 
 const float hlBorderSize = 4;
@@ -541,7 +549,9 @@ void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
 if(panel_bg != "0")\
        draw_BorderPicture(panel_pos - '1 1 0' * panel_bg_border, panel_bg, panel_size + '1 1 0' * 2 * panel_bg_border, panel_bg_color, panel_bg_alpha * alpha, '1 1 0' * (panel_bg_border/BORDER_MULTIPLIER));\
 if(highlightedPanel_prev == active_panel && autocvar__hud_configure)\
-       HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);
+{\
+       HUD_Panel_HlBorder(panel_bg_border + 1.5 * hlBorderSize, '0 0.5 1', 0.25 * (1 - autocvar__menu_alpha) * alpha);\
+} ENDS_WITH_CURLY_BRACE
 
 void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
 {
@@ -595,8 +605,6 @@ vector HUD_Panel_CheckMove(vector myPos, vector mySize)
        vector myTarget;
        myTarget = myPos;
 
-       vector targPos;
-       vector targSize;
        vector myCenter;
        vector targCenter;
        myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
@@ -606,7 +614,7 @@ vector HUD_Panel_CheckMove(vector myPos, vector mySize)
                if(i == highlightedPanel || !panel_enabled)
                        continue;
 
-               HUD_Panel_UpdatePosSizeForId(i)
+               HUD_Panel_UpdatePosSizeForId(i);
 
                panel_pos -= '1 1 0' * panel_bg_border;
                panel_size += '2 2 0' * panel_bg_border;
@@ -657,8 +665,8 @@ vector HUD_Panel_CheckMove(vector myPos, vector mySize)
                        else // push it downwards
                                myTarget_y = panel_pos_y + panel_size_y;
                }
-               if(cvar("hud_configure_checkcollisions_debug"))
-                       drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
+               //if(cvar("hud_configure_checkcollisions_debug"))
+                       //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
        }
 
        return myTarget;
@@ -666,12 +674,12 @@ vector HUD_Panel_CheckMove(vector myPos, vector mySize)
 
 void HUD_Panel_SetPos(vector pos)
 {
-       HUD_Panel_UpdatePosSizeForId(highlightedPanel)
+       HUD_Panel_UpdatePosSizeForId(highlightedPanel);
        vector mySize;
        mySize = panel_size;
 
-       if(cvar("hud_configure_checkcollisions_debug"))
-               drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
+       //if(cvar("hud_configure_checkcollisions_debug"))
+               //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
 
        if(autocvar_hud_configure_grid)
        {
@@ -696,12 +704,9 @@ void HUD_Panel_SetPos(vector pos)
 vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
        float i;
 
-       float targBorder;
-       vector targPos;
-       vector targSize;
        vector targEndPos;
 
-       vector dist;
+       float dist_x, dist_y;
        float ratio;
        ratio = mySize_x/mySize_y;
 
@@ -709,7 +714,7 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
                if(i == highlightedPanel || !panel_enabled)
                        continue;
 
-               HUD_Panel_UpdatePosSizeForId(i)
+               HUD_Panel_UpdatePosSizeForId(i);
 
                panel_pos -= '1 1 0' * panel_bg_border;
                panel_size += '2 2 0' * panel_bg_border;
@@ -799,8 +804,8 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
                        else
                                mySize_y = min(mySize_y, dist_y);
                }
-               if(cvar("hud_configure_checkcollisions_debug"))
-                       drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
+               //if(cvar("hud_configure_checkcollisions_debug"))
+                       //drawfill(panel_pos, panel_size, '1 1 0', .3, DRAWFLAG_NORMAL);
        }
 
        return mySize;
@@ -808,7 +813,7 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
 
 void HUD_Panel_SetPosSize(vector mySize)
 {
-       HUD_Panel_UpdatePosSizeForId(highlightedPanel)
+       HUD_Panel_UpdatePosSizeForId(highlightedPanel);
        vector resizeorigin;
        resizeorigin = panel_click_resizeorigin;
        vector myPos;
@@ -853,8 +858,8 @@ void HUD_Panel_SetPosSize(vector mySize)
        if(myPos_y + mySize_y > vid_conheight)
                mySize_y = vid_conheight - myPos_y;
 
-       if(cvar("hud_configure_checkcollisions_debug"))
-               drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
+       //if(cvar("hud_configure_checkcollisions_debug"))
+               //drawfill(myPos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
 
        // before checkresize, otherwise panel can be snapped partially inside another panel or panel aspect ratio can be broken
        if(autocvar_hud_configure_grid)
@@ -885,8 +890,8 @@ void HUD_Panel_SetPosSize(vector mySize)
                myPos_y = resizeorigin_y;
        }
 
-       if(cvar("hud_configure_checkcollisions_debug"))
-               drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
+       //if(cvar("hud_configure_checkcollisions_debug"))
+               //drawfill(myPos, mySize, '0 1 0', .3, DRAWFLAG_NORMAL);
 
        HUD_Panel_GetName(highlightedPanel);
        string s;
@@ -902,8 +907,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)
 {
@@ -944,7 +947,7 @@ void HUD_Panel_Arrow_Action(float nPrimary)
 
        highlightedPanel = highlightedPanel_prev;
 
-       HUD_Panel_UpdatePosSizeForId(highlightedPanel)
+       HUD_Panel_UpdatePosSizeForId(highlightedPanel);
 
        vector prev_pos, prev_size;
        prev_pos = panel_pos;
@@ -1004,7 +1007,7 @@ void HUD_Panel_Arrow_Action(float nPrimary)
                HUD_Panel_SetPos(pos);
        }
 
-       HUD_Panel_UpdatePosSizeForId(highlightedPanel)
+       HUD_Panel_UpdatePosSizeForId(highlightedPanel);
 
        if (prev_pos != panel_pos || prev_size != panel_size)
        {
@@ -1017,6 +1020,8 @@ void HUD_Panel_Arrow_Action(float nPrimary)
 
 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 {
+       string s;
+
        if(!autocvar__hud_configure)
                return false;
 
@@ -1059,7 +1064,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");
@@ -1095,17 +1099,28 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                        if (bInputType == 1)
                                return true;
 
-                       if (highlightedPanel_copied != -1 && highlightedPanel_prev != -1)
-                       {
-                               // backup first!
-                               panel_pos_backup = panel_pos;
-                               panel_size_backup = panel_size;
-                               highlightedPanel_backup = highlightedPanel_prev;
+                       if (highlightedPanel_copied == -1 || highlightedPanel_prev == -1)
+                               return true;
 
-                               string s;
-                               s = strcat(ftos(panel_size_copied_x/vid_conwidth), " ", ftos(panel_size_copied_y/vid_conheight));
-                               cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
-                       }
+                       HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev);
+
+                       // reduce size if it'd go beyond screen boundaries
+                       vector tmp_size = panel_size_copied;
+                       if (panel_pos_x + panel_size_copied_x > vid_conwidth)
+                               tmp_size_x = vid_conwidth - panel_pos_x;
+                       if (panel_pos_y + panel_size_copied_y > vid_conheight)
+                               tmp_size_y = vid_conheight - panel_pos_y;
+
+                       if (panel_size == tmp_size)
+                               return true;
+
+                       // backup first!
+                       panel_pos_backup = panel_pos;
+                       panel_size_backup = panel_size;
+                       highlightedPanel_backup = highlightedPanel_prev;
+
+                       s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
+                       cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
                }
                else if(nPrimary == 'z') // undo last action
                {
@@ -1114,8 +1129,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                        //restore previous values
                        if (highlightedPanel_backup != -1)
                        {
-                               HUD_Panel_GetName(highlightedPanel_backup)
-                               string s;
+                               HUD_Panel_GetName(highlightedPanel_backup);
                                s = strcat(ftos(panel_pos_backup_x/vid_conwidth), " ", ftos(panel_pos_backup_y/vid_conheight));
                                cvar_set(strcat("hud_panel_", panel_name, "_pos"), s);
                                s = strcat(ftos(panel_size_backup_x/vid_conwidth), " ", ftos(panel_size_backup_y/vid_conheight));
@@ -1153,7 +1167,7 @@ float HUD_Panel_HighlightCheck()
                i = panel_order[j];
                j += 1;
 
-               HUD_Panel_UpdatePosSizeForId(i)
+               HUD_Panel_UpdatePosSizeForId(i);
 
                panelPos = panel_pos;
                panelSize = panel_size;
@@ -1237,7 +1251,7 @@ void HUD_Panel_Highlight()
                i = panel_order[j];
                j += 1;
 
-               HUD_Panel_UpdatePosSizeForId(i)
+               HUD_Panel_UpdatePosSizeForId(i);
 
                panelPos = panel_pos;
                panelSize = panel_size;
@@ -1306,22 +1320,26 @@ void HUD_Panel_Highlight()
 }
 
 float highlightcheck;
-float would_backup;
+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;
        }
@@ -1335,22 +1353,29 @@ void HUD_Panel_Mouse()
 
        if(mouseClicked)
        {
-               vector prev_pos, prev_size;
                if(prevMouseClicked == 0)
                {
                        HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
                                                                        // and calls HUD_Panel_UpdatePosSizeForId() for the highlighted panel
-                       would_backup = TRUE;
-               }
-               else if (would_backup)
-               {
-                       // this is not the actual backup! Saving pos and size values
-                       // only to check later if they are different from new values
                        prev_pos = panel_pos;
                        prev_size = panel_size;
                }
+               else
+                       HUD_Panel_UpdatePosSizeForId(highlightedPanel);
 
-               hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
+               if (prev_pos != panel_pos || prev_size != panel_size)
+               {
+                       hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
+                       // backup!
+                       panel_pos_backup = prev_pos;
+                       panel_size_backup = prev_size;
+                       highlightedPanel_backup = highlightedPanel;
+               }
+               else
+                       // in case the clicked panel is inside another panel and we aren't
+                       // moving it, avoid the immediate "fix" of its position/size
+                       // (often unwanted and hateful) by disabling collisions check
+                       hud_configure_checkcollisions = false;
 
                if(highlightedAction == 1)
                        HUD_Panel_SetPos(mousepos - panel_click_distance);
@@ -1373,26 +1398,13 @@ void HUD_Panel_Mouse()
                        HUD_Panel_SetPosSize(mySize);
                }
 
-               HUD_Panel_UpdatePosSizeForId(highlightedPanel)
-               if (prevMouseClicked)
-               if (would_backup)
-               if (prev_pos != panel_pos || prev_size != panel_size)
-               {
-                       // backup!
-                       panel_pos_backup = prev_pos;
-                       panel_size_backup = prev_size;
-                       highlightedPanel_backup = highlightedPanel;
-                       would_backup = FALSE;
-               }
-
                // doubleclick check
                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)
+                       HUD_Panel_GetName(highlightedPanel);
                        localcmd("menu_showhudoptions ", panel_name, "\n");
                        return;
                }
@@ -1407,18 +1419,17 @@ void HUD_Panel_Mouse()
                highlightcheck = HUD_Panel_HighlightCheck();
        }
        // draw cursor after performing move/resize to have the panel pos/size updated before highlightcheck
-       string cursor;
        vector cursorsize;
        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;
 }
@@ -1429,7 +1440,7 @@ float weaponspace[10];
 #define HUD_Weapons_Clear()\
        float idx;\
        for(idx = 0; idx < 10; ++idx)\
-               weaponspace[idx] = 0;
+               weaponspace[idx] = 0
 
 entity weaponorder[WEP_MAXCOUNT];
 void weaponorder_swap(float i, float j, entity pass)
@@ -1440,7 +1451,6 @@ void weaponorder_swap(float i, float j, entity pass)
        weaponorder[j] = h;
 }
 
-string weaponorder_cmp_str_save;
 string weaponorder_cmp_str;
 float weaponorder_cmp(float i, float j, entity pass)
 {
@@ -1469,13 +1479,14 @@ float GetAmmoTypeForWep(float i)
        {
                case WEP_SHOTGUN: return 0;
                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;
                case WEP_MINSTANEX: return 3;
                case WEP_NEX: return 3;
+               case WEP_CAMPINGRIFLE: return 1;
                case WEP_HAGAR: return 2;
                case WEP_ROCKET_LAUNCHER: return 2;
                case WEP_SEEKER: return 2;
@@ -1487,6 +1498,9 @@ float GetAmmoTypeForWep(float i)
 
 void HUD_Weapons(void)
 {
+       float f, screen_ar;
+       float center_x, center_y;
+
        if(!autocvar_hud_panel_weapons && !autocvar__hud_configure)
                return;
 
@@ -1514,7 +1528,7 @@ void HUD_Weapons(void)
 
        if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
        {
-               float f = (time - (weapontime + timeout)) / timeout_effect_length;
+               f = (time - (weapontime + timeout)) / timeout_effect_length;
                if (cvar("hud_panel_weapons_timeout_effect"))
                {
                        panel_bg_alpha *= (1 - f);
@@ -1523,10 +1537,9 @@ void HUD_Weapons(void)
                if (cvar("hud_panel_weapons_timeout_effect") == 1)
                {
                        f *= f; // for a cooler movement
-                       vector center;
                        center_x = panel_pos_x + panel_size_x/2;
                        center_y = panel_pos_y + panel_size_y/2;
-                       float screen_ar = vid_conwidth/vid_conheight;
+                       screen_ar = vid_conwidth/vid_conheight;
                        if (center_x/center_y < screen_ar) //bottom left
                        {
                                if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
@@ -1546,7 +1559,7 @@ void HUD_Weapons(void)
        }
        else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
        {
-               float f = (time - weaponprevtime) / timein_effect_length;
+               f = (time - weaponprevtime) / timein_effect_length;
                if (cvar("hud_panel_weapons_timeout_effect"))
                {
                        panel_bg_alpha *= (f);
@@ -1556,10 +1569,9 @@ void HUD_Weapons(void)
                {
                        f *= f; // for a cooler movement
                        f = 1 - f;
-                       vector center;
                        center_x = panel_pos_x + panel_size_x/2;
                        center_y = panel_pos_y + panel_size_y/2;
-                       float screen_ar = vid_conwidth/vid_conheight;
+                       screen_ar = vid_conwidth/vid_conheight;
                        if (center_x/center_y < screen_ar) //bottom left
                        {
                                if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom
@@ -1577,7 +1589,7 @@ void HUD_Weapons(void)
                }
        }
 
-       float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt;
+       float i, weapid, wpnalpha, weapon_cnt;
        weapon_cnt = 0;
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
@@ -1587,13 +1599,17 @@ void HUD_Weapons(void)
        }
 
        // TODO make this configurable
-       weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
-
-       if(weaponorder_cmp_str != weaponorder_cmp_str_save)
+       if(weaponorder_bypriority != cvar_string("cl_weaponpriority"))
        {
-               if(weaponorder_cmp_str_save)
-                       strunzone(weaponorder_cmp_str_save);
-               weaponorder_cmp_str_save = strzone(weaponorder_cmp_str);
+               if(weaponorder_bypriority)
+                       strunzone(weaponorder_bypriority);
+               if(weaponorder_byimpulse)
+                       strunzone(weaponorder_byimpulse);
+
+               weaponorder_bypriority = strzone(cvar_string("cl_weaponpriority"));
+               weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
+               weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
+
                weapon_cnt = 0;
                for(i = WEP_FIRST; i <= WEP_LAST; ++i)
                {
@@ -1605,15 +1621,78 @@ void HUD_Weapons(void)
                        }
                }
                heapsort(weapon_cnt, weaponorder_swap, weaponorder_cmp, world);
+
+               weaponorder_cmp_str = string_null;
+       }
+
+       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)
+       if(cvar_or("hud_panel_weapons_fade", 1))
+       {
+               wpnalpha = 3.2 - 2 * (time - weapontime);
+               wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
+       }
+       else
+               wpnalpha = panel_fg_alpha;
+
+       HUD_Weapons_Clear();
+
+       float rows, columns;
+       float aspect = cvar("hud_panel_weapons_aspect");
+       rows = panel_size_y/panel_size_x;
+       rows = bound(1, floor((sqrt(4 * aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT);
+
+       columns = ceil(WEP_COUNT/rows);
+       float row, column;
+
+       float a, type, fullammo;
+       float when;
+       when = cvar("hud_panel_weapons_complainbubble_time");
+       float fadetime;
+       fadetime = cvar("hud_panel_weapons_complainbubble_fadetime");
+
+       vector color;
+       vector wpnpos;
+       vector wpnsize;
+       
+       float fullammo_shells, fullammo_nails, fullammo_rockets, fullammo_cells, fullammo_fuel;
+       vector ammo_color;
+       float ammo_alpha;
+       float barsize_x, barsize_y;
+       wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
+       float show_ammo = cvar("hud_panel_weapons_ammo");
+       if (show_ammo)
+       {
+               fullammo_shells = cvar("hud_panel_weapons_ammo_full_shells");
+               fullammo_nails = cvar("hud_panel_weapons_ammo_full_nails");
+               fullammo_rockets = cvar("hud_panel_weapons_ammo_full_rockets");
+               fullammo_cells = cvar("hud_panel_weapons_ammo_full_cells");
+               fullammo_fuel = cvar("hud_panel_weapons_ammo_full_fuel");
+               ammo_color = stov(cvar_string("hud_panel_weapons_ammo_color"));
+               ammo_alpha = panel_fg_alpha * cvar("hud_panel_weapons_ammo_alpha");
+
+               if(wpnsize_x/wpnsize_y > aspect)
                {
-                       panel_pos += '1 1 0' * panel_bg_padding;
-                       panel_size -= '2 2 0' * panel_bg_padding;
+                       barsize_x = aspect * wpnsize_y;
+                       barsize_y = wpnsize_y;
                }
+               else
+               {
+                       barsize_y = 1/aspect * wpnsize_x;
+                       barsize_x = wpnsize_x;
+               }
+       }
 
+       float show_accuracy;
+       float weapon_stats, weapon_number;
+       if(cvar("hud_panel_weapons_accuracy") && acc_levels)
+       {
+               show_accuracy = true;
                // hits
                weapon_stats = getstati(STAT_DAMAGE_HITS);
                weapon_number = weapon_stats & 63;
@@ -1622,56 +1701,32 @@ void HUD_Weapons(void)
                weapon_stats = getstati(STAT_DAMAGE_FIRED);
                weapon_number = weapon_stats & 63;
                weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
+               if (acc_col_x[0] == -1)
+                       for (i = 0; i < acc_levels; ++i)
+                               acc_col[i] = stov(cvar_string(strcat("hud_panel_weapons_accuracy_color", ftos(i))));
+       }
+       float label = cvar("hud_panel_weapons_label");
 
-               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();
-
-               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;
+       for(i = 0; i < weapon_cnt; ++i)
+       {
+               wpnpos = panel_pos + eX * column * wpnsize_x + eY * row * wpnsize_y;
 
-               float a, type, fullammo;
-               float when;
-               when = autocvar_hud_panel_weapons_complainbubble_time;
-               float fadetime;
-               fadetime = autocvar_hud_panel_weapons_complainbubble_fadetime;
+               self = weaponorder[i];
+               weapid = self.impulse;
 
-               vector color;
-               vector wpnpos;
-               vector wpnsize;
+               // draw background behind currently selected weapon
+               if(self.weapon == activeweapon)
+                       drawpic_aspect_skin(wpnpos, "weapon_current_bg", wpnsize, '1 1 1', wpnalpha, DRAWFLAG_NORMAL);
 
-               for(i = 0; i < weapon_cnt; ++i)
+               // draw the weapon accuracy
+               if(show_accuracy)
                {
-                       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 the weapon accuracy
-                       if(acc_levels)
+                       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;
@@ -1682,230 +1737,224 @@ void HUD_Weapons(void)
                                // 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);
+                               color = acc_col[j];
+                               color = color + factor * (acc_col[j+1] - color);
 
-                               if(weapon_damage)
-                                       drawpic_aspect_skin(wpnpos, "weapon_accuracy", wpnsize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+                               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', wpnalpha, 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(label == 1) // weapon number
+                               drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * wpnsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       else if(label == 2) // bind
+                               drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * wpnsize_y, '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)
+                       // draw ammo status bar
+                       if(show_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?
+
+                               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 = fullammo_shells; break;
+                                               case 1: fullammo = fullammo_nails; break;
+                                               case 2: fullammo = fullammo_rockets; break;
+                                               case 3: fullammo = fullammo_cells; break;
+                                               case 4: fullammo = fullammo_fuel; break;
+                                               default: fullammo = 60;
+                                       }
 
-                                       if(a > 0)
+                                       float barpos_x, barpos_y;
+                                       if(wpnsize_x/wpnsize_y > aspect)
                                        {
-                                               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();
+                                               barpos_x = wpnpos_x + (wpnsize_x - barsize_x) / 2;
+                                               barpos_y = wpnpos_y;
                                        }
+                                       else
+                                       {
+                                               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, ammo_color, 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 && cvar("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 = stov(cvar_string("hud_panel_weapons_complainbubble_color_outofammo"));
+                       }
+                       else if(complain_weapon_type == 1) {
+                               s = "Don't have";
+                               color = stov(cvar_string("hud_panel_weapons_complainbubble_color_donthave"));
+                       }
+                       else {
+                               s = "Unavailable";
+                               color = stov(cvar_string("hud_panel_weapons_complainbubble_color_unavailable"));
                        }
+                       float padding = cvar("hud_panel_weapons_complainbubble_padding");
+                       drawpic_aspect_skin(wpnpos + '1 1 0' * padding, "weapon_complainbubble", wpnsize - '2 2 0' * padding, color, a * panel_fg_alpha, DRAWFLAG_NORMAL);
+                       drawstring_aspect(wpnpos + '1 1 0' * padding, s, wpnsize - '2 2 0' * 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;
 
-               HUD_Panel_DrawBg(1);
+       vector pos, mySize;
+       pos = panel_pos;
+       mySize = panel_size;
+
+       HUD_Panel_DrawBg(1);
        if(panel_bg_padding)
        {
                pos += '1 1 0' * panel_bg_padding;
@@ -1945,7 +1994,8 @@ void HUD_Weapons(void)
 
 void DrawNumIcon(float iconalign, vector myPos, vector mySize, float x, string icon, float left, vector color, float alpha)
 {
-       vector newSize, newPos;
+       vector newPos;
+       float newSize_x, newSize_y;
        if(mySize_x/mySize_y > 3)
        {
                newSize_x = 3 * mySize_y;
@@ -2011,21 +2061,17 @@ void HUD_Powerups(void) {
        if(!autocvar_hud_panel_powerups && !autocvar__hud_configure)
                return;
 
-       active_panel = HUD_PANEL_POWERUPS;
-       HUD_Panel_UpdateCvars(powerups);
-       float stat_items;
-       stat_items = getstati(STAT_ITEMS);
-
        if(!autocvar__hud_configure)
        {
-               if not(stat_items & IT_STRENGTH)
-                       if not(stat_items & IT_INVINCIBLE)
-                               return;
+               if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE))
+                       return;
 
                if (getstati(STAT_HEALTH) <= 0)
                        return;
        }
 
+       active_panel = HUD_PANEL_POWERUPS;
+       HUD_Panel_UpdateCvars(powerups);
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -2089,7 +2135,7 @@ void HUD_Powerups(void) {
 
                        if(autocvar_hud_panel_powerups_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor(leftname)
+                               HUD_Panel_GetProgressBarColorForString(leftname);
                                HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
                        }
                        if(leftcnt > 1)
@@ -2110,8 +2156,8 @@ void HUD_Powerups(void) {
 
                        if(autocvar_hud_panel_powerups_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor(rightname)
-                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_GetProgressBarColorForString(rightname);
+                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
                        }
                        if(rightcnt > 1)
                                DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
@@ -2133,8 +2179,8 @@ void HUD_Powerups(void) {
 
                        if(autocvar_hud_panel_powerups_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor(leftname)
-                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_GetProgressBarColorForString(leftname);
+                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
                        }
                        if(leftcnt > 1)
                                DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
@@ -2154,8 +2200,8 @@ void HUD_Powerups(void) {
 
                        if(autocvar_hud_panel_powerups_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor(rightname)
-                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_GetProgressBarColorForString(rightname);
+                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
                        }
                        if(rightcnt > 1)
                                DrawNumIcon(autocvar_hud_panel_powerups_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
@@ -2185,8 +2231,8 @@ void HUD_Powerups(void) {
 
                        if(autocvar_hud_panel_powerups_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor(leftname)
-                               HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_GetProgressBarColorForString(leftname);
+                               HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
                        }
                        if(leftcnt <= 5)
                                drawpic_aspect_skin_expanding(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (leftcnt - leftexact) / 0.5, 1));
@@ -2215,8 +2261,8 @@ void HUD_Powerups(void) {
 
                        if(autocvar_hud_panel_powerups_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor(rightname)
-                               HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1) * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_GetProgressBarColorForString(rightname);
+                               HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
                        }
                        if(rightcnt <= 5)
                                drawpic_aspect_skin_expanding(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL, bound(0, (rightcnt - rightexact) / 0.5, 1));
@@ -2248,12 +2294,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)
        {
@@ -2292,7 +2336,7 @@ void HUD_HealthArmor(void)
                        biggercount = "health";
                        if(autocvar_hud_panel_healtharmor_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor("health")
+                               HUD_Panel_GetProgressBarColor(health);
                                HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        if(armor)
@@ -2303,7 +2347,7 @@ void HUD_HealthArmor(void)
                        biggercount = "armor";
                        if(autocvar_hud_panel_healtharmor_progressbar)
                        {
-                               HUD_Panel_GetProgressBarColor("armor")
+                               HUD_Panel_GetProgressBarColor(armor);
                                HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        if(health)
@@ -2321,7 +2365,7 @@ void HUD_HealthArmor(void)
                                barpos = pos;
                                barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
                        }
-                       HUD_Panel_GetProgressBarColor("fuel")
+                       HUD_Panel_GetProgressBarColor(fuel);
                        HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                }
        }
@@ -2369,7 +2413,7 @@ void HUD_HealthArmor(void)
 
                                if(autocvar_hud_panel_healtharmor_progressbar)
                                {
-                                       HUD_Panel_GetProgressBarColor(leftname)
+                                       HUD_Panel_GetProgressBarColorForString(leftname);
                                        HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
                                DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
@@ -2387,7 +2431,7 @@ void HUD_HealthArmor(void)
 
                                if(autocvar_hud_panel_healtharmor_progressbar)
                                {
-                                       HUD_Panel_GetProgressBarColor(rightname)
+                                       HUD_Panel_GetProgressBarColorForString(rightname);
                                        HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
                                DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
@@ -2402,7 +2446,7 @@ void HUD_HealthArmor(void)
                                        barpos = pos;
                                        barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
                                }
-                               HUD_Panel_GetProgressBarColor("fuel")
+                               HUD_Panel_GetProgressBarColor(fuel);
                                HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                        }
                }
@@ -2420,7 +2464,7 @@ void HUD_HealthArmor(void)
 
                                if(autocvar_hud_panel_healtharmor_progressbar)
                                {
-                                       HUD_Panel_GetProgressBarColor(leftname)
+                                       HUD_Panel_GetProgressBarColorForString(leftname);
                                        HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
                                DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
@@ -2438,7 +2482,7 @@ void HUD_HealthArmor(void)
 
                                if(autocvar_hud_panel_healtharmor_progressbar)
                                {
-                                       HUD_Panel_GetProgressBarColor(rightname)
+                                       HUD_Panel_GetProgressBarColorForString(rightname);
                                        HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
                                DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, HUD_Get_Num_Color(rightcnt, 200), 1);
@@ -2453,7 +2497,7 @@ void HUD_HealthArmor(void)
                                        barpos = pos;
                                        barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
                                }
-                               HUD_Panel_GetProgressBarColor("fuel")
+                               HUD_Panel_GetProgressBarColor(fuel);
                                HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                        }
                }
@@ -2479,7 +2523,7 @@ void HUD_HealthArmor(void)
 
                                if(autocvar_hud_panel_healtharmor_progressbar)
                                {
-                                       HUD_Panel_GetProgressBarColor(leftname)
+                                       HUD_Panel_GetProgressBarColorForString(leftname);
                                        HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
                                drawpic_aspect_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -2506,7 +2550,7 @@ void HUD_HealthArmor(void)
 
                                if(autocvar_hud_panel_healtharmor_progressbar)
                                {
-                                       HUD_Panel_GetProgressBarColor(rightname)
+                                       HUD_Panel_GetProgressBarColorForString(rightname);
                                        HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
                                drawpic_aspect_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -2522,7 +2566,7 @@ void HUD_HealthArmor(void)
                                        barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
                                        barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
                                }
-                               HUD_Panel_GetProgressBarColor("fuel")
+                               HUD_Panel_GetProgressBarColor(fuel);
                                HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, panel_fg_alpha * 0.8, DRAWFLAG_NORMAL);
                        }
                }
@@ -2591,41 +2635,41 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                        if (alsoprint)
                                print("^1", sprintf(Weapon_SuicideMessage(type), strcat(s1, "^1")), "\n");
                } else if (type == DEATH_KILL) {
-                       HUD_KillNotify_Push(s1, "", 0, DEATH_KILL, s1));
+                       HUD_KillNotify_Push(s1, "", 0, DEATH_KILL);
                        if (alsoprint)
-                               print(sprintf("^1%s^1 couldn't take it anymore\n", s1));
+                               print ("^1",s1, "^1 couldn't take it anymore\n");
                } else if (type == DEATH_ROT) {
-                       HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC, s1));
+                       HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
                        if (alsoprint)
-                               print(sprintf("^1%s^1 died\n", s1));
+                               print ("^1",s1, "^1 died\n");
                } else if (type == DEATH_NOAMMO) {
-                       HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO, s1));
+                       HUD_KillNotify_Push(s1, "", 0, DEATH_NOAMMO);
                        if (alsoprint)
-                               print(sprintf("^7%s^7 committed suicide. What's the point of living without ammo?\n", s1));
+                               print ("^7",s1, "^7 committed suicide. What's the point of living without ammo?\n");
                } else if (type == DEATH_CAMP) {
-                       HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP, s1));
+                       HUD_KillNotify_Push(s1, "", 0, DEATH_CAMP);
                        if (alsoprint)
-                               print(sprintf("^1%s^1 thought they found a nice camping ground\n", s1));
+                               print ("^1",s1, "^1 thought they found a nice camping ground\n");
                } else if (type == KILL_TEAM_RED || type == KILL_TEAM_BLUE) {
-                       HUD_KillNotify_Push(s1, "", 0, type, s1));
+                       HUD_KillNotify_Push(s1, "", 0, type);
                        if (alsoprint)
-                               print(sprintf("^1%s^1 didn't become friends with the Lord of Teamplay\n", s1));
+                               print ("^1",s1, "^1 didn't become friends with the Lord of Teamplay\n");
                } else if (type == DEATH_CHEAT) {
-                       HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC, s1));
+                       HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
                        if (alsoprint)
-                               print(sprintf("^1%s^1 unfairly eliminated themself\n", s1));
+                               print ("^1",s1, "^1 unfairly eliminated themself\n");
                } else if (type == DEATH_FIRE) {
-                       HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC, s1));
+                       HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
                        if (alsoprint)
-                               print(sprintf("^1%s^1 burned to death\n", s1));
+                               print ("^1",s1, "^1 burned to death\n");
                } else if (type != DEATH_TEAMCHANGE && type != DEATH_QUIET) {
-                       HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC, s1));
+                       HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
                        if (alsoprint)
-                               print(sprintf("^1%s^1 couldn't resist the urge to self-destruct\n", s1));
+                               print ("^1",s1, "^1 couldn't resist the urge to self-destruct\n");
                } 
                
                if (stof(s2) > 2) // killcount > 2
-                       print(sprintf("^1%s^1 ended it all after a %s kill spree\n", s1, s2));
+                       print ("^1",s1,"^1 ended it all after a ",s2," kill spree\n");
        } else if(msg == MSG_KILL) {
                w = DEATH_WEAPONOF(type);
                if(WEP_VALID(w)) {
@@ -2638,9 +2682,9 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                        if(alsoprint)
                        {
                                if(gentle) {
-                                       print(sprintf("^1%s^1 took action against a team mate\n", s1));
+                                       print ("^1", s1, "^1 took action against a team mate\n");
                                } else {
-                                       print(sprintf("^1%s^1 mows down a team mate\n", s1));
+                                       print ("^1", s1, "^1 mows down a team mate\n");
                                }
                        }
                        if (stof(s2) > 2 && type == KILL_TEAM_SPREE) {
@@ -2747,7 +2791,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)
@@ -2852,11 +2900,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)
@@ -3735,16 +3783,10 @@ void HUD_VoteWindow(void)
        if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
                return;
 
-       active_panel = HUD_PANEL_VOTE;
-       HUD_Panel_UpdateCvars(vote);
-       vector pos, mySize;
-       pos = panel_pos;
-       mySize = panel_size;
-
        if(!autocvar__hud_configure)
        {
                panel_fg_alpha = autocvar_hud_panel_fg_alpha;
-               panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
+               panel_bg_alpha_str = cvar_string("hud_panel_vote_bg_alpha");
 
                if(panel_bg_alpha_str == "") {
                        panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
@@ -3774,9 +3816,16 @@ void HUD_VoteWindow(void)
        if(!vote_alpha)
                return;
 
-       a = panel_bg_alpha * vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
+       active_panel = HUD_PANEL_VOTE;
+       HUD_Panel_UpdateCvars(vote);
+       vector pos, mySize;
+       pos = panel_pos;
+       mySize = panel_size;
+
+       a = vote_alpha * bound(cvar("hud_panel_vote_alreadyvoted_alpha"), 1 - vote_highlighted, 1);
        HUD_Panel_DrawBg(a);
-       a = panel_fg_alpha * vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
+       a = panel_fg_alpha * a;
+
        if(panel_bg_padding)
        {
                pos += '1 1 0' * panel_bg_padding;
@@ -3809,9 +3858,9 @@ void HUD_VoteWindow(void)
        drawcolorcodedstring_aspect(pos + eY * (2/8) * mySize_y, s, eX * mySize_x + eY * (1.75/8) * mySize_y, a, DRAWFLAG_NORMAL);
 
        // print the yes/no counts
-       s = strcat("Yes (", getcommandkey("not bound", "vyes"), "): ", ftos(vote_yescount));
+       s = strcat("Yes (", getcommandkey("vyes", "vyes"), "): ", ftos(vote_yescount));
        drawstring_aspect(pos + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '0 1 0', a, DRAWFLAG_NORMAL);
-       s = strcat("No (", getcommandkey("not bound", "vno"), "): ", ftos(vote_nocount));
+       s = strcat("No (", getcommandkey("vno", "vno"), "): ", ftos(vote_nocount));
        drawstring_aspect(pos + eX * 0.5 * mySize_x + eY * (4/8) * mySize_y, s, eX * 0.5 * mySize_x + eY * (1.5/8) * mySize_y, '1 0 0', a, DRAWFLAG_NORMAL);
 
        // draw the progress bar backgrounds
@@ -3846,6 +3895,37 @@ void HUD_VoteWindow(void)
 
 float mod_active; // is there any active mod icon?
 
+// Clan Arena HUD modicons
+void HUD_Mod_CA(vector pos, vector mySize)
+{
+       mod_active = 1; // CA should never hide the mod icons panel
+       float redalive, bluealive;
+       redalive = getstati(STAT_REDALIVE);
+       bluealive = getstati(STAT_BLUEALIVE);
+
+       drawfont = hud_bigfont;
+       vector redpos, bluepos;
+       if(mySize_x > mySize_y)
+       {
+               redpos = pos;
+               bluepos = pos + eY * 0.5 * mySize_y;
+               drawpic_aspect_skin(redpos, "player_red.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(redpos + eX * 0.5 * mySize_x, ftos(redalive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(bluepos, "player_blue.tga", 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(bluepos + eX * 0.5 * mySize_x, ftos(bluealive), 0.5 * mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       }
+       else
+       {
+               redpos = pos;
+               bluepos = pos + eY * 0.5 * mySize_y;
+               drawpic_aspect_skin(redpos, "player_red.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(redpos + eY * 0.3 * mySize_y, ftos(redalive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(bluepos, "player_blue.tga", eX * mySize_x + eY * 0.3 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+               drawstring_aspect(bluepos + eY * 0.3 * mySize_y, ftos(bluealive), eX * mySize_x + eY * 0.2 * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+       }
+       drawfont = hud_font;
+}
+
 // CTF HUD modicon section
 float redflag_prevframe, blueflag_prevframe; // status during previous frame
 float redflag_prevstatus, blueflag_prevstatus; // last remembered status
@@ -4177,7 +4257,7 @@ void HUD_Mod_NexBall(vector pos, vector mySize)
                        barsize = eX * mySize_x + eY * p * mySize_y;
                        vertical = 1;
                }
-               HUD_Panel_GetProgressBarColor("nexball")
+               HUD_Panel_GetProgressBarColor(nexball);
                HUD_Panel_DrawProgressBar(pos, vertical, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
 
@@ -4230,16 +4310,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
@@ -4251,13 +4346,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) {
@@ -4268,13 +4363,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)
@@ -4283,27 +4377,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) {
@@ -4328,7 +4422,7 @@ void HUD_ModIcons(void)
        if(!autocvar_hud_panel_modicons && !autocvar__hud_configure)
                return;
 
-       if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && !autocvar__hud_configure)
+       if (gametype != GAME_KEYHUNT && gametype != GAME_CTF && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && !autocvar__hud_configure)
                return;
 
        active_panel = HUD_PANEL_MODICONS;
@@ -4365,6 +4459,8 @@ void HUD_ModIcons(void)
                HUD_Mod_NexBall(pos, mySize);
        else if(gametype == GAME_CTS || gametype == GAME_RACE)
                HUD_Mod_Race(pos, mySize);
+       else if(gametype == GAME_CA)
+               HUD_Mod_CA(pos, mySize);
 }
 
 // Draw pressed keys (#11)
@@ -4391,19 +4487,20 @@ void HUD_DrawPressedKeys(void)
        }
 
        // force custom aspect
-       if(autocvar_hud_panel_pressedkeys_aspect)
+       float aspect = cvar("hud_panel_pressedkeys_aspect");
+       if(aspect)
        {
                vector newSize;
-               if(mySize_x/mySize_y > autocvar_hud_panel_pressedkeys_aspect)
+               if(mySize_x/mySize_y > aspect)
                {
-                       newSize_x = autocvar_hud_panel_pressedkeys_aspect * mySize_y;
+                       newSize_x = aspect * mySize_y;
                        newSize_y = mySize_y;
 
                        pos_x = pos_x + (mySize_x - newSize_x) / 2;
                }
                else
                {
-                       newSize_y = 1/autocvar_hud_panel_pressedkeys_aspect * mySize_x;
+                       newSize_y = 1/aspect * mySize_x;
                        newSize_x = mySize_x;
 
                        pos_y = pos_y + (mySize_y - newSize_y) / 2;
@@ -4517,29 +4614,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;
                }
        }
 
@@ -4552,6 +4652,11 @@ void HUD_EngineInfo(void)
 
 // Info messages panel (#14)
 //
+#define drawInfoMessage(s)\
+       if(autocvar_hud_panel_infomessages_flip)\
+               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize);\
+       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);\
+       o_y += fontsize_y;
 void HUD_InfoMessages(void)
 {
        if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
@@ -4610,35 +4715,22 @@ void HUD_InfoMessages(void)
                                s = "^1Observing";
                        else
                                s = strcat("^1Spectating: ^7", GetPlayerName(spectatee_status - 1));
-
-                       if(autocvar_hud_panel_infomessages_flip)
-                               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-                       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                       o += eY * fontsize_y;
+                       drawInfoMessage(s)
 
                        if(spectatee_status == -1)
-                               s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 to spectate");
+                               s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 to spectate");
                        else
-                               s = strcat("^1Press ^3", getcommandkey("primary fire", "+attack"), "^1 for another player");
-                       if(autocvar_hud_panel_infomessages_flip)
-                               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-                       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                       o += eY * fontsize_y;
+                               s = strcat("^1Press ^3", getcommandkey("primary fire", "+fire"), "^1 for another player");
+                       drawInfoMessage(s)
 
                        if(spectatee_status == -1)
                                s = strcat("^1Use ^3", getcommandkey("next weapon", "weapnext"), "^1 or ^3", getcommandkey("previous weapon", "weapprev"), "^1 to change the speed");
                        else
-                               s = strcat("^1Press ^3", getcommandkey("secondary fire", "+attack2"), "^1 to observe");
-                       if(autocvar_hud_panel_infomessages_flip)
-                               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-                       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                       o += eY * fontsize_y;
+                               s = strcat("^1Press ^3", getcommandkey("secondary fire", "+fire2"), "^1 to observe");
+                       drawInfoMessage(s)
 
                        s = strcat("^1Press ^3", getcommandkey("server info", "+show_info"), "^1 for gamemode info");
-                       if(autocvar_hud_panel_infomessages_flip)
-                               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-                       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                       o += eY * fontsize_y;
+                       drawInfoMessage(s)
 
                        if(gametype == GAME_ARENA)
                                s = "^1Wait for your turn to join";
@@ -4655,10 +4747,7 @@ void HUD_InfoMessages(void)
                        }
                        else
                                s = strcat("^1Press ^3", getcommandkey("jump", "+jump"), "^1 to join");
-                       if(autocvar_hud_panel_infomessages_flip)
-                               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-                       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                       o += eY * fontsize_y;
+                       drawInfoMessage(s)
 
                        //show restart countdown:
                        if (time < getstatf(STAT_GAMESTARTTIME)) {
@@ -4667,16 +4756,13 @@ void HUD_InfoMessages(void)
                                countdown = ceil(getstatf(STAT_GAMESTARTTIME) - time);
                                s = strcat("^1Game starts in ^3", ftos(countdown), "^1 seconds");
                                drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                               o += eY * fontsize_y;
+                               o_y += fontsize_y;
                        }
                }
                if(warmup_stage && !intermission)
                {
                        s = "^2Currently in ^1warmup^2 stage!";
-                       if(autocvar_hud_panel_infomessages_flip)
-                               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-                       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                       o += eY * fontsize_y;
+                       drawInfoMessage(s)
                }
 
                string blinkcolor;
@@ -4701,18 +4787,12 @@ void HUD_InfoMessages(void)
                                else
                                        s = strcat("^2Waiting for others to ready up...");
                        }
-                       if(autocvar_hud_panel_infomessages_flip)
-                               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-                       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                       o += eY * fontsize_y;
+                       drawInfoMessage(s)
                }
                else if(warmup_stage && !intermission && !spectatee_status)
                {
                        s = strcat("^2Press ^3", getcommandkey("ready", "ready"), "^2 to end warmup");
-                       if(autocvar_hud_panel_infomessages_flip)
-                               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-                       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                       o += eY * fontsize_y;
+                       drawInfoMessage(s)
                }
 
                if(teamplay && !intermission && !spectatee_status && gametype != GAME_CA && teamnagger)
@@ -4738,11 +4818,7 @@ void HUD_InfoMessages(void)
                                        if (tm.team != COLOR_SPECTATOR)
                                        if (tm.team_size == ts_max)
                                                s = strcat(s, " Press ^3", getcommandkey("team menu", "menu_showteamselect"), blinkcolor, " to adjust");
-
-                                       if(autocvar_hud_panel_infomessages_flip)
-                                               o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-                                       drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-                                       o += eY * fontsize_y;
+                                       drawInfoMessage(s)
                                }
                        }
                }
@@ -4750,25 +4826,13 @@ void HUD_InfoMessages(void)
        else 
        {
                s = "^7Press ^3ESC ^7to show HUD options.";
-               if(autocvar_hud_panel_infomessages_flip)
-                       o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-               drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-               o += eY * fontsize_y;
+               drawInfoMessage(s)
                s = "^3Doubleclick ^7a panel for panel-specific options.";
-               if(autocvar_hud_panel_infomessages_flip)
-                       o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-               drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-               o += eY * fontsize_y;
+               drawInfoMessage(s)
                s = "^3CTRL ^7to disable collision testing, ^3SHIFT ^7and";
-               if(autocvar_hud_panel_infomessages_flip)
-                       o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-               drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-               o += eY * fontsize_y;
+               drawInfoMessage(s)
                s = "^3ALT ^7+ ^3ARROW KEYS ^7for fine adjustments.";
-               if(autocvar_hud_panel_infomessages_flip)
-                       o_x = pos_x + mySize_x - stringwidth(s, TRUE, fontsize); 
-               drawcolorcodedstring(o, s, fontsize, a, DRAWFLAG_NORMAL);
-               o += eY * fontsize_y;
+               drawInfoMessage(s)
        }
 }
 
@@ -4819,11 +4883,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;
@@ -4851,6 +4915,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;
 
@@ -4860,18 +4926,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)
@@ -4915,14 +4979,12 @@ switch (id) {\
                HUD_EngineInfo(); break;\
        case (HUD_PANEL_INFOMESSAGES):\
                 HUD_InfoMessages(); break;\
-}
+} ENDS_WITH_CURLY_BRACE
 
 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);
@@ -4935,13 +4997,18 @@ 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
+       if (hud_skin_path != cvar_string("hud_skin"))
+       {
+               if (hud_skin_path)
+                       strunzone(hud_skin_path);
+               hud_skin_path = strzone(strcat("gfx/hud/", cvar_string("hud_skin")));
+       }
 
        // HUD configure visible grid
        if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
@@ -4959,29 +5026,34 @@ 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;
+               float hud_dock_color_team = cvar("hud_dock_color_team");
+               if((teamplay) && hud_dock_color_team) {
+                       f = stof(getplayerkey(player_localentnum - 1, "colors"));
+                       color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
+               }
+               else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
+                       color = '1 0 0' * hud_dock_color_team;
+               }
+               else
+               {
+                       string hud_dock_color = cvar_string("hud_dock_color");
+                       if(hud_dock_color == "shirt") {
+                               f = stof(getplayerkey(player_localentnum - 1, "colors"));
+                               color = colormapPaletteColor(floor(f / 16), 0);
+                       }
+                       else if(hud_dock_color == "pants") {
+                               f = stof(getplayerkey(player_localentnum - 1, "colors"));
+                               color = colormapPaletteColor(mod(f, 16), 1);
+                       }
+                       else
+                               color = stov(hud_dock_color);
+               }
+
                string pic;
                pic = strcat(hud_skin_path, "/", autocvar_hud_dock);
                if(precache_pic(pic) == "") {
@@ -4990,7 +5062,7 @@ void HUD_Main (void)
                                pic = "gfx/hud/default/dock_medium";
                        }
                }
-               drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, autocvar_hud_dock_alpha * hud_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
+               drawpic('0 0 0', pic, eX * vid_conwidth + eY * vid_conheight, color, cvar("hud_dock_alpha") * hud_fade_alpha, DRAWFLAG_NORMAL); // no aspect ratio forcing on dock...
        }
 
        // cache the panel order into the panel_order array
@@ -5011,7 +5083,7 @@ void HUD_Main (void)
 
        // draw chat panel on top if it is maximized
        if(autocvar__con_chat_maximized)
-               HUD_DrawPanel(HUD_PANEL_CHAT);
+               HUD_Chat(); // HUD_DrawPanel(HUD_PANEL_CHAT);
 
        // TODO hud_'ify these
        if (cvar("cl_showspeed"))
@@ -5025,5 +5097,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;
 }