From d378b78b6a17acd7649aca989803cc42873f8641 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 17 Mar 2007 13:31:48 +0000 Subject: Allow using the left/right keys to select button in a selection box. (Selection boxes are used, for instance, when asking the player to verify that he wants to save the game to a specific slot.) svn-id: r26168 --- engines/agi/text.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines/agi') diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp index 70d7e25d58..8414e47011 100644 --- a/engines/agi/text.cpp +++ b/engines/agi/text.cpp @@ -310,6 +310,7 @@ int AgiEngine::messageBox(const char *s) { * @param b NULL-terminated list of button labels */ int AgiEngine::selectionBox(const char *m, const char **b) { + int numButtons = 0; int x, y, i, s; int key, active = 0; int rc = -1; @@ -325,6 +326,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) { /* Automatically position buttons */ for (i = 0; b[i]; i++) { + numButtons++; s -= CHAR_COLS * strlen(b[i]); } @@ -362,6 +364,16 @@ int AgiEngine::selectionBox(const char *m, const char **b) { case KEY_ESCAPE: rc = -1; goto getout; + case KEY_RIGHT: + active++; + if (active >= numButtons) + active = 0; + break; + case KEY_LEFT: + active--; + if (active < 0) + active = numButtons - 1; + break; case BUTTON_LEFT: for (i = 0; b[i]; i++) { if (_gfx->testButton(bx[i], by[i], b[i])) { -- cgit v1.2.3