From 01bf142e7f780ea26c1bdaa2685a477dfef2a5d6 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 1 Aug 2010 22:24:09 +0200 Subject: [PATCH] Make weapons panel automatically disappear hud_panel_weapons_timeout "10" "panel disappears if you don't switch weapon for this amount of seconds" hud_panel_weapons_timeout_effect "1" "disappearance effect: 0) no effect; 1) panel moves out of screen; 2) panel fades out" Note: I had to use panel_pos and panel_size instead of pos and mySize to make properly work HUD_Panel_DrawBg(1);. Actually, it's even a good thing as pos and mySize aren't really needed... (like in every other panel, btw). --- defaultXonotic.cfg | 2 ++ qcsrc/client/hud.qc | 60 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index 2e5b56cd1..2f7dc51dd 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1353,6 +1353,8 @@ seta hud_panel_weapons_ammo_full_nails 200 "show 100% of the status bar at this seta hud_panel_weapons_ammo_full_cells 80 "show 100% of the status bar at this ammo count" seta hud_panel_weapons_ammo_full_rockets 80 "show 100% of the status bar at this ammo count" seta hud_panel_weapons_ammo_full_fuel 100 "show 100% of the status bar at this ammo count" +seta hud_panel_weapons_timeout "10" "panel disappears if you don't switch weapon for this amount of seconds" +seta hud_panel_weapons_timeout_effect "1" "disappearance effect: 0) no effect; 1) panel moves out of screen; 2) panel fades out" seta hud_panel_notify_time 10 "time that a new entry stays until it fades out" seta hud_panel_notify_fadetime 3 "fade out time" diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index be7169dba..fd49022c3 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1484,14 +1484,52 @@ void HUD_Weapons(void) if(!autocvar_hud_panel_weapons && !autocvar__hud_configure) return; + float timeout = cvar("hud_panel_weapons_timeout"); + float timeout_effect_lenght; + if (cvar("hud_panel_weapons_timeout_effect") == 0) + timeout_effect_lenght = 0; + else + timeout_effect_lenght = 0.75; + + if (timeout && time >= weapontime + timeout + timeout_effect_lenght && !autocvar__hud_configure) + return; + active_panel = HUD_PANEL_WEAPONS; HUD_Panel_UpdateCvars(weapons); - vector pos, mySize; - float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt; - pos = panel_pos; - mySize = panel_size; + if (timeout && time >= weapontime + timeout && !autocvar__hud_configure) + { + float f = (time - (weapontime + timeout)) / timeout_effect_lenght; + if (cvar("hud_panel_weapons_timeout_effect") == 2) + { + panel_bg_alpha *= (1 - f); + panel_fg_alpha *= (1 - f); + } + else + { + f *= f; // for a cooler movement + vector center; + center_x = panel_pos_x + panel_size_x/2; + center_y = panel_pos_y + panel_size_y/2; + float screen_ar = vid_conwidth/vid_conheight; + if (center_x/center_y < screen_ar) //bottom left + { + if ((vid_conwidth - center_x)/center_y < screen_ar) //bottom + panel_pos_y += f * (vid_conheight - panel_pos_y); + else //left + panel_pos_x -= f * (panel_pos_x + panel_size_x); + } + else //top right + { + if ((vid_conwidth - center_x)/center_y < screen_ar) //right + panel_pos_x += f * (vid_conwidth - panel_pos_x); + else //top + panel_pos_y -= f * (panel_pos_y + panel_size_y); + } + } + } + float i, weapid, fade, weapon_stats, weapon_number, weapon_cnt; weapon_cnt = 0; for(i = WEP_FIRST; i <= WEP_LAST; ++i) { @@ -1524,8 +1562,8 @@ void HUD_Weapons(void) HUD_Panel_DrawBg(1); if(panel_bg_padding) { - pos += '1 1 0' * panel_bg_padding; - mySize -= '2 2 0' * panel_bg_padding; + panel_pos += '1 1 0' * panel_bg_padding; + panel_size -= '2 2 0' * panel_bg_padding; } // hits @@ -1548,7 +1586,7 @@ void HUD_Weapons(void) HUD_Weapons_Clear(); float rows, columns; - rows = mySize_y/mySize_x; + rows = panel_size_y/panel_size_x; rows = bound(1, floor((sqrt(4 * autocvar_hud_panel_weapons_aspect * rows * WEP_COUNT + rows * rows) + rows + 0.5) / 2), WEP_COUNT); columns = ceil(WEP_COUNT/rows); @@ -1566,8 +1604,8 @@ void HUD_Weapons(void) for(i = 0; i < weapon_cnt; ++i) { - wpnpos = pos + eX * column * mySize_x*(1/columns) + eY * row * mySize_y*(1/rows); - wpnsize = eX * mySize_x*(1/columns) + eY * mySize_y*(1/rows); + wpnpos = panel_pos + eX * column * panel_size_x*(1/columns) + eY * row * panel_size_y*(1/rows); + wpnsize = eX * panel_size_x*(1/columns) + eY * panel_size_y*(1/rows); self = weaponorder[i]; weapid = self.impulse; @@ -1609,9 +1647,9 @@ void HUD_Weapons(void) drawpic_aspect_skin(wpnpos, strcat("weapon", self.netname), wpnsize, '1 1 1', fade * panel_fg_alpha, DRAWFLAG_NORMAL); if(autocvar_hud_panel_weapons_label == 1) // weapon number - drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring(wpnpos, ftos(weapid), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); else if(autocvar_hud_panel_weapons_label == 2) // bind - drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * mySize_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring(wpnpos, getcommandkey(ftos(weapid), strcat("impulse ", ftos(weapid))), '1 1 0' * 0.5 * panel_size_y*(1/rows), '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); // draw ammo status bar if(autocvar_hud_panel_weapons_ammo && weapid != WEP_TUBA && weapid != WEP_LASER && weapid != WEP_PORTO) -- 2.39.2