summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/saveload/waypoint_sl.cpp2
-rw-r--r--src/vehicle_gui.cpp4
-rw-r--r--src/vehicle_gui.h2
-rw-r--r--src/waypoint_cmd.cpp2
-rw-r--r--src/waypoint_gui.cpp22
5 files changed, 21 insertions, 11 deletions
diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp
index e759dc7f8..780271068 100644
--- a/src/saveload/waypoint_sl.cpp
+++ b/src/saveload/waypoint_sl.cpp
@@ -85,6 +85,8 @@ static void Load_WAYP()
Waypoint *wp = new (index) Waypoint();
SlObject(wp, _waypoint_desc);
+ wp->facilities |= FACIL_TRAIN;
+
if (_waypoint_spec.grfid != 0) {
wp->num_specs = 2;
wp->speclist = CallocT<StationSpecList>(2);
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index e6f26237f..0f0c353f1 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1181,10 +1181,10 @@ void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type)
}
}
-void ShowVehicleListWindow(const Waypoint *wp)
+void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, const Waypoint *wp)
{
if (wp == NULL) return;
- ShowVehicleListWindowLocal(wp->owner, VLW_WAYPOINT_LIST, VEH_TRAIN, wp->index);
+ ShowVehicleListWindowLocal(company, VLW_WAYPOINT_LIST, vehicle_type, wp->index);
}
void ShowVehicleListWindow(const Vehicle *v)
diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h
index 45383341a..9ac62d506 100644
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -72,7 +72,7 @@ uint ShowRefitOptionsList(int left, int right, int y, EngineID engine);
StringID GetCargoSubtypeText(const Vehicle *v);
void ShowVehicleListWindow(const Vehicle *v);
-void ShowVehicleListWindow(const Waypoint *wp);
+void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, const Waypoint *wp);
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type);
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationID station);
void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile);
diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp
index 882ba6097..cb6f3b767 100644
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -193,6 +193,7 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1
AllocateSpecToStation(GetCustomStationSpec(STAT_CLASS_WAYP, p1), wp, true);
wp->delete_ctr = 0;
+ wp->facilities |= FACIL_TRAIN;
wp->build_date = _date;
if (wp->town == NULL) MakeDefaultWaypointName(wp);
@@ -228,6 +229,7 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justre
wp->delete_ctr = 30; // let it live for this many days before we do the actual deletion.
wp->sign.MarkDirty();
+ wp->facilities &= ~FACIL_TRAIN;
Train *v = NULL;
if (justremove) {
diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp
index 02d2e8fa0..cdf0ad6f0 100644
--- a/src/waypoint_gui.cpp
+++ b/src/waypoint_gui.cpp
@@ -25,36 +25,42 @@ enum WaypointWindowWidgets {
WAYPVW_SPACER,
WAYPVW_CENTERVIEW,
WAYPVW_RENAME,
- WAYPVW_SHOW_TRAINS,
+ WAYPVW_SHOW_VEHICLES,
};
struct WaypointWindow : Window {
private:
+ VehicleType vt;
Waypoint *wp;
public:
WaypointWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
this->wp = Waypoint::Get(this->window_number);
+ this->vt = (wp->facilities & FACIL_TRAIN) ? VEH_TRAIN : VEH_SHIP;
+
if (this->wp->owner != OWNER_NONE) this->owner = this->wp->owner;
this->flags4 |= WF_DISABLE_VP_SCROLL;
InitializeWindowViewport(this, 3, 17, 254, 86, this->wp->xy, ZOOM_LVL_MIN);
+ this->widget[WAYPVW_SHOW_VEHICLES].data = this->vt == VEH_TRAIN ? STR_TRAIN : STR_SHIP;
+ this->widget[WAYPVW_SHOW_VEHICLES].tooltips = this->vt == VEH_TRAIN ? STR_SCHEDULED_TRAINS_TIP : STR_SCHEDULED_SHIPS_TIP;
+
this->FindWindowPlacementAndResize(desc);
}
~WaypointWindow()
{
- DeleteWindowById(WC_TRAINS_LIST, (this->window_number << 16) | (VEH_TRAIN << 11) | VLW_WAYPOINT_LIST | this->wp->owner);
+ DeleteWindowById(WC_TRAINS_LIST, (this->window_number << 16) | (this->vt << 11) | VLW_WAYPOINT_LIST | this->wp->owner);
}
virtual void OnPaint()
{
/* You can only change your own waypoints */
- this->SetWidgetDisabledState(WAYPVW_RENAME, this->wp->owner != _local_company);
+ this->SetWidgetDisabledState(WAYPVW_RENAME, (this->wp->facilities & ~FACIL_WAYPOINT) == 0 || (this->wp->owner != _local_company && this->wp->owner != OWNER_NONE));
/* Disable the widget for waypoints with no owner (after company bankrupt) */
- this->SetWidgetDisabledState(WAYPVW_SHOW_TRAINS, this->wp->owner == OWNER_NONE);
+ this->SetWidgetDisabledState(WAYPVW_SHOW_VEHICLES, (this->wp->facilities & ~FACIL_WAYPOINT) == 0);
SetDParam(0, this->wp->index);
this->DrawWidgets();
@@ -78,8 +84,8 @@ public:
ShowQueryString(STR_WAYPOINT_NAME, STR_EDIT_WAYPOINT_NAME, MAX_LENGTH_WAYPOINT_NAME_BYTES, MAX_LENGTH_WAYPOINT_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
break;
- case WAYPVW_SHOW_TRAINS: // show list of trains having this waypoint in their orders
- ShowVehicleListWindow(this->wp);
+ case WAYPVW_SHOW_VEHICLES: // show list of vehicles having this waypoint in their orders
+ ShowVehicleListWindow((this->wp->owner == OWNER_NONE) ? _local_company : this->wp->owner, this->vt, this->wp);
break;
}
}
@@ -108,7 +114,7 @@ static const Widget _waypoint_view_widgets[] = {
{ WWT_INSET, RESIZE_NONE, COLOUR_GREY, 2, 257, 16, 103, 0x0, STR_NULL}, // WAYPVW_SPACER
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 121, 106, 117, STR_BUTTON_LOCATION, STR_STATION_VIEW_CENTER_TOOLTIP}, // WAYPVW_CENTERVIEW
{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 122, 244, 106, 117, STR_QUERY_RENAME, STR_CHANGE_WAYPOINT_NAME}, // WAYPVW_RENAME
-{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 245, 259, 106, 117, STR_TRAIN, STR_SCHEDULED_TRAINS_TIP }, // WAYPVW_SHOW_TRAINS
+{ WWT_PUSHTXTBTN, RESIZE_NONE, COLOUR_GREY, 245, 259, 106, 117, STR_NULL, STR_NULL }, // WAYPVW_SHOW_TRAINS
{ WIDGETS_END},
};
@@ -131,7 +137,7 @@ static const NWidgetPart _nested_waypoint_view_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WAYPVW_CENTERVIEW), SetMinimalSize(122, 12), SetDataTip(STR_BUTTON_LOCATION, STR_STATION_VIEW_CENTER_TOOLTIP),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WAYPVW_RENAME), SetMinimalSize(123, 12), SetDataTip(STR_QUERY_RENAME, STR_CHANGE_WAYPOINT_NAME),
- NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WAYPVW_SHOW_TRAINS), SetMinimalSize(15, 12), SetDataTip(STR_TRAIN, STR_SCHEDULED_TRAINS_TIP),
+ NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WAYPVW_SHOW_VEHICLES), SetMinimalSize(15, 12),
EndContainer(),
};