]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
remove unused vector
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 864e1017c21260e97ec5e0a1db209e14f238a2eb..4e7628f3fdaf8da08018ac1eeadcff9c11b55ed3 100644 (file)
@@ -84,6 +84,10 @@ void drawpic_skin_expanding(vector pos, string pic, vector sz, vector rgb, float
        drawpic_expanding(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
 }
 
+void drawpic_skin_expanding_two(vector pos, string pic, vector sz, vector rgb, float alpha, float flag, float fadelerp) {
+       drawpic_expanding_two(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/", pic), sz, rgb, alpha, flag, fadelerp);
+}
+
 // return HUD background color
 vector HUD_GetBgColor()
 {
@@ -181,7 +185,7 @@ void HUD_DrawXNum (vector pos, float num, float digits, float showsign, float le
                hl_pos_y = pos_y - lettersize/20;
                hl_pos_z = 0;
 
-               drawpic_skin(hl_pos, strcat("highlight_", l_length), hl_size, '1 1 1', alpha, dflags);
+               drawpic_skin(hl_pos, strcat("num_leading_", l_length), hl_size, '1 1 1', alpha, dflags);
        }
 
        if (stroke == 1)
@@ -575,14 +579,15 @@ void HUD_Panel_ExportCfg(string cfgname)
                fputs(fh, strcat("seta hud_skin \"", cvar_string("hud_skin"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg \"", cvar_string("hud_bg"), "\"", "\n"));
                fputs(fh, strcat("seta hud_bg_color \"", cvar_string("hud_bg_color"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_bg_alpha ", ftos(cvar("hud_bg_alpha")), "\n"));
-               fputs(fh, strcat("seta hud_bg_border ", ftos(cvar("hud_bg_border")), "\n"));
-               fputs(fh, strcat("seta hud_fg_alpha ", ftos(cvar("hud_fg_alpha")), "\n"));
+               fputs(fh, strcat("seta hud_bg_alpha \"", cvar_string("hud_bg_alpha"), "\"", "\n"));
+               fputs(fh, strcat("seta hud_bg_border \"", cvar_string("hud_bg_border"), "\"", "\n"));
+               fputs(fh, strcat("seta hud_bg_padding \"", cvar_string("hud_bg_padding"), "\"", "\n"));
+               fputs(fh, strcat("seta hud_fg_alpha \"", cvar_string("hud_fg_alpha"), "\"", "\n"));
                fputs(fh, "\n");
 
                fputs(fh, strcat("seta hud_dock \"", cvar_string("hud_dock"), "\"", "\n"));
                fputs(fh, strcat("seta hud_dock_color \"", cvar_string("hud_dock_color"), "\"", "\n"));
-               fputs(fh, strcat("seta hud_dock_alpha ", ftos(cvar("hud_dock_alpha")), "\n"));
+               fputs(fh, strcat("seta hud_dock_alpha \"", ftos(cvar("hud_dock_alpha")), "\"", "\n"));
                fputs(fh, "\n");
 
                fputs(fh, strcat("seta hud_progressbar_alpha ", ftos(cvar("hud_progressbar_alpha")), "\n"));
@@ -603,8 +608,9 @@ void HUD_Panel_ExportCfg(string cfgname)
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_size \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_size")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg")), "\"", "\n"));
                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_color \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_color")), "\"", "\n"));
-                       fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha"))), "\n"));
-                       fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_bg_border"))), "\n"));
+                       fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_alpha \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_alpha")), "\"", "\n"));
+                       fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_border \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_border")), "\"", "\n"));
+                       fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_bg_padding \"", cvar_string(strcat("hud_", HUD_Panel_GetName(i), "_bg_padding")), "\"", "\n"));
                        switch(i) {
                                case 0:
                                        fputs(fh, strcat("seta hud_", HUD_Panel_GetName(i), "_accuracy_height ", ftos(cvar(strcat("hud_", HUD_Panel_GetName(i), "_accuracy_height"))), "\n"));
@@ -633,41 +639,46 @@ void HUD_Panel_ExportCfg(string cfgname)
        fclose(fh);
 }
 
-vector HUD_Panel_CheckLimitSize(float id, vector mySize)
+vector HUD_Panel_GetMinSize(float id)
 {
+       vector mySize;
+       // note: please only set mySize_y on aspect ratio forced panels
        switch(id) {
                case 0: 
-                       mySize_x = max(mySize_y * (1/10), mySize_x); // at least 1/10 * height
-                       mySize_y = max(mySize_x * (1/26), mySize_y); // at least 1/26 * width
+                       mySize_x = 1/10; // at least 1/10 * height
+                       mySize_y = 1/26; // at least 1/26 * width
                        break;
                case 1: 
-                       mySize_x = max(mySize_y * 0.7, mySize_x); // at least 0.7 * height
+                       if(cvar("hud_inventory_onlycurrent"))
+                               mySize_y = 2/5; //  2/5 width
+                       else
+                               mySize_x = 0.7; // at least 0.7 * height
+                       break;
+               case 3: 
+                       if(cvar("hud_healtharmor") == 2)
+                               mySize_y = 0.23; // 0.23 * width, trial and error...
                        break;
-               //case 2: 
-               //      mySize_x = max(mySize_y * 1.5, mySize_x); // at least 1.5 * height
-               //      break;
-               //case 3: 
-               //      mySize_x = max(mySize_y * 2, mySize_x); // at least 2 * height
-               //      break;
                case 5: 
-                       mySize_y = (1/4.1) * mySize_x; // 1/4.1 * width, trial and error...
+                       mySize_y = 1/4.1; // 1/4.1 * width, trial and error...
                        break;
                case 7: 
-                       mySize_y = (1/4) * mySize_x; // 1/4 * width
+                       mySize_y = 1/4; // 1/4 * width
                        break;
                case 8: 
-                       mySize_y = (1/4) * mySize_x; // 1/4 * width
+                       mySize_y = 1/4; // 1/4 * width
                        break;
                case 9: 
-                       mySize_y = (1/4) * mySize_x; // 1/4 * width
+                       mySize_y = 1/4; // 1/4 * width
                        break;
                case 10: 
-                       mySize_y = (1/2) * mySize_x; // 1/2 * width
+                       mySize_y = 1/2; // 1/2 * width
                        break;
                case 11: 
-                       mySize_y = 0.5898 * mySize_x; // 0.5898 * width, reason: bg has weird dimensions...
+                       mySize_y = 0.5898; // 0.5898 * width, reason: bg has weird dimensions...
                        break;
        }
+       if(!mySize_x)
+               mySize_x = 1/mySize_y;
        return mySize;
 }
 
