From: terencehill Date: Mon, 14 Mar 2022 14:36:39 +0000 (+0100) Subject: Show the Game menu dialog by pressing ESC instead of F11 X-Git-Tag: xonotic-v0.8.5~129^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2096db4bd1bdc7949c1cad5ffd2641fae177e4a7;p=xonotic%2Fxonotic-data.pk3dir.git Show the Game menu dialog by pressing ESC instead of F11 --- diff --git a/binds-xonotic.cfg b/binds-xonotic.cfg index 77d4147b7..8a900b7de 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 7acbfe6cb..a70627d80 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 878928449..2613454b3 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 272f882fe..b0d12ea60 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 e1956b394..d1bc88c46 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"));