From: Holger Schemel Date: Wed, 23 Feb 2022 23:23:59 +0000 (+0100) Subject: fixed treating already handled click on gadget as "leave screen" event X-Git-Tag: 4.3.2.0~108 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=e393d823c775211475df75fc855dea7344a71aa9;p=rocksndiamonds.git fixed treating already handled click on gadget as "leave screen" event This bug occured when clicking on the "previous level" or "next level" gadget on the high score screen, followed by an empty scores screen, which itself treats any button click as a "leave screen" event, thus handling that mouse click twice, which results in that empty scores screen to be immediately left (although it should wait for *another* button click here, of course). This fix makes sure that button clicks on gadgets that were already handled are not immediately handled again. --- diff --git a/src/screens.c b/src/screens.c index f07f7030..62497e67 100644 --- a/src/screens.c +++ b/src/screens.c @@ -5145,6 +5145,9 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, int num_entries = numTreeInfoInGroup(ti); int num_page_entries = MIN(num_entries, NUM_MENU_ENTRIES_ON_SCREEN); boolean position_set_by_scrollbar = (dx == 999); + boolean button_action = (button == MB_MENU_LEAVE || button == MB_MENU_CHOICE); + boolean button_is_valid = (mx >= 0 && my >= 0); + boolean button_screen_clicked = (button_action && button_is_valid); if (game_status == GAME_MODE_SCORES) { @@ -5172,7 +5175,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, { drawChooseTreeScreen_Scores_NotAvailable(); } - else if (button == MB_MENU_LEAVE || button == MB_MENU_CHOICE) + else if (button_screen_clicked) { PlaySound(SND_MENU_ITEM_SELECTING);