]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - data/qcsrc/client/hud.qc
Remove the code for each HUD background image, and create a system which allows defin...
[voretournament/voretournament.git] / data / qcsrc / client / hud.qc
index 5e9b0717ea3c4284844ede607023df37f8d81591..f0f8b116ace17e6061e7867cf4a8a1eda7e2bb92 100644 (file)
@@ -1766,6 +1766,44 @@ string GetAmmoPicture(float i)
        }\r
 }\r
 \r
+void Sbar_DrawBackgrounds()\r
+{\r
+       // Draw all backgrounds defined by our HUD setup\r
+       if (cvar("viewsize") > 100 || !sbar_hudselector)\r
+               return;\r
+\r
+       float total = cvar("hud_backgrounds");\r
+       float i;\r
+       for(i = 1; i <= total; i++)\r
+       {\r
+               string img = cvar_string(strcat("hud_background_", ftos(i), "_texture"));\r
+               vector pos = stov(cvar_string(strcat("hud_background_", ftos(i), "_position")));\r
+               vector sz = stov(cvar_string(strcat("hud_background_", ftos(i), "_scale")));\r
+\r
+               pos = Sbar_ConvertToScreen_PicPosition(pos, sz);\r
+               sz = Sbar_ConvertToScreen_PicScale(sz);\r
+\r
+               vector col;\r
+               switch(cvar(strcat("hud_background_", ftos(i), "_colortype")))\r
+               {\r
+                       case 1:\r
+                               if(teamplay)\r
+                                       col = GetTeamRGB(myteam) * sbar_color_bg_team;\r
+                               else\r
+                                       col = stov(cvar_string("sbar_color_bg"));\r
+                               break;\r
+                       case 2:\r
+                               col = Sbar_ColorFade(Sbar_GetVoreColor());\r
+                               break;\r
+                       default:\r
+                               col = '1 1 1';\r
+                               break;\r
+               }\r
+\r
+               drawpic(pos, img, sz, col, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
+       }\r
+}\r
+\r
 float race_status_time;\r
 float race_status_prev;\r
 string race_status_name_prev;\r
@@ -2118,9 +2156,6 @@ void Sbar_Status()
        float stat_items;\r
        stat_items = getstati(STAT_ITEMS);\r
 \r
-       if (cvar("viewsize") <= 100 && sbar_hudselector)\r
-               Sbar_DrawPic("gfx/hud/bg_status", stov(cvar_string("hud_panel_status_background_position")), stov(cvar_string("hud_panel_status_background_scale")), TRUE);\r
-\r
        // armor\r
        x = armor;\r
        if (x > 0)\r
@@ -2183,7 +2218,7 @@ void Sbar_Status()
        entity e;\r
        e = get_weaponinfo(activeweapon);\r
        if (e && e.netname != "" && e.netname != "N/A")\r
-               Sbar_DrawPic(strcat("gfx/hud/bg_status_activeweapon_", e.netname), stov(cvar_string("hud_item_weapon_position")), stov(cvar_string("hud_item_weapon_scale")), FALSE);\r
+               Sbar_DrawPic(strcat("gfx/hud/sb_activeweapon_", e.netname), stov(cvar_string("hud_item_weapon_position")), stov(cvar_string("hud_item_weapon_scale")), FALSE);\r
 }\r
 \r
 void Sbar_Timer()\r
@@ -2225,16 +2260,6 @@ void Sbar_Timer()
                seconds = secondsLeft;\r
        }\r
 \r
-       if (cvar("viewsize") <= 100 && sbar_hudselector) { // draw timer background when viewsize <= 100\r
-               if (teamplay)\r
-                       drawpic('1 0 0' * (vid_conwidth - (70 + 17 + 12)), "gfx/hud/bg_timer", '120 30 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // timer bg color = myteam color\r
-               else {\r
-                       color = stov(cvar_string("sbar_color_bg"));\r
-\r
-                       drawpic('1 0 0' * (vid_conwidth - (70 + 17 + 12)), "gfx/hud/bg_timer", '120 30 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
-               }\r
-       }\r
-\r
        Sbar_DrawPic("gfx/hud/sb_time", stov(cvar_string("hud_item_timer_icon_position")), stov(cvar_string("hud_item_timer_icon_scale")), FALSE);\r
 \r
        finaltime = strcat(ftos(minutes), ":");\r
@@ -3214,21 +3239,11 @@ void Sbar_Draw (void)
                        }\r
                }\r
 \r
+               Sbar_DrawBackgrounds();\r
+\r
                if(g_vore) // only when the vore system is active\r
                {\r
                        // draw the stomach board\r
-                       if (cvar("viewsize") <= 100 && sbar_hudselector) {\r
-                               if (teamplay)\r
-                                       drawpic(bottomleft- '0 256 0', "gfx/hud/bg_stomach", '256 256 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color\r
-                               else {\r
-                                       // allow for custom HUD colors in non-teamgames\r
-                                       color = stov(cvar_string("sbar_color_bg"));\r
-\r
-                                       drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach", '256 256 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
-                               }\r
-                       }\r
-\r
-                       drawpic(bottomleft - '0 256 0', "gfx/hud/bg_stomach_status", '256 256 0', Sbar_ColorFade(Sbar_GetVoreColor()), cvar("sbar_stomachboard_status_alpha") * sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
                        float stomach_load, stomach_maxload; // shows the predator's stomach load when we are eaten, and ours otherwise\r
                        stomach_load = getstati(STAT_VORE_LOAD);\r