mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-22 19:54:06 +01:00
Codechange: Use SetDisplayedPlane instead of UpdateWidgetSize to hide various buttons (#14831)
This commit is contained in:
@@ -266,10 +266,12 @@ static constexpr std::initializer_list<NWidgetPart> _nested_small_news_widgets =
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE, WID_N_CLOSEBOX),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_N_CAPTION),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_LIGHT_BLUE, WID_N_SHOW_GROUP),
|
||||
SetAspect(WidgetDimensions::ASPECT_VEHICLE_ICON),
|
||||
SetResize(1, 0),
|
||||
SetToolTip(STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP),
|
||||
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_N_SHOW_GROUP_SEL),
|
||||
NWidget(WWT_TEXTBTN, COLOUR_LIGHT_BLUE, WID_N_SHOW_GROUP),
|
||||
SetAspect(WidgetDimensions::ASPECT_VEHICLE_ICON),
|
||||
SetResize(1, 0),
|
||||
SetToolTip(STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
||||
/* Main part */
|
||||
@@ -368,8 +370,12 @@ struct NewsWindow : Window {
|
||||
|
||||
this->CreateNestedTree();
|
||||
|
||||
bool has_vehicle_id = std::holds_alternative<VehicleID>(ni->ref1);
|
||||
NWidgetStacked *nwid_sel = this->GetWidget<NWidgetStacked>(WID_N_SHOW_GROUP_SEL);
|
||||
if (nwid_sel != nullptr) nwid_sel->SetDisplayedPlane(has_vehicle_id ? 0 : SZSP_NONE);
|
||||
|
||||
NWidgetCore *nwid = this->GetWidget<NWidgetCore>(WID_N_SHOW_GROUP);
|
||||
if (std::holds_alternative<VehicleID>(ni->ref1) && nwid != nullptr) {
|
||||
if (has_vehicle_id && nwid != nullptr) {
|
||||
const Vehicle *v = Vehicle::Get(std::get<VehicleID>(ni->ref1));
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN:
|
||||
@@ -470,14 +476,6 @@ struct NewsWindow : Window {
|
||||
d2.height += WidgetDimensions::scaled.captiontext.Vertical();
|
||||
d2.width += WidgetDimensions::scaled.captiontext.Horizontal();
|
||||
size = d2;
|
||||
} else {
|
||||
/* Hide 'Show group window' button if this news is not about a vehicle. */
|
||||
size.width = 0;
|
||||
size.height = 0;
|
||||
resize.width = 0;
|
||||
resize.height = 0;
|
||||
fill.width = 0;
|
||||
fill.height = 0;
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user