From 1ad5e9b81bb22e261e21c0da1abe8e8f74b520a8 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Mon, 3 Mar 2025 18:36:11 +0000 Subject: [PATCH] Codechange: Move to GetWidgetString for group window. --- src/group_gui.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/group_gui.cpp b/src/group_gui.cpp index fc86e0000d..f40b986aab 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -84,7 +84,7 @@ static constexpr NWidgetPart _nested_group_widgets[] = { NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize), NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalTextLines(1, WidgetDimensions::unscaled.framerect.Vertical()), SetFill(0, 1), SetResize(1, 0), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_FILTER_BY_CARGO), SetMinimalSize(0, 12), SetFill(0, 1), SetStringTip(STR_JUST_STRING, STR_TOOLTIP_FILTER_CRITERIA), + NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_FILTER_BY_CARGO), SetMinimalSize(0, 12), SetFill(0, 1), SetToolTip(STR_TOOLTIP_FILTER_CRITERIA), NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(0, 1), SetResize(1, 0), EndContainer(), EndContainer(), EndContainer(), @@ -96,7 +96,7 @@ static constexpr NWidgetPart _nested_group_widgets[] = { NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(1, 0), SetFill(1, 1), SetResize(1, 0), EndContainer(), NWidget(NWID_HORIZONTAL), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_GL_AVAILABLE_VEHICLES), SetMinimalSize(106, 12), - SetStringTip(STR_JUST_STRING, STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP), + SetToolTip(STR_VEHICLE_LIST_AVAILABLE_ENGINES_TOOLTIP), NWidget(WWT_PANEL, COLOUR_GREY), SetMinimalSize(0, 12), SetFill(1, 0), SetResize(1, 0), EndContainer(), NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_GL_MANAGE_VEHICLES_DROPDOWN), SetMinimalSize(118, 12), SetStringTip(STR_VEHICLE_LIST_MANAGE_LIST, STR_VEHICLE_LIST_MANAGE_LIST_TOOLTIP), @@ -502,34 +502,28 @@ public: this->SetDirty(); } - void SetStringParameters(WidgetID widget) const override + std::string GetWidgetString(WidgetID widget, StringID stringid) const override { switch (widget) { case WID_GL_FILTER_BY_CARGO: - SetDParam(0, this->GetCargoFilterLabel(this->cargo_filter_criteria)); - break; + return GetString(this->GetCargoFilterLabel(this->cargo_filter_criteria)); case WID_GL_AVAILABLE_VEHICLES: - SetDParam(0, STR_VEHICLE_LIST_AVAILABLE_TRAINS + this->vli.vtype); - break; + return GetString(STR_VEHICLE_LIST_AVAILABLE_TRAINS + this->vli.vtype); case WID_GL_CAPTION: /* If selected_group == DEFAULT_GROUP || ALL_GROUP, draw the standard caption * We list all vehicles or ungrouped vehicles */ if (IsDefaultGroupID(this->vli.ToGroupID()) || IsAllGroupID(this->vli.ToGroupID())) { - SetDParam(0, STR_COMPANY_NAME); - SetDParam(1, this->vli.company); - SetDParam(2, this->vehicles.size()); - SetDParam(3, this->vehicles.size()); + return GetString(stringid, STR_COMPANY_NAME, this->vli.company, this->vehicles.size(), this->vehicles.size()); } else { uint num_vehicle = GetGroupNumVehicle(this->vli.company, this->vli.ToGroupID(), this->vli.vtype); - SetDParam(0, STR_GROUP_NAME); - SetDParam(1, this->vli.ToGroupID()); - SetDParam(2, num_vehicle); - SetDParam(3, num_vehicle); + return GetString(stringid, STR_GROUP_NAME, this->vli.ToGroupID(), num_vehicle, num_vehicle); } - break; + + default: + return this->Window::GetWidgetString(widget, stringid); } }