From ca213ae9bbafeeeaef4dab065fc0a171e8bfafeb Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Wed, 16 May 2012 23:19:59 +0300 Subject: [PATCH] Adapt all of the status panel to the new code. Needs correct settings next --- data/qcsrc/client/hud.qc | 63 +++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/data/qcsrc/client/hud.qc b/data/qcsrc/client/hud.qc index 8f4fa174..3b2e0b99 100644 --- a/data/qcsrc/client/hud.qc +++ b/data/qcsrc/client/hud.qc @@ -72,11 +72,11 @@ vector Sbar_AccuracyColor(float accuracy) return rgb; } -void Sbar_DrawPic(string pic, vector position, vector size, float background) +void Sbar_DrawPic(string pic, vector position, vector dimensions, float background) { vector pos, sz; - sz_x = vid_conwidth * size_x; - sz_y = vid_conheight * size_y; + sz_x = vid_conwidth * dimensions_x; + sz_y = vid_conheight * dimensions_y; pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2); pos_x -= sz_x / 2; pos_y = (vid_conheight / 2) * bound(0, 1 + position_y, 2); @@ -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); } +void Sbar_DrawString(string text, vector position, float lettersize) +{ + vector pos, sz; + sz_x = sz_y = lettersize; + pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2); + pos_x -= stringwidth(text, FALSE, sz) * 0.5; + pos_y = (vid_conheight / 2) * bound(0, 1 + position_y, 2); + pos_y -= sz_y / 2; + + drawstring(pos, text, sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); +} + void Sbar_DrawXNum (vector position, float num, float digits, float showminusplus, float lettersize, vector rgb, float alpha, float dflags) { float l; @@ -2004,8 +2016,6 @@ void Sbar_Status() float stat_items; stat_items = getstati(STAT_ITEMS); - vector pos, pos2; - if (cvar("viewsize") <= 100 && sbar_hudselector) Sbar_DrawPic("gfx/hud/bg_status", stov(cvar_string("hud_panel_status_background_position")), stov(cvar_string("hud_panel_status_background_scale")), TRUE); @@ -2014,17 +2024,13 @@ void Sbar_Status() if (x > 0) { 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); - 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); + 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); } -/* // health - pos = edge - stov(cvar_string("hud_panel_status_item_health_text_position")); - pos2 = edge - stov(cvar_string("hud_panel_status_item_health_icon_position")); x = health; - drawpic(pos2, "gfx/hud/sb_health", stov(cvar_string("hud_panel_status_item_health_icon_scale")), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '1 1 0' * cvar("hud_panel_status_item_health_text_scale")) * 0.5; - Sbar_DrawXNum(pos, x, 3, 0, cvar("hud_panel_status_item_health_text_scale"), Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); + 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); // if we are dead, we can skip the HUD from here if(health <= 0) @@ -2036,12 +2042,9 @@ void Sbar_Status() // if we are using the jetpack, show fuel ammo. Otherwise show the ammo of our weapon if(stat_items & IT_JETPACK && button_jetpack) { - pos = edge - stov(cvar_string("hud_panel_status_item_noload_ammo_text_position")); - pos2 = edge - stov(cvar_string("hud_panel_status_item_ammo_icon_position")); a = getstati(GetAmmoStat(0)); // how much fuel do we have? - drawpic(pos2, GetAmmoPicture(0), stov(cvar_string("hud_panel_status_item_noload_ammo_icon_scale")), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - pos -= '1 0 0' * stringwidth(ftos(a), FALSE, '1 1 0' * cvar("hud_panel_status_item_noload_ammo_text_scale")) * 0.5; - Sbar_DrawXNum(pos, a, 3, 0, cvar("hud_panel_status_item_noload_ammo_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); + 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); } else { @@ -2053,46 +2056,32 @@ void Sbar_Status() // if (stat_items & GetAmmoItemCode(i)) { a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i? - pos2 = edge - stov(cvar_string("hud_panel_status_item_ammo_icon_position")); - drawpic(pos2, GetAmmoPicture(i), stov(cvar_string("hud_panel_status_item_ammo_icon_scale")), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); weapon_clipsize = getstati(STAT_WEAPON_CLIPSIZE); // if the weapon we're holding is reloadable, show both its ammo and load if(weapon_clipsize) { weapon_clipload = getstati(STAT_WEAPON_CLIPLOAD); - pos = edge - stov(cvar_string("hud_panel_status_item_load_clip_text_position")); if(weapon_clipload < 0) // we're reloading - { - pos -= '1 0 0' * stringwidth("- -", FALSE, '1 1 0' * cvar("hud_panel_status_item_load_clip_text_scale")) * 0.5; - drawstring(pos, "- -", '1 1 0' * cvar("hud_panel_status_item_load_clip_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - } + Sbar_DrawString("- -", stov(cvar_string("hud_panel_status_item_load_clip_text_position")), cvar("hud_panel_status_item_load_clip_text_scale")); else - { - pos -= '1 0 0' * stringwidth(ftos(weapon_clipload), FALSE, '1 1 0' * cvar("hud_panel_status_item_load_clip_text_scale")) * 0.5; - Sbar_DrawXNum(pos, weapon_clipload, 2, 0, cvar("hud_panel_status_item_load_clip_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - } - pos = edge - stov(cvar_string("hud_panel_status_item_load_ammo_text_position")); - pos -= '1 0 0' * stringwidth(ftos(a), FALSE, '1 1 0' * cvar("hud_panel_status_item_load_ammo_text_scale")) * 0.5; - Sbar_DrawXNum(pos, a, 3, 0, cvar("hud_panel_status_item_load_ammo_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); + 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); } else { - pos = edge - stov(cvar_string("hud_panel_status_item_noload_ammo_text_position")); - pos -= '1 0 0' * stringwidth(ftos(a), FALSE, '1 1 0' * cvar("hud_panel_status_item_noload_ammo_text_scale")) * 0.5; - Sbar_DrawXNum(pos, a, 3, 0, cvar("hud_panel_status_item_noload_ammo_text_scale"), '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); } } } } // weapon icon - pos = edge - stov(cvar_string("hud_panel_status_item_weapon_position")); entity e; e = get_weaponinfo(activeweapon); if (e && e.netname != "" && e.netname != "N/A") - 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); -*/ + 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); } void Sbar_Timer() -- 2.39.2