]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Optimize ammo panel code
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 43658f31b200b8c5634835e0a43de104e9ee05f6..c22f4341b8a4a307e763407b38663ef0594c5e3a 100644 (file)
@@ -422,7 +422,8 @@ HUD panels
 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)
        {
                HUD_Write_Cvar_q("hud_skin");
@@ -524,11 +525,11 @@ void HUD_Panel_ExportCfg(string cfgname)
                }
                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);
        }
        else
-               print("^1Couldn't write to hud_", autocvar_hud_skin, "_", cfgname, ".cfg\n");
+               print("^1Couldn't write to ", filename, "\n");
 }
 
 const float hlBorderSize = 4;
@@ -1588,7 +1589,7 @@ void HUD_Weapons(void)
                }
        }
 
-       float i, weapid, wpnalpha, weapon_stats, weapon_number, weapon_cnt;
+       float i, weapid, wpnalpha, weapon_cnt;
        weapon_cnt = 0;
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
        {
@@ -1631,15 +1632,6 @@ void HUD_Weapons(void)
                panel_size -= '2 2 0' * panel_bg_padding;
        }
 
-       // hits
-       weapon_stats = getstati(STAT_DAMAGE_HITS);
-       weapon_number = weapon_stats & 63;
-       weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
-       // fired
-       weapon_stats = getstati(STAT_DAMAGE_FIRED);
-       weapon_number = weapon_stats & 63;
-       weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
-
        if(cvar_or("hud_panel_weapons_fade", 1))
        {
                wpnalpha = 3.2 - 2 * (time - weapontime);
@@ -1697,12 +1689,21 @@ void HUD_Weapons(void)
        }
 
        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;
+               weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
+               // fired
+               weapon_stats = getstati(STAT_DAMAGE_FIRED);
+               weapon_number = weapon_stats & 63;
+               weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64);
                if (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))));
-               show_accuracy = true;
        }
        float label = cvar("hud_panel_weapons_label");
 
@@ -1879,9 +1880,14 @@ string GetAmmoPicture(float i)
 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)
+       {
+               if(itemcode == 2)
+                       currently_selected = true; //rockets always selected
                a = 100;
+       }
+       else
+               a = getstati(GetAmmoStat(itemcode)); // how much ammo do we have of type itemcode?
 
        vector color;
        if(a < 10)
@@ -1947,8 +1953,6 @@ void HUD_Ammo(void)
 
        active_panel = HUD_PANEL_AMMO;
        HUD_Panel_UpdateCvars(ammo);
-       float i, currently_selected;
-
        vector pos, mySize;
        pos = panel_pos;
        mySize = panel_size;
@@ -1960,6 +1964,26 @@ void HUD_Ammo(void)
                mySize -= '2 2 0' * panel_bg_padding;
        }
 
+       float i, stat_items, currently_selected;
+       if (autocvar_hud_panel_ammo_onlycurrent)
+       {
+               if(autocvar__hud_configure)
+               {
+                       DrawAmmoItem(pos, mySize, 2, true); //show rockets
+                       return;
+               }
+               stat_items = getstati(STAT_ITEMS);
+               for (i = 0; i < AMMO_COUNT; ++i) {
+                       currently_selected = stat_items & GetAmmoItemCode(i);
+                       if (currently_selected)
+                       {
+                               DrawAmmoItem(pos, mySize, i, currently_selected);
+                               return;
+                       }
+               }
+               return; // nothing to display
+       }
+
        float rows, columns;
        rows = mySize_y/mySize_x;
        rows = bound(1, floor((sqrt(4 * (3/1) * rows * AMMO_COUNT + rows * rows) + rows + 0.5) / 2), AMMO_COUNT);
@@ -1968,25 +1992,16 @@ void HUD_Ammo(void)
        columns = ceil(AMMO_COUNT/rows);
 
        float row, column;
