From c3f9cdf84f8e0075ad12afcad67e4038175deb22 Mon Sep 17 00:00:00 2001 From: mmtunligit <156685720+mmtunligit@users.noreply.github.com> Date: Tue, 25 Nov 2025 12:05:24 +0100 Subject: [PATCH] Codechange 7a0814c: Use SetDisplayedPlane instead of UpdateWidgetSize (#14823) --- src/misc_gui.cpp | 15 ++++----------- src/widgets/misc_widget.h | 1 + 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 936480e855..fdb53d53d4 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -921,6 +921,7 @@ struct QueryStringWindow : public Window this->flags = flags; this->CreateNestedTree(); + this->GetWidget(WID_QS_DEFAULT_SEL)->SetDisplayedPlane((this->flags.Test(QueryStringFlag::EnableDefault)) ? 0 : SZSP_NONE); this->GetWidget(WID_QS_MOVE_SEL)->SetDisplayedPlane((this->flags.Test(QueryStringFlag::EnableMove)) ? 0 : SZSP_NONE); this->FinishInitNested(WN_QUERY_STRING); @@ -929,16 +930,6 @@ struct QueryStringWindow : public Window this->SetFocusedWidget(WID_QS_TEXT); } - void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override - { - if (widget == WID_QS_DEFAULT && !this->flags.Test(QueryStringFlag::EnableDefault)) { - /* We don't want this widget to show! */ - fill.width = 0; - resize.width = 0; - size.width = 0; - } - } - std::string GetWidgetString(WidgetID widget, StringID stringid) const override { if (widget == WID_QS_CAPTION) return GetString(this->editbox.caption); @@ -1041,7 +1032,9 @@ static constexpr std::initializer_list _nested_query_string_widgets NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QS_TEXT), SetMinimalSize(256, 0), SetFill(1, 0), SetPadding(2, 2, 2, 2), EndContainer(), NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize), - NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_DEFAULT), SetMinimalSize(65, 12), SetFill(1, 1), SetStringTip(STR_BUTTON_DEFAULT), + NWidget(NWID_SELECTION, INVALID_COLOUR, WID_QS_DEFAULT_SEL), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_DEFAULT), SetMinimalSize(65, 12), SetFill(1, 1), SetStringTip(STR_BUTTON_DEFAULT), + EndContainer(), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_CANCEL), SetMinimalSize(65, 12), SetFill(1, 1), SetStringTip(STR_BUTTON_CANCEL), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_OK), SetMinimalSize(65, 12), SetFill(1, 1), SetStringTip(STR_BUTTON_OK), NWidget(NWID_SELECTION, INVALID_COLOUR, WID_QS_MOVE_SEL), diff --git a/src/widgets/misc_widget.h b/src/widgets/misc_widget.h index 758d418014..79ff3a4cd9 100644 --- a/src/widgets/misc_widget.h +++ b/src/widgets/misc_widget.h @@ -33,6 +33,7 @@ enum QueryStringWidgets : WidgetID { WID_QS_CAPTION, ///< Caption of the window. WID_QS_TEXT, ///< Text of the query. WID_QS_DEFAULT, ///< Default button. + WID_QS_DEFAULT_SEL, ///< Container for default button, which can be hidden. WID_QS_CANCEL, ///< Cancel button. WID_QS_OK, ///< OK button. WID_QS_MOVE, ///< Move button.