From 2096db4bd1bdc7949c1cad5ffd2641fae177e4a7 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 14 Mar 2022 15:36:39 +0100 Subject: [PATCH] Show the Game menu dialog by pressing ESC instead of F11 --- binds-xonotic.cfg | 1 - qcsrc/client/main.qc | 26 ++++++++++++++++++++++++++ qcsrc/menu/xonotic/dialog_gamemenu.qc | 8 ++++++++ qcsrc/menu/xonotic/dialog_gamemenu.qh | 1 + qcsrc/menu/xonotic/keybinder.qc | 1 - 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/binds-xonotic.cfg b/binds-xonotic.cfg index 77d4147b75..8a900b7de3 100644 --- a/binds-xonotic.cfg +++ b/binds-xonotic.cfg @@ -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 diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 7acbfe6cba..a70627d807 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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; } diff --git a/qcsrc/menu/xonotic/dialog_gamemenu.qc b/qcsrc/menu/xonotic/dialog_gamemenu.qc index 8789284499..2613454b36 100644 --- a/qcsrc/menu/xonotic/dialog_gamemenu.qc +++ b/qcsrc/menu/xonotic/dialog_gamemenu.qc @@ -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)); diff --git a/qcsrc/menu/xonotic/dialog_gamemenu.qh b/qcsrc/menu/xonotic/dialog_gamemenu.qh index 272f882fe6..b0d12ea606 100644 --- a/qcsrc/menu/xonotic/dialog_gamemenu.qh +++ b/qcsrc/menu/xonotic/dialog_gamemenu.qh @@ -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); diff --git a/qcsrc/menu/xonotic/keybinder.qc b/qcsrc/menu/xonotic/keybinder.qc index e1956b3946..d1bc88c46a 100644 --- a/qcsrc/menu/xonotic/keybinder.qc +++ b/qcsrc/menu/xonotic/keybinder.qc @@ -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")); -- 2.39.2