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
This commit is contained in:
Roman Fomin 2024-02-16 14:01:46 +07:00 committed by GitHub
parent bdd1deef59
commit 5aed42c18e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5935,50 +5935,58 @@ static boolean M_MenuMouseResponder(void)
return true; 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; setup_menu_t *current_item = current_setup_menu + set_menu_itemon;
int flags = current_item->m_flags; int flags = current_item->m_flags;
default_t *def = current_item->var.def; default_t *def = current_item->var.def;
mrect_t *rect = &current_item->rect; mrect_t *rect = &current_item->rect;
if (ItemDisabled(flags))
{
return false;
}
if (M_InputActivated(input_menu_enter) if (M_InputActivated(input_menu_enter)
&& !M_PointInsideRect(rect, mouse_state_x, mouse_state_y)) && !M_PointInsideRect(rect, mouse_state_x, mouse_state_y))
{ {
return true; // eat event return true; // eat event
} }
if (ItemDisabled(flags))
{
return false;
}
if (flags & S_THERMO) if (flags & S_THERMO)
{ {
if (active_thermo && active_thermo != current_item)
{
active_thermo = NULL;
}
if (M_InputActivated(input_menu_enter)) if (M_InputActivated(input_menu_enter))
{ {
active_thermo = true; active_thermo = current_item;
}
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();
}
}
} }
} }
@ -5991,7 +5999,7 @@ static boolean M_MenuMouseResponder(void)
if (max == UL) if (max == UL)
{ {
const char **strings = GetStrings(current_item->strings_id); const char **strings = GetStrings(active_thermo->strings_id);
if (strings) if (strings)
max = array_size(strings) - 1; max = array_size(strings) - 1;
else else
@ -6006,9 +6014,9 @@ static boolean M_MenuMouseResponder(void)
{ {
def->location->i = value; 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); S_StartSound(NULL, sfx_stnmov);
} }
@ -6020,12 +6028,6 @@ static boolean M_MenuMouseResponder(void)
return false; return false;
} }
if (ItemDisabled(flags))
{
S_StartSound(NULL, sfx_oof);
return false;
}
if (flags & (S_YESNO|S_ONOFF)) // yes or no setting? if (flags & (S_YESNO|S_ONOFF)) // yes or no setting?
{ {
M_SetupYesNo(); M_SetupYesNo();