@@ -707,16 +718,84 @@ vector HUD_Panel_GetPos(float id)
 
 float HUD_Panel_GetBorder(float id)
 {
-       float border;
-       border = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
-       if(!border)
-               border = cvar("hud_bg_border");
-       return border;
+       string border;
+       border = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_border"));
+       if(border == "")
+               border = cvar_string("hud_bg_border");
+       return stof(border);
+}
+
+vector HUD_Panel_GetColor(float id)
+{
+       float f;
+       vector color_vec;
+       string color;
+       color = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color"));
+       color_vec = stov(color);
+       if(color == "") {
+               color = cvar_string("hud_bg_color");
+               color_vec = stov(color);
+               if(color == "shirt") {
+                       f = stof(getplayerkey(self.sv_entnum, "colors"));
+                       color_vec = colormapPaletteColor(floor(f / 16), 0);
+               }
+               else if(color == "pants") {
+                       f = stof(getplayerkey(self.sv_entnum, "colors"));
+                       color_vec = colormapPaletteColor(mod(f, 16), 1);
+               }
+       }
+       else if(color == "shirt") {
+               f = stof(getplayerkey(self.sv_entnum, "colors"));
+               color_vec = colormapPaletteColor(floor(f / 16), 0);
+       }
+       else if(color == "pants") {
+               f = stof(getplayerkey(self.sv_entnum, "colors"));
+               color_vec = colormapPaletteColor(mod(f, 16), 1);
+       }
+       return color_vec;
+}
+
+vector HUD_Panel_Dock_GetColor(void)
+{
+       float f;
+       vector color_vec;
+       string color;
+       color = cvar_string("hud_dock_color");
+       color_vec = stov(color);
+       if(color == "shirt") {
+               f = stof(getplayerkey(self.sv_entnum, "colors"));
+               color_vec = colormapPaletteColor(floor(f / 16), 0);
+       }
+       else if(color == "pants") {
+               f = stof(getplayerkey(self.sv_entnum, "colors"));
+               color_vec = colormapPaletteColor(mod(f, 16), 1);
+       }
+       return color_vec;
+}
+
+float HUD_Panel_GetAlpha(float id)
+{
+       string alpha;
+       alpha = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
+       if(alpha == "")
+               alpha = cvar_string("hud_bg_alpha");
+       return stof(alpha);
+}
+
+float HUD_Panel_GetPadding(float id)
+{
+       string padding;
+       padding = cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       if(padding == "")
+               padding = cvar_string("hud_bg_padding");
+       return stof(padding);
 }
 
 // draw the background/borders
 void HUD_Panel_DrawBg(float id, vector pos, vector mySize)
 {
+       float alpha;
+
        if(!hud_configure && cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg")) == "0")
                return;
 
@@ -725,54 +804,68 @@ void HUD_Panel_DrawBg(float id, vector pos, vector mySize)
        if(bg == "")
                bg = cvar_string("hud_bg");
 
+       if(bg == "0" && hud_configure) {
+               bg = "border"; // we probably want to see a background in config mode at all times...
+               alpha = cvar("hud_configure_bg_minalpha");
+       }
+
        if(bg != "0")
        {
                float border;
                border = max(0.0000001, HUD_Panel_GetBorder(id)); // draw_BorderPicture does not like border = 0
 
                vector color;
-               if(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color")) != "")
-                       color = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_bg_color")));
-               else
-                       color = stov(cvar_string("hud_bg_color"));
+               color = HUD_Panel_GetColor(id);
 
-               float alpha;
-               alpha = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_alpha"));
                if(!alpha)
-                       alpha = cvar("hud_bg_alpha");
-               if(hud_configure)
-                       alpha = max(cvar("hud_configure_bg_minalpha"), alpha);
+                       alpha = HUD_Panel_GetAlpha(id);
 
                draw_BorderPicture(pos - '1 1 0' * border, strcat("gfx/hud/", cvar_string("hud_skin"), "/", bg), mySize + '1 1 0' * 2 * border, color, alpha, '1 1 0' * (border/BORDER_MULTIPLIER));
        }
 }
 
+void HUD_Panel_DrawProgressBar(vector pos, float vertical, vector mySize, vector color, float alpha, float drawflag)
+{
+//float        drawsubpic(vector position, vector size, string pic, vector srcPosition, vector srcSize, vector rgb, float alpha, float flag) = #328;
+       string pic;
+       pic = strcat("gfx/hud/", cvar_string("hud_skin"), "/");
+       if(vertical) {
+               drawsubpic(pos, eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0 0', '1 0.25 0', color, alpha, drawflag);
+               if(mySize_y/mySize_x > 2)
+                       drawsubpic(pos + eY * mySize_x, eY * (mySize_y - 2 * mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0.25 0', '1 0.5 0', color, alpha, drawflag);
+               drawsubpic(pos + eY * mySize_y - eY * min(mySize_y * 0.5, mySize_x), eY * min(mySize_y * 0.5, mySize_x) + eX * mySize_x, strcat(pic, "statusbar_vertical"), '0 0.75 0', '1 0.25 0', color, alpha, drawflag);
+       } else {
+               drawsubpic(pos, eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0 0 0', '0.25 1 0', color, alpha, drawflag);
+               if(mySize_x/mySize_y > 2)
+                       drawsubpic(pos + eX * mySize_y, eX * (mySize_x - 2 * mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0.25 0 0', '0.5 1 0', color, alpha, drawflag);
+               drawsubpic(pos + eX * mySize_x - eX * min(mySize_x * 0.5, mySize_y), eX * min(mySize_x * 0.5, mySize_y) + eY * mySize_y, strcat(pic, "statusbar"), '0.75 0 0', '0.25 1 0', color, alpha, drawflag);
+       }
+}
+
 vector HUD_Panel_GetProgressBarColor(string item)
 {
        return stov(cvar_string(strcat("hud_progressbar_", item, "_color")));
 }
 
-float resizeCorner; // 1 = topleft, 2 = topright, 3 = bottomleft, 4 = bottomright
-// check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
-vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize)
+// check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
+vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
 {
        float i;
 
        vector myTarget;
-       myTarget = mySize;
+       myTarget = myPos;
 
        vector targPos;
        vector targSize;
        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 < panel_cnt; ++i) {
                if(i == id || !HUD_Panel_CheckActive(i))
                        continue;
 
-               targPos = HUD_Panel_GetPos(i);
-               targSize = HUD_Panel_GetSize(i);
-
                targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
                targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
 
@@ -794,25 +887,24 @@ vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize)
                targCenter_x = targPos_x + 0.5 * targSize_x;
                targCenter_y = targPos_y + 0.5 * targSize_y;
 
-               float k, y;
-               if(myCenter_x < targCenter_x && myCenter_y < targCenter_y && resizeCorner != 1) // top left (of target panel)
+               if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
                {
                        if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
-                               myTarget_x = targPos_x - myPos_x;
+                               myTarget_x = targPos_x - mySize_x;
                        else // push it upwards
-                               myTarget_y = targPos_y - myPos_y;
+                               myTarget_y = targPos_y - mySize_y;
                }
-               else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y && resizeCorner != 2) // top right
+               else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
                {
                        if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
                                myTarget_x = targPos_x + targSize_x;
                        else // push it upwards
-                               myTarget_y = targPos_y - myPos_y;
+                               myTarget_y = targPos_y - mySize_y;
                }
                else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
                {
                        if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
-                               myTarget_x = targPos_x - myPos_x;
+                               myTarget_x = targPos_x - mySize_x;
                        else // push it downwards
                                myTarget_y = targPos_y + targSize_y;
                }
@@ -828,68 +920,59 @@ vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize)
        return myTarget;
 }
 
-// TODO: checkResize
-float HUD_Panel_SetSize(float id, vector mySize)
+void HUD_Panel_SetPos(float id, vector pos)
 {
-       float didntresize;
-
-       vector oldSize;
-       oldSize = stov(cvar_string(strcat("hud_", HUD_Panel_GetName(id), "_size")));
+       vector oldPos;
+       oldPos = HUD_Panel_GetPos(id);
 
-       vector myPos;
-       myPos = HUD_Panel_GetPos(id);
+       vector mySize;
+       mySize = HUD_Panel_GetSize(id);
 
-       // check for collisions
        if(cvar("hud_configure_checkcollisions"))
-               mySize = HUD_Panel_CheckResize(id, HUD_Panel_GetPos(id), mySize);
-
-       mySize_x = bound(0.025 * vid_conwidth, mySize_x, vid_conwidth - myPos_x);
-       mySize_y = bound(0.025 * vid_conheight, mySize_y, vid_conheight - myPos_y);
-
-       // cap against panel's own limits
-       mySize = HUD_Panel_CheckLimitSize(id, mySize);
+               pos = HUD_Panel_CheckMove(id, pos, mySize);
 
-       //mySize_x = bound(0.025 * vid_conwidth, mySize_x, vid_conwidth);
-       //mySize_y = bound(0.025 * vid_conheight, mySize_y, vid_conheight);
+       pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
+       pos_y = bound(0, pos_y, vid_conheight - mySize_y);
 
        if(cvar("hud_configure_grid"))
        {
-               mySize_x = floor(mySize_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
-               mySize_y = floor(mySize_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
+               pos_x = floor(pos_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
+               pos_y = floor(pos_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
        }
 
-       // TODO: is this needed?
-       // this is to check if (and how) SetPos should be called
-       if(mySize_x == oldSize_x && mySize_y == oldSize_y)
-               didntresize = 3; // didnt resize either
-       else if(mySize_x == oldSize_x && mySize_y != oldSize_y)
-               didntresize = 2; // resized Y
-       else if(mySize_y == oldSize_y && mySize_x != oldSize_x)
-               didntresize = 1; // resized X
+       if (pos_x + 0.5 * mySize_x > 0.5 * vid_conwidth)
+               pos_x = pos_x - vid_conwidth;
+       if (pos_y + 0.5 * mySize_y > 0.5 * vid_conheight)
+               pos_y = pos_y - vid_conheight;
 
        string s;
-       s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
-       cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
-       return didntresize;
+       s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
+
+       cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
 }
 
-// check if move will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
-vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
+// check if resize will result in panel being moved into another panel. If so, return snapped vector, otherwise return the given vector
+vector HUD_Panel_CheckResize(float id, vector myPos, vector mySize)
 {
        float i;
 
        vector myTarget;
-       myTarget = myPos;
+       myTarget = mySize;
 
        vector targPos;
        vector targSize;
        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 < panel_cnt; ++i) {
                if(i == id || !HUD_Panel_CheckActive(i))
                        continue;
 
+               targPos = HUD_Panel_GetPos(i);
+               targSize = HUD_Panel_GetSize(i);
+
                targPos = HUD_Panel_GetPos(i) - '1 1 0' * HUD_Panel_GetBorder(id);
                targSize = HUD_Panel_GetSize(i) + '2 2 0' * HUD_Panel_GetBorder(id);
 
@@ -911,25 +994,24 @@ vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
                targCenter_x = targPos_x + 0.5 * targSize_x;
                targCenter_y = targPos_y + 0.5 * targSize_y;
 
-               float k, y;
-               if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of the target panel)
+               if(myCenter_x < targCenter_x && myCenter_y < targCenter_y) // top left (of target panel)
                {
                        if(myPos_x + mySize_x - targPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
-                               myTarget_x = targPos_x - mySize_x;
+                               myTarget_x = targPos_x - myPos_x;
                        else // push it upwards
-                               myTarget_y = targPos_y - mySize_y;
+                               myTarget_y = targPos_y - myPos_y;
                }
                else if(myCenter_x > targCenter_x && myCenter_y < targCenter_y) // top right
                {
                        if(targPos_x + targSize_x - myPos_x < myPos_y + mySize_y - targPos_y) // push it to the side
                                myTarget_x = targPos_x + targSize_x;
                        else // push it upwards
-                               myTarget_y = targPos_y - mySize_y;
+                               myTarget_y = targPos_y - myPos_y;
                }
                else if(myCenter_x < targCenter_x && myCenter_y > targCenter_y) // bottom left
                {
                        if(myPos_x + mySize_x - targPos_x < targPos_y + targSize_y - myPos_y) // push it to the side
-                               myTarget_x = targPos_x - mySize_x;
+                               myTarget_x = targPos_x - myPos_x;
                        else // push it downwards
                                myTarget_y = targPos_y + targSize_y;
                }
@@ -945,40 +1027,95 @@ vector HUD_Panel_CheckMove(float id, vector myPos, vector mySize)
        return myTarget;
 }
 
-void HUD_Panel_SetPos(float id, vector pos, float didntresize)
+void HUD_Panel_SetPosSize(float id, vector resizeorigin)
 {
+       vector mySize, myPos;
        vector oldPos;
-       oldPos = HUD_Panel_GetPos(id);
-       if(didntresize == 2)
-               pos_x = oldPos_x;
-       else if(didntresize == 1)
-               pos_y = oldPos_y;
-       else if(didntresize == 3)
-               return;
 
-       vector mySize;
-       mySize = HUD_Panel_GetSize(id);
+       if(resizeCorner == 1) {
+               mySize_x = resizeorigin_x - (mousepos_x - panel_click_distance_x);
+               mySize_y = resizeorigin_y - (mousepos_y - panel_click_distance_y);
+       } else if(resizeCorner == 2) {          
+               mySize_x = mousepos_x + panel_click_distance_x - resizeorigin_x;
+               mySize_y = panel_click_distance_y + resizeorigin_y - mousepos_y;
+       } else if(resizeCorner == 3) {
+               mySize_x = resizeorigin_x + panel_click_distance_x - mousepos_x;
+               mySize_y = mousepos_y + panel_click_distance_y - resizeorigin_y;
+       } else { // resizeCorner == 4
+               mySize_x = mousepos_x - (resizeorigin_x - panel_click_distance_x);
+               mySize_y = mousepos_y - (resizeorigin_y - panel_click_distance_y);
+       }
 
-       if(cvar("hud_configure_checkcollisions"))
-               pos = HUD_Panel_CheckMove(id, pos, mySize);
+       // minimum panel size cap
+       mySize_x = max(0.025 * vid_conwidth, mySize_x);
+       mySize_y = max(0.025 * vid_conheight, mySize_y);
 
-       pos_x = bound(0, pos_x, vid_conwidth - mySize_x);
-       pos_y = bound(0, pos_y, vid_conheight - mySize_y);
+       // cap against panel's own limits
+       vector minSize;
+       minSize = HUD_Panel_GetMinSize(id); // mySize_x at least minSize_x * mySize_y, and vice versa
+
+       mySize_x = max(minSize_x * mySize_y, mySize_x);
+       mySize_y = max(minSize_y * mySize_x, mySize_y);
+
+       // collision testing|
+       // -----------------+
+
+       // we need to know pos at this stage, but it might still change later if we hit a screen edge/other panel (?)
+       if(resizeCorner == 1) {
+               myPos_x = resizeorigin_x - mySize_x;
+               myPos_y = resizeorigin_y - mySize_y;
+       } else if(resizeCorner == 2) {
+               myPos_x = resizeorigin_x;
+               myPos_y = resizeorigin_y - mySize_y;
+       } else if(resizeCorner == 3) {
+               myPos_x = resizeorigin_x - mySize_x;
+               myPos_y = resizeorigin_y;
+       } else { // resizeCorner == 4
+               myPos_x = resizeorigin_x;
+               myPos_y = resizeorigin_y;
+       }
+
+       // left/top screen edges
+       mySize_x = min(myPos_x + mySize_x, mySize_x);
+       mySize_y = min(myPos_y + mySize_y, mySize_y);
+
+       // bottom/right screen edges
+       mySize_x = min(vid_conwidth - myPos_x, mySize_x); 
+       mySize_y = min(vid_conheight - myPos_y, mySize_y); 
+
+       if(cvar("hud_configure_checkcollisions")) {
+               oldPos = myPos;
+               mySize = HUD_Panel_CheckResize(id, myPos, mySize);
+               myPos = HUD_Panel_CheckMove(id, myPos, mySize); // touching myPos won't do anything... unless we make it change mySize somehow, see next line
+               mySize = mySize - myPos + oldPos; // TODO: this is still borked in some situations :(
+       }
 
        if(cvar("hud_configure_grid"))
        {
-               pos_x = floor(pos_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
-               pos_y = floor(pos_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
+               mySize_x = floor(mySize_x/cvar("hud_configure_grid_x") + 0.5) * cvar("hud_configure_grid_x");
+               mySize_y = floor(mySize_y/cvar("hud_configure_grid_y") + 0.5) * cvar("hud_configure_grid_y");
        }
 
-       if (pos_x + 0.5 * mySize_x > 0.5 * vid_conwidth)
-               pos_x = pos_x - vid_conwidth;
-       if (pos_y + 0.5 * mySize_y > 0.5 * vid_conheight)
-               pos_y = pos_y - vid_conheight;
+       // do another pos check, as size might have changed by now
+       if(resizeCorner == 1) {
+               myPos_x = resizeorigin_x - mySize_x;
+               myPos_y = resizeorigin_y - mySize_y;
+       } else if(resizeCorner == 2) {
+               myPos_x = resizeorigin_x;
+               myPos_y = resizeorigin_y - mySize_y;
+       } else if(resizeCorner == 3) {
+               myPos_x = resizeorigin_x - mySize_x;
+               myPos_y = resizeorigin_y;
+       } else { // resizeCorner == 4
+               myPos_x = resizeorigin_x;
+               myPos_y = resizeorigin_y;
+       }
 
        string s;
-       s = strcat(ftos(pos_x/vid_conwidth), " ", ftos(pos_y/vid_conheight));
+       s = strcat(ftos(mySize_x/vid_conwidth), " ", ftos(mySize_y/vid_conheight));
+       cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_size"), s);
 
+       s = strcat(ftos(myPos_x/vid_conwidth), " ", ftos(myPos_y/vid_conheight));
        cvar_set(strcat("hud_", HUD_Panel_GetName(id), "_pos"), s);
 }
 
@@ -1001,12 +1138,6 @@ float HUD_Panel_InputEvent(float bInputType, float nPrimary, float nSecondary)
        return false;
 }
 
-vector mousepos, mouseprevpos;
-vector panel_click_distance; // mouse cursor distance from the top left corner of the panel (saved only upon a click)
-vector panel_click_pos; // panel pos (saved only upon a click)
-vector panel_click_size; // panel size (saved only upon a click)
-float highlightedPanel;
-float highlightedAction; // 0 = nothing, 1 = move, 2 = resize
 void HUD_Panel_Mouse()
 {
        if(mouseClicked == 0) {
@@ -1073,48 +1204,38 @@ void HUD_Panel_Mouse()
                        {
                                if(prevMouseClicked == 0)
                                {
-                                       panel_click_distance = mousepos - panelPos;
-                                       panel_click_pos = panelPos;
-                                       panel_click_size = panelSize;
+                                       if(highlightedAction == 1)
+                                               panel_click_distance = mousepos - panelPos;
+                                       else if(highlightedAction == 2)
+                                       {
+                                               if(resizeCorner == 1) {
+                                                       panel_click_distance = mousepos - panelPos;
+                                                       panel_click_resizeorigin = panelPos + panelSize;
+                                               } else if(resizeCorner == 2) {
+                                                       panel_click_distance_x = panelSize_x - mousepos_x + panelPos_x;
+                                                       panel_click_distance_y = mousepos_y - panelPos_y;
+                                                       panel_click_resizeorigin = panelPos + eY * panelSize_y;
+                                               } else if(resizeCorner == 3) {
+                                                       panel_click_distance_x = mousepos_x - panelPos_x;
+                                                       panel_click_distance_y = panelSize_y - mousepos_y + panelPos_y;
+                                                       panel_click_resizeorigin = panelPos + eX * panelSize_x;
+                                               } else if(resizeCorner == 4) {
+                                                       panel_click_distance = panelSize - mousepos + panelPos;
+                                                       panel_click_resizeorigin = panelPos;
+                                               }
+                                       }       
                                }
 
                                if(highlightedAction == 1)
-                                       HUD_Panel_SetPos(i, mousepos - panel_click_distance, 0);
+                                       HUD_Panel_SetPos(i, mousepos - panel_click_distance);
                                else if(highlightedAction == 2)
-                               {
-                                       float didntresize; // panel too big/too small, dont resize (also has to affect moving)
-                                       if(resizeCorner == 1) {
-                                               didntresize = HUD_Panel_SetSize(i, panelSize + mouseprevpos - mousepos);
-                                               HUD_Panel_SetPos(i, mousepos - panel_click_distance, didntresize);
-                                       }
-                                       if(resizeCorner == 2) {
-                                               didntresize = HUD_Panel_SetSize(i, eY * panel_click_size_y + eX * (mousepos_x - panelPos_x - (panel_click_distance_x - panel_click_size_x))
-                                                               + eY * (panel_click_distance_y + (panel_click_pos_y - mousepos_y)));
-                                               HUD_Panel_SetPos(i, eX * panelPos_x + eY * (mousepos_y - panel_click_distance_y), didntresize);
-                                       }
-                                       if(resizeCorner == 3) {
-                                               didntresize = HUD_Panel_SetSize(i, panelSize + eX * (mouseprevpos_x - mousepos_x) + eY * (mousepos_y - mouseprevpos_y));
-                                               HUD_Panel_SetPos(i, eX * (mousepos_x - panel_click_distance_x) + eY * panelPos_y, didntresize);
-                                       }
-                                       if(resizeCorner == 4) {
-                                               HUD_Panel_SetSize(i, mousepos - panelPos - (panel_click_distance - panel_click_size));
-                                       }
-                               }
+                                       HUD_Panel_SetPosSize(i, panel_click_resizeorigin);
                        }
                }
        }
-       mouseprevpos = mousepos;
        prevMouseClicked = mouseClicked;
 }
 
-/*void HUD_DrawDockEdge(float id, vector p1, vector p2, float target)
-{
-       vector pos;
-       vector size;
-
-       pos =
-*/ // maybe one day, since this will be quite complicated
-
 // Weapon icons (#0)
 //
 float weaponspace[10];
@@ -1137,7 +1258,7 @@ void weaponorder_swap(float i, float j, entity pass)
 
 float weaponorder_cmp(float i, float j, entity pass)
 {
-       float d, ii, ij;
+       float d;
        d = mod(weaponorder[i].impulse + 9, 10) - mod(weaponorder[j].impulse + 9, 10);
        if(d)
                return d;
@@ -1148,13 +1269,12 @@ float weaponorder_cmp(float i, float j, entity pass)
 void HUD_WeaponIcons()
 {
        float id = 0;
-       float alpha, height, accuracybar_height, stat_weapons; // "constants"
-       vector pos, mySize, mysize, mypos, accuracy_color;
+       float alpha, stat_weapons; // "constants"
+       vector pos, mySize, accuracy_color;
        float i, weapid, fade, weapon_stats, weapon_hit, weapon_damage, weapon_cnt; // variables
 
        pos = HUD_Panel_GetPos(id);
        mySize = HUD_Panel_GetSize(id);
-       accuracybar_height = cvar_or("hud_weaponicons_accuracy_height", 3);
 
        stat_weapons = getstati(STAT_WEAPONS);
        for(i = WEP_FIRST; i <= WEP_LAST; ++i)
@@ -1170,7 +1290,7 @@ void HUD_WeaponIcons()
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -1215,12 +1335,9 @@ void HUD_WeaponIcons()
                        weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
                        weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
 
+                       // draw background behind currently selected weapon
                        if(self.weapon == activeweapon)
                                drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), "weapon_current_bg", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * hud_alpha_fg, DRAWFLAG_NORMAL);
-                       drawpic(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("gfx/weapons/weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * hud_alpha_fg, DRAWFLAG_NORMAL);
-
-                       if(cvar_or("hud_weaponicons_number", 1))
-                               drawstring(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
 
                        // draw the weapon accuracy on the HUD
                        if(hud_accuracy_hud && !(gametype == GAME_RACE || gametype == GAME_CTS))
@@ -1230,8 +1347,14 @@ void HUD_WeaponIcons()
 
                                accuracy_color = HUD_AccuracyColor(weapon_stats);
                                if(weapon_damage)
-                                       drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows) - '2 0 0' + eY * (mySize_y/rows - accuracybar_height), "accuracy_bar.tga", eX * mySize_x*(1/columns) + eY * accuracybar_height, accuracy_color, hud_alpha_fg, DRAWFLAG_NORMAL);
+                                       drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), "weapon_accuracy", eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), accuracy_color, hud_alpha_fg, DRAWFLAG_NORMAL);
                        }
+
+                       // draw the weapon icon
+                       drawpic_skin(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), strcat("weapon", self.netname), eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows), '1 1 1', fade * hud_alpha_fg, DRAWFLAG_NORMAL);
+
+                       if(cvar_or("hud_weaponicons_number", 1))
+                               drawstring(pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows), ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                }
 
                ++row;
@@ -1278,7 +1401,7 @@ string GetAmmoPicture(float i)
        {
                case 0: return "ammo_shells";
                case 1: return "ammo_bullets";
-               case 2: return "ammo_rocket";
+               case 2: return "ammo_rockets";
                case 3: return "ammo_cells";
                case 4: return "ammo_fuel";
                default: return "";
@@ -1297,7 +1420,7 @@ void HUD_Inventory()
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -1314,12 +1437,11 @@ void HUD_Inventory()
 
                if(cvar("hud_inventory_onlycurrent")) {
                        if (stat_items & GetAmmoItemCode(i)) {
-                               drawpic_skin(pos, "ammo_current_bg", mySize, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
-                               drawpic_skin(pos + eY * 0.05 * mySize_y, GetAmmoPicture(i), '1 1 0' * 0.8 * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
+                               drawpic_skin(pos, GetAmmoPicture(i), '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                                if(a < 10)
-                                       HUD_DrawXNum(pos + eX * 0.8 * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '0.7 0 0', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
+                                       HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '0.7 0 0', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                                else
-                                       HUD_DrawXNum(pos + eX * 0.8 * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
+                                       HUD_DrawXNum(pos + eX * mySize_y + eY * 0.25 * mySize_y, a, strlen(ftos(a)), 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                        }
                } else {
                        if (a > 0) {
@@ -1374,8 +1496,6 @@ void HUD_Inventory()
 
 // Powerups (#2)
 //
-float shield_maxtime;
-float strength_maxtime;
 void HUD_Powerups() {
        float id = 2;
        float stat_items;
@@ -1397,7 +1517,7 @@ void HUD_Powerups() {
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -1406,8 +1526,8 @@ void HUD_Powerups() {
 
        float strength_time, shield_time;
 
-       strength_time = bound(0, ceil(getstatf(STAT_STRENGTH_FINISHED) - time), 99);
-       shield_time = bound(0, ceil(getstatf(STAT_INVINCIBLE_FINISHED) - time), 99);
+       strength_time = bound(0, getstatf(STAT_STRENGTH_FINISHED) - time, 99);
+       shield_time = bound(0, getstatf(STAT_INVINCIBLE_FINISHED) - time, 99);
 
        if(hud_configure)
        {
@@ -1423,24 +1543,28 @@ void HUD_Powerups() {
 
        string leftname, rightname;
        float leftcnt, rightcnt;
+       float leftexact, rightexact;
        float leftalpha, rightalpha;
        if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) {
                leftname = "strength";
-               leftcnt = strength_time;
+               leftcnt = ceil(strength_time);
+               leftexact = strength_time;
 
                rightname = "shield";
-               rightcnt = shield_time;
+               rightcnt = ceil(shield_time);
+               rightexact = shield_time;
        } else {
                leftname = "shield";
-               leftcnt = shield_time;
+               leftcnt = ceil(shield_time);
+               leftexact = shield_time;
 
                rightname = "strength";
-               rightcnt = strength_time;
+               rightcnt = ceil(strength_time);
+               rightexact = strength_time;
        }
-       leftalpha = bound(0, leftcnt, 1);
-       rightalpha = bound(0, rightcnt, 1);
+       leftalpha = bound(0, leftexact, 1);
+       rightalpha = bound(0, rightexact, 1);
 
-       // TODO: tile statusbars?
        if (mySize_x/mySize_y > 4)
        {
                if(leftcnt)
@@ -1459,8 +1583,11 @@ void HUD_Powerups() {
                                numpos = picpos + eX * mySize_y - eX * (2-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
                        }
 
-                       drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                       if(leftcnt <= 5)
+                               drawpic_skin_expanding_two(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
+                       else
+                               drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
                        HUD_DrawXNum(numpos, leftcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                }
 
@@ -1480,8 +1607,11 @@ void HUD_Powerups() {
                                numpos = picpos - eX * mySize_y + eY * 0.25 * mySize_y;
                        }
 
-                       drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                       if(rightcnt <= 5)
+                               drawpic_skin_expanding_two(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
+                       else
+                               drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
                        HUD_DrawXNum(numpos, rightcnt, 2, 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                }
        }
@@ -1503,8 +1633,11 @@ void HUD_Powerups() {
                                numpos = picpos + eX * 0.5 * mySize_y;
                        }
 
-                       drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                       if(leftcnt <= 5)
+                               drawpic_skin_expanding_two(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
+                       else
+                               drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
                        HUD_DrawXNum(numpos, leftcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                }
 
@@ -1524,8 +1657,11 @@ void HUD_Powerups() {
                                numpos = picpos + eX * 0.5 * mySize_y;
                        }
 
-                       drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                       if(rightcnt <= 5)
+                               drawpic_skin_expanding_two(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
+                       else
+                               drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
                        HUD_DrawXNum(numpos, rightcnt, len, 0, 0.5 * mySize_y, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                }
        }
@@ -1547,8 +1683,11 @@ void HUD_Powerups() {
                                numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x;
                        }
 
-                       drawpic_skin(barpos, "statusbar_vertical", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                       HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                       if(leftcnt <= 5)
+                               drawpic_skin_expanding_two(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_ADDITIVE, bound(0, (leftcnt - leftexact) / 0.5, 1));
+                       else
+                               drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
                        HUD_DrawXNum(numpos, leftcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                }
 
@@ -1568,59 +1707,14 @@ void HUD_Powerups() {
                                numpos = pos + eX * ((2-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.25 * mySize_x + eX * 0.5 * mySize_x;
                        }
 
-                       drawpic_skin(barpos, "statusbar_vertical", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
-                       HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
-               }
-       }
-
-       /* TODO: add expand from old code!
-       //strength
-       if (strength_time) {
-               dt = strength_time - time;
-               if(dt > 0)
-               {
-                       if(dt < 5)
-                       {
-                               drawpic_expanding_two(pos, "str", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE,
-                                       bound(0, (ceil(dt) - dt) / 0.5, 1));
-                       }
+                       HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                       if(rightcnt <= 5)
+                               drawpic_skin_expanding_two(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_ADDITIVE, bound(0, (rightcnt - rightexact) / 0.5, 1));
                        else
-                       {
-                               drawpic_skin(pos, "str", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE);
-                       }
-                       HUD_DrawXNum(pos - '40 -2 0', ceil(dt), 2, 0, countdown_fontsize, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
-               }
-               else if(dt > -1)
-               {
-                       drawpic_expanding(pos, "str", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE,
-                               bound(0, -dt / 0.5, 1));
-               }
-       }
-
-       //invincibility
-       if (invincibility_time) {
-               dt = invincibility_time - time;
-               if(dt > 0)
-               {
-                       if(dt < 5)
-                       {
-                               drawpic_expanding_two(pos - '0 -22 0', "invinc", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE,
-                                       bound(0, (ceil(dt) - dt) / 0.5, 1));
-                       }
-                       else
-                       {
-                               drawpic_skin(pos - '0 -22 0', "invinc", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE);
-                       }
-                       HUD_DrawXNum(pos - '40 -24 0', ceil(dt), 2, 0, countdown_fontsize, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
-               }
-               else if(dt > -1)
-               {
-                       drawpic_expanding(pos - '0 -22 0', "invinc", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_ADDITIVE,
-                               bound(0, -dt / 0.5, 1));
+                               drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                       HUD_DrawXNum(numpos, rightcnt, len, 0, 0.25 * mySize_x, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                }
        }
-       */
 }
 
 // Health/armor (#3)
@@ -1634,14 +1728,14 @@ void HUD_HealthArmor(void)
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
                mySize -= '2 2 0' * padding;
        }
 
-       float armor, health, x;
+       float armor, health;
        armor = getstati(STAT_ARMOR);
        health = getstati(STAT_HEALTH);
 
@@ -1660,223 +1754,225 @@ void HUD_HealthArmor(void)
 
        float len;
 
-       // TODO!
-       /*
-       if(hud_hudselector == 2) // combined health and armor display
+       if(cvar("hud_healtharmor") == 2) // combined health and armor display
        {
                vector v;
                v = healtharmor_maxdamage(health, armor, armorblockpercent);
 
-               vector num_pos;
-               num_pos = - '96 28 0';
-
+               float x;
                x = floor(v_x + 1);
 
-               if(v_z) // fully armored
+               if(v_z) // NOT fully armored
                {
-                       // here, armorideal > armor
-                       drawpic_skin(num_pos + '78 -4.5 0', "health", '32 32 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
-                       drawpic_skin(num_pos + '108 -4.5 0', "armor", '20 20 0', '1 1 1', hud_alpha_fg * armor / v_y, DRAWFLAG_NORMAL);
+                       drawpic_skin(pos + eX * 3 * mySize_y, "health", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
+                       if(armor)
+                               drawpic_skin(pos + eX * 4 * mySize_y, "armor", '0.5 0.5 0' * mySize_y, '1 1 1', hud_alpha_fg * armor / health, DRAWFLAG_NORMAL);
                }
                else
                {
-                       drawpic_skin(num_pos + '108 -4.5 0', "health", '20 20 0', '1 1 1', hud_alpha_fg * v_y / armor, DRAWFLAG_NORMAL);
-                       drawpic_skin(num_pos + '78 -4.5 0', "armor", '32 32 0', '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
+                       drawpic_skin(pos + eX * 4 * mySize_y, "health", '0.5 0.5 0' * mySize_y, '1 1 1', hud_alpha_fg * health / armor, DRAWFLAG_NORMAL);
+                       if(armor)
+                               drawpic_skin(pos + eX * 3 * mySize_y, "armor", '1 1 0' * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                }
-               HUD_DrawXNum_Colored(num_pos, x, 3, 24, hud_alpha_fg); // draw the combined health and armor
+               HUD_DrawXNum_Colored(pos, x, 3, mySize_y, hud_alpha_fg); // draw the combined health and armor
        }
 
        else
        {
-       */
-       vector barpos, barsize;
-       vector picpos;
-       vector numpos;
-
-       string leftname, rightname;
-       float leftcnt, rightcnt;
-       float leftactive, rightactive;
-       float leftalpha, rightalpha;
-       // TODO!
-       if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
-               leftname = "armor";
-               leftcnt = armor;
-               if(leftcnt)
+               vector barpos, barsize;
+               vector picpos;
+               vector numpos;
+
+               string leftname, rightname;
+               float leftcnt, rightcnt;
+               float leftactive, rightactive;
+               float leftalpha, rightalpha;
+               if (cvar(strcat("hud_", HUD_Panel_GetName(id), "_flip"))) { // old style layout with armor left/top of health
+                       leftname = "armor";
+                       leftcnt = armor;
+                       if(leftcnt)
+                               leftactive = 1;
+                       leftalpha = min((armor+10)/55, 1);
+
+                       rightname = "health";
+                       rightcnt = health;
+                       rightactive = 1;
+                       rightalpha = 1;
+               } else {
+                       leftname = "health";
+                       leftcnt = health;
                        leftactive = 1;
-               leftalpha = min((armor+10)/55, 1);
+                       leftalpha = 1;
 
-               rightname = "health";
-               rightcnt = health;
-               rightactive = 1;
-               rightalpha = 1;
-       } else {
-               leftname = "health";
-               leftcnt = health;
-               leftactive = 1;
-               leftalpha = 1;
-
-               rightname = "armor";
-               rightcnt = armor;
-               if(rightcnt)
-                       rightactive = 1;
-               rightalpha = min((armor+10)/55, 1);
-       }
+                       rightname = "armor";
+                       rightcnt = armor;
+                       if(rightcnt)
+                               rightactive = 1;
+                       rightalpha = min((armor+10)/55, 1);
+               }
 
-       // TODO: tile statusbars?
-       if (mySize_x/mySize_y > 5)
-       {
-               if(leftactive)
+               if (mySize_x/mySize_y > 5)
                {
-                       len = strlen(ftos(leftcnt));
+                       if(leftactive)
+                       {
+                               len = strlen(ftos(leftcnt));
 
-                       if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
-                               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;
-                               picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
-                               numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
-                       } else {
-                               barpos = pos;
-                               barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
-                               picpos = pos;
-                               numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
+                               if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
+                                       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;
+                                       picpos = pos + eX * 0.5 * mySize_x - eX * mySize_y;
+                                       numpos = picpos - eX * 3 * 0.5 * mySize_y + eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
+                               } else {
+                                       barpos = pos;
+                                       barsize = eX * 0.5 * mySize_x * min(1, leftcnt/200) + eY * mySize_y;
+                                       picpos = pos;
+                                       numpos = picpos + eX * mySize_y + eY * 0.25 * mySize_y;
+                               }
+
+                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                               drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                               HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, hud_alpha_fg);
                        }
 
-                       drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, leftname, '1 1 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
-                       HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, hud_alpha_fg);
-               }
+                       if(rightactive)
+                       {
+                               len = strlen(ftos(rightcnt));
 
-               if(rightactive)
-               {
-                       len = strlen(ftos(rightcnt));
+                               if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
+                                       barpos = pos + eX * 0.5 * mySize_x;
+                                       barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
+                                       picpos = pos + eX * 0.5 * mySize_x;
+                                       numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
+                               } else {
+                                       barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
+                                       barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
+                                       picpos = pos + eX * mySize_x - eX * mySize_y;
+                                       numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
+                               }
+
+                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                               drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                               HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, hud_alpha_fg);
+                       }
 
                        if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
-                               barpos = pos + eX * 0.5 * mySize_x;
-                               barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
-                               picpos = pos + eX * 0.5 * mySize_x;
-                               numpos = picpos + eX * mySize_y - eX * (3-len) * 0.5 * mySize_y + eY * 0.25 * mySize_y;
+                               barpos = pos - eX * mySize_x * min(1, fuel/100);
+                               barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
                        } else {
-                               barpos = pos + eX * mySize_x - eX * 0.5 * mySize_x * min(1, rightcnt/200);
-                               barsize = eX * 0.5 * mySize_x * min(1, rightcnt/200) + eY * mySize_y;
-                               picpos = pos + eX * mySize_x - eX * mySize_y;
-                               numpos = picpos - eX * 1.5 * mySize_y + eY * 0.25 * mySize_y;
+                               barpos = pos;
+                               barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y;
                        }
-
-                       drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, rightname, '1 1 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
-                       HUD_DrawXNum_Colored(numpos, rightcnt, 3, 0.5 * mySize_y, hud_alpha_fg);
+                       if(fuel)
+                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), hud_alpha_fg * 0.8, DRAWFLAG_NORMAL);
                }
-
-               if(fuel)
-                       drawpic_skin(pos, "statusbar", eX * mySize_x * min(1, fuel/100) + eY * 0.2 * mySize_y, HUD_Panel_GetProgressBarColor("fuel"), hud_alpha_fg * 0.8, DRAWFLAG_NORMAL);
-       }
-       else if (mySize_x/mySize_y > 2)
-       {
-               if(leftactive)
+               else if (mySize_x/mySize_y > 2)
                {
-                       len = strlen(ftos(leftcnt));
+                       if(leftactive)
+                       {
+                               len = strlen(ftos(leftcnt));
 
-                       if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
-                               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;
-                               picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
-                               numpos = picpos - eX * len * 0.5 * mySize_y;
-                       } else {
-                               barpos = pos;
-                               barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
-                               picpos = pos;
-                               numpos = picpos + eX * 0.5 * mySize_y;
+                               if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
+                                       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;
+                                       picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y;
+                                       numpos = picpos - eX * len * 0.5 * mySize_y;
+                               } else {
+                                       barpos = pos;
+                                       barsize = eX * mySize_x * min(1, leftcnt/200) + eY * 0.5 * mySize_y;
+                                       picpos = pos;
+                                       numpos = picpos + eX * 0.5 * mySize_y;
+                               }
+
+                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                               drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                               HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, hud_alpha_fg);
                        }
 
-                       drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, leftname, '0.5 0.5 0' * mySize_y, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
-                       HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.5 * mySize_y, hud_alpha_fg);
-               }
+                       if(rightactive)
+                       {
+                               len = strlen(ftos(rightcnt));
 
-               if(rightactive)
-               {
-                       len = strlen(ftos(rightcnt));
+                               if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
+                                       barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
+                                       barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
+                                       picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
+                                       numpos = picpos - eX * len * 0.5 * mySize_y;
+                               } else {
+                                       barpos = pos + eY * 0.5 * mySize_y;
+                                       barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
+                                       picpos = pos + eY * 0.5 * mySize_y;
+                                       numpos = picpos + eX * 0.5 * mySize_y;
+                               }
+
+                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                               drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                               HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, hud_alpha_fg);
+                       }
 
                        if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
-                               barpos = pos + eX * mySize_x - eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
-                               barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
-                               picpos = pos + eX * mySize_x - eX * 0.5 * mySize_y + eY * 0.5 * mySize_y;
-                               numpos = picpos - eX * len * 0.5 * mySize_y;
+                               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 {
-                               barpos = pos + eY * 0.5 * mySize_y;
-                               barsize = eX * mySize_x * min(1, rightcnt/200) + eY * 0.5 * mySize_y;
-                               picpos = pos + eY * 0.5 * mySize_y;
-                               numpos = picpos + eX * 0.5 * mySize_y;
+                               barpos = pos;
+                               barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
                        }
-
-                       drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, rightname, '0.5 0.5 0' * mySize_y, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
-                       HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.5 * mySize_y, hud_alpha_fg);
+                       if(fuel)
+                               HUD_Panel_DrawProgressBar(barpos, 0, barsize, HUD_Panel_GetProgressBarColor("fuel"), hud_alpha_fg * 0.8, DRAWFLAG_NORMAL);
                }
-
-               if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
-                       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 {
-                       barpos = pos;
-                       barsize = eX * mySize_x * min(1, fuel/100) + eY * 0.1 * mySize_y;
-               }
-               if(fuel)
-                       drawpic_skin(barpos, "statusbar", barsize, HUD_Panel_GetProgressBarColor("fuel"), hud_alpha_fg * 0.8, DRAWFLAG_NORMAL);
-       }
-       else
-       {
-               if(leftactive)
+               else
                {
-                       len = strlen(ftos(leftcnt));
+                       if(leftactive)
+                       {
+                               len = strlen(ftos(leftcnt));
 
-                       if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
-                               barpos = pos;
-                               barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
-                               picpos = pos + eX * 0.05 * mySize_x;
-                               numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
-                       } else {
-                               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);
-                               picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
-                               numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
+                               if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
+                                       barpos = pos;
+                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, leftcnt/200);
+                                       picpos = pos + eX * 0.05 * mySize_x;
+                                       numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x;
+                               } else {
+                                       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);
+                                       picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x;
+                                       numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x;
+                               }
+
+                               HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                               drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                               HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, hud_alpha_fg);
                        }
 
-                       drawpic_skin(barpos, "statusbar_vertical", barsize, HUD_Panel_GetProgressBarColor(leftname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, leftname, '0.4 0.4 0' * mySize_x, '1 1 1', leftalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
-                       HUD_DrawXNum_Colored(numpos, leftcnt, len, 0.166 * mySize_x, hud_alpha_fg);
-               }
+                       if(rightactive)
+                       {
+                               len = strlen(ftos(rightcnt));
 
-               if(rightactive)
-               {
-                       len = strlen(ftos(rightcnt));
+                               if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
+                                       barpos = pos + eX * 0.5 * mySize_x;
+                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
+                                       picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
+                                       numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
+                               } else {
+                                       barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
+                                       barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
+                                       picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
+                                       numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
+                               }
+
+                               HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+                               drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+                               HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, hud_alpha_fg);
+                       }
 
                        if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
-                               barpos = pos + eX * 0.5 * mySize_x;
-                               barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
-                               picpos = pos + eX * 0.05 * mySize_x + eX * 0.5 * mySize_x;
-                               numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * 0.4 * mySize_x + eX * 0.5 * mySize_x;
+                               barpos = pos;
+                               barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
                        } else {
-                               barpos = pos + eY * mySize_y - eY * mySize_y * min(1, rightcnt/200) + eX * 0.5 * mySize_x;
-                               barsize = eX * 0.5 * mySize_x + eY * mySize_y * min(1, rightcnt/200);
-                               picpos = pos + eX * 0.05 * mySize_x + eY * mySize_y - eY * 0.566 * mySize_x + eX * 0.5 * mySize_x;
-                               numpos = pos + eX * ((3-len)/2) * 0.25 * mySize_x + eY * mySize_y - eY * 0.166 * mySize_x + eX * 0.5 * mySize_x;
+                               barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
+                               barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
                        }
