From 3e91747d2d39d5c6ed3fa4fced57ac07bb34bf69 Mon Sep 17 00:00:00 2001 From: driAn Date: Sat, 4 Oct 2008 13:02:38 +0000 Subject: [PATCH] navigate menus using TAB and TAB+LSHIFT git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2815 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/console.cpp | 4 ++-- source/src/main.cpp | 2 +- source/src/menus.cpp | 7 ++++++- source/src/protos.h | 4 ++-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/src/console.cpp b/source/src/console.cpp index 0b0dc00c..9275d632 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -391,13 +391,13 @@ void consolekey(int code, bool isdown, int cooked) } } -void keypress(int code, bool isdown, int cooked) +void keypress(int code, bool isdown, int cooked, SDLMod mod) { keym *haskey = NULL; loopv(keyms) if(keyms[i].code==code) { haskey = &keyms[i]; break; } if(haskey && haskey->pressed) execbind(*haskey, isdown); // allow pressed keys to release else if(saycommandon) consolekey(code, isdown, cooked); // keystrokes go to commandline - else if(!menukey(code, isdown, cooked)) // keystrokes go to menu + else if(!menukey(code, isdown, cooked, mod)) // keystrokes go to menu { if(haskey) execbind(*haskey, isdown); } diff --git a/source/src/main.cpp b/source/src/main.cpp index ac0c11ba..1ab38703 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -414,7 +414,7 @@ void checkinput() case SDL_KEYDOWN: case SDL_KEYUP: - keypress(event.key.keysym.sym, event.key.state==SDL_PRESSED, event.key.keysym.unicode); + keypress(event.key.keysym.sym, event.key.state==SDL_PRESSED, event.key.keysym.unicode, event.key.keysym.mod); break; case SDL_ACTIVEEVENT: diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 8748762e..8bb6fcf5 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -586,7 +586,7 @@ COMMAND(menuitemkeyinput, ARG_4STR); COMMAND(menuitemcheckbox, ARG_3STR); -bool menukey(int code, bool isdown, int unicode) +bool menukey(int code, bool isdown, int unicode, SDLMod mod) { if(!curmenu) return false; int n = curmenu->items.length(), menusel = curmenu->menusel; @@ -617,6 +617,11 @@ bool menukey(int code, bool isdown, int unicode) menusel++; break; + case SDLK_TAB: + if(mod & KMOD_LSHIFT) menusel--; + else menusel++; + break; + case SDLK_1: case SDLK_2: case SDLK_3: diff --git a/source/src/protos.h b/source/src/protos.h index 0ec373e7..85a610c4 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -68,7 +68,7 @@ extern int curscontext(); extern int execcontext; // console -extern void keypress(int code, bool isdown, int cooked); +extern void keypress(int code, bool isdown, int cooked, SDLMod mod = KMOD_NONE); extern void rendercommand(int x, int y); extern void renderconsole(); extern char *getcurcommand(); @@ -97,7 +97,7 @@ extern bool menuvisible(); extern void menureset(void *menu); extern void menumanual(void *menu, char *text, char *action = NULL, color *bgcolor = NULL, const char *desc = NULL); extern void menuheader(void *menu, char *header = NULL, char *footer = NULL); -extern bool menukey(int code, bool isdown, int unicode); +extern bool menukey(int code, bool isdown, int unicode, SDLMod mod = KMOD_NONE); extern void *addmenu(const char *name, const char *title = NULL, bool allowinput = true, void (__cdecl *refreshfunc)(void *, bool) = NULL, bool hotkeys = false, bool forwardkeys = false); extern void rendermenumdl(); extern void menuset(void *m, bool save = true);