From 19f455811254040f345aac3af25e92be61d762e9 Mon Sep 17 00:00:00 2001 From: aerkefiende Date: Mon, 12 Nov 2012 21:53:44 +0000 Subject: [PATCH] Command line now can use the mouse input as well (thanks to Felix-The-Ghost and SKB) conskip fix (thanks to SKB) new windows binaries git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6926 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/console.cpp | 9 ++++++--- source/src/cube.h | 8 ++++++++ source/src/menus.cpp | 8 ++++---- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/source/src/console.cpp b/source/src/console.cpp index 71578902..ab92375c 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -16,7 +16,8 @@ struct console : consolebuffer int conskip; void setconskip(int n) { - conskip = clamp(conskip + n, 0, conlines.length()); + int visible_lines = (int)(min(fullconsole ? ((VIRTH*2 - 2*CONSPAD - 2*FONTH/3)*(fullconsole==1 ? altconsize : fullconsize))/100 : FONTH*consize, (VIRTH*2 - 2*CONSPAD - 2*FONTH/3))/ (CONSPAD + 2*FONTH/3)) - 1; + conskip = clamp(conskip + n, 0, clamp(conlines.length()-visible_lines, 0, conlines.length())); } static const int WORDWRAP = 80; @@ -486,11 +487,13 @@ void consolekey(int code, bool isdown, int cooked) scrolldoc(4); break; + case SDL_AC_BUTTON_WHEELUP: case SDLK_UP: if(histpos > history.length()) histpos = history.length(); if(histpos > 0) history[--histpos]->restore(); break; + case SDL_AC_BUTTON_WHEELDOWN: case SDLK_DOWN: if(histpos + 1 < history.length()) history[++histpos]->restore(); break; @@ -511,7 +514,7 @@ void consolekey(int code, bool isdown, int cooked) } else { - if(code==SDLK_RETURN) + if(code==SDLK_RETURN || code==SDL_AC_BUTTON_LEFT || code==SDL_AC_BUTTON_MIDDLE) { hline *h = NULL; if(cmdline.buf[0]) @@ -531,7 +534,7 @@ void consolekey(int code, bool isdown, int cooked) saycommand(NULL); if(h) h->run(); } - else if(code==SDLK_ESCAPE) + else if(code==SDLK_ESCAPE || code== SDL_AC_BUTTON_RIGHT) { histpos = history.length(); saycommand(NULL); diff --git a/source/src/cube.h b/source/src/cube.h index 827b951d..d63764ee 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -20,6 +20,14 @@ #include "varray.h" #include "vote.h" #include "console.h" + enum + { + SDL_AC_BUTTON_WHEELDOWN = -5, + SDL_AC_BUTTON_WHEELUP = -4, + SDL_AC_BUTTON_RIGHT = -3, + SDL_AC_BUTTON_MIDDLE = -2, + SDL_AC_BUTTON_LEFT = -1 + }; #endif extern sqr *world, *wmip[]; // map data, the mips are sequential 2D arrays in memory diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 463609c4..592de38f 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -1045,18 +1045,18 @@ bool menukey(int code, bool isdown, int unicode, SDLMod mod) else menusel += pagesize; break; case SDLK_ESCAPE: - case -3: + case SDL_AC_BUTTON_RIGHT: if(!curmenu->allowinput) return false; menuset(menustack.empty() ? NULL : menustack.pop(), false); return true; break; case SDLK_UP: - case -4: + case SDL_AC_BUTTON_WHEELUP: if(!curmenu->allowinput) return false; menusel--; break; case SDLK_DOWN: - case -5: + case SDL_AC_BUTTON_WHEELDOWN: if(!curmenu->allowinput) return false; menusel++; break; @@ -1117,7 +1117,7 @@ bool menukey(int code, bool isdown, int unicode, SDLMod mod) { if(!curmenu->allowinput || !curmenu->items.inrange(menusel)) return false; mitem &m = *curmenu->items[menusel]; - if(code==SDLK_RETURN || code==SDLK_SPACE || code==-1 || code==-2) + if(code==SDLK_RETURN || code==SDLK_SPACE || code==SDL_AC_BUTTON_LEFT || code==SDL_AC_BUTTON_MIDDLE) { m.select(); audiomgr.playsound(S_MENUENTER, SP_HIGHEST);