From 1e5b84ea141582ef8e229c1989fe0f7cd9582d5b Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 8 Jan 2010 02:10:05 +0000 Subject: [PATCH] - Fixed: I forgot to reimplement the number keys for Strife's dialogues when I redid the menus to work with controllers. SVN r2103 (trunk) --- src/m_menu.cpp | 55 ++++++++++++++++++++++++++--------------------- src/m_options.cpp | 54 ++++++++++++++++++---------------------------- 2 files changed, 52 insertions(+), 57 deletions(-) diff --git a/src/m_menu.cpp b/src/m_menu.cpp index e817bebbca..229da94db3 100644 --- a/src/m_menu.cpp +++ b/src/m_menu.cpp @@ -2966,40 +2966,47 @@ bool M_Responder (event_t *ev) { mkey = MKEY_Clear; } - else if (!keyup && !OptionsActive) + else if (!keyup) { - ch = tolower (ch); - if (messageToPrint) + if (OptionsActive) { - // Take care of any messages that need input - ch = tolower (ch); - assert(messageRoutine != NULL); - if (ch != ' ' && ch != 'n' && ch != 'y') - { - return false; - } - D_RemoveNextCharEvent(); - M_EndMessage(ch); - return true; + M_OptResponder(ev); } else { - // Search for a menu item associated with the pressed key. - for (i = (itemOn + 1) % currentMenu->numitems; - i != itemOn; - i = (i + 1) % currentMenu->numitems) + ch = tolower (ch); + if (messageToPrint) { + // Take care of any messages that need input + ch = tolower (ch); + assert(messageRoutine != NULL); + if (ch != ' ' && ch != 'n' && ch != 'y') + { + return false; + } + D_RemoveNextCharEvent(); + M_EndMessage(ch); + return true; + } + else + { + // Search for a menu item associated with the pressed key. + for (i = (itemOn + 1) % currentMenu->numitems; + i != itemOn; + i = (i + 1) % currentMenu->numitems) + { + if (currentMenu->menuitems[i].alphaKey == ch) + { + break; + } + } if (currentMenu->menuitems[i].alphaKey == ch) { - break; + itemOn = i; + S_Sound(CHAN_VOICE | CHAN_UI, "menu/cursor", 1, ATTN_NONE); + return true; } } - if (currentMenu->menuitems[i].alphaKey == ch) - { - itemOn = i; - S_Sound(CHAN_VOICE | CHAN_UI, "menu/cursor", 1, ATTN_NONE); - return true; - } } } break; diff --git a/src/m_options.cpp b/src/m_options.cpp index 9815443f4e..5e95f1a5e7 100644 --- a/src/m_options.cpp +++ b/src/m_options.cpp @@ -2141,11 +2141,10 @@ void M_OptResponder(event_t *ev) CurrentMenu->items[0].label = OldMessage; CurrentMenu->items[0].type = OldType; } - else if (ev->type == EV_GUI_Event && ev->subtype == EV_GUI_KeyDown && tolower(ev->data1) == 't') + else if (ev->type == EV_GUI_Event && ev->subtype == EV_GUI_KeyDown) { - // Test selected resolution - if (CurrentMenu == &ModesMenu) - { + if (CurrentMenu == &ModesMenu && (ev->data1 == 't' || ev->data1 == 'T')) + { // Test selected resolution if (!(item->type == screenres && GetSelectedSize (CurrentItem, &NewWidth, &NewHeight))) { @@ -2161,6 +2160,23 @@ void M_OptResponder(event_t *ev) S_Sound (CHAN_VOICE | CHAN_UI, "menu/choose", 1, ATTN_NONE); SetModesMenu (NewWidth, NewHeight, NewBits); } + else if (ev->data1 >= '0' && ev->data1 <= '9') + { // Activate an item of type numberedmore + int i; + int num = ev->data1 == '0' ? 10 : ev->data1 - '0'; + + for (i = 0; i < CurrentMenu->numitems; ++i) + { + menuitem_t *item = CurrentMenu->items + i; + + if (item->type == numberedmore && item->b.position == num) + { + CurrentItem = i; + M_OptButtonHandler(MKEY_Enter, false); + break; + } + } + } } } @@ -2769,35 +2785,7 @@ void M_OptButtonHandler(EMenuKey key, bool repeat) item->b.key1 = item->c.key2 = 0; } break; -/* - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - int lookfor = ch == '0' ? 10 : ch - '0', i; - for (i = 0; i < CurrentMenu->numitems; ++i) - { - if (CurrentMenu->items[i].b.position == lookfor) - { - CurrentItem = i; - item = &CurrentMenu->items[i]; - break; - } - } - if (i == CurrentMenu->numitems) - { - break; - } - // Otherwise, fall through to '\r' below - } -*/ + case MKEY_Enter: if (CurrentMenu == &ModesMenu && item->type == screenres) {