From: terencehill Date: Sun, 27 Oct 2024 11:49:05 +0000 (+0100) Subject: Use a new alias spec_ask_forfeit to ask for forfeit confirmation X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a82f753fefd2ebd103e6b175ce9345471abebf71;p=xonotic%2Fxonotic-data.pk3dir.git Use a new alias spec_ask_forfeit to ask for forfeit confirmation Add code to automatically update existing spec binds to spec_ask_forfeit, executed by the menu only once --- diff --git a/binds-xonotic.cfg b/binds-xonotic.cfg index 2a81e7069..73fa46d3e 100644 --- a/binds-xonotic.cfg +++ b/binds-xonotic.cfg @@ -55,7 +55,7 @@ bind PAUSE pause // function keys bind F1 vyes bind F2 vno -bind F3 spec +bind F3 spec_ask_forfeit bind F4 ready bind F5 team_selection_show bind F6 team_auto diff --git a/commands.cfg b/commands.cfg index 748f2aecd..bca8dc0e1 100644 --- a/commands.cfg +++ b/commands.cfg @@ -211,7 +211,13 @@ alias team_pink "cmd selectteam pink; cmd join" alias team_yellow "cmd selectteam yellow; cmd join" alias team_auto "togglemenu 0; cmd selectteam auto; cmd join" + +// Xonotic 0.9.0 update: menu will change any spec bind to spec_ask_forfeit (and set this cvar to 1) +// TODO remove menu code and this cvar in a later Xonotic version +seta _spec_ask_forfeit_bindupdate 0 + alias spec "spectate ${* ?}" +alias spec_ask_forfeit "spectate \"\" ASK_FORFEIT" // mutator aliases alias sandbox "cmd g_sandbox ${* ?}" diff --git a/qcsrc/menu/xonotic/dialog_forfeit.qc b/qcsrc/menu/xonotic/dialog_forfeit.qc index 48de56763..5de1982f2 100644 --- a/qcsrc/menu/xonotic/dialog_forfeit.qc +++ b/qcsrc/menu/xonotic/dialog_forfeit.qc @@ -19,7 +19,7 @@ void XonoticForfeitDialog_fill(entity me) me.TD(me, 1, 2, makeXonoticTextLabel(0.5, _("Are you sure you want to observe and quit current match?"))); me.TR(me); me.TR(me); - me.TD(me, 1, 1, e = makeXonoticCommandButton(_("Yes"), '1 0 0', "spec \"\" FORFEIT", COMMANDBUTTON_CLOSE)); + me.TD(me, 1, 1, e = makeXonoticCommandButton(_("Yes"), '1 0 0', "spec", COMMANDBUTTON_CLOSE)); me.TD(me, 1, 1, e = makeXonoticButton(_("No"), '0 1 0')); e.onClick = Dialog_Close; e.onClickEntity = me; diff --git a/qcsrc/menu/xonotic/keybinder.qc b/qcsrc/menu/xonotic/keybinder.qc index 47f7a3557..1638fbb60 100644 --- a/qcsrc/menu/xonotic/keybinder.qc +++ b/qcsrc/menu/xonotic/keybinder.qc @@ -115,7 +115,7 @@ void KeyBinds_BuildList() KEYBIND_HEADER(_("Teamplay")); KEYBIND_DEF("team_auto" , _("auto-join team")); KEYBIND_DEF("team_selection_show" , _("team selection")); - KEYBIND_DEF("spec" , _("observe")); + KEYBIND_DEF("spec_ask_forfeit" , _("observe")); KEYBIND_EMPTY_LINE(); KEYBIND_HEADER(_("Misc")); @@ -178,6 +178,14 @@ void XonoticKeyBinder_configureXonoticKeyBinder(entity me) replace_bind("impulse 8", "weapon_group_8"); replace_bind("impulse 9", "weapon_group_9"); replace_bind("impulse 14", "weapon_group_0"); + + // Xonotic 0.9.0 update + // TODO remove cvar and this code in a later Xonotic version + if (!cvar("_spec_ask_forfeit_bindupdate")) + { + replace_bind("spec", "spec_ask_forfeit"); + cvar_set("_spec_ask_forfeit_bindupdate", "1"); + } } void XonoticKeyBinder_loadKeyBinds(entity me) { diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index cbc1df1ee..64fe5ab46 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -710,13 +710,11 @@ void ClientCommand_spectate(entity caller, int request) return; } - bool caller_wants_to_forfeit = false; - if (argv(2) == "FORFEIT" || warmup_stage) - caller_wants_to_forfeit = true; // player replied that they want to forfeit + bool forfeit_now = (warmup_stage || argv(2) != "ASK_FORFEIT"); - if (IS_PLAYER(caller) && !caller_wants_to_forfeit && caller.cvar__menu_forfeit_dialog_available) + if (IS_PLAYER(caller) && !forfeit_now && caller.cvar__menu_forfeit_dialog_available) { - // ask player if they want to forfeit + // ask player to confirm the forfeit stuffcmd(caller, "menu_showforfeitdialog\n"); return; } @@ -737,7 +735,7 @@ void ClientCommand_spectate(entity caller, int request) if (mutator_returnvalue == MUT_SPECCMD_RETURN_FORFEIT) { - if (caller_wants_to_forfeit || !caller.cvar__menu_forfeit_dialog_available) + if (forfeit_now || !caller.cvar__menu_forfeit_dialog_available) mutator_returnvalue = MUT_SPECCMD_FORCE; else {