From: FruitieX Date: Sun, 15 Aug 2010 10:20:57 +0000 (+0300) Subject: add fade stuff to the menu, make default fade at 3 sec X-Git-Tag: xonotic-v0.1.0preview~360 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=7208ddb706692d70ae1105b77623f1a68e770212;p=xonotic%2Fxonotic-data.pk3dir.git add fade stuff to the menu, make default fade at 3 sec --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index eff54aaa0..c9b5cd7df 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -1339,6 +1339,7 @@ seta sbar_info_pos 0 "Y-axis distance from lower right corner for engine info pr // hud cvar descriptions exec _hud_descriptions.cfg // exec the default skin config. remember, NO menu_restart in the deafault cfg (dp segfaults at startup otherwise) +// please add any new cvars into the hud_save script in qcsrc/client/hud.qc for consistency exec hud_default.cfg // user preference cvars (i.e. shouldn't be adjusted by a skin config) @@ -1356,7 +1357,7 @@ 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 "3" "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" diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index d1a76320f..2fc1ce308 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -1278,6 +1278,7 @@ void Net_WeaponComplain() { complain_weapon_type = ReadByte(); complain_weapon_time = time; + weapontime = time; // ping the weapon panel } // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer. diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 6dc62337d..5dcca2588 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -1491,29 +1491,71 @@ void HUD_Weapons(void) return; float timeout = cvar("hud_panel_weapons_timeout"); - float timeout_effect_lenght; + float timeout_effect_length, timein_effect_length; if (cvar("hud_panel_weapons_timeout_effect") == 0) - timeout_effect_lenght = 0; + { + timeout_effect_length = 0; + timein_effect_length = 0; + } else - timeout_effect_lenght = 0.75; + { + timeout_effect_length = 0.75; + timein_effect_length = 0.375; + } - if (timeout && time >= weapontime + timeout + timeout_effect_lenght && !autocvar__hud_configure) + if (timeout && time >= weapontime + timeout + timeout_effect_length && !autocvar__hud_configure) + { + weaponprevtime = time; return; + } active_panel = HUD_PANEL_WEAPONS; HUD_Panel_UpdateCvars(weapons); if (timeout && time >= weapontime + timeout && !autocvar__hud_configure) { - float f = (time - (weapontime + timeout)) / timeout_effect_lenght; - if (cvar("hud_panel_weapons_timeout_effect") == 2) + float f = (time - (weapontime + timeout)) / timeout_effect_length; + if (cvar("hud_panel_weapons_timeout_effect")) { panel_bg_alpha *= (1 - f); panel_fg_alpha *= (1 - f); } - else + if (cvar("hud_panel_weapons_timeout_effect") == 1) + { + 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); + } + } + weaponprevtime = time - (1 - f) * timein_effect_length; + } + else if (timeout && time < weaponprevtime + timein_effect_length && !autocvar__hud_configure) + { + float f = (time - weaponprevtime) / timein_effect_length; + if (cvar("hud_panel_weapons_timeout_effect")) + { + panel_bg_alpha *= (f); + panel_fg_alpha *= (f); + } + if (cvar("hud_panel_weapons_timeout_effect") == 1) { f *= f; // for a cooler movement + f = 1 - f; vector center; center_x = panel_pos_x + panel_size_x/2; center_y = panel_pos_y + panel_size_y/2; diff --git a/qcsrc/client/hud.qh b/qcsrc/client/hud.qh index e416da62a..0f1cbdc2b 100644 --- a/qcsrc/client/hud.qh +++ b/qcsrc/client/hud.qh @@ -33,6 +33,7 @@ float ts_primary, ts_secondary; float last_weapon; float weapontime; +float weaponprevtime; float teamnagger; float hud_accuracy_hud; diff --git a/qcsrc/menu/xonotic/dialog_hudpanel_weapons.c b/qcsrc/menu/xonotic/dialog_hudpanel_weapons.c index a32099d9d..538723bce 100644 --- a/qcsrc/menu/xonotic/dialog_hudpanel_weapons.c +++ b/qcsrc/menu/xonotic/dialog_hudpanel_weapons.c @@ -4,7 +4,7 @@ CLASS(XonoticHUDWeaponsDialog) EXTENDS(XonoticRootDialog) ATTRIB(XonoticHUDWeaponsDialog, title, string, "Weapons Panel") ATTRIB(XonoticHUDWeaponsDialog, color, vector, SKINCOLOR_DIALOG_TEAMSELECT) ATTRIB(XonoticHUDWeaponsDialog, intendedWidth, float, 0.4) - ATTRIB(XonoticHUDWeaponsDialog, rows, float, 15) + ATTRIB(XonoticHUDWeaponsDialog, rows, float, 17) ATTRIB(XonoticHUDWeaponsDialog, columns, float, 4) ATTRIB(XonoticHUDWeaponsDialog, name, string, "HUDweapons") ENDCLASS(XonoticHUDWeaponsDialog) @@ -71,6 +71,23 @@ void XonoticHUDWeaponsDialog_fill(entity me) for(i = 0; i <= 10; ++i) e.addValue(e, strzone(ftos_decimals(i - 5, 0)), strzone(ftos(i - 5))); e.configureXonoticTextSliderValues(e); + me.TR(me); + me.TDempty(me, 0.2); + me.TD(me, 1, 1.2, e = makeXonoticTextLabel(0, "Fade out after:")); + me.TD(me, 1, 2.6, e = makeXonoticTextSlider(strzone(strcat("hud_panel_", panelname, "_timeout")))); + e.addValue(e, "Never", "0"); + for(i = 1; i <= 10; ++i) + e.addValue(e, strzone(strcat(ftos_decimals(i, 0), "s")), strzone(ftos(i))); + e.configureXonoticTextSliderValues(e); + me.TR(me); + me.TDempty(me, 0.2); + me.TD(me, 1, 1.4, e = makeXonoticTextLabel(0, "Fade effect:")); + me.TD(me, 1, 0.8, e = makeXonoticRadioButton(3, "hud_panel_weapons_timeout_effect", "0", "None")); + setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_timeout")), "0"); + me.TD(me, 1, 0.8, e = makeXonoticRadioButton(3, "hud_panel_weapons_timeout_effect", "1", "Slide")); + setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_timeout")), "0"); + me.TD(me, 1, 0.8, e = makeXonoticRadioButton(3, "hud_panel_weapons_timeout_effect", "2", "Alpha")); + setDependentStringNotEqual(e, strzone(strcat("hud_panel_", panelname, "_timeout")), "0"); me.TR(me); me.TD(me, 1, 2, e = makeXonoticTextLabel(0, "Weapon icons:")); me.TR(me);