diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 0f0bdcd81e..0822110772 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -10,6 +10,7 @@ - Fix: [#13334] Uninitialised variables in CustomTabDesc. - Fix: [#13342] Rename tabChange to onTabChange in WindowDesc interface. - Fix: [#13427] Newly created Go-Karts show "Race won by ". +- Fix: [#13431] [Plugin] UI disabled widgets can still be interacted with. - Fix: [#13454] Plug-ins do not load on Windows if the user directory contains non-ASCII characters. - Fix: [#13469] Exception thrown from plugin in context.subscribe. - Fix: [#13477] Plug-in widget tooltips do not work. diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index ed0f14e109..9dffee73f8 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -1014,6 +1014,18 @@ void WidgetSetEnabled(rct_window* w, rct_widgetindex widgetIndex, bool enabled) } } +void WidgetSetDisabled(rct_window* w, rct_widgetindex widgetIndex, bool value) +{ + if (value) + { + w->disabled_widgets |= (1ULL << widgetIndex); + } + else + { + w->disabled_widgets &= ~(1ULL << widgetIndex); + } +} + void WidgetSetCheckboxValue(rct_window* w, rct_widgetindex widgetIndex, int32_t value) { if (value) diff --git a/src/openrct2-ui/scripting/CustomWindow.cpp b/src/openrct2-ui/scripting/CustomWindow.cpp index 3b24fc15b7..4ee5097111 100644 --- a/src/openrct2-ui/scripting/CustomWindow.cpp +++ b/src/openrct2-ui/scripting/CustomWindow.cpp @@ -871,6 +871,8 @@ namespace OpenRCT2::Ui::Windows widget.text = STR_DROPDOWN_GLYPH; widget.tooltip = STR_NONE; widget.flags |= WIDGET_FLAGS::IS_ENABLED; + if (desc.IsDisabled) + widget.flags |= WIDGET_FLAGS::IS_DISABLED; widgetList.push_back(widget); } else if (desc.Type == "groupbox") @@ -917,6 +919,8 @@ namespace OpenRCT2::Ui::Windows widget.text = STR_NUMERIC_DOWN; widget.tooltip = STR_NONE; widget.flags |= WIDGET_FLAGS::IS_ENABLED; + if (desc.IsDisabled) + widget.flags |= WIDGET_FLAGS::IS_DISABLED; widgetList.push_back(widget); // Add the increment button diff --git a/src/openrct2-ui/scripting/ScWidget.hpp b/src/openrct2-ui/scripting/ScWidget.hpp index 50a875b02c..c151f6798e 100644 --- a/src/openrct2-ui/scripting/ScWidget.hpp +++ b/src/openrct2-ui/scripting/ScWidget.hpp @@ -299,11 +299,21 @@ namespace OpenRCT2::Scripting auto w = GetWindow(); if (w != nullptr) { - auto mask = 1ULL << _widgetIndex; - if (value) - w->disabled_widgets |= mask; - else - w->disabled_widgets &= ~mask; + WidgetSetDisabled(w, _widgetIndex, value); + + auto widget = GetWidget(); + if (widget != nullptr) + { + if (widget->type == WindowWidgetType::DropdownMenu) + { + WidgetSetDisabled(w, _widgetIndex + 1, value); + } + else if (widget->type == WindowWidgetType::Spinner) + { + WidgetSetDisabled(w, _widgetIndex + 1, value); + WidgetSetDisabled(w, _widgetIndex + 2, value); + } + } } } diff --git a/src/openrct2/interface/Widget.h b/src/openrct2/interface/Widget.h index 252fec04a6..7bb87829f9 100644 --- a/src/openrct2/interface/Widget.h +++ b/src/openrct2/interface/Widget.h @@ -145,6 +145,7 @@ void WidgetScrollGetPart( int32_t* output_scroll_area, int32_t* scroll_id); void WidgetSetEnabled(rct_window* w, rct_widgetindex widgetIndex, bool enabled); +void WidgetSetDisabled(rct_window* w, rct_widgetindex widgetIndex, bool value); void WidgetSetCheckboxValue(rct_window* w, rct_widgetindex widgetIndex, int32_t value); #endif