]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Merge branch 'master' into terencehill/newpanelhud
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 6930cb2fd078f0a23ca7b00c65a080218af78a2f..e8a8250e6c782ed58008e2d507ee8369274e9648 100644 (file)
@@ -151,7 +151,7 @@ void centerprint(string strMessage)
 
        centerprint_expire = min(centerprint_expire, time); // if any of the returns happens, this message will fade out
 
-       if(cvar("scr_centertime") <= 0)
+       if(autocvar_scr_centertime <= 0)
                return;
 
        if(strMessage == "")
@@ -210,8 +210,8 @@ void centerprint(string strMessage)
        h = centerprint_fontsize_y*hcount;
 
        havail = vid_conheight;
-       if(cvar("con_chatpos") < 0)
-               havail -= (-cvar("con_chatpos") + cvar("con_chat")) * cvar("con_chatsize"); // avoid overlapping chat
+       if(autocvar_con_chatpos < 0)
+               havail -= (-autocvar_con_chatpos + autocvar_con_chat) * autocvar_con_chatsize; // avoid overlapping chat
        if(havail > vid_conheight - 70)
                havail = vid_conheight - 70; // avoid overlapping HUD
 
@@ -269,7 +269,7 @@ void centerprint(string strMessage)
 
        centerprint_num = i;
 
-       centerprint_expire = time + cvar("scr_centertime");
+       centerprint_expire = time + autocvar_scr_centertime;
 }
 
 void HUD_DrawCenterPrint (void)
@@ -289,7 +289,7 @@ void HUD_DrawCenterPrint (void)
 
        sz = 0.8 + (a / 5);
 
-       if(centerprint_num * cvar("scr_centersize") > 24 && scoreboard_active) // 24 = height of Scoreboard text
+       if(centerprint_num * autocvar_scr_centersize > 24 && scoreboard_active) // 24 = height of Scoreboard text
                centerprint_start_y = scoreboard_bottom + centerprint_fontsize_y;
 
        pos = centerprint_start;
