From: MirceaKitsune Date: Wed, 16 May 2012 15:37:33 +0000 (+0300) Subject: Allow cvar positions and sizes for the status HUD panel (everything else will follow... X-Git-Url: https://de.git.xonotic.org/?p=voretournament%2Fvoretournament.git;a=commitdiff_plain;h=e68fa753a36ce6bcec2d2c7676967f462f73030b Allow cvar positions and sizes for the status HUD panel (everything else will follow). Some icons are not positioned properly, but this can be fixed later on --- diff --git a/data/default.cfg b/data/default.cfg index c6d6a1b2..252cc5ce 100644 --- a/data/default.cfg +++ b/data/default.cfg @@ -4,4 +4,5 @@ exec botsVT.cfg exec ctfscoringVT.cfg exec physicsVT.cfg exec balanceVT.cfg -exec turretsVT.cfg \ No newline at end of file +exec turretsVT.cfg +exec hudVT.cfg \ No newline at end of file diff --git a/data/qcsrc/client/hud.qc b/data/qcsrc/client/hud.qc index 64f428c4..4406129b 100644 --- a/data/qcsrc/client/hud.qc +++ b/data/qcsrc/client/hud.qc @@ -33,6 +33,20 @@ float ts_primary, ts_secondary; vector color; +vector Sbar_Edge(string str) +{ + vector pos; + switch(str) + { + case "bottom": + pos_x = vid_conwidth / 2; + pos_y = vid_conheight; + default: + break; + } + return pos; +} + void CSQC_kh_hudreset(); void CSQC_kh_hud(); void CSQC_ctf_hudreset(); @@ -1973,11 +1987,6 @@ void Sbar_Score() void Sbar_Status() { - vector bottom; - bottom_x = vid_conwidth/2; - bottom_y = vid_conheight; - bottom_z = 0; - float armor, health, x, a; armor = getstati(STAT_ARMOR); health = getstati(STAT_HEALTH); @@ -1985,54 +1994,56 @@ void Sbar_Status() float stat_items; stat_items = getstati(STAT_ITEMS); - vector health_pos, armor_pos, pos; - health_pos = bottom - '43 58 0'; - armor_pos = bottom - '43 68 0'; + vector edge, pos, pos2; + edge = Sbar_Edge(cvar_string("hud_panel_status_edge")); + pos = edge - stov(cvar_string("hud_panel_status_background_position")); if (cvar("viewsize") <= 100 && sbar_hudselector) { if (teamplay) - 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 + 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 else { // allow for custom HUD colors in non-teamgames color = stov(cvar_string("sbar_color_bg")); - drawpic(bottom - '96 96 0', "gfx/hud/bg_status", '192 96 0', color, sbar_alpha_bg, DRAWFLAG_NORMAL); + drawpic(pos, "gfx/hud/bg_status", stov(cvar_string("hud_panel_status_background_scale")), color, sbar_alpha_bg, DRAWFLAG_NORMAL); } } // 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(armor_pos + '-8 -13.5 0', "gfx/hud/sb_armor", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - armor_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '12 12 0') * 0.5; - Sbar_DrawXNum(armor_pos, x, 3, 0, 12, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); } // 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(health_pos + '-11 16 0', "gfx/hud/sb_health", '32 32 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - health_pos -= '1 0 0' * stringwidth(ftos(x), FALSE, '22 22 0') * 0.5; - Sbar_DrawXNum(health_pos, x, 3, 0, 22, Sbar_NumColor(x), sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); // if we are dead, we can skip the HUD from here if(health <= 0) return; // ammo - pos_x = bottom_x + 140; - pos_y = bottom_y - 20; - float weapon_clipload, weapon_clipsize; - vector ammo_pos_offset; // 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(pos - '98 18 0', GetAmmoPicture(0), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); - ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5; - Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); } else { @@ -2044,40 +2055,45 @@ void Sbar_Status() // if (stat_items & GetAmmoItemCode(i)) { a = getstati(GetAmmoStat(i)); // how much ammo do we have of type i? - drawpic(pos - '98 18 0', GetAmmoPicture(i), '20 20 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); 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 { - ammo_pos_offset = '1 0 0' * stringwidth("- -", FALSE, '16 16 0') * 0.5; - drawstring(pos - '118 23 0' - ammo_pos_offset, "- -", '16 16 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); } else { - ammo_pos_offset = '1 0 0' * stringwidth(ftos(weapon_clipload), FALSE, '16 16 0') * 0.5; - Sbar_DrawXNum(pos - '118 23 0' - ammo_pos_offset, weapon_clipload, 2, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); } - ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '12 12 0') * 0.5; - Sbar_DrawXNum(pos - '118 7 0' - ammo_pos_offset, a, 3, 0, 12, '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); } else { - ammo_pos_offset = '1 0 0' * stringwidth(ftos(a), FALSE, '16 16 0') * 0.5; - Sbar_DrawXNum(pos - '118 16 0' - ammo_pos_offset, a, 3, 0, 16, '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); } } } } // 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(bottom - '96 96 0', strcat("gfx/hud/bg_status_activeweapon_", e.netname), '192 96 0', '1 1 1', sbar_alpha_fg, DRAWFLAG_NORMAL); + 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); } void Sbar_Timer()