]> git.rm.cloudns.org Git - voretournament/voretournament.git/commitdiff
Adapt all of the status panel to the new code. Needs correct settings next
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 16 May 2012 20:19:59 +0000 (23:19 +0300)
committerMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>
Wed, 16 May 2012 20:19:59 +0000 (23:19 +0300)
data/qcsrc/client/hud.qc

index 8f4fa174349e5eb92b8a0f223d978ad9bc72ec2b..3b2e0b9972da5c30be290f4708e0060c95f098e9 100644 (file)
@@ -72,11 +72,11 @@ vector Sbar_AccuracyColor(float accuracy)
        return rgb;\r
 }\r
 \r
-void Sbar_DrawPic(string pic, vector position, vector size, float background)\r
+void Sbar_DrawPic(string pic, vector position, vector dimensions, float background)\r
 {\r
        vector pos, sz;\r
-       sz_x = vid_conwidth * size_x;\r
-       sz_y = vid_conheight * size_y;\r
+       sz_x = vid_conwidth * dimensions_x;\r
+       sz_y = vid_conheight * dimensions_y;\r
        pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2);\r
        pos_x -= sz_x / 2;\r
        pos_y = (vid_conheight / 2) * bound(0, 1 + position_y, 2);\r
@@ -93,6 +93,18 @@ void Sbar_DrawPic(string pic, vector position, vector size, float background)
                drawpic(pos, pic, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
 }\r
 \r
+void Sbar_DrawString(string text, vector position, float lettersize)\r
+{\r
+       vector pos, sz;\r
+       sz_x = sz_y = lettersize;\r
+       pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2);\r
+       pos_x -= stringwidth(text, FALSE, sz) * 0.5;\r
+       pos_y = (vid_conheight / 2) * bound(0, 1 + position_y, 2);\r
+       pos_y -= sz_y / 2;\r
+\r
+       drawstring(pos, text, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+}\r
+\r
 void Sbar_DrawXNum (vector position, float num, float digits, float showminusplus, float lettersize, vector rgb, float alpha, float dflags)\r
 {\r
        float l;\r
@@ -2004,8 +2016,6 @@ void Sbar_Status()
        float stat_items;\r
        stat_items = getstati(STAT_ITEMS);\r
 \r
-       vector pos, pos2;\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
@@ -2014,17 +2024,13 @@ void Sbar_Status()
        if (x > 0)\r
        {\r
                Sbar_DrawPic("gfx/hud/sb_armor", stov(cvar_string("hud_panel_status_item_armor_icon_position")), stov(cvar_string("hud_panel_status_item_armor_icon_scale")), FALSE);\r
-               Sbar_DrawXNum(stov(cvar_string("hud_panel_status_item_armor_icon_position")), x, 3, 0, cvar("hud_panel_status_item_armor_text_scale"), Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+               Sbar_DrawXNum(stov(cvar_string("hud_panel_status_item_armor_text_position")), x, 3, 0, cvar("hud_panel_status_item_armor_text_scale"), Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL);\r
        }\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(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
+       Sbar_DrawPic("gfx/hud/sb_health", stov(cvar_string("hud_panel_status_item_health_icon_position")), stov(cvar_string("hud_panel_status_item_health_icon_scale")), FALSE);\r
+       Sbar_DrawXNum(stov(cvar_string("hud_panel_status_item_health_text_position")), 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
@@ -2036,12 +2042,9 @@ void Sbar_Status()
        // 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(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
+               Sbar_DrawPic(GetAmmoPicture(0), stov(cvar_string("hud_panel_status_item_ammo_icon_position")), stov(cvar_string("hud_panel_status_item_noload_ammo_icon_scale")), FALSE);\r
+               Sbar_DrawXNum(stov(cvar_string("hud_panel_status_item_noload_ammo_text_position")), 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
@@ -2053,46 +2056,32 @@ void Sbar_Status()
                        // if (stat_items & GetAmmoItemCode(i))\r
                        {\r
                                a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i?\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
+                               Sbar_DrawPic(GetAmmoPicture(i), stov(cvar_string("hud_panel_status_item_ammo_icon_position")), stov(cvar_string("hud_panel_status_item_ammo_icon_scale")), FALSE);\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
-                                               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
+                                               Sbar_DrawString("- -", stov(cvar_string("hud_panel_status_item_load_clip_text_position")), cvar("hud_panel_status_item_load_clip_text_scale"));\r
                                        else\r
-                                       {\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
-                                       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
+                                               Sbar_DrawXNum(stov(cvar_string("hud_panel_status_item_load_clip_text_position")), weapon_clipload, 2, 0, cvar("hud_panel_status_item_load_clip_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL);\r
+                                       Sbar_DrawXNum(stov(cvar_string("hud_panel_status_item_load_ammo_text_position")), 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
-                                       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
+                                       Sbar_DrawXNum(stov(cvar_string("hud_panel_status_item_noload_ammo_text_position")), 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(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
+               Sbar_DrawPic(strcat("gfx/hud/bg_status_activeweapon_", e.netname), stov(cvar_string("hud_panel_status_item_weapon_position")), stov(cvar_string("hud_panel_status_item_weapon_scale")), FALSE);\r
 }\r
 \r
 void Sbar_Timer()\r