OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
51 STR_ORDER_FULL_LOAD_ANY,
56 STR_ORDER_UNLOAD_FULL_LOAD,
57 STR_ORDER_UNLOAD_FULL_LOAD_ANY,
58 STR_ORDER_UNLOAD_NO_LOAD,
62 STR_ORDER_TRANSFER_FULL_LOAD,
63 STR_ORDER_TRANSFER_FULL_LOAD_ANY,
64 STR_ORDER_TRANSFER_NO_LOAD,
74 STR_ORDER_NO_UNLOAD_FULL_LOAD,
75 STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
76 STR_ORDER_NO_UNLOAD_NO_LOAD,
83 STR_ORDER_FULL_LOAD_REFIT,
84 STR_ORDER_FULL_LOAD_ANY_REFIT,
87 STR_ORDER_UNLOAD_REFIT,
89 STR_ORDER_UNLOAD_FULL_LOAD_REFIT,
90 STR_ORDER_UNLOAD_FULL_LOAD_ANY_REFIT,
93 STR_ORDER_TRANSFER_REFIT,
95 STR_ORDER_TRANSFER_FULL_LOAD_REFIT,
96 STR_ORDER_TRANSFER_FULL_LOAD_ANY_REFIT,
105 STR_ORDER_NO_UNLOAD_REFIT,
107 STR_ORDER_NO_UNLOAD_FULL_LOAD_REFIT,
108 STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY_REFIT,
114 static const StringID _order_non_stop_drowdown[] = {
116 STR_ORDER_GO_NON_STOP_TO,
118 STR_ORDER_GO_NON_STOP_VIA,
121 static const StringID _order_full_load_drowdown[] = {
122 STR_ORDER_DROP_LOAD_IF_POSSIBLE,
124 STR_ORDER_DROP_FULL_LOAD_ALL,
125 STR_ORDER_DROP_FULL_LOAD_ANY,
126 STR_ORDER_DROP_NO_LOADING,
129 static const StringID _order_unload_drowdown[] = {
130 STR_ORDER_DROP_UNLOAD_IF_ACCEPTED,
131 STR_ORDER_DROP_UNLOAD,
132 STR_ORDER_DROP_TRANSFER,
134 STR_ORDER_DROP_NO_UNLOADING,
137 static const StringID _order_goto_dropdown[] = {
139 STR_ORDER_GO_TO_NEAREST_DEPOT,
140 STR_ORDER_CONDITIONAL,
144 static const StringID _order_goto_dropdown_aircraft[] = {
146 STR_ORDER_GO_TO_NEAREST_HANGAR,
147 STR_ORDER_CONDITIONAL,
163 static const StringID _order_conditional_condition[] = {
164 STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS,
165 STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS,
166 STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN,
167 STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS,
168 STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN,
169 STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS,
170 STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE,
171 STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE,
177 static const StringID _order_depot_action_dropdown[] = {
178 STR_ORDER_DROP_GO_ALWAYS_DEPOT,
179 STR_ORDER_DROP_SERVICE_DEPOT,
180 STR_ORDER_DROP_HALT_DEPOT,
181 STR_ORDER_DROP_UNBUNCH,
184 static int DepotActionStringIndex(
const Order *order)
197 static const StringID _order_refit_action_dropdown[] = {
198 STR_ORDER_DROP_REFIT_AUTO,
199 STR_ORDER_DROP_REFIT_AUTO_ANY,
214 void DrawOrderString(
const Vehicle *v,
const Order *order,
int order_index,
int y,
bool selected,
bool timetable,
int left,
int middle,
int right)
218 SpriteID sprite = rtl ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT;
230 if (order->
IsType(OT_IMPLICIT)) {
231 colour = (selected ? TC_SILVER : TC_GREY) |
TC_NO_SHADE;
232 }
else if (selected) {
259 SetDParam(3, timetable ? STR_EMPTY : STR_ORDER_IMPLICIT);
262 case OT_GOTO_STATION: {
267 SetDParam(0, valid_station ? STR_ORDER_GO_TO_STATION : STR_ORDER_GO_TO_STATION_CAN_T_USE_STATION);
300 SetDParam(0, STR_ORDER_GO_TO_NEAREST_DEPOT_FORMAT);
310 SetDParam(0, STR_ORDER_GO_TO_DEPOT_FORMAT);
327 if (!timetable && order->
IsRefit()) {
339 case OT_GOTO_WAYPOINT:
347 SetDParam(0, STR_ORDER_CONDITIONAL_UNCONDITIONAL);
352 SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
367 default: NOT_REACHED();
370 DrawString(rtl ? left : middle, rtl ? middle : right, y, STR_ORDER_TEXT, colour);
462 default: NOT_REACHED();
588 int num = this->selected_order;
614 assert(type > OPOS_NONE && type < OPOS_END);
622 this->goto_type = type;
636 if (order ==
nullptr)
return;
655 if (order ==
nullptr)
return;
667 order.
next =
nullptr;
686 if (order ==
nullptr)
return;
713 if (order ==
nullptr || order->
GetNonStopType() == non_stop)
return;
735 this->vehicle->
tile, this->vehicle->index,
_ctrl_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()));
744 int selected = this->selected_order + (int)
_networking;
747 this->selected_order = selected >= this->vehicle->
GetNumOrders() ? -1 : selected;
748 this->UpdateButtonState();
761 if (!this->vehicle->
IsOrderListShared() || this->selected_order != this->vehicle->GetNumOrders())
return;
772 this->UpdateButtonState();
799 this->can_do_refit =
false;
800 this->can_do_autorefit =
false;
815 nwid->tool_tip = STR_ORDER_TRAIN_DEPOT_ACTION_TOOLTIP + v->
type;
819 this->selected_order = -1;
821 this->goto_type = OPOS_NONE;
828 int station_orders = 0;
830 if (order->
IsType(OT_GOTO_STATION)) station_orders++;
843 size.height = 6 *
resize.height + padding.height;
851 d.width += padding.width;
852 d.height += padding.height;
859 d.width += padding.width;
860 d.height += padding.height;
872 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
890 if (this->selected_order == -1)
break;
893 this->selected_order = -1;
903 if (gui_scope)
break;
904 from =
GB(data, 0, 8);
908 if (this->selected_order == -1)
break;
910 if (from == to)
break;
912 if (from != this->selected_order) {
914 this->selected_order -= (int)(from <= this->selected_order);
916 this->selected_order += (int)(to <= this->selected_order);
924 this->selected_order = -1;
929 this->selected_order = to;
934 if (gui_scope) this->UpdateButtonState();
942 void UpdateButtonState()
956 if (shared_orders && this->selected_order == this->vehicle->
GetNumOrders()) {
963 (uint)this->vehicle->
GetNumOrders() + ((shared_orders || this->vehicle->GetNumOrders() != 0) ? 1 : 0) <= (uint)this->selected_order);
968 if (this->selected_order == this->vehicle->
GetNumOrders()) {
969 nwi->
SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_ALL_TOOLTIP);
971 nwi->
SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP);
987 assert(row_sel !=
nullptr || (train_row_sel !=
nullptr && left_sel !=
nullptr && middle_sel !=
nullptr && right_sel !=
nullptr));
990 if (order ==
nullptr) {
991 if (row_sel !=
nullptr) {
1009 case OT_GOTO_STATION:
1010 if (row_sel !=
nullptr) {
1027 ((!this->can_do_refit || !this->can_do_autorefit) && !order->
IsRefit()));
1031 case OT_GOTO_WAYPOINT:
1032 if (row_sel !=
nullptr) {
1048 if (row_sel !=
nullptr) {
1062 (!this->can_do_refit && !order->
IsRefit()));
1065 case OT_CONDITIONAL: {
1066 if (row_sel !=
nullptr) {
1073 this->GetWidget<NWidgetCore>(
WID_O_COND_VARIABLE)->widget_data = STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + ocv;
1081 if (row_sel !=
nullptr) {
1106 this->selected_order = -1;
1113 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1121 int middle = rtl ? ir.right - index_column_width : ir.left + index_column_width;
1124 int line_height = this->GetWidget<NWidgetBase>(
WID_O_ORDER_LIST)->resize_y;
1130 while (order !=
nullptr) {
1132 if (!this->vscroll->
IsVisible(i))
break;
1134 if (i != this->selected_order && i == this->order_over) {
1137 int bottom = std::min(
top + 2, ir.bottom);
1138 top = std::max(
top - 3, ir.top);
1145 order = order->
next;
1151 order = this->vehicle->
GetOrder(i);
1155 while (order !=
nullptr) {
1157 if (!this->vscroll->
IsVisible(i))
break;
1159 DrawOrderString(this->vehicle, order, i, y, i == this->selected_order,
false, ir.left, middle, ir.right);
1163 order = order->
next;
1168 DrawString(rtl ? ir.left : middle, rtl ? middle : ir.right, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
1172 void SetStringParameters(
WidgetID widget)
const override
1179 if (order !=
nullptr && order->
IsType(OT_CONDITIONAL)) {
1194 if (order ==
nullptr || !order->
IsType(OT_GOTO_DEPOT)) {
1202 SetDParam(0, STR_ORDER_DROP_SERVICE_DEPOT);
1204 SetDParam(0, STR_ORDER_DROP_HALT_DEPOT);
1208 SetDParam(0, STR_ORDER_DROP_GO_ALWAYS_DEPOT);
1215 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1219 if (this->goto_type == OPOS_CONDITIONAL) {
1223 order.
next =
nullptr;
1246 this->selected_order = -1;
1247 }
else if (sel == this->selected_order) {
1250 this->vehicle->
tile, this->vehicle->index, sel,
1251 MOF_STOP_LOCATION, (this->vehicle->GetOrder(sel)->GetStopLocation() + 1) % OSL_END);
1255 this->selected_order = sel;
1263 this->UpdateButtonState();
1280 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1284 assert(o !=
nullptr);
1286 o->
IsType(OT_GOTO_STATION) ? 0 : (o->
IsType(OT_GOTO_WAYPOINT) ? 3 : 12));
1291 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1292 if (this->goto_type != OPOS_NONE) {
1299 switch (this->goto_type) {
1300 case OPOS_NONE: sel = -1;
break;
1301 case OPOS_GOTO: sel = 0;
break;
1302 case OPOS_CONDITIONAL: sel = 2;
break;
1303 case OPOS_SHARE: sel = 3;
break;
1304 default: NOT_REACHED();
1311 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1319 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1335 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1349 list.push_back(MakeDropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + ocv, ocv));
1357 assert(o !=
nullptr);
1364 assert(order !=
nullptr);
1373 ShowVehicleListWindow(this->vehicle);
1378 void OnQueryTextFinished(std::optional<std::string> str)
override
1380 if (!str.has_value() || str->empty())
return;
1383 uint value = atoi(str->c_str());
1392 value =
Clamp(value, 0, 100);
1401 void OnDropdownSelect(
WidgetID widget,
int index)
override
1422 default: NOT_REACHED();
1453 this->selected_order = -1;
1454 this->UpdateButtonState();
1498 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
1500 if (this->goto_type == OPOS_GOTO) {
1502 if (cmd.
IsType(OT_NOTHING))
return;
1511 bool OnVehicleSelect(
const Vehicle *v)
override
1518 bool share_order =
_ctrl_pressed || this->goto_type == OPOS_SHARE;
1519 if (this->vehicle->
GetNumOrders() != 0 && !share_order)
return false;
1522 this->vehicle->
tile, share_order ? CO_SHARE : CO_COPY, this->vehicle->index, v->
index)) {
1523 this->selected_order = -1;
1535 bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end)
override
1537 bool share_order =
_ctrl_pressed || this->goto_type == OPOS_SHARE;
1538 if (this->vehicle->
GetNumOrders() != 0 && !share_order)
return false;
1545 OnVehicleSelect(*begin);
1554 OnVehicleSelect(*begin);
1565 this->goto_type = OPOS_NONE;
1585 this->order_over = to_order;
1602 Hotkey(
'D',
"skip", OHK_SKIP),
1603 Hotkey(
'F',
"delete", OHK_DELETE),
1604 Hotkey(
'G',
"goto", OHK_GOTO),
1605 Hotkey(
'H',
"nonstop", OHK_NONSTOP),
1606 Hotkey(
'J',
"fullload", OHK_FULLLOAD),
1607 Hotkey(
'K',
"unload", OHK_UNLOAD),
1608 Hotkey(0,
"nearest_depot", OHK_NEAREST_DEPOT),
1609 Hotkey(0,
"always_service", OHK_ALWAYS_SERVICE),
1610 Hotkey(0,
"transfer", OHK_TRANSFER),
1611 Hotkey(0,
"no_unload", OHK_NO_UNLOAD),
1612 Hotkey(0,
"no_load", OHK_NO_LOAD),
1627 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_O_ORDER_LIST),
SetMinimalSize(372, 62),
SetDataTip(0x0, STR_ORDERS_LIST_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_O_SCROLLBAR),
EndContainer(),
1676 SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP),
SetResize(1, 0),
1686 WDP_AUTO,
"view_vehicle_orders_train", 384, 100,
1690 &OrdersWindow::hotkeys
1704 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_O_ORDER_LIST),
SetMinimalSize(372, 62),
SetDataTip(0x0, STR_ORDERS_LIST_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_O_SCROLLBAR),
EndContainer(),
1750 SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP),
SetResize(1, 0),
1759 WDP_AUTO,
"view_vehicle_orders", 384, 100,
1763 &OrdersWindow::hotkeys
1777 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_O_ORDER_LIST),
SetMinimalSize(372, 72),
SetDataTip(0x0, STR_ORDERS_LIST_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_O_SCROLLBAR),
EndContainer(),
1786 WDP_AUTO,
"view_vehicle_orders_competitor", 384, 86,
1790 &OrdersWindow::hotkeys
1793 void ShowOrdersWindow(
const Vehicle *v)
@ ES_HANDLED
The passed event is handled.
@ DA_STOP
Go to the depot and stop there.
uint8_t GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
StationFacility facilities
The facilities that this station has.
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
bool IsRefit() const
Is this order a refit order.
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
bool IsType(OrderType type) const
Check whether this order is of the given type.
static Titem * Get(size_t index)
Returns Titem with given index.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
void OrderClick_Delete()
Handle the click on the delete button.
Vehicle * PreviousShared() const
Get the previous vehicle of the shared vehicle chain.
@ FACIL_TRAIN
Station with train station.
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
List of hotkeys for a window.
@ MOF_COND_COMPARATOR
A comparator changes.
uint8_t VehicleOrderID
The index of an order within its current vehicle (not pool related)
static const CargoID CARGO_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
Dimensions (a width and height) of a rectangle in 2D.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
@ ODTFB_SERVICE
This depot order is because of the servicing limit.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
OrderLoadFlags
Flags related to the loading order.
void OrderClick_StopSharing()
Handle the click on the 'stop sharing' button.
@ FACIL_DOCK
Station with a dock.
VehicleOrderID order_over
Order over which another order is dragged, INVALID_VEH_ORDER_ID if none.
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
DisplayPane
Displayed planes of the NWID_SELECTION widgets.
DestinationID GetDestination() const
Gets the destination of this order.
void OrderClick_Skip()
Handle the click on the skip button.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
@ DP_ROW_LOAD
Display 'load' / 'unload' / 'refit' buttons in the top row of the ship/airplane order window.
uint16_t GetConditionValue() const
Get the value to base the skip on.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable, int left, int middle, int right)
Draws an order in order or timetable GUI.
@ DP_ROW_CONDITIONAL
Display the conditional order buttons in the top row of the ship/airplane order window.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
bool new_nonstop
ttdpatch compatible nonstop handling
bool VehiclesHaveSameOrderList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicles have the same list of orders.
void OrderClick_NearestDepot()
Handle the click on the service in nearest depot button.
Tindex index
Index of this pool item.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
@ VEH_TRAIN
Train vehicle type.
@ MOF_UNLOAD
Passes an OrderUnloadType.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
void Free()
'Free' the order
void EnableWidget(WidgetID widget_index)
Sets a widget to Enabled.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
static constexpr NWidgetPart _nested_other_orders_widgets[]
Nested widget definition for competitor orders.
bool _ctrl_pressed
Is Ctrl pressed?
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
@ VEH_ROAD
Road vehicle type.
void UpdateAutoRefitState()
Cache auto-refittability of the vehicle chain.
static Station * Get(size_t index)
Gets station with given index.
ClientSettings _settings_client
The current settings for this game.
@ WC_VEHICLE_TIMETABLE
Vehicle timetable; Window numbers:
@ MP_INDUSTRY
Part of an industry.
static constexpr NWidgetPart _nested_orders_widgets[]
Nested widget definition for "your" orders (non-train).
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
@ SA_RIGHT
Right align the text (must be a single bit).
Defines the internal data of a functional industry.
Owner owner
Which company owns the vehicle?
static const StringID _station_load_types[][5][5]
Order load types that could be given to station orders.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Owner owner
The owner of this station.
debug_inline bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
OrderStopLocation
Where to stop the trains.
bool IsRailWaypointTile(Tile t)
Is this tile a station tile and a rail waypoint?
void OrderClick_Goto(OrderPlaceObjectState type)
Handle the click on the goto button.
@ ODATFB_UNBUNCH
Service the vehicle and then unbunch it.
void OnResize() override
Called after the window got resized.
Station * neutral_station
Associated neutral station.
void OrderClick_Nonstop(int non_stop)
Handle the click on the nonstop button.
@ MOF_STOP_LOCATION
Passes an OrderStopLocation.
OrderType GetType() const
Get the type of order of this order.
OrderStopLocation GetStopLocation() const
Where must we stop at the platform?
@ ONSF_NO_STOP_AT_ANY_STATION
The vehicle will not stop at any stations it passes including the destination.
High level window description.
uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle *v, int conditional_depth)
Get the distance between two orders of a vehicle.
static const CursorID ANIMCURSOR_PICKSTATION
716 - 718 - goto-order icon
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
TransportType
Available types of transport.
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
IterateWrapper Orders() const
Returns an iterable ensemble of orders of a vehicle.
constexpr bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
@ OLF_FULL_LOAD_ANY
Full load a single cargo of the consist.
@ EF_AUTO_REFIT
Automatic refitting is allowed.
@ WDP_AUTO
Find a place automatically.
CargoID GetRefitCargo() const
Get the cargo to to refit to.
bool can_do_autorefit
Vehicle chain can be auto-refitted.
ResizeInfo resize
Resize information.
@ ONSF_STOP_EVERYWHERE
The vehicle will stop at any station it passes and the destination.
@ WC_VEHICLE_VIEW
Vehicle view; Window numbers:
@ FS_NORMAL
Index of the normal font in the font tables.
@ OWNER_NONE
The tile has no ownership.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
static const OrderConditionVariable _order_conditional_variable[]
Variables for conditional orders; this defines the order of appearance in the dropdown box.
TileIndex tile
Current tile index.
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
uint ConvertDisplaySpeedToSpeed(uint speed, VehicleType type)
Convert the given display speed to the (internal) speed.
void OrderClick_Service(int i)
Handle the click on the service.
@ OUF_UNLOAD_IF_POSSIBLE
Unload all cargo that the station accepts.
@ ES_NOT_HANDLED
The passed event is not handled.
@ DP_MIDDLE_SERVICE
Display 'service' in the middle button of the top row of the train/rv order window.
@ MOF_COND_VALUE
The value to set the condition to.
@ VEH_SHIP
Ship vehicle type.
@ ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
void OrderClick_FullLoad(OrderLoadFlags load_type, bool toggle=false)
Handle the click on the full load button.
@ DP_GROUNDVEHICLE_ROW_NORMAL
Display the row for normal/depot orders in the top row of the train/rv order window.
VehicleOrderID OrderGetSel() const
Return the memorised selected order.
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
bool IsBuoyTile(Tile t)
Is tile t a buoy tile?
@ WC_VEHICLE_DETAILS
Vehicle details; Window numbers:
@ OCC_IS_TRUE
Skip if the variable is true.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
@ DA_ALWAYS_GO
Always go to the depot.
VehicleOrderID GetOrderFromPt(int y)
Calculate the selected order.
@ ODTFB_PART_OF_ORDERS
This depot order is because of a regular order.
bool IsGotoOrder() const
Is this a 'goto' order with a real destination?
OrderConditionComparator GetConditionComparator() const
What is the comparator to use?
@ TC_NO_SHADE
Do not add shading to this text colour.
bool _networking
are we in networking mode?
@ DP_MIDDLE_UNLOAD
Display 'unload' in the middle button of the top row of the train/rv order window.
bool IsDepotTypeTile(Tile tile, TransportType type)
Check if a tile is a depot and it is a depot of the given type.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
@ MOF_LOAD
Passes an OrderLoadType.
@ FACIL_TRUCK_STOP
Station with truck stops.
OrderPlaceObjectState
Under what reason are we using the PlaceObject functionality?
Coordinates of a point in 2D.
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
WindowNumber window_number
Window number within the window class.
@ DP_RIGHT_EMPTY
Display an empty panel in the right button of the top row of the train/rv order window.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
DepotID GetDepotIndex(Tile t)
Get the index of which depot is attached to the tile.
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
@ OLF_LOAD_IF_POSSIBLE
Load as long as there is cargo that fits in the train.
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
@ ODATFB_HALT
Service the vehicle and then halt it.
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
@ DP_RIGHT_REFIT
Display 'refit' in the right button of the top row of the train/rv order window.
@ HT_DRAG
dragging items in the depot windows
@ VIWD_CONSIST_CHANGED
Vehicle composition was changed.
static constexpr NWidgetPart _nested_orders_train_widgets[]
Nested widget definition for "your" train orders.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
@ ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
static const CargoID CARGO_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
@ MOF_NON_STOP
Passes an OrderNonStopFlags.
uint16_t GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not).
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
OrderUnloadFlags
Flags related to the unloading order.
bool quick_goto
Allow quick access to 'goto button' in vehicle orders window.
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
@ OCV_MAX_SPEED
Skip based on the maximum speed.
@ OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
@ OCV_RELIABILITY
Skip based on the reliability.
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
Order * GetFirstOrder() const
Get the first order of the vehicles order list.
uint ConvertSpeedToDisplaySpeed(uint speed, VehicleType type)
Convert the given (internal) speed to the display speed.
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
static Aircraft * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
bool IsRoadWaypointTile(Tile t)
Is this tile a station tile and a road waypoint?
@ VIWD_AUTOREPLACE
Autoreplace replaced the vehicle.
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
Get the order command a vehicle can do in a given tile.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
StationID GetStationIndex(Tile t)
Get StationID from a tile.
@ OCV_REMAINING_LIFETIME
Skip based on the remaining lifetime.
uint16_t GetRange() const
Get the range of this aircraft.
@ OUFB_NO_UNLOAD
Totally no unloading will be done.
bool HasFullLoadOrder() const
Check if the current vehicle has a full load order.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
@ DP_ROW_DEPOT
Display 'refit' / 'service' buttons in the top row of the ship/airplane order window.
@ MP_STATION
A tile of a station.
void ShowDropDownMenu(Window *w, std::span< const StringID > strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
EventState
State of handling an event.
@ HT_RECT
rectangle (stations, depots, ...)
uint8_t stop_location
what is the default stop location of trains?
Order window code for all vehicles.
StringID name
Name of this type of cargo.
bool IsAutoRefit() const
Is this order a auto-refit order.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
void OnPaint() override
The window must be repainted.
bool HasUnbunchingOrder() const
Check if the current vehicle has an unbunching order.
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
@ OCV_LOAD_PERCENTAGE
Skip based on the amount of load.
int top
y position of top edge of the window
void MakeConditional(VehicleOrderID order)
Makes this order an conditional order.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
HighLightStyle
Highlighting draw styles.
OrderDepotTypeFlags GetDepotOrderType() const
What caused us going to the depot?
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
@ FACIL_BUS_STOP
Station with bus stops.
bool HasConditionalOrder() const
Check if the current vehicle has a conditional order.
bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end) override
Clones an order list from a vehicle list.
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
VehicleType
Available vehicle types.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
void SetObjectToPlaceWnd(CursorID icon, PaletteID pal, HighLightStyle mode, Window *w)
Change the cursor and mouse click/drag handling to a mode for performing special operations like tile...
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
@ VEH_AIRCRAFT
Aircraft vehicle type.
Dimension GetStringListBoundingBox(std::span< const StringID > list, FontSize fontsize)
Get maximum dimension of a list of strings.
bool can_do_refit
Vehicle chain can be refitted in depot.
@ DA_UNBUNCH
Go to the depot and unbunch.
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
bool IsEngineRefittable(EngineID engine)
Check if an engine is refittable.
@ OCV_REQUIRES_SERVICE
Skip when the vehicle requires service.
Data structure for an opened window.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or nullptr when it doesn't exists.
@ DP_LEFT_REFIT
Display 'refit' in the left button of the top row of the train/rv order window.
VehicleType type
Type of vehicle.
void OrderClick_Refit(int i, bool auto_refit)
Handle the click on the refit button.
void DrawWidgets() const
Paint all widgets of a window.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
bool AllEqual(It begin, It end, Pred pred)
Generic helper function that checks if all elements of the range are equal with respect to the given ...
@ MOF_COND_VARIABLE
A conditional variable changes.
@ DP_LEFT_LOAD
Display 'load' in the left button of the top row of the train/rv order window.
@ VIWD_MODIFY_ORDERS
Other order modifications.
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
Can this station be used by the given engine type?
@ OCV_MAX_RELIABILITY
Skip based on the maximum reliability.
Specification of a rectangle with absolute coordinates of all edges.
@ DP_GROUNDVEHICLE_ROW_CONDITIONAL
Display the row for conditional orders in the top row of the train/rv order window.
Point pos
logical mouse position
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
@ OCC_IS_FALSE
Skip if the variable is false.
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
@ VIWD_REMOVE_ALL_ORDERS
Removed / replaced all orders (after deleting / sharing).
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action=ODATF_SERVICE_ONLY, CargoID cargo=CARGO_NO_REFIT)
Makes this order a Go To Depot order.
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
Show the refit window for a vehicle.
void OrderClick_Unload(OrderUnloadFlags unload_type, bool toggle=false)
Handle the click on the unload button.
Order * next
Pointer to next order. If nullptr, end of list.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
@ DA_SERVICE
Service only if needed.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
@ CS_NUMERAL
Only numeric ones.
@ OCV_AGE
Skip based on the age.
@ MOF_DEPOT_ACTION
Selects the OrderDepotAction.
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
OrderConditionComparator
Comparator for the skip reasoning.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
@ WC_VEHICLE_ORDERS
Vehicle orders; Window numbers:
GUISettings gui
settings related to the GUI
@ OCV_UNCONDITIONALLY
Always skip.
@ OLFB_NO_LOAD
Do not load anything.
OrderLoadFlags GetLoadType() const
How must the consist be loaded?
All data for a single hotkey.
@ DP_BOTTOM_MIDDLE_STOP_SHARING
Display 'stop sharing' in the middle button of the bottom row of the vehicle order window.
@ FACIL_AIRPORT
Station with an airport.
const Vehicle * vehicle
Vehicle owning the orders being displayed and manipulated.
@ DP_BOTTOM_MIDDLE_DELETE
Display 'delete' in the middle button of the bottom row of the vehicle order window.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.