From 3dd0b9369810d03ab689f01652638301a4157c70 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Thu, 2 Jan 2025 11:57:05 +0100 Subject: [PATCH] Codechange: use SetStringTip instead of accessing widget_data and tool_tip directly --- src/autoreplace_gui.cpp | 3 +-- src/build_vehicle_gui.cpp | 12 ++++-------- src/group_gui.cpp | 2 +- src/newgrf_gui.cpp | 16 +++++++--------- src/vehicle_gui.cpp | 3 +-- 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 1dcd55bdd7..d790471c4e 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -281,8 +281,7 @@ public: this->vscroll[1] = this->GetScrollbar(WID_RV_RIGHT_SCROLLBAR); NWidgetCore *widget = this->GetWidget(WID_RV_SHOW_HIDDEN_ENGINES); - widget->widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype; - widget->tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype; + widget->SetStringTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + vehicletype, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + vehicletype); widget->SetLowered(this->show_hidden_engines); this->FinishInitNested(vehicletype); diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 83335a3c82..1810e11fbb 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1193,11 +1193,9 @@ struct BuildVehicleWindow : Window { if (refit) refit = Engine::Get(this->sel_engine)->GetDefaultCargoType() != this->cargo_filter_criteria; if (refit) { - widget->widget_data = STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type; - widget->tool_tip = STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP + this->vehicle_type; + widget->SetStringTip(STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type, STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_TOOLTIP + this->vehicle_type); } else { - widget->widget_data = STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type; - widget->tool_tip = STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP + this->vehicle_type; + widget->SetStringTip(STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type, STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_TOOLTIP + this->vehicle_type); } } @@ -1230,12 +1228,10 @@ struct BuildVehicleWindow : Window { widget->tool_tip = STR_BUY_VEHICLE_TRAIN_HIDE_SHOW_TOGGLE_TOOLTIP + type; widget = this->GetWidget(WID_BV_RENAME); - widget->widget_data = STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON + type; - widget->tool_tip = STR_BUY_VEHICLE_TRAIN_RENAME_TOOLTIP + type; + widget->SetStringTip(STR_BUY_VEHICLE_TRAIN_RENAME_BUTTON + type, STR_BUY_VEHICLE_TRAIN_RENAME_TOOLTIP + type); widget = this->GetWidget(WID_BV_SHOW_HIDDEN_ENGINES); - widget->widget_data = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + type; - widget->tool_tip = STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + type; + widget->SetStringTip(STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN + type, STR_SHOW_HIDDEN_ENGINES_VEHICLE_TRAIN_TOOLTIP + type); widget->SetLowered(this->show_hidden_engines); this->details_height = ((this->vehicle_type == VEH_TRAIN) ? 10 : 9); diff --git a/src/group_gui.cpp b/src/group_gui.cpp index bd77877a1a..7642aa713e 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -406,7 +406,7 @@ public: this->group_sb->SetCount(this->groups.size()); this->GetWidget(WID_GL_CAPTION)->widget_data = STR_VEHICLE_LIST_TRAIN_CAPTION + this->vli.vtype; - this->GetWidget(WID_GL_LIST_VEHICLE)->tool_tip = STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->vli.vtype; + this->GetWidget(WID_GL_LIST_VEHICLE)->SetToolTip(STR_VEHICLE_LIST_TRAIN_LIST_TOOLTIP + this->vli.vtype); this->GetWidget(WID_GL_CREATE_GROUP)->widget_data += this->vli.vtype; this->GetWidget(WID_GL_RENAME_GROUP)->widget_data += this->vli.vtype; diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index a73eb6d207..130ff1159a 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -1325,19 +1325,17 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { has_missing |= c->status == GCS_NOT_FOUND; has_compatible |= HasBit(c->flags, GCF_COMPATIBLE); } - uint32_t widget_data; + StringID text; StringID tool_tip; if (has_missing || has_compatible) { - widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON; - tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP; + text = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON; + tool_tip = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_TOOLTIP; } else { - widget_data = STR_INTRO_ONLINE_CONTENT; - tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT; + text = STR_INTRO_ONLINE_CONTENT; + tool_tip = STR_INTRO_TOOLTIP_ONLINE_CONTENT; } - this->GetWidget(WID_NS_CONTENT_DOWNLOAD)->widget_data = widget_data; - this->GetWidget(WID_NS_CONTENT_DOWNLOAD)->tool_tip = tool_tip; - this->GetWidget(WID_NS_CONTENT_DOWNLOAD2)->widget_data = widget_data; - this->GetWidget(WID_NS_CONTENT_DOWNLOAD2)->tool_tip = tool_tip; + this->GetWidget(WID_NS_CONTENT_DOWNLOAD)->SetStringTip(text, tool_tip); + this->GetWidget(WID_NS_CONTENT_DOWNLOAD2)->SetStringTip(text, tool_tip); this->SetWidgetDisabledState(WID_NS_PRESET_SAVE, has_missing); } diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 40244892e2..47a4c184e2 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -949,8 +949,7 @@ struct RefitWindow : public Window { this->GetWidget(WID_VR_SELECT_HEADER)->tool_tip = STR_REFIT_TRAIN_LIST_TOOLTIP + v->type; this->GetWidget(WID_VR_MATRIX)->tool_tip = STR_REFIT_TRAIN_LIST_TOOLTIP + v->type; NWidgetCore *nwi = this->GetWidget(WID_VR_REFIT); - nwi->widget_data = STR_REFIT_TRAIN_REFIT_BUTTON + v->type; - nwi->tool_tip = STR_REFIT_TRAIN_REFIT_TOOLTIP + v->type; + nwi->SetStringTip(STR_REFIT_TRAIN_REFIT_BUTTON + v->type, STR_REFIT_TRAIN_REFIT_TOOLTIP + v->type); this->GetWidget(WID_VR_SHOW_HSCROLLBAR)->SetDisplayedPlane(v->IsGroundVehicle() ? 0 : SZSP_HORIZONTAL); this->GetWidget(WID_VR_VEHICLE_PANEL_DISPLAY)->tool_tip = (v->type == VEH_TRAIN) ? STR_REFIT_SELECT_VEHICLES_TOOLTIP : STR_NULL;