-
-                       drawpic_skin(barpos, "statusbar_vertical", barsize, HUD_Panel_GetProgressBarColor(rightname), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
-                       drawpic_skin(picpos, rightname, '0.4 0.4 0' * mySize_x, '1 1 1', rightalpha * hud_alpha_fg, DRAWFLAG_NORMAL);
-                       HUD_DrawXNum_Colored(numpos, rightcnt, len, 0.166 * mySize_x, hud_alpha_fg);
+                       if(fuel)
+                               HUD_Panel_DrawProgressBar(barpos, 1, barsize, HUD_Panel_GetProgressBarColor("fuel"), hud_alpha_fg * 0.8, DRAWFLAG_NORMAL);
                }
-
-               if(cvar(strcat("hud_", HUD_Panel_GetName(id), "_mirror"))) {
-                       barpos = pos;
-                       barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
-               } else {
-                       barpos = pos + eY * mySize_y - eY * mySize_y * min(1, fuel/100);
-                       barsize = eX * 0.05 * mySize_x + eY * mySize_y * min(1, fuel/100);
-               }
-               if(fuel)
-                       drawpic_skin(barpos, "statusbar_vertical", barsize, HUD_Panel_GetProgressBarColor("fuel"), hud_alpha_fg * 0.8, DRAWFLAG_NORMAL);
        }
 }
 