@@ -427,7 +427,7 @@ HUD panels
 void HUD_Panel_ExportCfg(string cfgname)
 {
        float fh;
-       string filename = strcat("hud_", cvar_string("hud_skin"), "_", cfgname, ".cfg");
+       string filename = strcat("hud_", autocvar_hud_skin, "_", cfgname, ".cfg");
        fh = fopen(filename, FILE_WRITE);
        if(fh >= 0)
        {
@@ -492,12 +492,15 @@ void HUD_Panel_ExportCfg(string cfgname)
                                        HUD_Write_PanelCvar_q("_ammo_color");
                                        HUD_Write_PanelCvar_q("_ammo_alpha");
                                        HUD_Write_PanelCvar_q("_aspect");
+                                       HUD_Write_PanelCvar_q("_timeout");
+                                       HUD_Write_PanelCvar_q("_timeout_effect");
                                        break;
                                case HUD_PANEL_AMMO:
                                        HUD_Write_PanelCvar_q("_onlycurrent");
                                        HUD_Write_PanelCvar_q("_iconalign");
                                        HUD_Write_PanelCvar_q("_progressbar");
                                        HUD_Write_PanelCvar_q("_progressbar_name");
+                                       HUD_Write_PanelCvar_q("_progressbar_xoffset");
                                        HUD_Write_PanelCvar_q("_text");
                                        break;
                                case HUD_PANEL_POWERUPS:
@@ -566,7 +569,7 @@ void HUD_Panel_HlBorder(float myBorder, vector color, float alpha)
 #define HUD_Panel_DrawBg(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)\
+if(highlightedPanel_prev == hud_configure_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);\
 } ENDS_WITH_CURLY_BRACE
@@ -663,15 +666,10 @@ void HUD_Panel_DrawHighlight(vector pos, vector mySize, vector color, float alph
 vector HUD_Panel_CheckMove(vector myPos, vector mySize)
 {
        float i;
-
+       float myCenter_x, myCenter_y, targCenter_x, targCenter_y;
        vector myTarget;
        myTarget = myPos;
 
-       vector myCenter;
-       vector targCenter;
-       myCenter = '0 0 0'; // shut up fteqcc, there IS a reference
-       targCenter = '0 0 0'; // shut up fteqcc, there IS a reference
-
        for (i = 0; i < HUD_PANEL_NUM; ++i) {
                if(i == highlightedPanel || !panel_enabled)
                        continue;
@@ -743,7 +741,7 @@ void HUD_Panel_SetPos(vector pos)
        //if(cvar("hud_configure_checkcollisions_debug"))
                //drawfill(pos, mySize, '1 1 1', .2, DRAWFLAG_NORMAL);
 
-       if(cvar("hud_configure_grid"))
+       if(autocvar_hud_configure_grid)
        {
                pos_x = floor((pos_x/vid_conwidth)/hud_configure_gridSize_x + 0.5) * hud_configure_realGridSize_x;
                pos_y = floor((pos_y/vid_conheight)/hud_configure_gridSize_y + 0.5) * hud_configure_realGridSize_y;
@@ -804,7 +802,7 @@ vector HUD_Panel_CheckResize(vector mySize, vector resizeorigin) {
                        // (which side the resize direction finds for first) and reduce the size up to there
                        //
                        // dist is the distance between resizeorigin and the "analogous" point of the panel
-                       // in this case resizeorigin (bottom-right point) and the bottom-right point of the panel
+                       // in this case between resizeorigin (bottom-right point) and the bottom-right point of the panel
                        dist_x = resizeorigin_x - targEndPos_x;
                        dist_y = resizeorigin_y - targEndPos_y;
                        if (dist_y <= 0 || dist_x / dist_y > ratio)
@@ -886,8 +884,8 @@ void HUD_Panel_SetPosSize(vector mySize)
 
        if(highlightedPanel == HUD_PANEL_CHAT) // some panels have their own restrictions, like the chat panel (which actually only moves the engine chat print around). Looks bad if it's too small.
        {
-               mySize_x = max(17 * cvar("con_chatsize"), mySize_x);
-               mySize_y = max(2 * cvar("con_chatsize") + 2 * panel_bg_padding, mySize_y);
+               mySize_x = max(17 * autocvar_con_chatsize, mySize_x);
+               mySize_y = max(2 * autocvar_con_chatsize + 2 * panel_bg_padding, mySize_y);
        }
 
        // collision testing|
@@ -924,7 +922,7 @@ void HUD_Panel_SetPosSize(vector mySize)
                //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(cvar("hud_configure_grid"))
+       if(autocvar_hud_configure_grid)
        {
                mySize_x = floor((mySize_x/vid_conwidth)/hud_configure_gridSize_x + 0.5) * hud_configure_realGridSize_x;
                mySize_y = floor((mySize_y/vid_conheight)/hud_configure_gridSize_y + 0.5) * hud_configure_realGridSize_y;
@@ -975,10 +973,10 @@ void HUD_Panel_Arrow_Action(float nPrimary)
        if (highlightedPanel_prev == -1 || mouseClicked)
                return;
 
-       hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
+       hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
 
        float step;
-       if(cvar("hud_configure_grid"))
+       if(autocvar_hud_configure_grid)
        {
                if (nPrimary == K_UPARROW || nPrimary == K_DOWNARROW)
                {
@@ -1080,6 +1078,17 @@ void HUD_Panel_Arrow_Action(float nPrimary)
        }
 }
 
+void HUD_Panel_EnableMenu();
+float tab_panels[HUD_PANEL_NUM];
+float tab_panel, tab_backward;
+vector tab_panel_pos;
+void HUD_Panel_FirstInDrawQ(float id);
+void reset_tab_panels()
+{
+       int i;
+       for(i = 0; i < HUD_PANEL_NUM; ++i)
+               tab_panels[i] = -1;
+}
 float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 {
        string s;
@@ -1111,6 +1120,22 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
        }
 
+       if(nPrimary == K_CTRL)
+       {
+               if (bInputType == 1) //ctrl has been released
+               {
+                       if (tab_panel != -1)
+                       {
+                               //switch to selected panel
+                               highlightedPanel = tab_panel;
+                               highlightedPanel_prev = tab_panel;
+                               HUD_Panel_FirstInDrawQ(highlightedPanel_prev);
+                       }
+                       tab_panel = -1;
+                       reset_tab_panels();
+               }
+       }
+
        if(nPrimary == K_MOUSE1)
        {
                if(bInputType == 0) { // key pressed
@@ -1130,13 +1155,100 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                menu_enabled_time = time;
                localcmd("menu_showhudexit\n");
        }
+       else if(nPrimary == K_TAB && hudShiftState & S_CTRL) // select and highlight another panel
+       {
+               if (bInputType == 1 || mouseClicked)
+                       return true;
+
+               //FIXME: if a panel is highlighted, has the same pos_x and lays in the same level
+               //of other panels then next consecutive ctrl-tab will select the highlighted panel too
+               //(it should only after every other panel of the hud)
+               //It's a minor bug anyway, we can live with it
+
+               float starting_panel;
+               float old_tab_panel = tab_panel;
+               if (tab_panel == -1) //first press of TAB
+               {
+                       if (highlightedPanel_prev != -1)
+                               HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev)
+                       else
+                               panel_pos = '0 0 0';
+                       starting_panel = highlightedPanel_prev; //can be -1, it means no starting panel
+                       tab_panel_pos = panel_pos; //to compute level
+               }
+               else
+               {
+                       if ( ((!tab_backward) && (hudShiftState & S_SHIFT)) || (tab_backward && !(hudShiftState & S_SHIFT)) ) //tab direction changed?
+                               reset_tab_panels();
+                       starting_panel = tab_panel;
+               }
+               tab_backward = (hudShiftState & S_SHIFT);
+
+               float k, level, start_pos_x;
+               vector candidate_pos;
+               const float LEVELS_NUM = 4;
+               const float level_height = vid_conheight / LEVELS_NUM;
+:find_tab_panel
+               level = floor(tab_panel_pos_y / level_height) * level_height; //starting level
+               candidate_pos_x = (!tab_backward) ? vid_conwidth : 0;
+               start_pos_x = tab_panel_pos_x;
+               tab_panel = -1;
+               k=0;
+               while(++k)
+               {
+                       for(i = 0; i < HUD_PANEL_NUM; ++i)
+                       {
+                               if (i == tab_panels[i] || i == starting_panel)
+                                       continue;
+                               HUD_Panel_UpdatePosSizeForId(i)
+                               if (panel_pos_y >= level && (panel_pos_y - level) < level_height)
+                               if (  ( !tab_backward && panel_pos_x >= start_pos_x && (panel_pos_x < candidate_pos_x || (panel_pos_x == candidate_pos_x && panel_pos_y <= candidate_pos_y)) )
+                                       || ( tab_backward && panel_pos_x <= start_pos_x && (panel_pos_x > candidate_pos_x || (panel_pos_x == candidate_pos_x && panel_pos_y >= candidate_pos_y)) )  )
+                               {
+                                       tab_panel = i;
+                                       tab_panel_pos = candidate_pos = panel_pos;
+                               }
+                       }
+                       if (tab_panel != -1)
+                               break;
+                       if (k == LEVELS_NUM) //tab_panel not found
+                       {
+                               reset_tab_panels();
+                               if (old_tab_panel == -2) //this prevents an infinite loop (should not happen normally)
+                               {
+                                       tab_panel = -1;
+                                       return true;
+                               }
+                               starting_panel = old_tab_panel;
+                               old_tab_panel = -2;
+                               goto find_tab_panel; //u must find tab_panel!
+                       }
+                       if (!tab_backward)
+                       {
+                               level = mod(level + level_height, vid_conheight);
+                               start_pos_x = 0;
+                               candidate_pos_x = vid_conwidth;
+                       }
+                       else
+                       {
+                               level = mod(level - level_height, vid_conheight);
+                               start_pos_x = vid_conwidth;
+                               candidate_pos_x = 0;
+                       }
+               }
+
+               tab_panels[tab_panel] = tab_panel;
+       }
        else if(nPrimary == K_SPACE && hudShiftState & S_CTRL) // enable/disable highlighted panel or dock
        {
                if (bInputType == 1 || mouseClicked)
                        return true;
 
                if (highlightedPanel_prev != -1)
+               {
+                       HUD_Panel_GetName(highlightedPanel_prev);
                        cvar_set(strcat("hud_panel_", panel_name), ftos(!(panel_enabled)));
+               }
                else
                        cvar_set(strcat("hud_dock"), (autocvar_hud_dock == "") ? "dock" : "");
        }
@@ -1147,6 +1259,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 
                if (highlightedPanel_prev != -1)
                {
+                       HUD_Panel_UpdatePosSizeForId(highlightedPanel_prev);
                        panel_size_copied = panel_size;
                        highlightedPanel_copied = highlightedPanel_prev;
                }
@@ -1177,6 +1290,7 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
                highlightedPanel_backup = highlightedPanel_prev;
 
                s = strcat(ftos(tmp_size_x/vid_conwidth), " ", ftos(tmp_size_y/vid_conheight));
+               HUD_Panel_GetName(highlightedPanel_prev);
                cvar_set(strcat("hud_panel_", panel_name, "_size"), s);
        }
        else if(nPrimary == 'z' && hudShiftState & S_CTRL) // undo last action
@@ -1206,10 +1320,20 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
 
                HUD_Panel_Arrow_Action(nPrimary); //move or resize panel
        }
+       else if(nPrimary == K_ENTER || nPrimary == K_SPACE || nPrimary == K_KP_ENTER)
+       {
+               if (bInputType == 1)
+                       return true;
+               if (highlightedPanel_prev != -1)
+               {
+                       highlightedPanel = highlightedPanel_prev;
+                       HUD_Panel_EnableMenu();
+               }
+       }
        else if(hit_con_bind)
                return false;
 
-       return true; // Suppress ALL other input
+       return true;
 }
 
 float HUD_Panel_HighlightCheck()
@@ -1367,6 +1491,13 @@ void HUD_Panel_Highlight()
        }
 }
 
+void HUD_Panel_EnableMenu()
+{
+       menu_enabled = 2;
+       menu_enabled_time = time;
+       HUD_Panel_GetName(highlightedPanel);
+       localcmd("menu_showhudoptions ", panel_name, "\n");
+}
 float highlightcheck;
 vector prev_pos, prev_size;
 void HUD_Panel_Mouse()
@@ -1378,7 +1509,7 @@ void HUD_Panel_Mouse()
        /*
        print("menu_enabled: ", ftos(menu_enabled), "\n");
        print("Highlighted: ", ftos(highlightedPanel), "\n");
-       print("Menu alpha: ", cvar_string("_menu_alpha"), "\n");
+       print("Menu alpha: ", ftos(autocvar__menu_alpha), "\n");
        */
 
        // instantly hide the editor cursor if we open the HUDExit dialog
@@ -1394,13 +1525,19 @@ void HUD_Panel_Mouse()
        if(highlightedPanel != -1)
                highlightedPanel_prev = highlightedPanel;
 
-       mousepos = mousepos + getmousepos() * cvar("menu_mouse_speed");
+       mousepos = mousepos + getmousepos() * autocvar_menu_mouse_speed;
 
        mousepos_x = bound(0, mousepos_x, vid_conwidth);
        mousepos_y = bound(0, mousepos_y, vid_conheight);
 
        if(mouseClicked)
        {
+               if (tab_panel != -1)
+               {
+                       //stop ctrl-tab selection
+                       tab_panel = -1;
+                       reset_tab_panels();
+               }
                if(prevMouseClicked == 0)
                {
                        HUD_Panel_Highlight(); // sets highlightedPanel, highlightedAction, panel_click_distance, panel_click_resizeorigin
@@ -1413,7 +1550,7 @@ void HUD_Panel_Mouse()
 
                if (prev_pos != panel_pos || prev_size != panel_size)
                {
-                       hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && cvar("hud_configure_checkcollisions"));
+                       hud_configure_checkcollisions = (!(hudShiftState & S_CTRL) && autocvar_hud_configure_checkcollisions);
                        // backup!
                        panel_pos_backup = prev_pos;
                        panel_size_backup = prev_size;
@@ -1450,10 +1587,7 @@ void HUD_Panel_Mouse()
                if(time - prevMouseClickedTime < 0.4 && prevMouseClicked == 0 && prevMouseClickedPos == mousepos && highlightedPanel >= 0)
                {
                        mouseClicked = 0; // to prevent spam, I guess.
-                       menu_enabled = 2;
-                       menu_enabled_time = time;
-                       HUD_Panel_GetName(highlightedPanel);
-                       localcmd("menu_showhudoptions ", panel_name, "\n");
+                       HUD_Panel_EnableMenu();
                        return;
                }
                if(prevMouseClicked == 0)
@@ -1471,13 +1605,13 @@ void HUD_Panel_Mouse()
        cursorsize = '32 32 0';
 
        if(highlightcheck == 0)
-               drawpic(mousepos, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
+               drawpic(mousepos, strcat("gfx/menu/", autocvar_menu_skin, "/cursor.tga"), cursorsize, '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"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
+               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_move.tga"), cursorsize, '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"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
+               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
        else
-               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", cvar_string("menu_skin"), "/cursor_resize2.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
+               drawpic(mousepos - cursorsize * 0.5, strcat("gfx/menu/", autocvar_menu_skin, "/cursor_resize2.tga"), cursorsize, '1 1 1', hud_fade_alpha, DRAWFLAG_NORMAL);
 
        prevMouseClicked = mouseClicked;
 }
@@ -1554,10 +1688,12 @@ void HUD_Weapons(void)
                if(!autocvar_hud_panel_weapons) return;
                if(spectatee_status == -1) return;
        }
+       else
+               hud_configure_active_panel = HUD_PANEL_WEAPONS;
 
-       float timeout = cvar("hud_panel_weapons_timeout");
+       float timeout = autocvar_hud_panel_weapons_timeout;
        float timeout_effect_length, timein_effect_length;
-       if (cvar("hud_panel_weapons_timeout_effect") == 0)
+       if (autocvar_hud_panel_weapons_timeout_effect == 0)
        {
                timeout_effect_length = 0;
                timein_effect_length = 0;
@@ -1574,18 +1710,17 @@ void HUD_Weapons(void)
                return;
        }
 
-       active_panel = HUD_PANEL_WEAPONS;
        HUD_Panel_UpdateCvars(weapons);
 
        if (timeout && time >= weapontime + timeout && !autocvar__hud_configure)
        {
                f = (time - (weapontime + timeout)) / timeout_effect_length;
-               if (cvar("hud_panel_weapons_timeout_effect"))
+               if (autocvar_hud_panel_weapons_timeout_effect)
                {
                        panel_bg_alpha *= (1 - f);
                        panel_fg_alpha *= (1 - f);
                }
-               if (cvar("hud_panel_weapons_timeout_effect") == 1)
+               if (autocvar_hud_panel_weapons_timeout_effect == 1)
                {
                        f *= f; // for a cooler movement
                        center_x = panel_pos_x + panel_size_x/2;
@@ -1611,12 +1746,12 @@ void HUD_Weapons(void)
        else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure)
        {
                f = (time - weaponprevtime) / timein_effect_length;
-               if (cvar("hud_panel_weapons_timeout_effect"))
+               if (autocvar_hud_panel_weapons_timeout_effect)
                {
                        panel_bg_alpha *= (f);
                        panel_fg_alpha *= (f);
                }
-               if (cvar("hud_panel_weapons_timeout_effect") == 1)
+               if (autocvar_hud_panel_weapons_timeout_effect == 1)
                {
                        f *= f; // for a cooler movement
                        f = 1 - f;
@@ -1650,14 +1785,14 @@ void HUD_Weapons(void)
        }
 
        // TODO make this configurable
-       if(weaponorder_bypriority != cvar_string("cl_weaponpriority"))
+       if(weaponorder_bypriority != autocvar_cl_weaponpriority)
        {
                if(weaponorder_bypriority)
                        strunzone(weaponorder_bypriority);
                if(weaponorder_byimpulse)
                        strunzone(weaponorder_byimpulse);
 
-               weaponorder_bypriority = strzone(cvar_string("cl_weaponpriority"));
+               weaponorder_bypriority = strzone(autocvar_cl_weaponpriority);
                weaponorder_byimpulse = strzone(W_FixWeaponOrder_BuildImpulseList(W_FixWeaponOrder_ForceComplete(W_NumberWeaponOrder(weaponorder_bypriority))));
                weaponorder_cmp_str = strcat(" ", weaponorder_byimpulse, " ");
 
@@ -1683,7 +1818,7 @@ void HUD_Weapons(void)
                panel_size -= '2 2 0' * panel_bg_padding;
        }
 
-       if(cvar_or("hud_panel_weapons_fade", 1))
+       if(autocvar_hud_panel_weapons_fade)
        {
                wpnalpha = 3.2 - 2 * (time - weapontime);
                wpnalpha = bound(0.7, wpnalpha, 1) * panel_fg_alpha;
@@ -1694,7 +1829,7 @@ void HUD_Weapons(void)
        HUD_Weapons_Clear();
 
        float rows, columns;
-       float aspect = cvar("hud_panel_weapons_aspect");
+       float aspect = autocvar_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);
 
@@ -1703,29 +1838,22 @@ void HUD_Weapons(void)
 
        float a, type, fullammo;
        float when;
-       when = cvar("hud_panel_weapons_complainbubble_time");
+       when = autocvar_hud_panel_weapons_complainbubble_time;
        float fadetime;
-       fadetime = cvar("hud_panel_weapons_complainbubble_fadetime");
+       fadetime = autocvar_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;
        wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows);
        float barsize_x, barsize_y, baroffset_x, baroffset_y;
-       float show_ammo = cvar("hud_panel_weapons_ammo");
-       if (show_ammo)
+       if (autocvar_hud_panel_weapons_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");
+               ammo_color = stov(autocvar_hud_panel_weapons_ammo_color);
+               ammo_alpha = panel_fg_alpha * autocvar_hud_panel_weapons_ammo_alpha;
 
 
                if(wpnsize_x/wpnsize_y > aspect)
@@ -1744,7 +1872,7 @@ void HUD_Weapons(void)
 
        float show_accuracy;
        float weapon_stats;
-       if(cvar("hud_panel_weapons_accuracy") && acc_levels)
+       if(autocvar_hud_panel_weapons_accuracy && acc_levels)
        {
                show_accuracy = true;
                if (acc_col_x[0] == -1)
@@ -1753,7 +1881,7 @@ void HUD_Weapons(void)
        }
 
        float weapons_st = getstati(STAT_WEAPONS);
-       float label = cvar("hud_panel_weapons_label");
+       float label = autocvar_hud_panel_weapons_label;
 
        for(i = 0; i < weapon_cnt; ++i)
        {
@@ -1799,7 +1927,7 @@ void HUD_Weapons(void)
                                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(show_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
+                       if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO)
                        {
                                a = 0;
                                type = GetAmmoTypeForWep(weapid);
@@ -1809,11 +1937,11 @@ void HUD_Weapons(void)
                                if(a > 0)
                                {
                                        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;
+                                               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;
                                        }
 
@@ -1835,7 +1963,7 @@ void HUD_Weapons(void)
                }
 
                // draw the complain message
-               if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && cvar("hud_panel_weapons_complainbubble"))
+               if(time - complain_weapon_time < when + fadetime && self.weapon == complain_weapon && autocvar_hud_panel_weapons_complainbubble)
                {
                        if(fadetime)
                        {
@@ -1855,17 +1983,17 @@ void HUD_Weapons(void)
                        string s;
                        if(complain_weapon_type == 0) {
                                s = "Out of ammo";
-                               color = stov(cvar_string("hud_panel_weapons_complainbubble_color_outofammo"));
+                               color = stov(autocvar_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"));
+                               color = stov(autocvar_hud_panel_weapons_complainbubble_color_donthave);
                        }
                        else {
                                s = "Unavailable";
-                               color = stov(cvar_string("hud_panel_weapons_complainbubble_color_unavailable"));
+                               color = stov(autocvar_hud_panel_weapons_complainbubble_color_unavailable);
                        }
-                       float padding = cvar("hud_panel_weapons_complainbubble_padding");
+                       float padding = autocvar_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);
                }
@@ -1947,10 +2075,10 @@ void DrawAmmoItem(vector myPos, vector mySize, float itemcode, float currently_s
        if (currently_selected)
                drawpic_aspect_skin(myPos, "ammo_current_bg", mySize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 
-    if(a > 0 && cvar("hud_panel_ammo_progressbar"))
-        HUD_Panel_DrawProgressBar(myPos + eX * cvar("hud_panel_ammo_progressbar_xoffset") * mySize_x, mySize - eX * cvar("hud_panel_ammo_progressbar_xoffset") * mySize_x, cvar_string("hud_panel_ammo_progressbar_name"), 0, 0, a/cvar("hud_panel_ammo_maxammo"), color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
+    if(a > 0 && autocvar_hud_panel_ammo_progressbar)
+        HUD_Panel_DrawProgressBar(myPos + eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, mySize - eX * autocvar_hud_panel_ammo_progressbar_xoffset * mySize_x, autocvar_hud_panel_ammo_progressbar_name, 0, 0, a/autocvar_hud_panel_ammo_maxammo, color, autocvar_hud_progressbar_alpha * panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
 
-    if(cvar("hud_panel_ammo_text"))
+    if(autocvar_hud_panel_ammo_text)
     {
         if(a > 0)
             drawstring_aspect(numpos, ftos(a), eX * (2/3) * mySize_x + eY * mySize_y, color, panel_fg_alpha * alpha, DRAWFLAG_NORMAL);
@@ -1970,8 +2098,9 @@ void HUD_Ammo(void)
                if(!autocvar_hud_panel_ammo) return;
                if(spectatee_status == -1) return;
        }
+       else
+               hud_configure_active_panel = HUD_PANEL_AMMO;
 
-       active_panel = HUD_PANEL_AMMO;
        HUD_Panel_UpdateCvars(ammo);
        vector pos, mySize;
        pos = panel_pos;
@@ -2138,33 +2267,32 @@ void DrawNumIcon_expanding(vector myPos, vector mySize, float x, string icon, fl
 
 // Powerups (#2)
 //
-void HUD_Powerups(void) {
+void HUD_Powerups(void)
+{
+       float strength_time, shield_time;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_powerups) return;
                if(spectatee_status == -1) return;
                if not(getstati(STAT_ITEMS) & (IT_STRENGTH | IT_INVINCIBLE)) return;
                if (getstati(STAT_HEALTH) <= 0) return;
+
+               strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
+               shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
+       }
+       else
+       {
+               hud_configure_active_panel = HUD_PANEL_POWERUPS;
+
+               strength_time = 15;
+               shield_time = 27;
        }
 
-       active_panel = HUD_PANEL_POWERUPS;
        HUD_Panel_UpdateCvars(powerups);
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
 
-       float strength_time, shield_time;
-       if(autocvar__hud_configure)
-       {
-               strength_time = 15;
-               shield_time = 27;
-       }
-       else
-       {
-               strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
-               shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
-       }
-
        HUD_Panel_DrawBg(bound(0, max(strength_time, shield_time), 1));
        if(panel_bg_padding)
        {
@@ -2180,32 +2308,32 @@ void HUD_Powerups(void) {
     string leftprogressname, rightprogressname;
        float leftcnt, rightcnt;
        float leftexact, rightexact;
-       if (cvar("hud_panel_powerups_flip")) {
+       if (autocvar_hud_panel_powerups_flip) {
                leftname = "strength";
-        leftprogressname = cvar_string("hud_panel_powerups_progressbar_strength");
+        leftprogressname = autocvar_hud_panel_powerups_progressbar_strength;
                leftcnt = ceil(strength_time);
                leftexact = strength_time;
 
                rightname = "shield";
-        rightprogressname = cvar_string("hud_panel_powerups_progressbar_shield");
+        rightprogressname = autocvar_hud_panel_powerups_progressbar_shield;
                rightcnt = ceil(shield_time);
                rightexact = shield_time;
        } else {
                leftname = "shield";
-        leftprogressname = cvar_string("hud_panel_powerups_progressbar_shield");
+        leftprogressname = autocvar_hud_panel_powerups_progressbar_shield;
                leftcnt = ceil(shield_time);
                leftexact = shield_time;
 
                rightname = "strength";
-        rightprogressname = cvar_string("hud_panel_powerups_progressbar_strength");
+        rightprogressname = autocvar_hud_panel_powerups_progressbar_strength;
                rightcnt = ceil(strength_time);
                rightexact = strength_time;
        }
 
        drawfont = hud_bigfont;
-       float baralign = cvar("hud_panel_powerups_baralign");
-       float iconalign = cvar("hud_panel_powerups_iconalign");
-       float progressbar = cvar("hud_panel_powerups_progressbar");
+       float baralign = autocvar_hud_panel_powerups_baralign;
+       float iconalign = autocvar_hud_panel_powerups_iconalign;
+
        float panel_ar = mySize_x/mySize_y;
        float is_vertical = (panel_ar < 1);
        if (panel_ar >= 4 || (panel_ar >= 1/4 && panel_ar < 1))
@@ -2213,12 +2341,12 @@ void HUD_Powerups(void) {
         barsize = eX * 0.5 * mySize_x + eY * mySize_y;
                if(leftcnt)
                {
-                       if(progressbar)
+                       if(autocvar_hud_panel_powerups_progressbar)
                        {
                                HUD_Panel_GetProgressBarColorForString(leftname);
                                HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
                        }
-            if(cvar("hud_panel_powerups_text"))
+            if(autocvar_hud_panel_powerups_text)
             {
                                if(leftcnt > 1)
                                        DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1);
@@ -2230,12 +2358,12 @@ void HUD_Powerups(void) {
                if(rightcnt)
                {
                        pos_x += barsize_x;
-                       if(progressbar)
+                       if(autocvar_hud_panel_powerups_progressbar)
                        {
                                HUD_Panel_GetProgressBarColorForString(rightname);
                                HUD_Panel_DrawProgressBar(pos, barsize, rightprogressname, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
                        }
-            if(cvar("hud_panel_powerups_text"))
+            if(autocvar_hud_panel_powerups_text)
             {
                                if(rightcnt > 1)
                                        DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
@@ -2249,12 +2377,12 @@ void HUD_Powerups(void) {
         barsize = eX * mySize_x + eY * 0.5 * mySize_y;
                if(leftcnt)
                {
-                       if(progressbar)
+                       if(autocvar_hud_panel_powerups_progressbar)
                        {
                                HUD_Panel_GetProgressBarColorForString(leftname);
                                HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/30, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
                        }
-            if(cvar("hud_panel_powerups_text"))
+            if(autocvar_hud_panel_powerups_text)
             {
                                if(leftcnt > 1)
                                        DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), '1 1 1', 1);
@@ -2266,12 +2394,12 @@ void HUD_Powerups(void) {
                if(rightcnt)
                {
                        pos_y += barsize_y;
-                       if(progressbar)
+                       if(autocvar_hud_panel_powerups_progressbar)
                        {
                                HUD_Panel_GetProgressBarColorForString(rightname);
                                HUD_Panel_DrawProgressBar(pos, barsize, rightprogressname, rightcnt/30, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha * bound(0, max(strength_time, shield_time), 1), DRAWFLAG_NORMAL);
                        }
-            if(cvar("hud_panel_powerups_text"))
+            if(autocvar_hud_panel_powerups_text)
             {
                                if(rightcnt > 1)
                                        DrawNumIcon(pos, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), '1 1 1', 1);
@@ -2287,13 +2415,27 @@ void HUD_Powerups(void) {
 //
 void HUD_HealthArmor(void)
 {
+       float armor, health, fuel;
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_healtharmor) return;
                if(spectatee_status == -1) return;
+
+               health = getstati(STAT_HEALTH);
+               if(health <= 0)
+                       return;
+               armor = getstati(STAT_ARMOR);
+               fuel = getstati(STAT_FUEL);
+       }
+       else
+       {
+               hud_configure_active_panel = HUD_PANEL_HEALTHARMOR;
+
+               health = 150;
+               armor = 75;
+               fuel = 20;
        }
 
-       active_panel = HUD_PANEL_HEALTHARMOR;
        HUD_Panel_UpdateCvars(healtharmor);
        vector pos, mySize;
        pos = panel_pos;
@@ -2306,31 +2448,15 @@ void HUD_HealthArmor(void)
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
-       float armor, health, fuel;
-       armor = getstati(STAT_ARMOR);
-       health = getstati(STAT_HEALTH);
-       fuel = getstati(STAT_FUEL);
-
-       if(autocvar__hud_configure)
-       {
-               armor = 75;
-               health = 150;
-               fuel = 20;
-       }
-
-       if(health <= 0)
-               return;
-
        vector barsize;
        vector picpos, numpos;
 
        drawfont = hud_bigfont;
-       float baralign = cvar("hud_panel_healtharmor_baralign");
-       float iconalign = cvar("hud_panel_healtharmor_iconalign");
-       float progressbar = cvar("hud_panel_healtharmor_progressbar");
+       float baralign = autocvar_hud_panel_healtharmor_baralign;
+       float iconalign = autocvar_hud_panel_healtharmor_iconalign;
 
-    float maxhealth = cvar("hud_panel_healtharmor_maxhealth");
-    float maxarmor = cvar("hud_panel_healtharmor_maxarmor");
+    float maxhealth = autocvar_hud_panel_healtharmor_maxhealth;
+    float maxarmor = autocvar_hud_panel_healtharmor_maxarmor;
        if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
        {
                vector v;
@@ -2344,28 +2470,28 @@ void HUD_HealthArmor(void)
                if(v_z) // NOT fully armored
                {
                        biggercount = "health";
-                       if(progressbar)
+                       if(autocvar_hud_panel_healtharmor_progressbar)
                        {
                                HUD_Panel_GetProgressBarColor(health);
-                               HUD_Panel_DrawProgressBar(pos, mySize, cvar_string("hud_panel_healtharmor_progressbar_health"), x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_health, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        if(armor)
-            if(cvar("hud_panel_healtharmor_text"))
+            if(autocvar_hud_panel_healtharmor_text)
                                drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha * armor / health, DRAWFLAG_NORMAL);
                }
                else
                {
                        biggercount = "armor";
-                       if(progressbar)
+                       if(autocvar_hud_panel_healtharmor_progressbar)
                        {
                                HUD_Panel_GetProgressBarColor(armor);
-                               HUD_Panel_DrawProgressBar(pos, mySize, cvar_string("hud_panel_healtharmor_progressbar_armor"), x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               HUD_Panel_DrawProgressBar(pos, mySize, autocvar_hud_panel_healtharmor_progressbar_armor, x/maxtotal, 0, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                        }
                        if(health)
-            if(cvar("hud_panel_healtharmor_text"))
+            if(autocvar_hud_panel_healtharmor_text)
                                drawpic_aspect_skin(pos + eX * mySize_x - eX * 0.5 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                }
-        if(cvar("hud_panel_healtharmor_text"))
+        if(autocvar_hud_panel_healtharmor_text)
                        DrawNumIcon(pos, mySize, x, biggercount, 0, iconalign, HUD_Get_Num_Color(x, maxtotal), 1);
 
                if(fuel)
@@ -2382,9 +2508,9 @@ void HUD_HealthArmor(void)
                float leftmax, rightmax;
                float leftactive, rightactive;
                float leftalpha, rightalpha;
-               if (cvar("hud_panel_healtharmor_flip")) { // layout with armor left/top of health
+               if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
                        leftname = "armor";
-            leftprogressname = cvar_string("hud_panel_healtharmor_progressbar_armor");
+            leftprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
                        leftcnt = armor;
                        if(leftcnt)
                                leftactive = 1;
@@ -2392,21 +2518,21 @@ void HUD_HealthArmor(void)
             leftmax = maxarmor;
 
                        rightname = "health";
-            rightprogressname = cvar_string("hud_panel_healtharmor_progressbar_health");
+            rightprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
                        rightcnt = health;
                        rightactive = 1;
                        rightalpha = 1;
             rightmax = maxhealth;
                } else {
                        leftname = "health";
-            leftprogressname = cvar_string("hud_panel_healtharmor_progressbar_health");
+            leftprogressname = autocvar_hud_panel_healtharmor_progressbar_health;
                        leftcnt = health;
                        leftactive = 1;
                        leftalpha = 1;
             leftmax = maxhealth;
 
                        rightname = "armor";
-            rightprogressname = cvar_string("hud_panel_healtharmor_progressbar_armor");
+            rightprogressname = autocvar_hud_panel_healtharmor_progressbar_armor;
                        rightcnt = armor;
                        if(rightcnt)
                                rightactive = 1;
@@ -2421,24 +2547,24 @@ void HUD_HealthArmor(void)
             barsize = eX * 0.5 * mySize_x + eY * mySize_y;
                        if(leftactive)
                        {
-                               if(progressbar)
+                               if(autocvar_hud_panel_healtharmor_progressbar)
                                {
                                        HUD_Panel_GetProgressBarColorForString(leftname);
-                                       HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/200, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/leftmax, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
-                               if(cvar("hud_panel_healtharmor_text"))
-                                       DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, 200), 1);
+                               if(autocvar_hud_panel_healtharmor_text)
+                                       DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, leftmax), 1);
                        }
 
                        if(rightactive)
                        {
-                               if(progressbar)
+                               if(autocvar_hud_panel_healtharmor_progressbar)
                                {
                                        HUD_Panel_GetProgressBarColorForString(rightname);
-                                       HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, barsize, rightprogressname, rightcnt/200, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       HUD_Panel_DrawProgressBar(pos + eX * 0.5 * mySize_x, barsize, rightprogressname, rightcnt/rightmax, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
-                               if(cvar("hud_panel_healtharmor_text"))
-                                       DrawNumIcon(pos + eX * 0.5 * mySize_x, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, 200), 1);
+                               if(autocvar_hud_panel_healtharmor_text)
+                                       DrawNumIcon(pos + eX * 0.5 * mySize_x, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, rightmax), 1);
                        }
 
                        if(fuel)
@@ -2453,27 +2579,27 @@ void HUD_HealthArmor(void)
                }
                else
                {
-            barsize = eX * 0.5 * mySize_x + eY * mySize_y;
+            barsize = eX * mySize_x + eY * 0.5 * mySize_y;
                        if(leftactive)
                        {
-                               if(progressbar)
+                               if(autocvar_hud_panel_healtharmor_progressbar)
                                {
                                        HUD_Panel_GetProgressBarColorForString(leftname);
-                                       HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/200, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       HUD_Panel_DrawProgressBar(pos, barsize, leftprogressname, leftcnt/leftmax, is_vertical, (baralign == 1 || baralign == 2), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
-                               if(cvar("hud_panel_healtharmor_text"))
-                                       DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, 200), 1);
+                               if(autocvar_hud_panel_healtharmor_text)
+                                       DrawNumIcon(pos, barsize, leftcnt, leftname, is_vertical, (iconalign == 1 || iconalign == 2), HUD_Get_Num_Color(leftcnt, leftmax), 1);
                        }
 
                        if(rightactive)
                        {
-                               if(progressbar)
+                               if(autocvar_hud_panel_healtharmor_progressbar)
                                {
                                        HUD_Panel_GetProgressBarColorForString(rightname);
-                                       HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, barsize, rightprogressname, rightcnt/200, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+                                       HUD_Panel_DrawProgressBar(pos + eY * 0.5 * mySize_y, barsize, rightprogressname, rightcnt/rightmax, is_vertical, (baralign == 1 || baralign == 3), progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
                                }
-                               if(cvar("hud_panel_healtharmor_text"))
-                                       DrawNumIcon(pos + eY * 0.5 * mySize_y, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, 200), 1);
+                               if(autocvar_hud_panel_healtharmor_text)
+                                       DrawNumIcon(pos + eY * 0.5 * mySize_y, barsize, rightcnt, rightname, is_vertical, (iconalign == 1 || iconalign == 3), HUD_Get_Num_Color(rightcnt, rightmax), 1);
                        }
 
                        if(fuel)
@@ -2534,8 +2660,8 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
 {
        float w;
        float alsoprint, gentle;
-       alsoprint = (cvar("hud_panel_notify_print") || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
-       gentle = (cvar("cl_gentle") || cvar("cl_gentle_messages"));
+       alsoprint = (autocvar_hud_panel_notify_print || !panel_enabled); // print message to console if: notify panel disabled, or cvar to do so enabled
+       gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
        
        if ((msg == MSG_SUICIDE || msg == MSG_KILL || msg == MSG_KILL_ACTION) && gametype == GAME_CTS) // selfkill isn't interesting in CTS and only spams up the notify panel
                return;
@@ -2902,7 +3028,7 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
 void HUD_Centerprint(string s1, string s2, float type, float msg)
 {
        float gentle;
-       gentle = (cvar("cl_gentle") || cvar("cl_gentle_messages"));
+       gentle = (autocvar_cl_gentle || autocvar_cl_gentle_messages);
        if(msg == MSG_SUICIDE) {
                if (type == DEATH_TEAMCHANGE) {
                        centerprint(strcat(DAMAGE_CENTERPRINT_SPACER, "You are now on: ", s1));
@@ -2988,10 +3114,13 @@ void HUD_Centerprint(string s1, string s2, float type, float msg)
 
 void HUD_Notify (void)
 {
-       if(!autocvar_hud_panel_notify && !autocvar__hud_configure)
-               return;
+       if(!autocvar__hud_configure)
+       {
+               if(!autocvar_hud_panel_notify) return;
+       }
+       else
+               hud_configure_active_panel = HUD_PANEL_NOTIFY;
 
-       active_panel = HUD_PANEL_NOTIFY;
        HUD_Panel_UpdateCvars(notify);
        vector pos, mySize;
        pos = panel_pos;
@@ -3013,9 +3142,9 @@ void HUD_Notify (void)
 
        float a;
        float when;
-       when = cvar("hud_panel_notify_time");
+       when = autocvar_hud_panel_notify_time;
        float fadetime;
-       fadetime = cvar("hud_panel_notify_fadetime");
+       fadetime = autocvar_hud_panel_notify_fadetime;
 
        string s;
 
@@ -3025,7 +3154,7 @@ void HUD_Notify (void)
        string attacker, victim;
 
        float i, j, w, step, limit;
-       if(cvar("hud_panel_notify_flip")) //order items from the top down
+       if(autocvar_hud_panel_notify_flip) //order items from the top down
        {
                i = 0;
                step = +1;
@@ -3301,10 +3430,13 @@ string seconds_tostring(float sec)
 
 void HUD_Timer(void)
 {
-       if(!autocvar_hud_panel_timer && !autocvar__hud_configure)
-               return;
+       if(!autocvar__hud_configure)
+       {
+               if(!autocvar_hud_panel_timer) return;
+       }
+       else
+               hud_configure_active_panel = HUD_PANEL_TIMER;
 
-       active_panel = HUD_PANEL_TIMER;
        HUD_Panel_UpdateCvars(timer);
        vector pos, mySize;
        pos = panel_pos;
@@ -3356,10 +3488,14 @@ void HUD_Timer(void)
 //
 void HUD_Radar(void)
 {
-       if ((autocvar_hud_panel_radar == 0 || (autocvar_hud_panel_radar != 2 && !teamplay)) && !autocvar__hud_configure)
-               return;
+       if (!autocvar__hud_configure)
+       {
+               if (autocvar_hud_panel_radar == 0) return;
+               if (autocvar_hud_panel_radar != 2 && !teamplay) return;
+       }
+       else
+               hud_configure_active_panel = HUD_PANEL_RADAR;
 
-       active_panel = HUD_PANEL_RADAR;
        HUD_Panel_UpdateCvars(radar);
        vector pos, mySize;
        pos = panel_pos;
@@ -3421,7 +3557,7 @@ void HUD_Radar(void)
        if(hud_panel_radar_rotation == 0)
        {
                // max-min distance must fit the radar in any rotation
-               bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_max - mi_min));
+               bigsize = vlen_minnorm2d(teamradar_size2d) * scale2d / (1.05 * vlen2d(mi_scale));
        }
        else
        {
@@ -3449,7 +3585,7 @@ void HUD_Radar(void)
                  f * bigsize
                + (1 - f) * normalsize;
        teamradar_origin3d_in_texcoord = teamradar_3dcoord_to_texcoord(
-                 f * (mi_min + mi_max) * 0.5
+                 f * mi_center
                + (1 - f) * view_origin);
 
        drawsetcliparea(
@@ -3481,10 +3617,13 @@ void HUD_Radar(void)
 void HUD_UpdatePlayerTeams();
 void HUD_Score(void)
 {
-       if(!autocvar__hud_configure && !autocvar_hud_panel_score)
-               return;
+       if(!autocvar__hud_configure)
+       {
+               if(!autocvar_hud_panel_score) return;
+       }
+       else
+               hud_configure_active_panel = HUD_PANEL_SCORE;
 
-       active_panel = HUD_PANEL_SCORE;
        HUD_Panel_UpdateCvars(score);
        vector pos, mySize;
        pos = panel_pos;
@@ -3539,7 +3678,7 @@ void HUD_Score(void)
                drawstring_aspect(pos, timer, eX * 0.75 * mySize_x + eY * mySize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
                drawfont = hud_font;
        } else if (!teamplay) { // non-teamgames
-               if ((spectatee_status == -1 && !autocvar__hud_configure) || cvar("hud_panel_score_rankings"))
+               if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
                {
 #define SCOREPANEL_MAX_ENTRIES 6
 #define SCOREPANEL_ASPECTRATIO 2
@@ -3562,7 +3701,7 @@ void HUD_Score(void)
                                        //simulate my score is lower than all displayed players,
                                        //so that I don't appear at all showing pure rankings.
                                        //This is to better show the difference between the 2 ranking views
-                                       if (i == entries-1 && cvar("hud_panel_score_rankings") == 1)
+                                       if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
                                        {
                                                rgb = '1 1 0';
                                                drawfill(pos - eY * (height * (1 - 0.9) / 2), eX * mySize_x + eY * height, rgb, 0.3 * panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -3592,7 +3731,7 @@ void HUD_Score(void)
                                        continue;
 
                                if (i == entries-1 && !me_printed && pl != me)
-                               if (cvar("hud_panel_score_rankings") == 1 && spectatee_status != -1)
+                               if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
                                {
                                        for (pl = me.sort_next; pl; pl = pl.sort_next)
                                                if (pl.team != COLOR_SPECTATOR)
@@ -3741,15 +3880,17 @@ void HUD_Score(void)
 
 // Race timer (#8)
 //
-void HUD_RaceTimer (void) {
+void HUD_RaceTimer (void)
+{
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_racetimer) return;
                if(!(gametype == GAME_RACE || gametype == GAME_CTS)) return;
                if(spectatee_status == -1) return;
        }
+       else
+               hud_configure_active_panel = HUD_PANEL_RACETIMER;
 
-       active_panel = HUD_PANEL_RACETIMER;
        HUD_Panel_UpdateCvars(racetimer);
        vector pos, mySize;
        pos = panel_pos;
@@ -3898,27 +4039,40 @@ float vote_change; // "time" when vote_active changed
 
 void HUD_VoteWindow(void) 
 {
-    uid2name_dialog = 0;
        if(autocvar_cl_allow_uid2name == -1 && (gametype == GAME_CTS || gametype == GAME_RACE))
        {
                vote_active = 1;
-               vote_called_vote = strzone(strcat("^2Name ^7instead of \"^1Unregistered player\"", " ^7in stats"));
-        uid2name_dialog = 1;
+               if (autocvar__hud_configure)
+               {
+                       vote_yescount = 0;
+                       vote_nocount = 0;
+                       print("^1You have to answer before entering hud configure mode\n");
+                       cvar_set("_hud_configure", "0");
+               }
+               vote_called_vote = strzone("^2Name ^7instead of \"^1Unregistered player^7\" in stats");
+               uid2name_dialog = 1;
        }
 
-       if(!autocvar_hud_panel_vote && !autocvar__hud_configure)
-               return;
-
        if(!autocvar__hud_configure)
        {
+               if(!autocvar_hud_panel_vote) return;
+
                panel_fg_alpha = autocvar_hud_panel_fg_alpha;
-               panel_bg_alpha_str = cvar_string("hud_panel_vote_bg_alpha");
+               panel_bg_alpha_str = autocvar_hud_panel_vote_bg_alpha;
 
                if(panel_bg_alpha_str == "") {
                        panel_bg_alpha_str = ftos(autocvar_hud_panel_bg_alpha);
                }
                panel_bg_alpha = stof(panel_bg_alpha_str);
        }
+       else
+       {
+               hud_configure_active_panel = HUD_PANEL_VOTE;
+
+               vote_yescount = 3;
+               vote_nocount = 2;
+               vote_needed = 4;
+       }
 
        string s;
        float a;
@@ -3932,17 +4086,9 @@ void HUD_VoteWindow(void)
        else
                vote_alpha = bound(0, 1 - (time - vote_change) * 2, 1);
 
-       if(autocvar__hud_configure)
-       {
-               vote_yescount = 3;
-               vote_nocount = 2;
-               vote_needed = 4;
-       }
-
        if(!vote_alpha)
                return;
 
-       active_panel = HUD_PANEL_VOTE;
        HUD_Panel_UpdateCvars(vote);
 
        if(uid2name_dialog)
@@ -3956,7 +4102,7 @@ void HUD_VoteWindow(void)
        pos = panel_pos;
        mySize = panel_size;
 
-       a = vote_alpha * bound(cvar("hud_panel_vote_alreadyvoted_alpha"), 1 - vote_highlighted, 1);
+       a = vote_alpha * bound(autocvar_hud_panel_vote_alreadyvoted_alpha, 1 - vote_highlighted, 1);
        HUD_Panel_DrawBg(a);
        a = panel_fg_alpha * a;
 
@@ -4469,9 +4615,9 @@ void HUD_Mod_Race(vector pos, vector mySize)
 
        if(score && (score < t || !t)) {
                db_put(ClientProgsDB, strcat(shortmapname, rr, "time"), ftos(score));
-               if(cvar("cl_autodemo_delete_keeprecords"))
+               if(autocvar_cl_autodemo_delete_keeprecords)
                {
-                       f = cvar("cl_autodemo_delete");
+                       f = autocvar_cl_autodemo_delete;
                        f &~= 1;
                        cvar_set("cl_autodemo_delete", ftos(f)); // don't delete demo with new record!
                }
@@ -4590,13 +4736,14 @@ float mod_change; // "time" when mod_active changed
 
 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 && gametype != GAME_CA && gametype != GAME_FREEZETAG && gametype != GAME_KEEPAWAY && !autocvar__hud_configure)
-               return;
+       if(!autocvar__hud_configure)
+       {
+               if(!autocvar_hud_panel_modicons) return;
+               if (gametype != GAME_CTF && gametype != GAME_KEYHUNT && gametype != GAME_NEXBALL && gametype != GAME_CTS && gametype != GAME_RACE && gametype != GAME_CA && gametype != GAME_FREEZETAG && gametype != GAME_KEEPAWAY) return;
+       }
+       else
+               hud_configure_active_panel = HUD_PANEL_MODICONS;
 
-       active_panel = HUD_PANEL_MODICONS;
        HUD_Panel_UpdateCvars(modicons);
        vector pos, mySize;
        pos = panel_pos;
@@ -4640,13 +4787,15 @@ void HUD_ModIcons(void)
 //
 void HUD_DrawPressedKeys(void)
 {
-       if(!autocvar_hud_panel_pressedkeys && !autocvar__hud_configure)
-               return;
+       if(!autocvar__hud_configure)
+       {
+               if(!autocvar_hud_panel_pressedkeys) return;
+               if(spectatee_status <= 0 && autocvar_hud_panel_pressedkeys < 2) return;
+       }
+       else
+               hud_configure_active_panel = HUD_PANEL_PRESSEDKEYS;
 
-       if(!(spectatee_status > 0 || autocvar_hud_panel_pressedkeys >= 2 || autocvar__hud_configure))
-               return;
 
-       active_panel = HUD_PANEL_PRESSEDKEYS;
        HUD_Panel_UpdateCvars(pressedkeys);
        vector pos, mySize;
        pos = panel_pos;
@@ -4660,7 +4809,7 @@ void HUD_DrawPressedKeys(void)
        }
 
        // force custom aspect
-       float aspect = cvar("hud_panel_pressedkeys_aspect");
+       float aspect = autocvar_hud_panel_pressedkeys_aspect;
        if(aspect)
        {
                vector newSize;
@@ -4699,13 +4848,18 @@ void HUD_DrawPressedKeys(void)
 //
 void HUD_Chat(void)
 {
-       if(!autocvar_hud_panel_chat && !autocvar__hud_configure)
+       if(!autocvar__hud_configure)
        {
-               cvar_set("con_chatrect", "0");
-               return;
+               if (!autocvar_hud_panel_chat)
+               {
+                       if (!autocvar_con_chatrect)
+                               cvar_set("con_chatrect", "0");
+                       return;
+               }
        }
+       else
+               hud_configure_active_panel = HUD_PANEL_CHAT;
 
-       active_panel = HUD_PANEL_CHAT;
        HUD_Panel_UpdateCvars(chat);
 
        if(autocvar__con_chat_maximized && !autocvar__hud_configure) // draw at full screen height if maximized
@@ -4736,27 +4890,29 @@ void HUD_Chat(void)
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
-       cvar_set("con_chatrect", "1");
+       if (!autocvar_con_chatrect)
+               cvar_set("con_chatrect", "1");
 
        cvar_set("con_chatrect_x", ftos(pos_x/vid_conwidth));
        cvar_set("con_chatrect_y", ftos(pos_y/vid_conheight));
 
        cvar_set("con_chatwidth", ftos(mySize_x/vid_conwidth));
-       cvar_set("con_chat", ftos(floor(mySize_y/cvar("con_chatsize") - 0.5)));
+       cvar_set("con_chat", ftos(floor(mySize_y/autocvar_con_chatsize - 0.5)));
 
        if(autocvar__hud_configure)
        {
-               float chatsize;
-               chatsize = cvar("con_chatsize");
+               vector chatsize;
+               chatsize = '1 1 0' * autocvar_con_chatsize;
                cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over alpha and such
                float i, a;
-               for(i = 0; i < cvar("con_chat"); ++i)
+               for(i = 0; i < autocvar_con_chat; ++i)
                {
-                       if(i == cvar("con_chat") - 1)
+                       if(i == autocvar_con_chat - 1)
                                a = panel_fg_alpha;
                        else
-                               a = panel_fg_alpha * floor(((i + 1) * 7 + cvar("con_chattime"))/45);
-                       drawcolorcodedstring(pos + eY * i * chatsize, textShortenToWidth("^3Player^7: This is the chat area.", mySize_x, '1 1 0' * chatsize, stringwidth_colors), '1 1 0' * chatsize, a, DRAWFLAG_NORMAL);
+                               a = panel_fg_alpha * floor(((i + 1) * 7 + autocvar_con_chattime)/45);
+                       drawcolorcodedstring(pos, textShortenToWidth("^3Player^7: This is the chat area.", mySize_x, chatsize, stringwidth_colors), chatsize, a, DRAWFLAG_NORMAL);
+                       pos_y += chatsize_y;
                }
        }
 }
@@ -4772,10 +4928,13 @@ float frametimeavg1; // 1 frame ago
 float frametimeavg2; // 2 frames ago
 void HUD_EngineInfo(void)
 {
-       if(!autocvar_hud_panel_engineinfo && !autocvar__hud_configure)
-               return;
+       if(!autocvar__hud_configure)
+       {
+               if(!autocvar_hud_panel_engineinfo) return;
+       }
+       else
+               hud_configure_active_panel = HUD_PANEL_ENGINEINFO;
 
-       active_panel = HUD_PANEL_ENGINEINFO;
        HUD_Panel_UpdateCvars(engineinfo);
        vector pos, mySize;
        pos = panel_pos;
@@ -4809,7 +4968,7 @@ void HUD_EngineInfo(void)
        else
        {
                framecounter += 1;
-               if(currentTime - prevfps_time > cvar("hud_panel_engineinfo_framecounter_time"))
+               if(currentTime - prevfps_time > autocvar_hud_panel_engineinfo_framecounter_time)
                {
                        prevfps = framecounter/(currentTime - prevfps_time);
                        framecounter = 0;
@@ -4820,7 +4979,7 @@ void HUD_EngineInfo(void)
        vector color;
        color = HUD_Get_Num_Color (prevfps, 100);
        drawfont = hud_bigfont;
-       drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, cvar("hud_panel_engineinfo_framecounter_decimals"))), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
+       drawstring_aspect(pos, strcat("FPS: ", ftos_decimals(prevfps, autocvar_hud_panel_engineinfo_framecounter_decimals)), mySize, color, panel_fg_alpha, DRAWFLAG_NORMAL);
        drawfont = hud_font;
 }
 
@@ -4833,10 +4992,13 @@ void HUD_EngineInfo(void)
        o_y += fontsize_y;
 void HUD_InfoMessages(void)
 {
-       if(!autocvar_hud_panel_infomessages && !autocvar__hud_configure)
-               return;
+       if(!autocvar__hud_configure)
+       {
+               if(!autocvar_hud_panel_infomessages) return;
+       }
+       else
+               hud_configure_active_panel = HUD_PANEL_INFOMESSAGES;
 
-       active_panel = HUD_PANEL_INFOMESSAGES;
        HUD_Panel_UpdateCvars(infomessages);
        vector pos, mySize;
        pos = panel_pos;
@@ -5017,10 +5179,13 @@ float acc_prevtime, acc_avg, top_speed, top_speed_time;
 
 void HUD_Physics(void)
 {
-       if(!autocvar_hud_panel_physics && !autocvar__hud_configure)
-               return;
+       if(!autocvar_hud_panel_physics)
+       {
+               if(!autocvar__hud_configure) return;
+       }
+       else
+               hud_configure_active_panel = HUD_PANEL_PHYSICS;
 
-       active_panel = HUD_PANEL_PHYSICS;
        HUD_Panel_UpdateCvars(physics);
 
        HUD_Panel_DrawBg(1);
@@ -5034,7 +5199,7 @@ void HUD_Physics(void)
        float speed, conversion_factor;
        string unit;
 
-       switch(cvar("hud_panel_physics_speed_unit"))
+       switch(autocvar_cl_showspeed_unit)
        {
                default:
                case 1:
@@ -5059,23 +5224,22 @@ void HUD_Physics(void)
                        break;
        }
 
-       float max_speed = floor( cvar("hud_panel_physics_speed_max") * conversion_factor + 0.5 );
+       float max_speed = floor( autocvar_hud_panel_physics_speed_max * conversion_factor + 0.5 );
        if (autocvar__hud_configure)
                speed = floor( max_speed * 0.65 + 0.5 );
-       else if(cvar("hud_panel_physics_speed_z"))
+       else if(autocvar_hud_panel_physics_speed_z)
                speed = floor( vlen(pmove_vel) * conversion_factor + 0.5 );
        else
                speed = floor( vlen(pmove_vel - pmove_vel_z * '0 0 1') * conversion_factor + 0.5 );
 
        //compute acceleration
        float acceleration, f;
-       float max_acceleration = cvar("hud_panel_physics_acceleration_max");
        if (autocvar__hud_configure)
-               acceleration = max_acceleration * 0.3;
+               acceleration = autocvar_hud_panel_physics_acceleration_max * 0.3;
        else
        {
                f = time - acc_prevtime;
-               if(cvar("hud_panel_physics_acceleration_z"))
+               if(autocvar_hud_panel_physics_acceleration_z)
                        acceleration = (vlen(pmove_vel) - vlen(acc_prevspeed)) * (1 / f);
                else
                        acceleration = (vlen(pmove_vel - '0 0 1' * pmove_vel_z) - vlen(acc_prevspeed - '0 0 1' * acc_prevspeed_z)) * (1 / f);
@@ -5089,14 +5253,12 @@ void HUD_Physics(void)
 
        //compute layout
        drawfont = hud_bigfont;
-       float baralign = cvar("hud_panel_physics_baralign");
-       float progressbar = cvar("hud_panel_physics_progressbar");
        float panel_ar = panel_size_x/panel_size_y;
        vector speed_offset, acceleration_offset;
        if (panel_ar >= 5)
        {
                panel_size_x *= 0.5;
-               if (cvar("hud_panel_physics_flip"))
+               if (autocvar_hud_panel_physics_flip)
                        speed_offset_x = panel_size_x;
                else
                        acceleration_offset_x = panel_size_x;
@@ -5104,25 +5266,27 @@ void HUD_Physics(void)
        else
        {
                panel_size_y *= 0.5;
-               if (cvar("hud_panel_physics_flip"))
+               if (autocvar_hud_panel_physics_flip)
                        speed_offset_y = panel_size_y;
                else
                        acceleration_offset_y = panel_size_y;
        }
        float speed_baralign, acceleration_baralign;
-       if (cvar("hud_panel_physics_flip"))
+       if (autocvar_hud_panel_physics_baralign == 1)
+               acceleration_baralign = speed_baralign = 1;
+       else if (autocvar_hud_panel_physics_flip)
        {
-               acceleration_baralign = (baralign == 1 || baralign == 2);
-               speed_baralign = (baralign == 1 || baralign == 3);
+               acceleration_baralign = (autocvar_hud_panel_physics_baralign == 2);
+               speed_baralign = (autocvar_hud_panel_physics_baralign == 3);
        }
        else
        {
-               speed_baralign = (baralign == 1 || baralign == 2);
-               acceleration_baralign = (baralign == 1 || baralign == 3);
+               speed_baralign = (autocvar_hud_panel_physics_baralign == 2);
+               acceleration_baralign = (autocvar_hud_panel_physics_baralign == 3);
        }
 
        //draw speed
-       if(speed && progressbar)
+       if(speed && autocvar_hud_panel_physics_progressbar)
        {
                HUD_Panel_GetProgressBarColor(speed);
                HUD_Panel_DrawProgressBar(panel_pos + speed_offset, panel_size, "progressbar", speed/max_speed, 0, speed_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -5142,7 +5306,7 @@ void HUD_Physics(void)
                tmp_offset_x = 0;
        else
                tmp_offset_x = tmp_size_x;
-       if (cvar("hud_panel_physics_speed_unit_show"))
+       if (autocvar_hud_panel_physics_speed_unit_show)
        {
                //tmp_offset_y = 0;
                tmp_size_x = panel_size_x * (1 - 0.75);
@@ -5151,7 +5315,7 @@ void HUD_Physics(void)
        }
 
        //compute and draw top speed
-       if (cvar("hud_panel_physics_topspeed"))
+       if (autocvar_hud_panel_physics_topspeed)
        {
                if (autocvar__hud_configure)
                {
@@ -5169,7 +5333,7 @@ void HUD_Physics(void)
                                f = 0;
                        else
                        {
-                               f = max(1, cvar("hud_panel_physics_topspeed_time"));
+                               f = max(1, autocvar_hud_panel_physics_topspeed_time);
                                // divide by f to make it start from 1
                                f = cos( ((time - top_speed_time) / f) * PI/2 );
                        }
@@ -5177,7 +5341,7 @@ void HUD_Physics(void)
                if (f > 0)
                {
                        //top speed progressbar peek
-                       if(progressbar && speed < top_speed)
+                       if(autocvar_hud_panel_physics_progressbar && speed < top_speed)
                        {
                                float peek_offset_x, peek_size_x;
                                if (speed_baralign)
@@ -5202,13 +5366,13 @@ void HUD_Physics(void)
        }
 
        //draw acceleration
-       if(acceleration && progressbar)
+       if(acceleration && autocvar_hud_panel_physics_progressbar)
        {
                if (acceleration < 0)
                        HUD_Panel_GetProgressBarColor(acceleration_neg);
                else
                        HUD_Panel_GetProgressBarColor(acceleration);
-               HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "progressbar", fabs(acceleration)/max_acceleration, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(panel_pos + acceleration_offset, panel_size, "progressbar", fabs(acceleration)/autocvar_hud_panel_physics_acceleration_max, 0, acceleration_baralign, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
        }
        drawstring_aspect(panel_pos + acceleration_offset, ftos_decimals(acceleration, 3), panel_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
        drawfont = hud_font;
@@ -5286,16 +5450,15 @@ void HUD_Main (void)
                return;
 
        // Drawing stuff
-       if (hud_skin_path != cvar_string("hud_skin"))
+       if (hud_skin_path != autocvar_hud_skin)
        {
                if (hud_skin_path)
                        strunzone(hud_skin_path);
-               hud_skin_path = strzone(strcat("gfx/hud/", cvar_string("hud_skin")));
+               hud_skin_path = strzone(strcat("gfx/hud/", autocvar_hud_skin));
        }
 
        // HUD configure visible grid
-       float hud_configure_grid_alpha;
-       if(autocvar__hud_configure && cvar("hud_configure_grid") && (hud_configure_grid_alpha = cvar("hud_configure_grid_alpha")))
+       if(autocvar__hud_configure && autocvar_hud_configure_grid && autocvar_hud_configure_grid_alpha)
        {
                hud_configure_gridSize_x = bound(0.005, cvar("hud_configure_grid_xsize"), 0.2);
                hud_configure_gridSize_y = bound(0.005, cvar("hud_configure_grid_ysize"), 0.2);
@@ -5303,10 +5466,10 @@ void HUD_Main (void)
                hud_configure_realGridSize_y = hud_configure_gridSize_y * vid_conheight;
                // x-axis
                for(i = 0; i < 1/hud_configure_gridSize_x; ++i)
-                       drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', hud_configure_grid_alpha, DRAWFLAG_NORMAL);
+                       drawfill(eX * i * hud_configure_realGridSize_x, eX + eY * vid_conheight, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
                // y-axis
                for(i = 0; i < 1/hud_configure_gridSize_y; ++i)
-                       drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', hud_configure_grid_alpha, DRAWFLAG_NORMAL);
+                       drawfill(eY * i * hud_configure_realGridSize_y, eY + eX * vid_conwidth, '0.5 0.5 0.5', autocvar_hud_configure_grid_alpha, DRAWFLAG_NORMAL);
        }
 
        // draw the dock
@@ -5314,7 +5477,7 @@ void HUD_Main (void)
        {
                float f;
                vector color;
-               float hud_dock_color_team = cvar("hud_dock_color_team");
+               float hud_dock_color_team = autocvar_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;
@@ -5324,7 +5487,7 @@ void HUD_Main (void)
                }
                else
                {
-                       string hud_dock_color = cvar_string("hud_dock_color");
+                       string hud_dock_color = autocvar_hud_dock_color;
                        if(hud_dock_color == "shirt") {
                                f = stof(getplayerkey(player_localentnum - 1, "colors"));
                                color = colormapPaletteColor(floor(f / 16), 0);
@@ -5345,7 +5508,7 @@ void HUD_Main (void)
                                pic = "gfx/hud/default/dock_medium";
                        }
                }
-               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...
+               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...
        }
 
        // cache the panel order into the panel_order array
@@ -5388,6 +5551,7 @@ void HUD_Main (void)
                        panel_order[i] = stof(argv(i));
                }
        }
+
        // draw panels in order specified by panel_order array
        for(i = HUD_PANEL_NUM - 1; i >= 0; --i) {
                if(i != HUD_PANEL_CHAT || !autocvar__con_chat_maximized) // don't draw maximized chat panel twice!
@@ -5401,6 +5565,12 @@ void HUD_Main (void)
        if (autocvar__hud_configure && spectatee_status && hud_configure_prev == -1) // try to join if we are in hud_configure mode, but still spectating, and in the first frame (in order to get rid of motd when launching a server via the menu "HUD Setup" button)
                localcmd("cmd selectteam auto; cmd join\n");
 
+       if(autocvar__hud_configure && tab_panel != -1)
+       {
+               HUD_Panel_UpdatePosSizeForId(tab_panel)
+               drawfill(panel_pos - '1 1 0' * panel_bg_border, panel_size + '2 2 0' * panel_bg_border, '1 1 1', .2, DRAWFLAG_NORMAL);
+       }
+
        hud_configure_prev = autocvar__hud_configure;
 
        if (!autocvar__hud_configure) // hud config mode disabled, enable normal alpha stuff again