]> git.rm.cloudns.org Git - voretournament/voretournament.git/commitdiff
Allow cvar positions and sizes for the status HUD panel (everything else will follow...
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 16 May 2012 15:37:33 +0000 (18:37 +0300)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 16 May 2012 15:37:33 +0000 (18:37 +0300)
data/default.cfg
data/qcsrc/client/hud.qc

index c6d6a1b288f608248844834f3ec4c83e31761ab0..252cc5ceb7a2ca111bde4cb493224c15fcda5e6a 100644 (file)
@@ -4,4 +4,5 @@ exec botsVT.cfg
 exec ctfscoringVT.cfg\r
 exec physicsVT.cfg\r
 exec balanceVT.cfg\r
-exec turretsVT.cfg
\ No newline at end of file
+exec turretsVT.cfg\r
+exec hudVT.cfg
\ No newline at end of file
index 64f428c4e603a02611a081013fc4d67e39ac252f..4406129beeb224d6cc7da4ac079d548ed01474af 100644 (file)
@@ -33,6 +33,20 @@ float ts_primary, ts_secondary;
 \r
 vector color;\r
 \r
+vector Sbar_Edge(string str)\r
+{\r
+       vector pos;\r
+       switch(str)\r
+       {\r
+               case "bottom":\r
+                       pos_x = vid_conwidth / 2;\r
+                       pos_y = vid_conheight;\r
+               default:\r
+                       break;\r
+       }\r
+       return pos;\r
+}\r
+\r
 void CSQC_kh_hudreset();\r
 void CSQC_kh_hud();\r
 void CSQC_ctf_hudreset();\r
@@ -1973,11 +1987,6 @@ void Sbar_Score()
 \r
 void Sbar_Status()\r
 {\r
-       vector bottom;\r
-       bottom_x = vid_conwidth/2;\r
-       bottom_y = vid_conheight;\r
-       bottom_z = 0;\r
-\r
        float armor, health, x, a;\r
        armor = getstati(STAT_ARMOR);\r
        health = getstati(STAT_HEALTH);\r
@@ -1985,54 +1994,56 @@ void Sbar_Status()
        float stat_items;\r
        stat_items = getstati(STAT_ITEMS);\r
 \r
-       vector health_pos, armor_pos, pos;\r
-       health_pos = bottom - '43 58 0';\r
-       armor_pos = bottom - '43 68 0';\r
+       vector edge, pos, pos2;\r
+       edge = Sbar_Edge(cvar_string("hud_panel_status_edge"));\r
 \r
+       pos = edge - stov(cvar_string("hud_panel_status_background_position"));\r
        if (cvar("viewsize") <= 100 && sbar_hudselector) {\r
                if (teamplay)\r
-                       drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color\r
+                       drawpic(pos, "gfx/hud/bg_status", stov(cvar_string("hud_panel_status_background_scale")), 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(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
+                       drawpic(pos, "gfx/hud/bg_status", stov(cvar_string("hud_panel_status_background_scale")), color, sbar_alpha_bg, DRAWFLAG_NORMAL);\r
                }\r
        }\r
 \r
        // armor\r
+       pos = edge - stov(cvar_string("hud_panel_status_item_armor_text_position"));\r
+       pos2 = edge - stov(cvar_string("hud_panel_status_item_armor_icon_position"));\r
        x = armor;\r
        if (x > 0)\r
        {\r
-               drawpic(armor_pos + '-8 -13.5 0', "gfx/hud/sb_armor", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-               armor_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '12 12 0') * 0.5;\r
-               Sbar_DrawXNum(armor_pos, x, 3, 0, 12, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+               drawpic(pos2, "gfx/hud/sb_armor", stov(cvar_string("hud_panel_status_item_armor_icon_scale")), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+               pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '1 1 0' * cvar("hud_panel_status_item_armor_text_scale")) * 0.5;\r
+               Sbar_DrawXNum(pos, x, 3, 0, cvar("hud_panel_status_item_armor_text_scale"), Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
        }\r
 \r
        // health\r
+       pos = edge - stov(cvar_string("hud_panel_status_item_health_text_position"));\r
+       pos2 = edge - stov(cvar_string("hud_panel_status_item_health_icon_position"));\r
        x = health;\r
-       drawpic(health_pos + '-11 16 0', "gfx/hud/sb_health", '32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-       health_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '22 22 0') * 0.5;\r
-       Sbar_DrawXNum(health_pos, x, 3, 0, 22, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+       drawpic(pos2, "gfx/hud/sb_health", stov(cvar_string("hud_panel_status_item_health_icon_scale")), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+       pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '1 1 0' * cvar("hud_panel_status_item_health_text_scale")) * 0.5;\r
+       Sbar_DrawXNum(pos, x, 3, 0, cvar("hud_panel_status_item_health_text_scale"), Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 \r
        // if we are dead, we can skip the HUD from here\r
        if(health <= 0)\r
                return;\r
 \r
        // ammo\r
-       pos_x = bottom_x + 140;\r
-       pos_y = bottom_y - 20;\r
-\r
        float weapon_clipload, weapon_clipsize;\r
-       vector ammo_pos_offset;\r
 \r
        // if we are using the jetpack, show fuel ammo. Otherwise show the ammo of our weapon\r
        if(stat_items & IT_JETPACK && button_jetpack)\r
        {\r
+               pos = edge - stov(cvar_string("hud_panel_status_item_noload_ammo_text_position"));\r
+               pos2 = edge - stov(cvar_string("hud_panel_status_item_ammo_icon_position"));\r
                a = getstati(GetAmmoStat(0)); // how much fuel do we have?\r
-               drawpic(pos - '98 18 0', GetAmmoPicture(0), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
-               ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5;\r
-               Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+               drawpic(pos2, GetAmmoPicture(0), stov(cvar_string("hud_panel_status_item_noload_ammo_icon_scale")), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+               pos -= '1 0 0' * stringwidth(ftos(a), FALSE, '1 1 0' * cvar("hud_panel_status_item_noload_ammo_text_scale")) * 0.5;\r
+               Sbar_DrawXNum(pos, a, 3, 0, cvar("hud_panel_status_item_noload_ammo_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
        }\r
        else\r
        {\r
@@ -2044,40 +2055,45 @@ void Sbar_Status()
                        // if (stat_items & GetAmmoItemCode(i))\r
                        {\r
                                a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?\r
-                               drawpic(pos - '98 18 0', GetAmmoPicture(i), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                               pos2 = edge - stov(cvar_string("hud_panel_status_item_ammo_icon_position"));\r
+                               drawpic(pos2, GetAmmoPicture(i), stov(cvar_string("hud_panel_status_item_ammo_icon_scale")), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                                weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE);\r
 \r
                                // if the weapon we're holding is reloadable, show both its ammo and load\r
                                if(weapon_clipsize)\r
                                {\r
                                        weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD);\r
+                                       pos = edge - stov(cvar_string("hud_panel_status_item_load_clip_text_position"));\r
                                        if(weapon_clipload < 0) // we're reloading\r
                                        {\r
-                                               ammo_pos_offset = '1 0 0' * stringwidth("- -", FALSE, '16 16 0') * 0.5;\r
-                                               drawstring(pos - '118 23 0' - ammo_pos_offset, "- -", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                                               pos -= '1 0 0' * stringwidth("- -", FALSE, '1 1 0' * cvar("hud_panel_status_item_load_clip_text_scale")) * 0.5;\r
+                                               drawstring(pos, "- -", '1 1 0' * cvar("hud_panel_status_item_load_clip_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                                        }\r
                                        else\r
                                        {\r
-                                               ammo_pos_offset = '1 0 0' * stringwidth(ftos(weapon_clipload), FALSE, '16 16 0') * 0.5;\r
-                                               Sbar_DrawXNum(pos - '118 23 0' - ammo_pos_offset, weapon_clipload, 2, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                                               pos -= '1 0 0' * stringwidth(ftos(weapon_clipload), FALSE, '1 1 0' * cvar("hud_panel_status_item_load_clip_text_scale")) * 0.5;\r
+                                               Sbar_DrawXNum(pos, weapon_clipload, 2, 0, cvar("hud_panel_status_item_load_clip_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                                        }\r
-                                       ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '12 12 0') * 0.5;\r
-                                       Sbar_DrawXNum(pos - '118 7 0' - ammo_pos_offset, a, 3, 0, 12, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                                       pos = edge - stov(cvar_string("hud_panel_status_item_load_ammo_text_position"));\r
+                                       pos -= '1 0 0' * stringwidth(ftos(a), FALSE, '1 1 0' * cvar("hud_panel_status_item_load_ammo_text_scale")) * 0.5;\r
+                                       Sbar_DrawXNum(pos, a, 3, 0, cvar("hud_panel_status_item_load_ammo_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                                }\r
                                else\r
                                {\r
-                                       ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5;\r
-                                       Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                                       pos = edge - stov(cvar_string("hud_panel_status_item_noload_ammo_text_position"));\r
+                                       pos -= '1 0 0' * stringwidth(ftos(a), FALSE, '1 1 0' * cvar("hud_panel_status_item_noload_ammo_text_scale")) * 0.5;\r
+                                       Sbar_DrawXNum(pos, a, 3, 0, cvar("hud_panel_status_item_noload_ammo_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
                                }\r
                        }\r
                }\r
        }\r
 \r
        // weapon icon\r
+       pos = edge - stov(cvar_string("hud_panel_status_item_weapon_position"));\r
        entity e;\r
        e = get_weaponinfo(activeweapon);\r
        if (e && e.netname != "" && e.netname != "N/A")\r
-               drawpic(bottom - '96 96 0', strcat("gfx/hud/bg_status_activeweapon_", e.netname), '192 96 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+               drawpic(pos, strcat("gfx/hud/bg_status_activeweapon_", e.netname), stov(cvar_string("hud_panel_status_item_weapon_scale")), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 }\r
 \r
 void Sbar_Timer()\r