From: MirceaKitsune Date: Wed, 16 May 2012 20:03:14 +0000 (+0300) Subject: Adapt Sbar_DrawXNum to the new system X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d0532c65c2a805db93f2b6085987223145e9f2f2;p=voretournament%2Fvoretournament.git Adapt Sbar_DrawXNum to the new system --- diff --git a/data/hudVT.cfg b/data/hudVT.cfg index 8a7123ee..b562491b 100644 --- a/data/hudVT.cfg +++ b/data/hudVT.cfg @@ -7,12 +7,12 @@ set hud_panel_status_item_weapon_scale "0.5 0.5 0" set hud_panel_status_item_health_icon_position "0.5 0.5 0" set hud_panel_status_item_health_icon_scale "0.5 0.5 0" set hud_panel_status_item_health_text_position "0.5 0.5 0" -set hud_panel_status_item_health_text_scale 0.5 +set hud_panel_status_item_health_text_scale 16 set hud_panel_status_item_armor_icon_position "0.5 0.5 0" set hud_panel_status_item_armor_icon_scale "0.5 0.5 0" set hud_panel_status_item_armor_text_position "0.5 0.5 0" -set hud_panel_status_item_armor_text_scale 0.5 +set hud_panel_status_item_armor_text_scale 16 set hud_panel_status_item_ammo_icon_position "-0.5 0.5 0" set hud_panel_status_item_ammo_icon_scale "0.5 0.5 0" diff --git a/data/qcsrc/client/hud.qc b/data/qcsrc/client/hud.qc index ed39de4c..8f4fa174 100644 --- a/data/qcsrc/client/hud.qc +++ b/data/qcsrc/client/hud.qc @@ -33,27 +33,6 @@ float ts_primary, ts_secondary; vector color; -void Sbar_DrawPic(string pic, vector position, vector size, float background) -{ - vector pos, sz; - sz_x = vid_conwidth * size_x; - sz_y = vid_conheight * size_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); - pos_y -= sz_y / 2; - - if(background) - { - if(teamplay) - drawpic(pos, "gfx/hud/bg_status", sz, GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color - else - drawpic(pos, "gfx/hud/bg_status", sz, stov(cvar_string("sbar_color_bg")), sbar_alpha_bg, DRAWFLAG_NORMAL); - } - else - drawpic(pos, "gfx/hud/bg_status", sz, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); -} - void CSQC_kh_hudreset(); void CSQC_kh_hud(); void CSQC_ctf_hudreset(); @@ -93,15 +72,32 @@ vector Sbar_AccuracyColor(float accuracy) return rgb; } -void Sbar_DrawXNum (vector pos, float num, float digits, float showminusplus, float lettersize, vector rgb, float alpha, float dflags) +void Sbar_DrawPic(string pic, vector position, vector size, float background) +{ + vector pos, sz; + sz_x = vid_conwidth * size_x; + sz_y = vid_conheight * size_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); + pos_y -= sz_y / 2; + + if(background) + { + if(teamplay) + drawpic(pos, pic, sz, GetTeamRGB(myteam) * sbar_color_bg_team, sbar_alpha_bg, DRAWFLAG_NORMAL); // hud color = myteam color + else + drawpic(pos, pic, sz, stov(cvar_string("sbar_color_bg")), sbar_alpha_bg, DRAWFLAG_NORMAL); + } + else + drawpic(pos, pic, 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; string str, tmp, l_length, final_num; float minus, plus; - vector vsize; - - vsize_x = vsize_y = lettersize; - vsize_z = 0; // showminusplus 1: always prefix with minus sign (useful in race distribution display) // showminusplus 2: always prefix with plus sign (useful in race distribution display) @@ -141,9 +137,16 @@ void Sbar_DrawXNum (vector pos, float num, float digits, float showminusplus, fl final_num = "-"; else if(plus) final_num = "+"; - final_num = strcat(final_num, str); - drawstring(pos, final_num, vsize, rgb, alpha, dflags); + + vector pos, sz; + sz_x = sz_y = lettersize; + pos_x = (vid_conwidth / 2) * bound(0, 1 + position_x, 2); + pos_x -= stringwidth(final_num, FALSE, sz) * 0.5; + pos_y = (vid_conheight / 2) * bound(0, 1 + position_y, 2); + pos_y -= sz_y / 2; + + drawstring(pos, final_num, sz, rgb, alpha, dflags); } vector Sbar_NumColor (float x) @@ -2006,18 +2009,15 @@ void Sbar_Status() 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); -/* // armor - pos = edge - stov(cvar_string("hud_panel_status_item_armor_text_position")); - pos2 = edge - stov(cvar_string("hud_panel_status_item_armor_icon_position")); x = armor; if (x > 0) { - drawpic(pos2, "gfx/hud/sb_armor", stov(cvar_string("hud_panel_status_item_armor_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_armor_text_scale")) * 0.5; - Sbar_DrawXNum(pos, x, 3, 0, cvar("hud_panel_status_item_armor_text_scale"), Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); } +/* // 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"));