]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Show the Game menu dialog by pressing ESC instead of F11
authorterencehill <piuntn@gmail.com>
Mon, 14 Mar 2022 14:36:39 +0000 (15:36 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 17 Mar 2022 16:28:13 +0000 (17:28 +0100)
binds-xonotic.cfg
qcsrc/client/main.qc
qcsrc/menu/xonotic/dialog_gamemenu.qc
qcsrc/menu/xonotic/dialog_gamemenu.qh
qcsrc/menu/xonotic/keybinder.qc

index 77d4147b754c9cd655629e0ac3022b68393f2d88..8a900b7de3a827b671fba892541d399fc575a928 100644 (file)
@@ -62,7 +62,6 @@ bind i +show_info
 bind PAUSE pause
 bind F9 "cl_cmd hud minigame"
 bind F10 menu_showquitdialog
-bind F11 menu_showgamemenudialog
 bind F12 screenshot
 bind F4 ready
 
index 7acbfe6cbafb20b4b0ee7ec41441e79828153dc7..a70627d807598cf8b25f2a45b738af986a9b11a8 100644 (file)
@@ -471,6 +471,32 @@ float CSQC_InputEvent(int bInputType, float nPrimary, float nSecondary)
        if(override)
                return true;
 
+       if(bInputType == 3 || bInputType == 2)
+               return false;
+
+       // at this point bInputType can only be 0 or 1 (key pressed or released)
+       bool key_pressed = (bInputType == 0);
+
+       if(key_pressed) {
+               if(nPrimary == K_ALT) hudShiftState |= S_ALT;
+               if(nPrimary == K_CTRL) hudShiftState |= S_CTRL;
+               if(nPrimary == K_SHIFT) hudShiftState |= S_SHIFT;
+       }
+       else {
+               if(nPrimary == K_ALT) hudShiftState -= (hudShiftState & S_ALT);
+               if(nPrimary == K_CTRL) hudShiftState -= (hudShiftState & S_CTRL);
+               if(nPrimary == K_SHIFT) hudShiftState -= (hudShiftState & S_SHIFT);
+       }
+
+       if (nPrimary == K_ESCAPE && !(hudShiftState & S_SHIFT) && key_pressed)
+       {
+               if (cvar("_menu_gamemenu_dialog_available"))
+               {
+                       localcmd("\nmenu_showgamemenudialog\n");
+                       return true;
+               }
+       }
+
        return false;
 }
 
index 87892844994a7c184f132710142253a62ff31e0d..2613454b366531addb25506309ffa7a7fb00d55b 100644 (file)
@@ -5,8 +5,16 @@
 #include "leavematchbutton.qh"
 #include "button.qh"
 
+void XonoticGameMenuDialog_destroy(entity me)
+{
+       cvar_set("_menu_gamemenu_dialog_available", "0");
+}
+
 void XonoticGameMenuDialog_fill(entity me)
 {
+       registercvar("_menu_gamemenu_dialog_available", "0", 0);
+       cvar_set("_menu_gamemenu_dialog_available", "1");
+
        entity e;
        me.TR(me);
                me.TD(me, 1, 1, e = makeXonoticCommandButton(_("Main menu"), '0 0 0', "menu_cmd nexposee", 0));
index 272f882fe6b92ae70ec3323ab87db21fd7e7725d..b0d12ea606bb34f850e8fae66b36538eb34b58e8 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "rootdialog.qh"
 CLASS(XonoticGameMenuDialog, XonoticRootDialog)
+       METHOD(XonoticGameMenuDialog, destroy, void(entity));
        METHOD(XonoticGameMenuDialog, fill, void(entity));
        ATTRIB(XonoticGameMenuDialog, title, string, _("Game menu"));
        ATTRIB(XonoticGameMenuDialog, color, vector, SKINCOLOR_DIALOG_QUIT);
index e1956b394636d02c341511c90fcf8e21ae55dd05..d1bc88c46a6032d7ef9f80041f38b6972eb7b090 100644 (file)
@@ -119,7 +119,6 @@ void KeyBinds_BuildList()
        KEYBIND_DEF("+use"                                  , _("drop key/flag, exit vehicle"));
        KEYBIND_DEF("kill"                                  , _("suicide / respawn"));
        KEYBIND_DEF("quickmenu"                             , _("quick menu"));
-       KEYBIND_DEF("menu_showgamemenudialog"               , _("game menu"));
        KEYBIND_EMPTY_LINE();
 
        KEYBIND_HEADER(_("User defined"));