-       // ammo
+       stat_items = getstati(STAT_ITEMS);
+       vector ammo_size = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows);
        for (i = 0; i < AMMO_COUNT; ++i) {
-               currently_selected = getstati(STAT_ITEMS) & GetAmmoItemCode(i);
-               if(autocvar_hud_panel_ammo_onlycurrent) {
-                       if(autocvar__hud_configure)
-                               i = 2;
-                       if (currently_selected || autocvar__hud_configure)
-                       {
-                               DrawAmmoItem(pos, mySize, i, currently_selected);
-                               break;
-                       }
-               } else {
-                       DrawAmmoItem(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), i, currently_selected);
-                       ++row;
-                       if(row >= rows)
-                       {
-                               row = 0;
-                               column = column + 1;
-                       }
+               currently_selected = stat_items & GetAmmoItemCode(i);
+               DrawAmmoItem(pos + eX * column * ammo_size_x + eY * row * ammo_size_y, ammo_size, i, currently_selected);
+               ++row;
+               if(row >= rows)
+               {
+                       row = 0;
+                       column = column + 1;
                }
        }
 }
@@ -2101,7 +2116,8 @@ void HUD_Powerups(void) {
        string leftname, rightname;
        float leftcnt, rightcnt;
        float leftexact, rightexact;
-       if (autocvar_hud_panel_powerups_flip) {
+       float flip = cvar("hud_panel_powerups_flip");
+       if (flip) {
                leftname = "strength";
                leftcnt = ceil(strength_time);
                leftexact = strength_time;
@@ -2120,11 +2136,14 @@ void HUD_Powerups(void) {
        }
 
        drawfont = hud_bigfont;
+       float baralign = cvar("hud_panel_powerups_baralign");
+       float iconalign = cvar("hud_panel_powerups_iconalign");
+       float progressbar = cvar("hud_panel_powerups_progressbar");
        if (mySize_x/mySize_y > 4)
        {
                if(leftcnt)
                {
-                       if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
+                       if(baralign == 1 || baralign == 3) { // right align
                                barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/30);
                                barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
                        } else { // left align
@@ -2132,20 +2151,20 @@ void HUD_Powerups(void) {
                                barsize = eX * 0.5 * mySize_x * min(1, leftcnt/30) + eY * mySize_y;
                        }
 
-                       if(autocvar_hud_panel_powerups_progressbar)
+                       if(progressbar)
                        {
                                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 * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
+                               DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
                        if(leftcnt <= 5)
-                               DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
+                               DrawNumIcon_expanding(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
                }
 
                if(rightcnt)
                {
-                       if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
+                       if(baralign == 0 || baralign == 3) { // left align
                                barpos = pos + eX * 0.5 * mySize_x;
                                barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
                        } else { // right align
@@ -2153,22 +2172,22 @@ void HUD_Powerups(void) {
                                barsize = eX * 0.5 * mySize_x * min(1, rightcnt/30) + eY * mySize_y;
                        }
 
-                       if(autocvar_hud_panel_powerups_progressbar)
+                       if(progressbar)
                        {
                                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) * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               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);
+                               DrawNumIcon(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
                        if(rightcnt <= 5)
-                               DrawNumIcon_expanding(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', bound(0, (rightcnt - rightexact) / 0.5, 1));
+                               DrawNumIcon_expanding(iconalign, pos + eX * 0.5 * mySize_x, eX * 0.5 * mySize_x + eY * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
                }
        }
        else if (mySize_x/mySize_y > 1.5)
        {
                if(leftcnt)
                {
-                       if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // right align
+                       if(baralign == 1 || baralign == 3) { // right align
                                barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/30);
                                barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
                        } else { // left align
@@ -2176,20 +2195,20 @@ void HUD_Powerups(void) {
                                barsize = eX * mySize_x * min(1, leftcnt/30) + eY * 0.5 * mySize_y;
                        }
 
-                       if(autocvar_hud_panel_powerups_progressbar)
+                       if(progressbar)
                        {
                                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) * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               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);
+                               DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', 1);
                        if(leftcnt <= 5)
-                               DrawNumIcon_expanding(autocvar_hud_panel_powerups_iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
+                               DrawNumIcon_expanding(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, '1 1 1', bound(0, (leftcnt - leftexact) / 0.5, 1));
                }
 
                if(rightcnt)
                {
-                       if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // left align
+                       if(baralign == 0 || baralign == 3) { // left align
                                barpos = pos + eY * 0.5 * mySize_y;
                                barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
                        } else { // right align
@@ -2197,22 +2216,22 @@ void HUD_Powerups(void) {
                                barsize = eX * mySize_x * min(1, rightcnt/30) + eY * 0.5 * mySize_y;
                        }
 
-                       if(autocvar_hud_panel_powerups_progressbar)
+                       if(progressbar)
                        {
                                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) * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               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);
+                               DrawNumIcon(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', 1);
                        if(rightcnt <= 5)
-                               DrawNumIcon_expanding(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', bound(0, (rightcnt - rightexact) / 0.5, 1));
+                               DrawNumIcon_expanding(iconalign, pos + eY * 0.5 * mySize_y, eX * mySize_x + eY * 0.5 * mySize_y, rightcnt, rightname, 0, '1 1 1', bound(0, (rightcnt - rightexact) / 0.5, 1));
                }
        }
        else
        {
                if(leftcnt)
                {
-                       if(autocvar_hud_panel_powerups_baralign == 1 || autocvar_hud_panel_powerups_baralign == 3) { // down align
+                       if(baralign == 1 || baralign == 3) { // down align
                                barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/30);
                                barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
                        } else { // up align
@@ -2220,7 +2239,7 @@ void HUD_Powerups(void) {
                                barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/30);
                        }
 
-                       if(autocvar_hud_panel_powerups_iconalign == 1 || autocvar_hud_panel_powerups_iconalign == 3) { // down align
+                       if(iconalign == 1 || iconalign == 3) { // down align
                                picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
                                numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
                        } else { // up align
@@ -2228,10 +2247,10 @@ void HUD_Powerups(void) {
                                numpos = pos + eY * 0.4 * mySize_x;
                        }
 
-                       if(autocvar_hud_panel_powerups_progressbar)
+                       if(progressbar)
                        {
                                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) * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               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));
@@ -2242,7 +2261,7 @@ void HUD_Powerups(void) {
 
                if(rightcnt)
                {
-                       if(autocvar_hud_panel_powerups_baralign == 0 || autocvar_hud_panel_powerups_baralign == 3) { // up align
+                       if(baralign == 0 || baralign == 3) { // up align
                                barpos = pos + eX * 0.5 * mySize_x;
                                barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
                        } else { // down align
@@ -2250,7 +2269,7 @@ void HUD_Powerups(void) {
                                barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/30);
                        }
 
-                       if(autocvar_hud_panel_powerups_iconalign == 0 || autocvar_hud_panel_powerups_iconalign == 3) { // up align
+                       if(iconalign == 0 || iconalign == 3) { // up align
                                picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
                                numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
                        } else { // down align
@@ -2258,10 +2277,10 @@ void HUD_Powerups(void) {
                                numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
                        }
 
-                       if(autocvar_hud_panel_powerups_progressbar)
+                       if(progressbar)
                        {
                                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) * panel_fg_alpha, DRAWFLAG_NORMAL);
+                               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));
@@ -2313,6 +2332,9 @@ void HUD_HealthArmor(void)
        vector 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");
        if(autocvar_hud_panel_healtharmor == 2) // combined health and armor display
        {
                vector v;
@@ -2321,7 +2343,7 @@ void HUD_HealthArmor(void)
                float x;
                x = floor(v_x + 1);
 
-               if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
+               if(baralign == 1 || baralign == 3) { // right align
                        barpos = pos + eX * mySize_x - eX * mySize_x * min(1, x/400);
                        barsize = eX * mySize_x * min(1, x/400) + eY * mySize_y;
                } else { // left align
@@ -2333,7 +2355,7 @@ void HUD_HealthArmor(void)
                if(v_z) // NOT fully armored
                {
                        biggercount = "health";
-                       if(autocvar_hud_panel_healtharmor_progressbar)
+                       if(progressbar)
                        {
                                HUD_Panel_GetProgressBarColor(health);
                                HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -2344,7 +2366,7 @@ void HUD_HealthArmor(void)
                else
                {
                        biggercount = "armor";
-                       if(autocvar_hud_panel_healtharmor_progressbar)
+                       if(progressbar)
                        {
                                HUD_Panel_GetProgressBarColor(armor);
                                HUD_Panel_DrawProgressBar(barpos, 0, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -2352,12 +2374,12 @@ void HUD_HealthArmor(void)
                        if(health)
                                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);
                }
-               DrawNumIcon(autocvar_hud_panel_healtharmor_iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
+               DrawNumIcon(iconalign, pos, mySize, x, biggercount, 1, HUD_Get_Num_Color(x, 2 * 200), 1);
 
                // fuel
                if(fuel)
                {
-                       if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
+                       if(baralign == 0 || baralign == 3) { // left align
                                barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
                                barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
                        } else {
@@ -2374,7 +2396,8 @@ void HUD_HealthArmor(void)
                float leftcnt, rightcnt;
                float leftactive, rightactive;
                float leftalpha, rightalpha;
-               if (autocvar_hud_panel_healtharmor_flip) { // old style layout with armor left/top of health
+               float flip = cvar("hud_panel_healtharmor_flip");
+               if (flip) { // old style layout with armor left/top of health
                        leftname = "armor";
                        leftcnt = armor;
                        if(leftcnt)
@@ -2402,7 +2425,7 @@ void HUD_HealthArmor(void)
                {
                        if(leftactive)
                        {
-                               if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
+                               if(baralign == 1 || baralign == 3) { // right align
                                        barpos = pos + eX * 0.5 * mySize_x - eX * 0.5 * mySize_x * min(1, leftcnt/200);
                                        barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
                                } else { // left align
@@ -2410,17 +2433,17 @@ void HUD_HealthArmor(void)
                                        barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
                                }
 
-                               if(autocvar_hud_panel_healtharmor_progressbar)
+                               if(progressbar)
                                {
                                        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);
+                               DrawNumIcon(iconalign, pos, eX * 0.5 * mySize_x + eY * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
                        }
 
                        if(rightactive)
                        {
-                               if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
+                               if(baralign == 0 || baralign == 3) { // left align
                                        barpos = pos + eX * 0.5 * mySize_x;
                                        barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
                                } else { // right align
@@ -2428,17 +2451,17 @@ void HUD_HealthArmor(void)
                                        barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
                                }
 
-                               if(autocvar_hud_panel_healtharmor_progressbar)
+                               if(progressbar)
                                {
                                        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);
+                               DrawNumIcon(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);
                        }
 
                        if(fuel)
                        {
-                               if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
+                               if(baralign == 0 || baralign == 3) { // left align
                                        barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
                                        barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
                                } else {
@@ -2453,7 +2476,7 @@ void HUD_HealthArmor(void)
                {
                        if(leftactive)
                        {
-                               if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // right align
+                               if(baralign == 1 || baralign == 3) { // right align
                                        barpos = pos + eX * mySize_x - eX * mySize_x * min(1, leftcnt/200);
                                        barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
                                } else { // left align
@@ -2461,17 +2484,17 @@ void HUD_HealthArmor(void)
                                        barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
                                }
 
-                               if(autocvar_hud_panel_healtharmor_progressbar)
+                               if(progressbar)
                                {
                                        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);
+                               DrawNumIcon(iconalign, pos, eX * mySize_x + eY * 0.5 * mySize_y, leftcnt, leftname, 1, HUD_Get_Num_Color(leftcnt, 200), 1);
                        }
 
                        if(rightactive)
                        {
-                               if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
+                               if(baralign == 0 || baralign == 3) { // left align
                                        barpos = pos + eY * 0.5 * mySize_y;
                                        barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
                                } else { // right align
@@ -2479,17 +2502,17 @@ void HUD_HealthArmor(void)
                                        barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
                                }
 
-                               if(autocvar_hud_panel_healtharmor_progressbar)
+                               if(progressbar)
                                {
                                        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);
+                               DrawNumIcon(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);
                        }
 
                        if(fuel)
                        {
-                               if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
+                               if(baralign == 0 || baralign == 3) { // left align
                                        barpos = pos + eX * mySize_x - eX * mySize_x * min(1, fuel/100);
                                        barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
                                } else {
@@ -2504,7 +2527,7 @@ void HUD_HealthArmor(void)
                {
                        if(leftactive)
                        {
-                               if(autocvar_hud_panel_healtharmor_baralign == 1 || autocvar_hud_panel_healtharmor_baralign == 3) { // down align
+                               if(baralign == 1 || baralign == 3) { // down align
                                        barpos = pos + eY * mySize_y - eY * mySize_y * min(1, leftcnt/200);
                                        barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
                                } else { // up align
@@ -2512,7 +2535,7 @@ void HUD_HealthArmor(void)
                                        barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
                                }
 
-                               if(autocvar_hud_panel_healtharmor_iconalign == 1 || autocvar_hud_panel_healtharmor_iconalign == 3) { // down align
+                               if(iconalign == 1 || iconalign == 3) { // down align
                                        picpos = pos + eX * 0.05 * mySize_x + eY * (mySize_y - 0.65 * mySize_x);
                                        numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x;
                                } else { // up align
@@ -2520,7 +2543,7 @@ void HUD_HealthArmor(void)
                                        numpos = pos + eY * 0.4 * mySize_x;
                                }
 
-                               if(autocvar_hud_panel_healtharmor_progressbar)
+                               if(progressbar)
                                {
                                        HUD_Panel_GetProgressBarColorForString(leftname);
                                        HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -2531,7 +2554,7 @@ void HUD_HealthArmor(void)
 
                        if(rightactive)
                        {
-                               if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // up align
+                               if(baralign == 0 || baralign == 3) { // up align
                                        barpos = pos + eX * 0.5 * mySize_x;
                                        barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
                                } else { // down align
@@ -2539,7 +2562,7 @@ void HUD_HealthArmor(void)
                                        barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
                                }
 
-                               if(autocvar_hud_panel_healtharmor_iconalign == 0 || autocvar_hud_panel_healtharmor_iconalign == 3) { // up align
+                               if(iconalign == 0 || iconalign == 3) { // up align
                                        picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
                                        numpos = pos + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
                                } else { // down align
@@ -2547,7 +2570,7 @@ void HUD_HealthArmor(void)
                                        numpos = pos + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
                                }
 
-                               if(autocvar_hud_panel_healtharmor_progressbar)
+                               if(progressbar)
                                {
                                        HUD_Panel_GetProgressBarColorForString(rightname);
                                        HUD_Panel_DrawProgressBar(barpos, 1, barsize, progressbar_color, autocvar_hud_progressbar_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
@@ -2558,7 +2581,7 @@ void HUD_HealthArmor(void)
 
                        if(fuel)
                        {
-                               if(autocvar_hud_panel_healtharmor_baralign == 0 || autocvar_hud_panel_healtharmor_baralign == 3) { // left align
+                               if(baralign == 0 || baralign == 3) { // left align
                                        barpos = pos;
                                        barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
                                } else {
@@ -4982,8 +5005,6 @@ switch (id) {\
 
 void HUD_Main (void)
 {
-       hud_skin_path = strcat("gfx/hud/", autocvar_hud_skin);
-
        // global hud alpha fade
        if(menu_enabled == 1)
                hud_fade_alpha = 1;
@@ -5004,6 +5025,12 @@ void HUD_Main (void)
                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)
@@ -5026,23 +5053,28 @@ 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") {
+               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(floor(f / 16), 0);
+                       color = colormapPaletteColor(mod(f, 16), 1) * hud_dock_color_team;
                }
-               else if(autocvar_hud_dock_color == "pants") {
-                       f = stof(getplayerkey(player_localentnum - 1, "colors"));
-                       color = colormapPaletteColor(mod(f, 16), 1);
+               else if(autocvar_hud_configure_teamcolorforced && autocvar__hud_configure && hud_dock_color_team) {
+                       color = '1 0 0' * hud_dock_color_team;
                }
                else
-                       color = stov(autocvar_hud_dock_color);
+               {
+                       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);
@@ -5052,7 +5084,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