From 1b51c6545a4d7cdac3c945aef36e00e4fb815518 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 15 Oct 2014 01:50:17 +0200 Subject: [PATCH] fixed menu display and key navigation bugs --- ChangeLog | 4 ++++ src/conftime.h | 2 +- src/screens.c | 44 +++++++++++++++++++++++++++++++------------- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 882b5a99..c3b930b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-10-15 + * fixed menu display bugs (drawing outside menu area with draw offset) + * fixed menu key navigation bugs (when using smaller menu list size) + 2014-10-14 * added support for animated door parts during opening/closing movement diff --git a/src/conftime.h b/src/conftime.h index 7ebc3ab5..25a2a7d1 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-10-14 16:13" +#define COMPILE_DATE_STRING "2014-10-15 01:48" diff --git a/src/screens.c b/src/screens.c index 32eec479..91131056 100644 --- a/src/screens.c +++ b/src/screens.c @@ -411,6 +411,9 @@ static struct menu.list_size[game_status] : \ MAX_MENU_ENTRIES_ON_SCREEN) +#define IN_VIS_MENU(x, y) IN_FIELD(x, y, SCR_FIELDX, \ + NUM_MENU_ENTRIES_ON_SCREEN) + /* title display and control definitions */ @@ -2046,7 +2049,7 @@ void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button) y += dy; } - if (IN_VIS_FIELD(x, y) && + if (IN_VIS_MENU(x, y) && y >= 0 && y < num_info_info && info_info[y].type & ~TYPE_SKIP_ENTRY) { if (button) @@ -3260,6 +3263,19 @@ static void AdjustChooseTreeScrollbar(int id, int first_entry, TreeInfo *ti) first_entry); } +static void clearMenuListArea() +{ + int scrollbar_xpos = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset; + + /* correct scrollbar position if placed outside menu (playfield) area */ + if (scrollbar_xpos > SC_SCROLLBAR_XPOS) + scrollbar_xpos = SC_SCROLLBAR_XPOS; + + /* clear menu list area, but not title or scrollbar */ + DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32, + scrollbar_xpos - mSX, NUM_MENU_ENTRIES_ON_SCREEN * 32); +} + static void drawChooseTreeList(int first_entry, int num_page_entries, TreeInfo *ti) { @@ -3275,10 +3291,7 @@ static void drawChooseTreeList(int first_entry, int num_page_entries, DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string); - /* clear tree list area, but not title or scrollbar */ - DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32, - SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset, - NUM_MENU_ENTRIES_ON_SCREEN * 32); + clearMenuListArea(); for (i = 0; i < num_page_entries; i++) { @@ -3548,7 +3561,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } if (!anyScrollbarGadgetActive() && - IN_VIS_FIELD(x, y) && + IN_VIS_MENU(x, y) && mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x && y >= 0 && y < num_page_entries) { @@ -5231,10 +5244,7 @@ static void drawSetupInfoList(struct TokenInfo *setup_info, if (first_entry + num_page_entries > max_setup_info) first_entry = 0; - /* clear tree list area, but not title or scrollbar */ - DrawBackground(mSX, mSY + MENU_SCREEN_START_YPOS * 32, - SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset, - NUM_MENU_ENTRIES_ON_SCREEN * 32); + clearMenuListArea(); for (i = 0; i < num_page_entries; i++) { @@ -5553,7 +5563,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) setup_info[first_entry + y].type & TYPE_SKIP_ENTRY) y += dy; - if (!IN_VIS_FIELD(x, y)) + if (!IN_VIS_MENU(x, y)) { choice += y - y_old; @@ -5587,7 +5597,7 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) } if (!anyScrollbarGadgetActive() && - IN_VIS_FIELD(x, y) && + IN_VIS_MENU(x, y) && mx < screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x && y >= 0 && y < num_page_entries) { @@ -5850,7 +5860,7 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) { HandleSetupScreen_Input_Player(1, dx < 0 ? -1 : +1); } - else if (IN_VIS_FIELD(x, y) && + else if (IN_VIS_FIELD(x, y) && // (does not use "IN_VIS_MENU()" yet) y >= pos_start && y <= pos_end && !(y >= pos_empty1 && y <= pos_empty2)) { @@ -6545,6 +6555,10 @@ static void CreateScreenScrollbuttons() width = SC_SCROLLBUTTON_XSIZE; height = SC_SCROLLBUTTON_YSIZE; + /* correct scrollbar position if placed outside menu (playfield) area */ + if (x > SC_SCROLL_UP_XPOS) + x = SC_SCROLL_UP_XPOS; + if (id == SCREEN_CTRL_ID_SCROLL_DOWN) y = mSY + (SC_SCROLL_VERTICAL_YPOS + (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE); @@ -6610,6 +6624,10 @@ static void CreateScreenScrollbars() width = scrollbar_info[i].width; height = scrollbar_info[i].height; + /* correct scrollbar position if placed outside menu (playfield) area */ + if (x > SC_SCROLL_VERTICAL_XPOS) + x = SC_SCROLL_VERTICAL_XPOS; + if (id == SCREEN_CTRL_ID_SCROLL_VERTICAL) height = (NUM_MENU_ENTRIES_ON_SCREEN - 2) * SC_SCROLLBUTTON_YSIZE; -- 2.34.1