@@ -1892,7 +1988,7 @@ void HUD_Notify (void)
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -2027,7 +2123,7 @@ void HUD_Timer()
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -2086,7 +2182,7 @@ void HUD_Radar(void)
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -2099,15 +2195,15 @@ void HUD_Radar(void)
        float scale2d, normalsize, bigsize;
        float f;
 
-       teamradar_origin2d = pos + 0.5 * mySize; // TODO: stupid compat, should be removed
+       teamradar_origin2d = pos + 0.5 * mySize;
        teamradar_size2d = mySize;
 
-       if(minimapname == "" && !ons_showmap)
+       if(minimapname == "")
                return;
 
        teamradar_loadcvars();
 
-       switch(cl_teamradar_zoommode)
+       switch(hud_radar_zoommode)
        {
                default:
                case 0:
@@ -2124,13 +2220,13 @@ void HUD_Radar(void)
                        break;
        }
 
-       switch(cl_teamradar_rotation)
+       switch(hud_radar_rotation)
        {
                case 0:
                        teamradar_angle = view_angles_y - 90;
                        break;
                default:
-                       teamradar_angle = 90 * cl_teamradar_rotation;
+                       teamradar_angle = 90 * hud_radar_rotation;
                        break;
        }
 
@@ -2140,7 +2236,7 @@ void HUD_Radar(void)
        teamradar_extraclip_mins = teamradar_extraclip_maxs = '0 0 0'; // we always center
 
        // pixels per world qu to match the teamradar_size2d_x range in the longest dimension
