]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use a new alias spec_ask_forfeit to ask for forfeit confirmation
authorterencehill <piuntn@gmail.com>
Sun, 27 Oct 2024 11:49:05 +0000 (12:49 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 27 Oct 2024 12:04:09 +0000 (13:04 +0100)
Add code to automatically update existing spec binds to spec_ask_forfeit, executed by the menu only once

binds-xonotic.cfg
commands.cfg
qcsrc/menu/xonotic/dialog_forfeit.qc
qcsrc/menu/xonotic/keybinder.qc
qcsrc/server/command/cmd.qc

index 2a81e706971d048c3106af270fc5ddbf8ff1eec2..73fa46d3ec226864e1d69d5c399328bb518ee12d 100644 (file)
@@ -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
index 748f2aecd1ebd48c341a4961ae62b7878b2a007e..bca8dc0e111b05f93226cfbfce8a865d46fe656c 100644 (file)
@@ -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 ${* ?}"
index 48de567631d328601e241f68a7bd259420cc2739..5de1982f253be932436482d609fa0f619878d44b 100644 (file)
@@ -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;
index 47f7a3557991dbfd38c72e6d96a022afc9c5dd7c..1638fbb60c8ba8e70829fd4bb0299043dfb95eca 100644 (file)
@@ -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)
 {
index cbc1df1eecc10c768373723b2d9ba7fc435ba843..64fe5ab46a75ae53a1ba3df180829683d9235905 100644 (file)
@@ -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
                                        {