(svn r16900) -Codechange: prepare the waypoint window for buoys

This commit is contained in:
rubidium
2009-07-21 16:30:01 +00:00
parent a8a3017921
commit 1dda60343f
5 changed files with 21 additions and 11 deletions

View File

@@ -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(),
};