-       if(cl_teamradar_rotation == 0)
+       if(hud_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));
@@ -2163,7 +2259,7 @@ void HUD_Radar(void)
                );
        }
 
-       normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / cl_teamradar_scale;
+       normalsize = vlen_maxnorm2d(teamradar_size2d) * scale2d / hud_radar_scale;
        if(bigsize > normalsize)
                normalsize = bigsize;
 
@@ -2184,29 +2280,7 @@ void HUD_Radar(void)
                mySize_y
        );
 
-       draw_teamradar_background(cl_teamradar_background_alpha, cl_teamradar_foreground_alpha);
-
-       if(ons_showmap)
-       {
-               drawresetcliparea();
-
-               vector frame_origin, frame_size;
-               frame_origin = frame_size = '0 0 0';
-
-               frame_origin_x = pos_x - teamradar_size2d_x * 0.55859375; // matches the picture
-               frame_origin_y = pos_y - teamradar_size2d_y * 0.55859375; // matches the picture
-               frame_size_x = pos_x * 1.1171875; // matches the picture
-               frame_size_y = pos_y * 1.1171875; // matches the picture
-               drawpic_skin(frame_origin, "gfx/ons-frame.tga", frame_size, '1 1 1', hud_alpha_fg, 0);
-               drawpic_skin(frame_origin, "gfx/ons-frame-team.tga", frame_size, rgb, hud_alpha_fg, 0);
-
-               drawsetcliparea(
-                       pos_x - teamradar_size2d_x * 0.5,
-                       pos_y - teamradar_size2d_y * 0.5,
-                       teamradar_size2d_x,
-                       teamradar_size2d_y
-               );
-       }
+       draw_teamradar_background(hud_radar_background_alpha, hud_radar_foreground_alpha);
 
        for(tm = world; (tm = find(tm, classname, "radarlink")); )
                draw_teamradar_link(tm.origin, tm.velocity, tm.team);
