Initial implementation of road waypoints

This commit is contained in:
Jonathan G Rennison
2022-01-25 22:02:32 +00:00
parent ace75f6864
commit b4fc0b4dc5
37 changed files with 546 additions and 87 deletions

View File

@@ -45,7 +45,24 @@ private:
if (!this->wp->IsInUse()) return this->wp->xy;
TileArea ta;
this->wp->GetTileArea(&ta, this->vt == VEH_TRAIN ? STATION_WAYPOINT : STATION_BUOY);
StationType type;
switch (this->vt) {
case VEH_TRAIN:
type = STATION_WAYPOINT;
break;
case VEH_ROAD:
type = STATION_ROADWAYPOINT;
break;
case VEH_SHIP:
type = STATION_BUOY;
break;
default:
NOT_REACHED();
}
this->wp->GetTileArea(&ta, type);
return ta.GetCenterTile();
}
@@ -58,15 +75,24 @@ public:
WaypointWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
{
this->wp = Waypoint::Get(window_number);
this->vt = (wp->string_id == STR_SV_STNAME_WAYPOINT) ? VEH_TRAIN : VEH_SHIP;
if (wp->string_id == STR_SV_STNAME_WAYPOINT) {
this->vt = HasBit(this->wp->waypoint_flags, WPF_ROAD) ? VEH_ROAD : VEH_TRAIN;
} else {
this->vt = VEH_SHIP;
}
this->CreateNestedTree();
if (this->vt == VEH_TRAIN) {
this->GetWidget<NWidgetCore>(WID_W_SHOW_VEHICLES)->SetDataTip(STR_TRAIN, STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP);
}
if (this->vt == VEH_ROAD) {
this->GetWidget<NWidgetCore>(WID_W_SHOW_VEHICLES)->SetDataTip(STR_LORRY, STR_STATION_VIEW_SCHEDULED_ROAD_VEHICLES_TOOLTIP);
}
if (this->vt != VEH_SHIP) {
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->show_hide_label = (this->vt != VEH_SHIP && _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);
@@ -135,7 +161,7 @@ public:
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);
bool show_hide_label = (this->vt != VEH_SHIP && _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);