Add setting to allow hiding viewport labels of inidivudal waypoints

This commit is contained in:
Jonathan G Rennison
2022-01-21 23:37:53 +00:00
parent c65901fef2
commit d81cbc25b8
22 changed files with 116 additions and 13 deletions

View File

@@ -34,6 +34,7 @@ struct WaypointWindow : Window {
private:
VehicleType vt; ///< Vehicle type using the waypoint.
Waypoint *wp; ///< Waypoint displayed by the window.
bool show_hide_label; ///< Show hide label button
/**
* Get the center tile of the waypoint.
@@ -65,6 +66,8 @@ public:
this->GetWidget<NWidgetCore>(WID_W_CENTER_VIEW)->tool_tip = STR_WAYPOINT_VIEW_CENTER_TOOLTIP;
this->GetWidget<NWidgetCore>(WID_W_RENAME)->tool_tip = STR_WAYPOINT_VIEW_CHANGE_WAYPOINT_NAME;
}
this->show_hide_label = (this->vt == VEH_TRAIN && _settings_client.gui.allow_hiding_waypoint_labels);
this->GetWidget<NWidgetStacked>(WID_W_TOGGLE_HIDDEN_SEL)->SetDisplayedPlane(this->show_hide_label ? 0 : SZSP_NONE);
this->FinishInitNested(window_number);
this->owner = this->wp->owner;
@@ -109,6 +112,10 @@ public:
case WID_W_DEPARTURES: // show departure times of vehicles
ShowWaypointDepartures((StationID)this->wp->index);
break;
case WID_W_TOGGLE_HIDDEN:
DoCommandP(0, this->window_number, HasBit(this->wp->waypoint_flags, WPF_HIDE_LABEL) ? 0 : 1, CMD_SET_WAYPOINT_LABEL_HIDDEN | CMD_MSG(STR_ERROR_CAN_T_CHANGE_WAYPOINT_NAME));
break;
}
}
@@ -122,9 +129,19 @@ public:
if (!gui_scope) return;
/* You can only change your own waypoints */
this->SetWidgetDisabledState(WID_W_RENAME, !this->wp->IsInUse() || (this->wp->owner != _local_company && this->wp->owner != OWNER_NONE));
this->SetWidgetDisabledState(WID_W_TOGGLE_HIDDEN, !this->wp->IsInUse() || this->wp->owner != _local_company);
/* Disable the widget for waypoints with no use */
this->SetWidgetDisabledState(WID_W_SHOW_VEHICLES, !this->wp->IsInUse());
this->SetWidgetLoweredState(WID_W_TOGGLE_HIDDEN, HasBit(this->wp->waypoint_flags, WPF_HIDE_LABEL));
bool show_hide_label = (this->vt == VEH_TRAIN && _settings_client.gui.allow_hiding_waypoint_labels);
if (show_hide_label != this->show_hide_label) {
this->show_hide_label = show_hide_label;
this->GetWidget<NWidgetStacked>(WID_W_TOGGLE_HIDDEN_SEL)->SetDisplayedPlane(this->show_hide_label ? 0 : SZSP_NONE);
this->ReInit();
}
ScrollWindowToTile(this->GetCenterTile(), this, true);
}
@@ -176,6 +193,9 @@ static const NWidgetPart _nested_waypoint_view_widgets[] = {
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_DEPARTURES), SetMinimalSize(100, 12), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_STATION_VIEW_DEPARTURES_BUTTON, STR_STATION_VIEW_DEPARTURES_TOOLTIP),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_W_TOGGLE_HIDDEN_SEL),
NWidget(WWT_IMGBTN, COLOUR_GREY, WID_W_TOGGLE_HIDDEN), SetMinimalSize(15, 12), SetDataTip(SPR_MISC_GUI_BASE, STR_WAYPOINT_VIEW_HIDE_VIEWPORT_LABEL),
EndContainer(),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_W_SHOW_VEHICLES), SetMinimalSize(15, 12), SetDataTip(STR_SHIP, STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),