From 5aed42c18e8f1b9c56fbe0738f23293f59a2f147 Mon Sep 17 00:00:00 2001 From: Roman Fomin Date: Fri, 16 Feb 2024 14:01:46 +0700 Subject: [PATCH] deactivate thermo if input deactivated not in active range (#1477) * fix all thermos on the page are activated don't release the button * remove redundant check --- src/m_menu.c | 76 +++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 3a455210..93ea8ebc 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -5935,50 +5935,58 @@ static boolean M_MenuMouseResponder(void) return true; } - static boolean active_thermo = false; + static setup_menu_t *active_thermo = NULL; + + if (M_InputDeactivated(input_menu_enter) && active_thermo) + { + int flags = active_thermo->m_flags; + default_t *def = active_thermo->var.def; + + if (flags & S_ACTION) + { + if (flags & (S_LEVWARN | S_PRGWARN)) + { + warn_about_changes(flags); + } + else if (def->current) + { + def->current->i = def->location->i; + } + + if (active_thermo->action) + { + active_thermo->action(); + } + } + active_thermo = NULL; + } setup_menu_t *current_item = current_setup_menu + set_menu_itemon; int flags = current_item->m_flags; default_t *def = current_item->var.def; mrect_t *rect = ¤t_item->rect; + if (ItemDisabled(flags)) + { + return false; + } + if (M_InputActivated(input_menu_enter) && !M_PointInsideRect(rect, mouse_state_x, mouse_state_y)) { return true; // eat event } - if (ItemDisabled(flags)) - { - return false; - } - if (flags & S_THERMO) { + if (active_thermo && active_thermo != current_item) + { + active_thermo = NULL; + } + if (M_InputActivated(input_menu_enter)) { - active_thermo = true; - } - else if (M_InputDeactivated(input_menu_enter)) - { - active_thermo = false; - - if (flags & S_ACTION) - { - if (flags & (S_LEVWARN | S_PRGWARN)) - { - warn_about_changes(flags); - } - else if (def->current) - { - def->current->i = def->location->i; - } - - if (current_item->action) - { - current_item->action(); - } - } + active_thermo = current_item; } } @@ -5991,7 +5999,7 @@ static boolean M_MenuMouseResponder(void) if (max == UL) { - const char **strings = GetStrings(current_item->strings_id); + const char **strings = GetStrings(active_thermo->strings_id); if (strings) max = array_size(strings) - 1; else @@ -6006,9 +6014,9 @@ static boolean M_MenuMouseResponder(void) { def->location->i = value; - if (!(flags & S_ACTION) && current_item->action) + if (!(flags & S_ACTION) && active_thermo->action) { - current_item->action(); + active_thermo->action(); } S_StartSound(NULL, sfx_stnmov); } @@ -6020,12 +6028,6 @@ static boolean M_MenuMouseResponder(void) return false; } - if (ItemDisabled(flags)) - { - S_StartSound(NULL, sfx_oof); - return false; - } - if (flags & (S_YESNO|S_ONOFF)) // yes or no setting? { M_SetupYesNo();