From: Dr. Jaska Date: Sun, 3 Sep 2023 16:35:14 +0000 (+0000) Subject: re-allow main menu to play music when coming back to it X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7892582d6cc926aeb623c2fa6ec904344b2139a2;p=xonotic%2Fxonotic-data.pk3dir.git re-allow main menu to play music when coming back to it --- diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index b2226b831..300be79d8 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -30,9 +30,13 @@ float menuAlpha; float menuLogoAlpha; float prevMenuAlpha; bool menuInitialized; -bool menuNotTheFirstFrame; int menuMouseMode; +// Used for having effects only execute once in main menu, not for every reload +// 0: never been in main menu before. 1: coming back to main menu. 2: in main menu. +int menuNotTheFirstFrame; +bool autocvar_menu_no_music_nor_welcome; + float conwidth_s, conheight_s; float vidwidth_s, vidheight_s, vidpixelheight_s; float realconwidth, realconheight; @@ -678,13 +682,14 @@ void m_tooltip(vector pos) } const int MIN_DISCONNECTION_TIME = 1; -float autocvar_menu_force_on_disconnection; bool autocvar_g_campaign; void m_draw(float width, float height) { static float connected_time; if (clientstate() == CS_DISCONNECTED) { + // avoid a bug where the main menu re-opens when changing maps + // potentially exclusive to `map ` cmd? if (connected_time && time - connected_time > MIN_DISCONNECTION_TIME) { if (autocvar_g_campaign) @@ -695,10 +700,18 @@ void m_draw(float width, float height) cvar_set("g_campaign", "0"); m_sync(); } - if (autocvar_menu_force_on_disconnection > 0) - m_toggle(true); + + // reload the menu so that disconnecting players don't + // have to press ESC to open it again + m_toggle(true); + localcmd("\nmenu_cmd directmenu Welcome RESET\n"); connected_time = 0; + + // reset main menu + // FIXME?: find out if anything should be done to reset it more, + // this is just a fix to make main menu music replay nicely + menuNotTheFirstFrame = 1; } } else @@ -720,18 +733,24 @@ void m_draw(float width, float height) m_init_delayed(); return; } - if (!menuNotTheFirstFrame) - { - menuNotTheFirstFrame = true; - if (Menu_Active && !cvar("menu_video_played")) - { - localcmd("cd loop $menu_cdtrack\n"); - // TODO: use this when we have a welcome sound - //localcmd("cd loop $menu_cdtrack; play sound/announcer/default/welcome.wav\n"); - menuLogoAlpha = -0.8; // no idea why, but when I start this at zero, it jumps instead of fading FIXME - } - // ALWAYS set this cvar; if we start but menu is not active, this means we want no background music! - localcmd("set menu_video_played 1\n"); + + if (menuNotTheFirstFrame == 0) // only fade the menu in once ever + menuLogoAlpha = -0.8; // no idea why, but when I start this at zero, it jumps instead of fading FIXME + + if (menuNotTheFirstFrame <= 1) // only once per menu reload + { + if (Menu_Active && !autocvar_menu_no_music_nor_welcome) + { + localcmd("cd loop $menu_cdtrack\n"); + + // TODO: enable this when we have a welcome sound + // FIXME: change the file used according to the selected announcer + // Only play the welcome announcement once, not on any menu reloads + //if (menuNotTheFirstFrame == 0) + //localcmd("play sound/announcer/default/welcome.wav\n"); + } + + menuNotTheFirstFrame = 2; } float t = gettime(); diff --git a/xonotic-client.cfg b/xonotic-client.cfg index 760f6529b..af952d0ce 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -493,7 +493,20 @@ seta menu_tooltips 1 "menu tooltips: 0 disabled, 1 enabled, 2 also shows cvar or set menu_picmip_bypass 0 "bypass texture quality enforcement based on system resources, not recommended and may cause crashes!" set menu_showboxes 0 "show item bounding boxes (debug)" set menu_cvarlist_onlymodified 0 "show only modified cvars in the cvar list" -set menu_force_on_disconnection 1 "force to show the menu after you get disconnected" + +set menu_no_music_nor_welcome 0 "don't play the menu music and skip the welcome announcer" + +seta menu_weaponarena "" + +seta menu_maxplayers 16 "maxplayers value when the menu starts a game" + +seta menu_mouse_absolute 1 "use the OS mouse pointer motion for menu" +seta menu_mouse_speed 1 "speed multiplier for the mouse in the menu (does not affect in-game aiming)" +set menu_use_default_hostname 1 +alias sethostname "set menu_use_default_hostname 0; hostname $*" + +set _menu_alpha "" // will be set by menu QC to the current fading of the menu, can be used by CSQC to fade items +set _menu_initialized 0 "is 0 on first menu loading, 1 later" set _menu_credits_export 0 "set to 1 and restart the menu to export credits to credits.txt (menu will automatically reset to 0)" alias menu_credits_export "_menu_credits_export 1; menu_restart" @@ -586,10 +599,6 @@ seta menu_slist_categories_CAT_OVERKILL_override "" seta menu_slist_categories_CAT_INSTAGIB_override "" seta menu_slist_categories_CAT_DEFRAG_override "" -seta menu_weaponarena "" - -seta menu_maxplayers 16 "maxplayers value when the menu starts a game" - // useful keybind to maximize the chat area temporarily // HUD code takes care of many of these now... //set _backup_con_chatvars_set 0 @@ -660,11 +669,6 @@ gl_texturecompression_sky 1 cl_maxfps 250 -seta menu_mouse_absolute 1 "use the OS mouse pointer motion for menu" -seta menu_mouse_speed 1 "speed multiplier for the mouse in the menu (does not affect in-game aiming)" -set menu_use_default_hostname 1 -alias sethostname "set menu_use_default_hostname 0; hostname $*" - seta cl_weaponpriority "vaporizer okhmg okrpc oknex vortex fireball mortar okmachinegun machinegun hagar rifle arc electro devastator crylink minelayer okshotgun shotgun shockwave hlac tuba blaster porto seeker hook" "weapon priority list" seta cl_weaponpriority_useforcycling 0 "when set, weapon cycling by the mouse wheel makes use of the weapon priority list (the special value 2 uses the weapon ID list for cycling)" seta cl_weaponpriority0 "okrpc devastator mortar hagar seeker fireball" "use weapon_priority_0_prev for prev gun from this list, weapon_priority_0_best for best gun, weapon_priority_0_next for next gun. Default value: explosives" @@ -768,9 +772,6 @@ set cl_shootfromfixedorigin "" "dummy cvar, value is synced from the server's g_ set cl_jumpspeedcap_min "" "dummy cvar, value is synced from the server's sv_jumpspeedcap_min setting" set cl_jumpspeedcap_max "" "dummy cvar, value is synced from the server's sv_jumpspeedcap_max setting" -set _menu_alpha "" // will be set by menu QC to the current fading of the menu, can be used by CSQC to fade items -set _menu_initialized 0 "is 0 on first menu loading, 1 later" - seta cl_noantilag 0 "turn this on if you believe antilag is bad" set cl_accuracy_data_share 0 "1 share my weapon accuracy data statistics with other players, 0 keep my weapon accuracy data statistics hidden"