@@ -2234,7 +2308,7 @@ void HUD_Score()
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -2243,7 +2317,7 @@ void HUD_Score()
 
        float score, distribution, leader;
        float score_len, distr_len;
-       vector score_pos, secondary_score_pos, distribution_color;
+       vector distribution_color;
        entity tm, pl, me;
        me = (spectatee_status > 0) ? playerslots[spectatee_status - 1] : playerslots[player_localentnum - 1];
 
@@ -2292,7 +2366,7 @@ void HUD_Score()
                }
                // race record display
                if (distribution <= 0 || distribution == score) // draw the highlight background behind the timer if we have the lead
-                       drawpic_skin(bottomright - '0 32 0' - '32 0 0' * (4 + TIME_DECIMALS), "highlight_4", '0 28 0' + '32 0 0' * (4 + TIME_DECIMALS), '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
+                       drawpic_skin(bottomright - '0 32 0' - '32 0 0' * (4 + TIME_DECIMALS), "num_leading_4", '0 28 0' + '32 0 0' * (4 + TIME_DECIMALS), '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
 
                HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0', racemsec, -TIME_DECIMALS, 0, 30, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                HUD_DrawXNum(bottomright - '0 32 0' - TIME_DECIMALS * '30 0 0'  - '66 0 0', racesec, -2, 0, 30, '1 1 1', 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
@@ -2334,7 +2408,7 @@ void HUD_Score()
 
                HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * 0.33 * mySize_y, distribution, 3, 3, 0.33 * mySize_y, distribution_color, 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                if (leader)
-                       drawpic_skin(pos + eX * mySize_x - eX * score_len * mySize_y - eX * 3 * 0.33 * mySize_y, strcat("highlight_", ftos(score_len)), eX * score_len * mySize_y + eY * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
+                       drawpic_skin(pos + eX * mySize_x - eX * score_len * mySize_y - eX * 3 * 0.33 * mySize_y, strcat("num_leading_", ftos(score_len)), eX * score_len * mySize_y + eY * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * mySize_y - eX * 3 * 0.33 * mySize_y, score, 3, 0, mySize_y, distribution_color, 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
        } else { // teamgames
                float max_fragcount;
@@ -2358,13 +2432,13 @@ void HUD_Score()
                                if (max_fragcount == score)
                                        leader = 1;
                                if (leader)
-                                       drawpic_skin(pos + eX * mySize_x - eX * score_len * mySize_y - eX * 3 * 0.33 * mySize_y, strcat("highlight_", ftos(score_len)), eX * score_len * mySize_y + eY * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
+                                       drawpic_skin(pos + eX * mySize_x - eX * score_len * mySize_y - eX * 3 * 0.33 * mySize_y, strcat("num_leading_", ftos(score_len)), eX * score_len * mySize_y + eY * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                                HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * mySize_y - eX * 3 * 0.33 * mySize_y, score, 3, 0, mySize_y, GetTeamRGB(tm.team) * 0.8, 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                        } else {
                                if (max_fragcount == score)
                                        leader = 1;
                                if (leader)
-                                       drawpic_skin(pos + eX * mySize_x - eX * 0.33 * score_len * mySize_y + eY * 0.33 * mySize_y * teamnum, strcat("highlight_", ftos(score_len)), eX * 0.33 * score_len * mySize_y + eY * 0.33 * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
+                                       drawpic_skin(pos + eX * mySize_x - eX * 0.33 * score_len * mySize_y + eY * 0.33 * mySize_y * teamnum, strcat("num_leading_", ftos(score_len)), eX * 0.33 * score_len * mySize_y + eY * 0.33 * mySize_y, '1 1 1', hud_alpha_fg, DRAWFLAG_NORMAL);
                                HUD_DrawXNum(pos + eX * mySize_x - eX * 3 * 0.33 * mySize_y + eY * 0.33 * mySize_y * teamnum, score, 3, 0, 0.33 * mySize_y, GetTeamRGB(tm.team) * 0.8, 0, 0, hud_alpha_fg, DRAWFLAG_NORMAL);
                                teamnum += 1;
                        }
@@ -2382,7 +2456,7 @@ void HUD_RaceTimer (void) {
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -2545,7 +2619,7 @@ void HUD_VoteWindow(void)
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -2555,11 +2629,11 @@ void HUD_VoteWindow(void)
        if(vote_alpha) {
                a = vote_alpha * bound(cvar_or("hud_vote_alreadyvoted_alpha", 0.75), 1 - vote_highlighted, 1);
 
-               drawpic_skin(pos, "voteprogress_back", mySize, HUD_GetBgColor(), a * hud_alpha_bg, DRAWFLAG_NORMAL);
+               drawpic_skin(pos, "voteprogress_back", mySize, HUD_Panel_GetColor(id), a * hud_alpha_bg, DRAWFLAG_NORMAL);
 
                s = "A vote has been called for: ";
                drawstring(pos + '0.5 0 0' * mySize_x + '0 0.1 0' * mySize_y - eX * stringwidth(s, FALSE, '1 1 0' * 0.5 * mySize_y*(1/5)), s, '1 1 0' * mySize_y*(1/5), '1 1 1', a * hud_alpha_fg, DRAWFLAG_NORMAL);
-               s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '10 0 0', stringwidth_colors);
+               s = textShortenToWidth(vote_called_vote, mySize_x * 0.96, '10 0 0', stringwidth_colors); // TODO: broken?
                if(hud_configure)
                        s = "Configure the HUD";
                drawcolorcodedstring(pos + '0.52 0 0' * mySize_x + '0 0.3 0' * mySize_y - eX * stringwidth(s, FALSE, '1 1 0' * 0.5 * mySize_y*(1/6)), s, '1 1 0' * mySize_y*(1/6), a * hud_alpha_fg, DRAWFLAG_NORMAL);
@@ -2620,6 +2694,12 @@ void HUD_Mod_CTF(vector pos, vector mySize)
        redflag = (stat_items/IT_RED_FLAG_TAKEN) & 3;
        blueflag = (stat_items/IT_BLUE_FLAG_TAKEN) & 3;
 
+       if(hud_configure)
+       {
+               redflag = 1;
+               blueflag = 2;
+       }
+
        // when status CHANGES, set old status into prevstatus and current status into status
        if (redflag != redflag_prevframe)
        {
@@ -2849,7 +2929,6 @@ void HUD_Mod_NexBall(vector pos, vector mySize)
        //Manage the progress bar if any
        if (nb_pb_starttime > 0)
        {
-               vector s;
                dt = mod(time - nb_pb_starttime, nb_pb_period);
                // one period of positive triangle
                p = 2 * dt / nb_pb_period;
@@ -2857,7 +2936,7 @@ void HUD_Mod_NexBall(vector pos, vector mySize)
                        p = 2 - p;
 
                //Draw the filling
-               drawpic_skin(pos, "statusbar", eX * p * mySize_x + eY * mySize_y, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(pos, 0, eX * p * mySize_x + eY * mySize_y, HUD_Panel_GetProgressBarColor("nexball"), cvar("hud_progressbar_alpha"), DRAWFLAG_NORMAL);
        }
 
        pos_x += 0.5 * mySize_x - 0.5 * mySize_y; //horizontal margin to the picture
@@ -3006,7 +3085,7 @@ void HUD_ModIcons(void)
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -3016,7 +3095,7 @@ void HUD_ModIcons(void)
        // TODO... well make them work in a panel etc
        if(gametype == GAME_KEYHUNT)
                HUD_Mod_KH(pos, mySize);
-       else if(gametype == GAME_CTF)
+       else if(gametype == GAME_CTF || hud_configure)
                HUD_Mod_CTF(pos, mySize);
        else if(gametype == GAME_NEXBALL)
                HUD_Mod_NexBall(pos, mySize);
@@ -3035,7 +3114,7 @@ void HUD_DrawPressedKeys(void)
 
        HUD_Panel_DrawBg(id, pos, mySize);
        float padding;
-       padding = cvar(strcat("hud_", HUD_Panel_GetName(id), "_bg_padding"));
+       padding = HUD_Panel_GetPadding(id);
        if(padding)
        {
                pos += '1 1 0' * padding;
@@ -3151,9 +3230,9 @@ void HUD_ShowAcceleration(void)
        }
 
        if (acceleration > 0)
-               drawpic_skin(pos, "statusbar", acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(pos, 0, acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_alpha_fg, DRAWFLAG_NORMAL);
        else if (acceleration < 0)
-               drawpic_skin(pos + acceleration * scale * '40 0 0', "statusbar", -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_alpha_fg, DRAWFLAG_NORMAL);
+               HUD_Panel_DrawProgressBar(pos + acceleration * scale * '40 0 0', 0, -acceleration * scale * '40 0 0' + sz * eY, rgb, alpha * hud_alpha_fg, DRAWFLAG_NORMAL);
 }
 
 void HUD_Reset (void)
@@ -3178,8 +3257,8 @@ void HUD_Main (void)
        hud_configure = cvar("_hud_configure");
 
        // Drawing stuff
-       if(cvar("hud_dock"))
-               drawpic_skin('0 0 0', "dock", eX * vid_conwidth + eY * vid_conheight, stov(cvar_string("hud_dock_color")), cvar("hud_dock_alpha"), DRAWFLAG_NORMAL);
+       if(cvar_string("hud_dock") != "")
+               drawpic_skin('0 0 0', cvar_string("hud_dock"), eX * vid_conwidth + eY * vid_conheight, HUD_Panel_Dock_GetColor(), cvar("hud_dock_alpha"), DRAWFLAG_NORMAL);
 
        if(HUD_Panel_CheckActive(0))
                HUD_WeaponIcons();
@@ -3195,7 +3274,7 @@ void HUD_Main (void)
                HUD_Timer();
        // TODO hud'ify
        if(HUD_Panel_CheckActive(6))
-               if(ons_showmap || cvar_string("cl_teamradar") != "0" && (cvar("cl_teamradar") == 2 || teamplay))
+               if(cvar_string("hud_radar") != "0" && (cvar("hud_radar") == 2 || teamplay))
                        HUD_Radar();
        if(HUD_Panel_CheckActive(7))
                HUD_Score();