From: divverent Date: Mon, 31 Dec 2007 13:37:32 +0000 (+0000) Subject: add a new key dest key_menu_grabbed that behaves like key_menu, but also passes funct... X-Git-Tag: xonotic-v0.1.0preview~2612 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=38dc528b36742bf91901a4a160954677cd762e0f;p=xonotic%2Fdarkplaces.git add a new key dest key_menu_grabbed that behaves like key_menu, but also passes function keys to the menu; useful for key bind editors git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7883 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/keys.c b/keys.c index 8faf34f9..dd718225 100644 --- a/keys.c +++ b/keys.c @@ -949,6 +949,7 @@ Key_Event (int key, char ascii, qboolean down) Key_Message (key, ascii); break; case key_menu: + case key_menu_grabbed: MR_KeyEvent (key, ascii, down); break; case key_game: @@ -963,7 +964,8 @@ Key_Event (int key, char ascii, qboolean down) return; } - // send function keydowns to interpreter no matter what mode is + // send function keydowns to interpreter no matter what mode is (unless the menu has specifically grabbed the keyboard, for rebinding keys) + if (key_dest != key_menu_grabbed) if (key >= K_F1 && key <= K_F12 && down) { // ignore key repeats on F1-F12 binds @@ -1022,6 +1024,7 @@ Key_Event (int key, char ascii, qboolean down) Key_Message (key, ascii); break; case key_menu: + case key_menu_grabbed: MR_KeyEvent (key, ascii, down); break; case key_game: diff --git a/keys.h b/keys.h index 7e3e9ef2..0d29ea2c 100644 --- a/keys.h +++ b/keys.h @@ -186,7 +186,7 @@ typedef enum keynum_e } keynum_t; -typedef enum keydest_e { key_game, key_message, key_menu } keydest_t; +typedef enum keydest_e { key_game, key_message, key_menu, key_menu_grabbed } keydest_t; #define MAX_INPUTLINES 32 #define MAX_BINDMAPS 8 diff --git a/menu.c b/menu.c index 59418bd5..29467965 100644 --- a/menu.c +++ b/menu.c @@ -277,7 +277,7 @@ void M_ToggleMenu_f (void) { m_entersound = true; - if (key_dest != key_menu || m_state != m_main) + if ((key_dest != key_menu && key_dest != key_menu_grabbed) || m_state != m_main) { if(Cmd_Argc() == 2 && !strcmp(Cmd_Argv(1), "1")) return; @@ -3169,7 +3169,7 @@ void M_Menu_Quit_f (void) int n; if (m_state == m_quit) return; - wasInMenus = (key_dest == key_menu); + wasInMenus = (key_dest == key_menu || key_dest == key_menu_grabbed); key_dest = key_menu; m_quit_prevstate = m_state; m_state = m_quit; @@ -4744,7 +4744,7 @@ void M_Init (void) void M_Draw (void) { - if (key_dest != key_menu) + if (key_dest != key_menu && key_dest != key_menu_grabbed) m_state = m_none; if (m_state == m_none) diff --git a/mvm_cmds.c b/mvm_cmds.c index 2947ebfa..11d0ddc9 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -89,6 +89,10 @@ void VM_M_setkeydest(void) // key_menu key_dest = key_menu; break; + case 3: + // key_menu_grabbed + key_dest = key_menu_grabbed; + break; case 1: // key_message // key_dest = key_message @@ -109,7 +113,7 @@ void VM_M_getkeydest(void) { VM_SAFEPARMCOUNT(0,VM_M_getkeydest); - // key_game = 0, key_message = 1, key_menu = 2, unknown = 3 + // key_game = 0, key_message = 1, key_menu = 2, key_menu_grabbed = 3, unknown = -1 switch(key_dest) { case key_game: @@ -118,12 +122,15 @@ void VM_M_getkeydest(void) case key_menu: PRVM_G_FLOAT(OFS_RETURN) = 2; break; + case key_menu_grabbed: + PRVM_G_FLOAT(OFS_RETURN) = 3; + break; case key_message: // not supported // PRVM_G_FLOAT(OFS_RETURN) = 1; // break; default: - PRVM_G_FLOAT(OFS_RETURN) = 3; + PRVM_G_FLOAT(OFS_RETURN) = -1; } }