OpenTTD Source: src/order_gui.cpp Source File

OpenTTD Source 13.1

order_gui.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #include "stdafx.h"
11 #include "command_func.h"
12 #include "viewport_func.h"
13 #include "depot_map.h"
14 #include "roadveh.h"
15 #include "timetable.h"
16 #include "strings_func.h"
17 #include "company_func.h"
18 #include "widgets/dropdown_type.h"
19 #include "widgets/dropdown_func.h"
20 #include "textbuf_gui.h"
21 #include "string_func.h"
22 #include "tilehighlight_func.h"
23 #include "network/network.h"
24 #include "station_base.h"
25 #include "industry.h"
26 #include "waypoint_base.h"
27 #include "core/geometry_func.hpp"
28 #include "hotkeys.h"
29 #include "aircraft.h"
30 #include "engine_func.h"
31 #include "vehicle_func.h"
32 #include "vehiclelist.h"
33 #include "vehicle_func.h"
34 #include "error.h"
35 #include "order_cmd.h"
36 #include "company_cmd.h"
37
38 #include "widgets/order_widget.h"
39
40 #include "safeguards.h"
41
42
44 static const StringID _station_load_types[][5][5] = {
45 {
46 /* No refitting. */
47 {
48 STR_EMPTY,
49 INVALID_STRING_ID,
50 STR_ORDER_FULL_LOAD,
51 STR_ORDER_FULL_LOAD_ANY,
52 STR_ORDER_NO_LOAD,
53 }, {
54 STR_ORDER_UNLOAD,
55 INVALID_STRING_ID,
56 STR_ORDER_UNLOAD_FULL_LOAD,
57 STR_ORDER_UNLOAD_FULL_LOAD_ANY,
58 STR_ORDER_UNLOAD_NO_LOAD,
59 }, {
60 STR_ORDER_TRANSFER,
61 INVALID_STRING_ID,
62 STR_ORDER_TRANSFER_FULL_LOAD,
63 STR_ORDER_TRANSFER_FULL_LOAD_ANY,
64 STR_ORDER_TRANSFER_NO_LOAD,
65 }, {
66 /* Unload and transfer do not work together. */
67 INVALID_STRING_ID,
68 INVALID_STRING_ID,
69 INVALID_STRING_ID,
70 INVALID_STRING_ID,
71 }, {
72 STR_ORDER_NO_UNLOAD,
73 INVALID_STRING_ID,
74 STR_ORDER_NO_UNLOAD_FULL_LOAD,
75 STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
76 STR_ORDER_NO_UNLOAD_NO_LOAD,
77 }
78 }, {
79 /* With auto-refitting. No loading and auto-refitting do not work together. */
80 {
81 STR_ORDER_AUTO_REFIT,
82 INVALID_STRING_ID,
83 STR_ORDER_FULL_LOAD_REFIT,
84 STR_ORDER_FULL_LOAD_ANY_REFIT,
85 INVALID_STRING_ID,
86 }, {
87 STR_ORDER_UNLOAD_REFIT,
88 INVALID_STRING_ID,
89 STR_ORDER_UNLOAD_FULL_LOAD_REFIT,
90 STR_ORDER_UNLOAD_FULL_LOAD_ANY_REFIT,
91 INVALID_STRING_ID,
92 }, {
93 STR_ORDER_TRANSFER_REFIT,
94 INVALID_STRING_ID,
95 STR_ORDER_TRANSFER_FULL_LOAD_REFIT,
96 STR_ORDER_TRANSFER_FULL_LOAD_ANY_REFIT,
97 INVALID_STRING_ID,
98 }, {
99 /* Unload and transfer do not work together. */
100 INVALID_STRING_ID,
101 INVALID_STRING_ID,
102 INVALID_STRING_ID,
103 INVALID_STRING_ID,
104 }, {
105 STR_ORDER_NO_UNLOAD_REFIT,
106 INVALID_STRING_ID,
107 STR_ORDER_NO_UNLOAD_FULL_LOAD_REFIT,
108 STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY_REFIT,
109 INVALID_STRING_ID,
110 }
111 }
112 };
113
114 static const StringID _order_non_stop_drowdown[] = {
115 STR_ORDER_GO_TO,
116 STR_ORDER_GO_NON_STOP_TO,
117 STR_ORDER_GO_VIA,
118 STR_ORDER_GO_NON_STOP_VIA,
119 INVALID_STRING_ID
120 };
121
122 static const StringID _order_full_load_drowdown[] = {
123 STR_ORDER_DROP_LOAD_IF_POSSIBLE,
124 STR_EMPTY,
125 STR_ORDER_DROP_FULL_LOAD_ALL,
126 STR_ORDER_DROP_FULL_LOAD_ANY,
127 STR_ORDER_DROP_NO_LOADING,
128 INVALID_STRING_ID
129 };
130
131 static const StringID _order_unload_drowdown[] = {
132 STR_ORDER_DROP_UNLOAD_IF_ACCEPTED,
133 STR_ORDER_DROP_UNLOAD,
134 STR_ORDER_DROP_TRANSFER,
135 STR_EMPTY,
136 STR_ORDER_DROP_NO_UNLOADING,
137 INVALID_STRING_ID
138 };
139
140 static const StringID _order_goto_dropdown[] = {
141 STR_ORDER_GO_TO,
142 STR_ORDER_GO_TO_NEAREST_DEPOT,
143 STR_ORDER_CONDITIONAL,
144 STR_ORDER_SHARE,
145 INVALID_STRING_ID
146 };
147
148 static const StringID _order_goto_dropdown_aircraft[] = {
149 STR_ORDER_GO_TO,
150 STR_ORDER_GO_TO_NEAREST_HANGAR,
151 STR_ORDER_CONDITIONAL,
152 STR_ORDER_SHARE,
153 INVALID_STRING_ID
154 };
155
157 static const OrderConditionVariable _order_conditional_variable[] = {
158 OCV_LOAD_PERCENTAGE,
159 OCV_RELIABILITY,
160 OCV_MAX_RELIABILITY,
161 OCV_MAX_SPEED,
162 OCV_AGE,
163 OCV_REMAINING_LIFETIME,
164 OCV_REQUIRES_SERVICE,
165 OCV_UNCONDITIONALLY,
166 };
167
168 static const StringID _order_conditional_condition[] = {
169 STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS,
170 STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS,
171 STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN,
172 STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS,
173 STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN,
174 STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS,
175 STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE,
176 STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE,
177 INVALID_STRING_ID,
178 };
179
180 extern uint ConvertSpeedToDisplaySpeed(uint speed);
181 extern uint ConvertDisplaySpeedToSpeed(uint speed);
182
183 static const StringID _order_depot_action_dropdown[] = {
184 STR_ORDER_DROP_GO_ALWAYS_DEPOT,
185 STR_ORDER_DROP_SERVICE_DEPOT,
186 STR_ORDER_DROP_HALT_DEPOT,
187 INVALID_STRING_ID
188 };
189
190 static int DepotActionStringIndex(const Order *order)
191 {
192 if (order->GetDepotActionType() & ODATFB_HALT) {
193 return DA_STOP;
194 } else if (order->GetDepotOrderType() & ODTFB_SERVICE) {
195 return DA_SERVICE;
196 } else {
197 return DA_ALWAYS_GO;
198 }
199 }
200
201 static const StringID _order_refit_action_dropdown[] = {
202 STR_ORDER_DROP_REFIT_AUTO,
203 STR_ORDER_DROP_REFIT_AUTO_ANY,
204 INVALID_STRING_ID
205 };
206
219 void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable, int left, int middle, int right)
220 {
221 bool rtl = _current_text_dir == TD_RTL;
222
223 SpriteID sprite = rtl ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT;
224 Dimension sprite_size = GetSpriteSize(sprite);
225 if (v->cur_real_order_index == order_index) {
226 DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
227 DrawSprite(sprite, PAL_NONE, rtl ? right - 2 * sprite_size.width : left + sprite_size.width, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
228 } else if (v->cur_implicit_order_index == order_index) {
229 DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
230 }
231
232 TextColour colour = TC_BLACK;
233 if (order->IsType(OT_IMPLICIT)) {
234 colour = (selected ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
235 } else if (selected) {
236 colour = TC_WHITE;
237 }
238
239 SetDParam(0, order_index + 1);
240 DrawString(left, rtl ? right - 2 * sprite_size.width - 3 : middle, y, STR_ORDER_INDEX, colour, SA_RIGHT | SA_FORCE);
241
242 SetDParam(5, STR_EMPTY);
243 SetDParam(8, STR_EMPTY);
244
245 /* Check range for aircraft. */
246 if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->GetRange() > 0 && order->IsGotoOrder()) {
247 const Order *next = order->next != nullptr ? order->next : v->GetFirstOrder();
248 if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(8, STR_ORDER_OUT_OF_RANGE);
249 }
250
251 switch (order->GetType()) {
252 case OT_DUMMY:
253 SetDParam(0, STR_INVALID_ORDER);
254 SetDParam(1, order->GetDestination());
255 break;
256
257 case OT_IMPLICIT:
258 SetDParam(0, STR_ORDER_GO_TO_STATION);
259 SetDParam(1, STR_ORDER_GO_TO);
260 SetDParam(2, order->GetDestination());
261 SetDParam(3, timetable ? STR_EMPTY : STR_ORDER_IMPLICIT);
262 break;
263
264 case OT_GOTO_STATION: {
265 OrderLoadFlags load = order->GetLoadType();
266 OrderUnloadFlags unload = order->GetUnloadType();
267 bool valid_station = CanVehicleUseStation(v, Station::Get(order->GetDestination()));
268
269 SetDParam(0, valid_station ? STR_ORDER_GO_TO_STATION : STR_ORDER_GO_TO_STATION_CAN_T_USE_STATION);
270 SetDParam(1, STR_ORDER_GO_TO + (v->IsGroundVehicle() ? order->GetNonStopType() : 0));
271 SetDParam(2, order->GetDestination());
272
273 if (timetable) {
274 SetDParam(3, STR_EMPTY);
275
276 if (order->GetWaitTime() > 0) {
277 SetDParam(5, order->IsWaitTimetabled() ? STR_TIMETABLE_STAY_FOR : STR_TIMETABLE_STAY_FOR_ESTIMATED);
278 SetTimetableParams(6, 7, order->GetWaitTime());
279 }
280 } else {
281 SetDParam(3, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[order->IsRefit()][unload][load]);
282 if (order->IsRefit()) {
283 SetDParam(4, order->IsAutoRefit() ? STR_ORDER_AUTO_REFIT_ANY : CargoSpec::Get(order->GetRefitCargo())->name);
284 }
285 if (v->type == VEH_TRAIN && (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) == 0) {
286 SetDParam(5, order->GetStopLocation() + STR_ORDER_STOP_LOCATION_NEAR_END);
287 }
288 }
289 break;
290 }
291
292 case OT_GOTO_DEPOT:
293 if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
294 SetDParam(0, STR_ORDER_GO_TO_NEAREST_DEPOT_FORMAT);
295 if (v->type == VEH_AIRCRAFT) {
296 SetDParam(2, STR_ORDER_NEAREST_HANGAR);
297 SetDParam(3, STR_EMPTY);
298 } else {
299 SetDParam(2, STR_ORDER_NEAREST_DEPOT);
300 SetDParam(3, STR_ORDER_TRAIN_DEPOT + v->type);
301 }
302 } else {
303 SetDParam(0, STR_ORDER_GO_TO_DEPOT_FORMAT);
304 SetDParam(2, v->type);
305 SetDParam(3, order->GetDestination());
306 }
307
308 if (order->GetDepotOrderType() & ODTFB_SERVICE) {
309 SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_SERVICE_NON_STOP_AT : STR_ORDER_SERVICE_AT);
310 } else {
311 SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO);
312 }
313
314 if (!timetable && (order->GetDepotActionType() & ODATFB_HALT)) {
315 SetDParam(5, STR_ORDER_STOP_ORDER);
316 }
317
318 if (!timetable && order->IsRefit()) {
319 SetDParam(5, (order->GetDepotActionType() & ODATFB_HALT) ? STR_ORDER_REFIT_STOP_ORDER : STR_ORDER_REFIT_ORDER);
320 SetDParam(6, CargoSpec::Get(order->GetRefitCargo())->name);
321 }
322 break;
323
324 case OT_GOTO_WAYPOINT:
325 SetDParam(0, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO_WAYPOINT : STR_ORDER_GO_TO_WAYPOINT);
326 SetDParam(1, order->GetDestination());
327 break;
328
329 case OT_CONDITIONAL:
330 SetDParam(1, order->GetConditionSkipToOrder() + 1);
331 if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) {
332 SetDParam(0, STR_ORDER_CONDITIONAL_UNCONDITIONAL);
333 } else {
334 OrderConditionComparator occ = order->GetConditionComparator();
335 SetDParam(0, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_ORDER_CONDITIONAL_TRUE_FALSE : STR_ORDER_CONDITIONAL_NUM);
336 SetDParam(2, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
337 SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
338
339 uint value = order->GetConditionValue();
340 if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
341 SetDParam(4, value);
342 }
343
344 if (timetable && order->GetWaitTime() > 0) {
345 SetDParam(5, order->IsWaitTimetabled() ? STR_TIMETABLE_AND_TRAVEL_FOR : STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED);
346 SetTimetableParams(6, 7, order->GetWaitTime());
347 } else {
348 SetDParam(5, STR_EMPTY);
349 }
350 break;
351
352 default: NOT_REACHED();
353 }
354
355 DrawString(rtl ? left : middle, rtl ? middle : right, y, STR_ORDER_TEXT, colour);
356 }
357
364 static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
365 {
366 /* Hack-ish; unpack order 0, so everything gets initialised with either zero
367 * or a suitable default value for the variable. Then also override the index
368 * as it is not coming from a pool, so would be initialised. */
369 Order order(0);
370 order.index = 0;
371
372 /* check depot first */
373 if (IsDepotTypeTile(tile, (TransportType)(uint)v->type) && IsTileOwner(tile, _local_company)) {
374 order.MakeGoToDepot(v->type == VEH_AIRCRAFT ? GetStationIndex(tile) : GetDepotIndex(tile),
375 ODTFB_PART_OF_ORDERS,
376 (_settings_client.gui.new_nonstop && v->IsGroundVehicle()) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
377
378 if (_ctrl_pressed) order.SetDepotOrderType((OrderDepotTypeFlags)(order.GetDepotOrderType() ^ ODTFB_SERVICE));
379
380 return order;
381 }
382
383 /* check rail waypoint */
384 if (IsRailWaypointTile(tile) &&
385 v->type == VEH_TRAIN &&
386 IsTileOwner(tile, _local_company)) {
387 order.MakeGoToWaypoint(GetStationIndex(tile));
388 if (_settings_client.gui.new_nonstop != _ctrl_pressed) order.SetNonStopType(ONSF_NO_STOP_AT_ANY_STATION);
389 return order;
390 }
391
392 /* check buoy (no ownership) */
393 if (IsBuoyTile(tile) && v->type == VEH_SHIP) {
394 order.MakeGoToWaypoint(GetStationIndex(tile));
395 return order;
396 }
397
398 /* check for station or industry with neutral station */
399 if (IsTileType(tile, MP_STATION) || IsTileType(tile, MP_INDUSTRY)) {
400 const Station *st = nullptr;
401
402 if (IsTileType(tile, MP_STATION)) {
403 st = Station::GetByTile(tile);
404 } else {
405 const Industry *in = Industry::GetByTile(tile);
406 st = in->neutral_station;
407 }
408 if (st != nullptr && (st->owner == _local_company || st->owner == OWNER_NONE)) {
409 byte facil;
410 switch (v->type) {
411 case VEH_SHIP: facil = FACIL_DOCK; break;
412 case VEH_TRAIN: facil = FACIL_TRAIN; break;
413 case VEH_AIRCRAFT: facil = FACIL_AIRPORT; break;
414 case VEH_ROAD: facil = FACIL_BUS_STOP | FACIL_TRUCK_STOP; break;
415 default: NOT_REACHED();
416 }
417 if (st->facilities & facil) {
418 order.MakeGoToStation(st->index);
419 if (_ctrl_pressed) order.SetLoadType(OLF_FULL_LOAD_ANY);
420 if (_settings_client.gui.new_nonstop && v->IsGroundVehicle()) order.SetNonStopType(ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
421 order.SetStopLocation(v->type == VEH_TRAIN ? (OrderStopLocation)(_settings_client.gui.stop_location) : OSL_PLATFORM_FAR_END);
422 return order;
423 }
424 }
425 }
426
427 /* not found */
428 order.Free();
429 return order;
430 }
431
433 enum {
434 OHK_SKIP,
435 OHK_DELETE,
436 OHK_GOTO,
437 OHK_NONSTOP,
438 OHK_FULLLOAD,
439 OHK_UNLOAD,
440 OHK_NEAREST_DEPOT,
441 OHK_ALWAYS_SERVICE,
442 OHK_TRANSFER,
443 OHK_NO_UNLOAD,
444 OHK_NO_LOAD,
445 };
446
487 struct OrdersWindow : public Window {
488 private:
490 enum OrderPlaceObjectState {
491 OPOS_NONE,
492 OPOS_GOTO,
493 OPOS_CONDITIONAL,
494 OPOS_SHARE,
495 OPOS_END,
496 };
497
499 enum DisplayPane {
500 /* WID_O_SEL_TOP_ROW_GROUNDVEHICLE */
501 DP_GROUNDVEHICLE_ROW_NORMAL = 0,
502 DP_GROUNDVEHICLE_ROW_CONDITIONAL = 1,
503
504 /* WID_O_SEL_TOP_LEFT */
505 DP_LEFT_LOAD = 0,
506 DP_LEFT_REFIT = 1,
507
508 /* WID_O_SEL_TOP_MIDDLE */
509 DP_MIDDLE_UNLOAD = 0,
510 DP_MIDDLE_SERVICE = 1,
511
512 /* WID_O_SEL_TOP_RIGHT */
513 DP_RIGHT_EMPTY = 0,
514 DP_RIGHT_REFIT = 1,
515
516 /* WID_O_SEL_TOP_ROW */
517 DP_ROW_LOAD = 0,
518 DP_ROW_DEPOT = 1,
519 DP_ROW_CONDITIONAL = 2,
520
521 /* WID_O_SEL_BOTTOM_MIDDLE */
522 DP_BOTTOM_MIDDLE_DELETE = 0,
523 DP_BOTTOM_MIDDLE_STOP_SHARING = 1,
524 };
525
526 int selected_order;
527 VehicleOrderID order_over;
528 OrderPlaceObjectState goto_type;
529 const Vehicle *vehicle;
530 Scrollbar *vscroll;
531 bool can_do_refit;
532 bool can_do_autorefit;
533
539 VehicleOrderID OrderGetSel() const
540 {
541 int num = this->selected_order;
542 return (num >= 0 && num < vehicle->GetNumOrders()) ? num : vehicle->GetNumOrders();
543 }
544
553 VehicleOrderID GetOrderFromPt(int y)
554 {
555 NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST);
556 uint sel = (y - nwid->pos_y - WidgetDimensions::scaled.framerect.top) / nwid->resize_y; // Selected line in the WID_O_ORDER_LIST panel.
557
558 if (sel >= this->vscroll->GetCapacity()) return INVALID_VEH_ORDER_ID;
559
560 sel += this->vscroll->GetPosition();
561
562 return (sel <= vehicle->GetNumOrders()) ? sel : INVALID_VEH_ORDER_ID;
563 }
564
568 void OrderClick_Goto(OrderPlaceObjectState type)
569 {
570 assert(type > OPOS_NONE && type < OPOS_END);
571
572 static const HighLightStyle goto_place_style[OPOS_END - 1] = {
573 HT_RECT | HT_VEHICLE, // OPOS_GOTO
574 HT_NONE, // OPOS_CONDITIONAL
575 HT_VEHICLE, // OPOS_SHARE
576 };
577 SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, goto_place_style[type - 1], this);
578 this->goto_type = type;
579 this->SetWidgetDirty(WID_O_GOTO);
580 }
581
587 void OrderClick_FullLoad(OrderLoadFlags load_type, bool toggle = false)
588 {
589 VehicleOrderID sel_ord = this->OrderGetSel();
590 const Order *order = this->vehicle->GetOrder(sel_ord);
591
592 if (order == nullptr) return;
593
594 if (toggle && order->GetLoadType() == load_type) {
595 load_type = OLF_LOAD_IF_POSSIBLE; // reset to 'default'
596 }
597 if (order->GetLoadType() == load_type) return; // If we still match, do nothing
598
599 Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_LOAD, load_type);
600 }
601
605 void OrderClick_Service(int i)
606 {
607 VehicleOrderID sel_ord = this->OrderGetSel();
608
609 if (i < 0) {
610 const Order *order = this->vehicle->GetOrder(sel_ord);
611 if (order == nullptr) return;
612 i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE;
613 }
614 Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_DEPOT_ACTION, i);
615 }
616
620 void OrderClick_NearestDepot()
621 {
622 Order order;
623 order.next = nullptr;
624 order.index = 0;
625 order.MakeGoToDepot(INVALID_DEPOT, ODTFB_PART_OF_ORDERS,
626 _settings_client.gui.new_nonstop && this->vehicle->IsGroundVehicle() ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
627 order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
628
629 Command<CMD_INSERT_ORDER>::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), order);
630 }
631
637 void OrderClick_Unload(OrderUnloadFlags unload_type, bool toggle = false)
638 {
639 VehicleOrderID sel_ord = this->OrderGetSel();
640 const Order *order = this->vehicle->GetOrder(sel_ord);
641
642 if (order == nullptr) return;
643
644 if (toggle && order->GetUnloadType() == unload_type) {
645 unload_type = OUF_UNLOAD_IF_POSSIBLE;
646 }
647 if (order->GetUnloadType() == unload_type) return; // If we still match, do nothing
648
649 Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_UNLOAD, unload_type);
650
651 /* Transfer and unload orders with leave empty as default */
652 if (unload_type == OUFB_TRANSFER || unload_type == OUFB_UNLOAD) {
653 Command<CMD_MODIFY_ORDER>::Post(this->vehicle->tile, this->vehicle->index, sel_ord, MOF_LOAD, OLFB_NO_LOAD);
654 this->SetWidgetDirty(WID_O_FULL_LOAD);
655 }
656 }
657
662 void OrderClick_Nonstop(int non_stop)
663 {
664 if (!this->vehicle->IsGroundVehicle()) return;
665
666 VehicleOrderID sel_ord = this->OrderGetSel();
667 const Order *order = this->vehicle->GetOrder(sel_ord);
668
669 if (order == nullptr || order->GetNonStopType() == non_stop) return;
670
671 /* Keypress if negative, so 'toggle' to the next */
672 if (non_stop < 0) {
673 non_stop = order->GetNonStopType() ^ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS;
674 }
675
676 this->SetWidgetDirty(WID_O_NON_STOP);
677 Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel_ord, MOF_NON_STOP, non_stop);
678 }
679
684 void OrderClick_Skip()
685 {
686 /* Don't skip when there's nothing to skip */
687 if (_ctrl_pressed && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return;
688 if (this->vehicle->GetNumOrders() <= 1) return;
689
690 Command<CMD_SKIP_TO_ORDER>::Post(_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER,
691 this->vehicle->tile, this->vehicle->index, _ctrl_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()));
692 }
693
697 void OrderClick_Delete()
698 {
699 /* When networking, move one order lower */
700 int selected = this->selected_order + (int)_networking;
701
702 if (Command<CMD_DELETE_ORDER>::Post(STR_ERROR_CAN_T_DELETE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel())) {
703 this->selected_order = selected >= this->vehicle->GetNumOrders() ? -1 : selected;
704 this->UpdateButtonState();
705 }
706 }
707
714 void OrderClick_StopSharing()
715 {
716 /* Don't try to stop sharing orders if 'End of Shared Orders' isn't selected. */
717 if (!this->vehicle->IsOrderListShared() || this->selected_order != this->vehicle->GetNumOrders()) return;
718 /* If Ctrl is pressed, delete the order list as if we clicked the 'Delete' button. */
719 if (_ctrl_pressed) {
720 this->OrderClick_Delete();
721 return;
722 }
723
724 /* Get another vehicle that share orders with this vehicle. */
725 Vehicle *other_shared = (this->vehicle->FirstShared() == this->vehicle) ? this->vehicle->NextShared() : this->vehicle->PreviousShared();
726 /* Copy the order list of the other vehicle. */
727 if (Command<CMD_CLONE_ORDER>::Post(STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST, this->vehicle->tile, CO_COPY, this->vehicle->index, other_shared->index)) {
728 this->UpdateButtonState();
729 }
730 }
731
738 void OrderClick_Refit(int i, bool auto_refit)
739 {
740 if (_ctrl_pressed) {
741 /* Cancel refitting */
742 Command<CMD_ORDER_REFIT>::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CT_NO_REFIT);
743 } else {
744 if (i == 1) { // Auto-refit to available cargo type.
745 Command<CMD_ORDER_REFIT>::Post(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CT_AUTO_REFIT);
746 } else {
747 ShowVehicleRefitWindow(this->vehicle, this->OrderGetSel(), this, auto_refit);
748 }
749 }
750 }
751
753 void UpdateAutoRefitState()
754 {
755 this->can_do_refit = false;
756 this->can_do_autorefit = false;
757 for (const Vehicle *w = this->vehicle; w != nullptr; w = w->IsGroundVehicle() ? w->Next() : nullptr) {
758 if (IsEngineRefittable(w->engine_type)) this->can_do_refit = true;
759 if (HasBit(Engine::Get(w->engine_type)->info.misc_flags, EF_AUTO_REFIT)) this->can_do_autorefit = true;
760 }
761 }
762
763 public:
764 OrdersWindow(WindowDesc *desc, const Vehicle *v) : Window(desc)
765 {
766 this->vehicle = v;
767
768 this->CreateNestedTree();
769 this->vscroll = this->GetScrollbar(WID_O_SCROLLBAR);
770 this->FinishInitNested(v->index);
771 if (v->owner == _local_company) {
772 this->DisableWidget(WID_O_EMPTY);
773 }
774
775 this->selected_order = -1;
776 this->order_over = INVALID_VEH_ORDER_ID;
777 this->goto_type = OPOS_NONE;
778 this->owner = v->owner;
779
780 this->UpdateAutoRefitState();
781
782 if (_settings_client.gui.quick_goto && v->owner == _local_company) {
783 /* If there are less than 2 station, make Go To active. */
784 int station_orders = 0;
785 for(const Order *order : v->Orders()) {
786 if (order->IsType(OT_GOTO_STATION)) station_orders++;
787 }
788
789 if (station_orders < 2) this->OrderClick_Goto(OPOS_GOTO);
790 }
791 this->OnInvalidateData(VIWD_MODIFY_ORDERS);
792 }
793
794 void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
795 {
796 switch (widget) {
797 case WID_O_ORDER_LIST:
798 resize->height = FONT_HEIGHT_NORMAL;
799 size->height = 6 * resize->height + padding.height;
800 break;
801
802 case WID_O_COND_VARIABLE: {
803 Dimension d = {0, 0};
804 for (uint i = 0; i < lengthof(_order_conditional_variable); i++) {
805 d = maxdim(d, GetStringBoundingBox(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i]));
806 }
807 d.width += padding.width;
808 d.height += padding.height;
809 *size = maxdim(*size, d);
810 break;
811 }
812
813 case WID_O_COND_COMPARATOR: {
814 Dimension d = {0, 0};
815 for (int i = 0; _order_conditional_condition[i] != INVALID_STRING_ID; i++) {
816 d = maxdim(d, GetStringBoundingBox(_order_conditional_condition[i]));
817 }
818 d.width += padding.width;
819 d.height += padding.height;
820 *size = maxdim(*size, d);
821 break;
822 }
823 }
824 }
825
831 void OnInvalidateData(int data = 0, bool gui_scope = true) override
832 {
833 VehicleOrderID from = INVALID_VEH_ORDER_ID;
834 VehicleOrderID to = INVALID_VEH_ORDER_ID;
835
836 switch (data) {
837 case VIWD_AUTOREPLACE:
838 /* Autoreplace replaced the vehicle */
839 this->vehicle = Vehicle::Get(this->window_number);
840 FALLTHROUGH;
841
842 case VIWD_CONSIST_CHANGED:
843 /* Vehicle composition was changed. */
844 this->UpdateAutoRefitState();
845 break;
846
847 case VIWD_REMOVE_ALL_ORDERS:
848 /* Removed / replaced all orders (after deleting / sharing) */
849 if (this->selected_order == -1) break;
850
851 this->CloseChildWindows();
852 HideDropDownMenu(this);
853 this->selected_order = -1;
854 break;
855
856 case VIWD_MODIFY_ORDERS:
857 /* Some other order changes */
858 break;
859
860 default:
861 if (data < 0) break;
862
863 if (gui_scope) break; // only do this once; from command scope
864 from = GB(data, 0, 8);
865 to = GB(data, 8, 8);
866 /* Moving an order. If one of these is INVALID_VEH_ORDER_ID, then
867 * the order is being created / removed */
868 if (this->selected_order == -1) break;
869
870 if (from == to) break; // no need to change anything
871
872 if (from != this->selected_order) {
873 /* Moving from preceding order? */
874 this->selected_order -= (int)(from <= this->selected_order);
875 /* Moving to preceding order? */
876 this->selected_order += (int)(to <= this->selected_order);
877 break;
878 }
879
880 /* Now we are modifying the selected order */
881 if (to == INVALID_VEH_ORDER_ID) {
882 /* Deleting selected order */
883 this->CloseChildWindows();
884 HideDropDownMenu(this);
885 this->selected_order = -1;
886 break;
887 }
888
889 /* Moving selected order */
890 this->selected_order = to;
891 break;
892 }
893
894 this->vscroll->SetCount(this->vehicle->GetNumOrders() + 1);
895 if (gui_scope) this->UpdateButtonState();
896
897 /* Scroll to the new order. */
898 if (from == INVALID_VEH_ORDER_ID && to != INVALID_VEH_ORDER_ID && !this->vscroll->IsVisible(to)) {
899 this->vscroll->ScrollTowards(to);
900 }
901 }
902
903 void UpdateButtonState()
904 {
905 if (this->vehicle->owner != _local_company) return; // No buttons are displayed with competitor order windows.
906
907 bool shared_orders = this->vehicle->IsOrderListShared();
908 VehicleOrderID sel = this->OrderGetSel();
909 const Order *order = this->vehicle->GetOrder(sel);
910
911 /* Second row. */
912 /* skip */
913 this->SetWidgetDisabledState(WID_O_SKIP, this->vehicle->GetNumOrders() <= 1);
914
915 /* delete / stop sharing */
916 NWidgetStacked *delete_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_BOTTOM_MIDDLE);
917 if (shared_orders && this->selected_order == this->vehicle->GetNumOrders()) {
918 /* The 'End of Shared Orders' order is selected, show the 'stop sharing' button. */
919 delete_sel->SetDisplayedPlane(DP_BOTTOM_MIDDLE_STOP_SHARING);
920 } else {
921 /* The 'End of Shared Orders' order isn't selected, show the 'delete' button. */
922 delete_sel->SetDisplayedPlane(DP_BOTTOM_MIDDLE_DELETE);
923 this->SetWidgetDisabledState(WID_O_DELETE,
924 (uint)this->vehicle->GetNumOrders() + ((shared_orders || this->vehicle->GetNumOrders() != 0) ? 1 : 0) <= (uint)this->selected_order);
925
926 /* Set the tooltip of the 'delete' button depending on whether the
927 * 'End of Orders' order or a regular order is selected. */
928 NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_O_DELETE);
929 if (this->selected_order == this->vehicle->GetNumOrders()) {
930 nwi->SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_ALL_TOOLTIP);
931 } else {
932 nwi->SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP);
933 }
934 }
935
936 /* First row. */
937 this->RaiseWidget(WID_O_FULL_LOAD);
938 this->RaiseWidget(WID_O_UNLOAD);
939 this->RaiseWidget(WID_O_SERVICE);
940
941 /* Selection widgets. */
942 /* Train or road vehicle. */
943 NWidgetStacked *train_row_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_ROW_GROUNDVEHICLE);
944 NWidgetStacked *left_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_LEFT);
945 NWidgetStacked *middle_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_MIDDLE);
946 NWidgetStacked *right_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_RIGHT);
947 /* Ship or airplane. */
948 NWidgetStacked *row_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_ROW);
949 assert(row_sel != nullptr || (train_row_sel != nullptr && left_sel != nullptr && middle_sel != nullptr && right_sel != nullptr));
950
951
952 if (order == nullptr) {
953 if (row_sel != nullptr) {
954 row_sel->SetDisplayedPlane(DP_ROW_LOAD);
955 } else {
956 train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
957 left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
958 middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
959 right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
960 this->DisableWidget(WID_O_NON_STOP);
961 this->RaiseWidget(WID_O_NON_STOP);
962 }
963 this->DisableWidget(WID_O_FULL_LOAD);
964 this->DisableWidget(WID_O_UNLOAD);
965 this->DisableWidget(WID_O_REFIT_DROPDOWN);
966 } else {
967 this->SetWidgetDisabledState(WID_O_FULL_LOAD, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // full load
968 this->SetWidgetDisabledState(WID_O_UNLOAD, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) != 0); // unload
969
970 switch (order->GetType()) {
971 case OT_GOTO_STATION:
972 if (row_sel != nullptr) {
973 row_sel->SetDisplayedPlane(DP_ROW_LOAD);
974 } else {
975 train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
976 left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
977 middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
978 right_sel->SetDisplayedPlane(DP_RIGHT_REFIT);
979 this->EnableWidget(WID_O_NON_STOP);
980 this->SetWidgetLoweredState(WID_O_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
981 }
982 this->SetWidgetLoweredState(WID_O_FULL_LOAD, order->GetLoadType() == OLF_FULL_LOAD_ANY);
983 this->SetWidgetLoweredState(WID_O_UNLOAD, order->GetUnloadType() == OUFB_UNLOAD);
984
985 /* Can only do refitting when stopping at the destination and loading cargo.
986 * Also enable the button if a refit is already set to allow clearing it. */
987 this->SetWidgetDisabledState(WID_O_REFIT_DROPDOWN,
988 order->GetLoadType() == OLFB_NO_LOAD || (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ||
989 ((!this->can_do_refit || !this->can_do_autorefit) && !order->IsRefit()));
990
991 break;
992
993 case OT_GOTO_WAYPOINT:
994 if (row_sel != nullptr) {
995 row_sel->SetDisplayedPlane(DP_ROW_LOAD);
996 } else {
997 train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
998 left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
999 middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
1000 right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
1001 this->EnableWidget(WID_O_NON_STOP);
1002 this->SetWidgetLoweredState(WID_O_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
1003 }
1004 this->DisableWidget(WID_O_FULL_LOAD);
1005 this->DisableWidget(WID_O_UNLOAD);
1006 this->DisableWidget(WID_O_REFIT_DROPDOWN);
1007 break;
1008
1009 case OT_GOTO_DEPOT:
1010 if (row_sel != nullptr) {
1011 row_sel->SetDisplayedPlane(DP_ROW_DEPOT);
1012 } else {
1013 train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
1014 left_sel->SetDisplayedPlane(DP_LEFT_REFIT);
1015 middle_sel->SetDisplayedPlane(DP_MIDDLE_SERVICE);
1016 right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
1017 this->EnableWidget(WID_O_NON_STOP);
1018 this->SetWidgetLoweredState(WID_O_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
1019 }
1020 /* Disable refit button if the order is no 'always go' order.
1021 * However, keep the service button enabled for refit-orders to allow clearing refits (without knowing about ctrl). */
1022 this->SetWidgetDisabledState(WID_O_REFIT,
1023 (order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT) ||
1024 (!this->can_do_refit && !order->IsRefit()));
1025 this->SetWidgetLoweredState(WID_O_SERVICE, order->GetDepotOrderType() & ODTFB_SERVICE);
1026 break;
1027
1028 case OT_CONDITIONAL: {
1029 if (row_sel != nullptr) {
1030 row_sel->SetDisplayedPlane(DP_ROW_CONDITIONAL);
1031 } else {
1032 train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_CONDITIONAL);
1033 }
1034 OrderConditionVariable ocv = order->GetConditionVariable();
1035 /* Set the strings for the dropdown boxes. */
1036 this->GetWidget<NWidgetCore>(WID_O_COND_VARIABLE)->widget_data = STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + ocv;
1037 this->GetWidget<NWidgetCore>(WID_O_COND_COMPARATOR)->widget_data = _order_conditional_condition[order->GetConditionComparator()];
1038 this->SetWidgetDisabledState(WID_O_COND_COMPARATOR, ocv == OCV_UNCONDITIONALLY);
1039 this->SetWidgetDisabledState(WID_O_COND_VALUE, ocv == OCV_REQUIRES_SERVICE || ocv == OCV_UNCONDITIONALLY);
1040 break;
1041 }
1042
1043 default: // every other order
1044 if (row_sel != nullptr) {
1045 row_sel->SetDisplayedPlane(DP_ROW_LOAD);
1046 } else {
1047 train_row_sel->SetDisplayedPlane(DP_GROUNDVEHICLE_ROW_NORMAL);
1048 left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
1049 middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
1050 right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
1051 this->DisableWidget(WID_O_NON_STOP);
1052 }
1053 this->DisableWidget(WID_O_FULL_LOAD);
1054 this->DisableWidget(WID_O_UNLOAD);
1055 this->DisableWidget(WID_O_REFIT_DROPDOWN);
1056 break;
1057 }
1058 }
1059
1060 /* Disable list of vehicles with the same shared orders if there is no list */
1061 this->SetWidgetDisabledState(WID_O_SHARED_ORDER_LIST, !shared_orders);
1062
1063 this->SetDirty();
1064 }
1065
1066 void OnPaint() override
1067 {
1068 if (this->vehicle->owner != _local_company) {
1069 this->selected_order = -1; // Disable selection any selected row at a competitor order window.
1070 } else {
1071 this->SetWidgetLoweredState(WID_O_GOTO, this->goto_type != OPOS_NONE);
1072 }
1073 this->DrawWidgets();
1074 }
1075
1076 void DrawWidget(const Rect &r, int widget) const override
1077 {
1078 if (widget != WID_O_ORDER_LIST) return;
1079
1080 Rect ir = r.Shrink(WidgetDimensions::scaled.frametext, WidgetDimensions::scaled.framerect);
1081 bool rtl = _current_text_dir == TD_RTL;
1082 SetDParamMaxValue(0, this->vehicle->GetNumOrders(), 2);
1083 int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + 2 * GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + WidgetDimensions::scaled.hsep_normal;
1084 int middle = rtl ? ir.right - index_column_width : ir.left + index_column_width;
1085
1086 int y = ir.top;
1087 int line_height = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST)->resize_y;
1088
1089 int i = this->vscroll->GetPosition();
1090 const Order *order = this->vehicle->GetOrder(i);
1091 /* First draw the highlighting underground if it exists. */
1092 if (this->order_over != INVALID_VEH_ORDER_ID) {
1093 while (order != nullptr) {
1094 /* Don't draw anything if it extends past the end of the window. */
1095 if (!this->vscroll->IsVisible(i)) break;
1096
1097 if (i != this->selected_order && i == this->order_over) {
1098 /* Highlight dragged order destination. */
1099 int top = (this->order_over < this->selected_order ? y : y + line_height) - WidgetDimensions::scaled.framerect.top;
1100 int bottom = std::min(top + 2, ir.bottom);
1101 top = std::max(top - 3, ir.top);
1102 GfxFillRect(ir.left, top, ir.right, bottom, _colour_gradient[COLOUR_GREY][7]);
1103 break;
1104 }
1105 y += line_height;
1106
1107 i++;
1108 order = order->next;
1109 }
1110
1111 /* Reset counters for drawing the orders. */
1112 y = ir.top;
1113 i = this->vscroll->GetPosition();
1114 order = this->vehicle->GetOrder(i);
1115 }
1116
1117 /* Draw the orders. */
1118 while (order != nullptr) {
1119 /* Don't draw anything if it extends past the end of the window. */
1120 if (!this->vscroll->IsVisible(i)) break;
1121
1122 DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false, ir.left, middle, ir.right);
1123 y += line_height;
1124
1125 i++;
1126 order = order->next;
1127 }
1128
1129 if (this->vscroll->IsVisible(i)) {
1130 StringID str = this->vehicle->IsOrderListShared() ? STR_ORDERS_END_OF_SHARED_ORDERS : STR_ORDERS_END_OF_ORDERS;
1131 DrawString(rtl ? ir.left : middle, rtl ? middle : ir.right, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
1132 }
1133 }
1134
1135 void SetStringParameters(int widget) const override
1136 {
1137 switch (widget) {
1138 case WID_O_COND_VALUE: {
1139 VehicleOrderID sel = this->OrderGetSel();
1140 const Order *order = this->vehicle->GetOrder(sel);
1141
1142 if (order != nullptr && order->IsType(OT_CONDITIONAL)) {
1143 uint value = order->GetConditionValue();
1144 if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
1145 SetDParam(0, value);
1146 }
1147 break;
1148 }
1149
1150 case WID_O_CAPTION:
1151 SetDParam(0, this->vehicle->index);
1152 break;
1153 }
1154 }
1155
1156 void OnClick(Point pt, int widget, int click_count) override
1157 {
1158 switch (widget) {
1159 case WID_O_ORDER_LIST: {
1160 if (this->goto_type == OPOS_CONDITIONAL) {
1161 VehicleOrderID order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
1162 if (order_id != INVALID_VEH_ORDER_ID) {
1163 Order order;
1164 order.next = nullptr;
1165 order.index = 0;
1166 order.MakeConditional(order_id);
1167
1168 Command<CMD_INSERT_ORDER>::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), order);
1169 }
1170 ResetObjectToPlace();
1171 break;
1172 }
1173
1174 VehicleOrderID sel = this->GetOrderFromPt(pt.y);
1175
1176 if (_ctrl_pressed && sel < this->vehicle->GetNumOrders()) {
1177 TileIndex xy = this->vehicle->GetOrder(sel)->GetLocation(this->vehicle);
1178 if (xy != INVALID_TILE) ScrollMainWindowToTile(xy);
1179 return;
1180 }
1181
1182 /* This order won't be selected any more, close all child windows and dropdowns */
1183 this->CloseChildWindows();
1184 HideDropDownMenu(this);
1185
1186 if (sel == INVALID_VEH_ORDER_ID || this->vehicle->owner != _local_company) {
1187 /* Deselect clicked order */
1188 this->selected_order = -1;
1189 } else if (sel == this->selected_order) {
1190 if (this->vehicle->type == VEH_TRAIN && sel < this->vehicle->GetNumOrders()) {
1191 Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER,
1192 this->vehicle->tile, this->vehicle->index, sel,
1193 MOF_STOP_LOCATION, (this->vehicle->GetOrder(sel)->GetStopLocation() + 1) % OSL_END);
1194 }
1195 } else {
1196 /* Select clicked order */
1197 this->selected_order = sel;
1198
1199 if (this->vehicle->owner == _local_company) {
1200 /* Activate drag and drop */
1201 SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
1202 }
1203 }
1204
1205 this->UpdateButtonState();
1206 break;
1207 }
1208
1209 case WID_O_SKIP:
1210 this->OrderClick_Skip();
1211 break;
1212
1213 case WID_O_DELETE:
1214 this->OrderClick_Delete();
1215 break;
1216
1217 case WID_O_STOP_SHARING:
1218 this->OrderClick_StopSharing();
1219 break;
1220
1221 case WID_O_NON_STOP:
1222 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1223 this->OrderClick_Nonstop(-1);
1224 } else {
1225 const Order *o = this->vehicle->GetOrder(this->OrderGetSel());
1226 ShowDropDownMenu(this, _order_non_stop_drowdown, o->GetNonStopType(), WID_O_NON_STOP, 0,
1227 o->IsType(OT_GOTO_STATION) ? 0 : (o->IsType(OT_GOTO_WAYPOINT) ? 3 : 12));
1228 }
1229 break;
1230
1231 case WID_O_GOTO:
1232 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1233 if (this->goto_type != OPOS_NONE) {
1234 ResetObjectToPlace();
1235 } else {
1236 this->OrderClick_Goto(OPOS_GOTO);
1237 }
1238 } else {
1239 int sel;
1240 switch (this->goto_type) {
1241 case OPOS_NONE: sel = -1; break;
1242 case OPOS_GOTO: sel = 0; break;
1243 case OPOS_CONDITIONAL: sel = 2; break;
1244 case OPOS_SHARE: sel = 3; break;
1245 default: NOT_REACHED();
1246 }
1247 ShowDropDownMenu(this, this->vehicle->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, sel, WID_O_GOTO, 0, 0);
1248 }
1249 break;
1250
1251 case WID_O_FULL_LOAD:
1252 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1253 this->OrderClick_FullLoad(OLF_FULL_LOAD_ANY, true);
1254 } else {
1255 ShowDropDownMenu(this, _order_full_load_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetLoadType(), WID_O_FULL_LOAD, 0, 2);
1256 }
1257 break;
1258
1259 case WID_O_UNLOAD:
1260 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1261 this->OrderClick_Unload(OUFB_UNLOAD, true);
1262 } else {
1263 ShowDropDownMenu(this, _order_unload_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetUnloadType(), WID_O_UNLOAD, 0, 8);
1264 }
1265 break;
1266
1267 case WID_O_REFIT:
1268 this->OrderClick_Refit(0, false);
1269 break;
1270
1271 case WID_O_SERVICE:
1272 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1273 this->OrderClick_Service(-1);
1274 } else {
1275 ShowDropDownMenu(this, _order_depot_action_dropdown, DepotActionStringIndex(this->vehicle->GetOrder(this->OrderGetSel())), WID_O_SERVICE, 0, 0);
1276 }
1277 break;
1278
1279 case WID_O_REFIT_DROPDOWN:
1280 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1281 this->OrderClick_Refit(0, true);
1282 } else {
1283 ShowDropDownMenu(this, _order_refit_action_dropdown, 0, WID_O_REFIT_DROPDOWN, 0, 0);
1284 }
1285 break;
1286
1287 case WID_O_TIMETABLE_VIEW:
1288 ShowTimetableWindow(this->vehicle);
1289 break;
1290
1291 case WID_O_COND_VARIABLE: {
1292 DropDownList list;
1293 for (uint i = 0; i < lengthof(_order_conditional_variable); i++) {
1294 list.emplace_back(new DropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false));
1295 }
1296 ShowDropDownList(this, std::move(list), this->vehicle->GetOrder(this->OrderGetSel())->GetConditionVariable(), WID_O_COND_VARIABLE);
1297 break;
1298 }
1299
1300 case WID_O_COND_COMPARATOR: {
1301 const Order *o = this->vehicle->GetOrder(this->OrderGetSel());
1302 ShowDropDownMenu(this, _order_conditional_condition, o->GetConditionComparator(), WID_O_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0);
1303 break;
1304 }
1305
1306 case WID_O_COND_VALUE: {
1307 const Order *order = this->vehicle->GetOrder(this->OrderGetSel());
1308 uint value = order->GetConditionValue();
1309 if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
1310 SetDParam(0, value);
1311 ShowQueryString(STR_JUST_INT, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, this, CS_NUMERAL, QSF_NONE);
1312 break;
1313 }
1314
1315 case WID_O_SHARED_ORDER_LIST:
1316 ShowVehicleListWindow(this->vehicle);
1317 break;
1318 }
1319 }
1320
1321 void OnQueryTextFinished(char *str) override
1322 {
1323 if (!StrEmpty(str)) {
1324 VehicleOrderID sel = this->OrderGetSel();
1325 uint value = atoi(str);
1326
1327 switch (this->vehicle->GetOrder(sel)->GetConditionVariable()) {
1328 case OCV_MAX_SPEED:
1329 value = ConvertDisplaySpeedToSpeed(value);
1330 break;
1331
1332 case OCV_RELIABILITY:
1333 case OCV_LOAD_PERCENTAGE:
1334 value = Clamp(value, 0, 100);
1335 break;
1336
1337 default:
1338 break;
1339 }
1340 Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, sel, MOF_COND_VALUE, Clamp(value, 0, 2047));
1341 }
1342 }
1343
1344 void OnDropdownSelect(int widget, int index) override
1345 {
1346 switch (widget) {
1347 case WID_O_NON_STOP:
1348 this->OrderClick_Nonstop(index);
1349 break;
1350
1351 case WID_O_FULL_LOAD:
1352 this->OrderClick_FullLoad((OrderLoadFlags)index);
1353 break;
1354
1355 case WID_O_UNLOAD:
1356 this->OrderClick_Unload((OrderUnloadFlags)index);
1357 break;
1358
1359 case WID_O_GOTO:
1360 switch (index) {
1361 case 0: this->OrderClick_Goto(OPOS_GOTO); break;
1362 case 1: this->OrderClick_NearestDepot(); break;
1363 case 2: this->OrderClick_Goto(OPOS_CONDITIONAL); break;
1364 case 3: this->OrderClick_Goto(OPOS_SHARE); break;
1365 default: NOT_REACHED();
1366 }
1367 break;
1368
1369 case WID_O_SERVICE:
1370 this->OrderClick_Service(index);
1371 break;
1372
1373 case WID_O_REFIT_DROPDOWN:
1374 this->OrderClick_Refit(index, true);
1375 break;
1376
1377 case WID_O_COND_VARIABLE:
1378 Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), MOF_COND_VARIABLE, index);
1379 break;
1380
1381 case WID_O_COND_COMPARATOR:
1382 Command<CMD_MODIFY_ORDER>::Post(STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), MOF_COND_COMPARATOR, index);
1383 break;
1384 }
1385 }
1386
1387 void OnDragDrop(Point pt, int widget) override
1388 {
1389 switch (widget) {
1390 case WID_O_ORDER_LIST: {
1391 VehicleOrderID from_order = this->OrderGetSel();
1392 VehicleOrderID to_order = this->GetOrderFromPt(pt.y);
1393
1394 if (!(from_order == to_order || from_order == INVALID_VEH_ORDER_ID || from_order > this->vehicle->GetNumOrders() || to_order == INVALID_VEH_ORDER_ID || to_order > this->vehicle->GetNumOrders()) &&
1395 Command<CMD_MOVE_ORDER>::Post(STR_ERROR_CAN_T_MOVE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, from_order, to_order)) {
1396 this->selected_order = -1;
1397 this->UpdateButtonState();
1398 }
1399 break;
1400 }
1401
1402 case WID_O_DELETE:
1403 this->OrderClick_Delete();
1404 break;
1405
1406 case WID_O_STOP_SHARING:
1407 this->OrderClick_StopSharing();
1408 break;
1409 }
1410
1411 ResetObjectToPlace();
1412
1413 if (this->order_over != INVALID_VEH_ORDER_ID) {
1414 /* End of drag-and-drop, hide dragged order destination highlight. */
1415 this->order_over = INVALID_VEH_ORDER_ID;
1416 this->SetWidgetDirty(WID_O_ORDER_LIST);
1417 }
1418 }
1419
1420 EventState OnHotkey(int hotkey) override
1421 {
1422 if (this->vehicle->owner != _local_company) return ES_NOT_HANDLED;
1423
1424 switch (hotkey) {
1425 case OHK_SKIP: this->OrderClick_Skip(); break;
1426 case OHK_DELETE: this->OrderClick_Delete(); break;
1427 case OHK_GOTO: this->OrderClick_Goto(OPOS_GOTO); break;
1428 case OHK_NONSTOP: this->OrderClick_Nonstop(-1); break;
1429 case OHK_FULLLOAD: this->OrderClick_FullLoad(OLF_FULL_LOAD_ANY, true); break;
1430 case OHK_UNLOAD: this->OrderClick_Unload(OUFB_UNLOAD, true); break;
1431 case OHK_NEAREST_DEPOT: this->OrderClick_NearestDepot(); break;
1432 case OHK_ALWAYS_SERVICE: this->OrderClick_Service(-1); break;
1433 case OHK_TRANSFER: this->OrderClick_Unload(OUFB_TRANSFER, true); break;
1434 case OHK_NO_UNLOAD: this->OrderClick_Unload(OUFB_NO_UNLOAD, true); break;
1435 case OHK_NO_LOAD: this->OrderClick_FullLoad(OLFB_NO_LOAD, true); break;
1436 default: return ES_NOT_HANDLED;
1437 }
1438 return ES_HANDLED;
1439 }
1440
1441 void OnPlaceObject(Point pt, TileIndex tile) override
1442 {
1443 if (this->goto_type == OPOS_GOTO) {
1444 const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
1445 if (cmd.IsType(OT_NOTHING)) return;
1446
1447 if (Command<CMD_INSERT_ORDER>::Post(STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), cmd)) {
1448 /* With quick goto the Go To button stays active */
1449 if (!_settings_client.gui.quick_goto) ResetObjectToPlace();
1450 }
1451 }
1452 }
1453
1454 bool OnVehicleSelect(const Vehicle *v) override
1455 {
1456 /* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet.
1457 * We disallow copying orders of other vehicles if we already have at least one order entry
1458 * ourself as it easily copies orders of vehicles within a station when we mean the station.
1459 * Obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
1460 * TODO: give a warning message */
1461 bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE;
1462 if (this->vehicle->GetNumOrders() != 0 && !share_order) return false;
1463
1464 if (Command<CMD_CLONE_ORDER>::Post(share_order ? STR_ERROR_CAN_T_SHARE_ORDER_LIST : STR_ERROR_CAN_T_COPY_ORDER_LIST,
1465 this->vehicle->tile, share_order ? CO_SHARE : CO_COPY, this->vehicle->index, v->index)) {
1466 this->selected_order = -1;
1467 ResetObjectToPlace();
1468 }
1469 return true;
1470 }
1471
1478 bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end) override
1479 {
1480 bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE;
1481 if (this->vehicle->GetNumOrders() != 0 && !share_order) return false;
1482
1483 if (!share_order) {
1484 /* If CTRL is not pressed: If all the vehicles in this list have the same orders, then copy orders */
1485 if (AllEqual(begin, end, [](const Vehicle *v1, const Vehicle *v2) {
1486 return VehiclesHaveSameOrderList(v1, v2);
1487 })) {
1488 OnVehicleSelect(*begin);
1489 } else {
1490 ShowErrorMessage(STR_ERROR_CAN_T_COPY_ORDER_LIST, STR_ERROR_CAN_T_COPY_ORDER_VEHICLE_LIST, WL_INFO);
1491 }
1492 } else {
1493 /* If CTRL is pressed: If all the vehicles in this list share orders, then copy orders */
1494 if (AllEqual(begin, end, [](const Vehicle *v1, const Vehicle *v2) {
1495 return v1->FirstShared() == v2->FirstShared();
1496 })) {
1497 OnVehicleSelect(*begin);
1498 } else {
1499 ShowErrorMessage(STR_ERROR_CAN_T_SHARE_ORDER_LIST, STR_ERROR_CAN_T_SHARE_ORDER_VEHICLE_LIST, WL_INFO);
1500 }
1501 }
1502
1503 return true;
1504 }
1505
1506 void OnPlaceObjectAbort() override
1507 {
1508 this->goto_type = OPOS_NONE;
1509 this->SetWidgetDirty(WID_O_GOTO);
1510
1511 /* Remove drag highlighting if it exists. */
1512 if (this->order_over != INVALID_VEH_ORDER_ID) {
1513 this->order_over = INVALID_VEH_ORDER_ID;
1514 this->SetWidgetDirty(WID_O_ORDER_LIST);
1515 }
1516 }
1517
1518 void OnMouseDrag(Point pt, int widget) override
1519 {
1520 if (this->selected_order != -1 && widget == WID_O_ORDER_LIST) {
1521 /* An order is dragged.. */
1522 VehicleOrderID from_order = this->OrderGetSel();
1523 VehicleOrderID to_order = this->GetOrderFromPt(pt.y);
1524 uint num_orders = this->vehicle->GetNumOrders();
1525
1526 if (from_order != INVALID_VEH_ORDER_ID && from_order <= num_orders) {
1527 if (to_order != INVALID_VEH_ORDER_ID && to_order <= num_orders) { // ..over an existing order.
1528 this->order_over = to_order;
1529 this->SetWidgetDirty(widget);
1530 } else if (from_order != to_order && this->order_over != INVALID_VEH_ORDER_ID) { // ..outside of the order list.
1531 this->order_over = INVALID_VEH_ORDER_ID;
1532 this->SetWidgetDirty(widget);
1533 }
1534 }
1535 }
1536 }
1537
1538 void OnResize() override
1539 {
1540 /* Update the scroll bar */
1541 this->vscroll->SetCapacityFromWidget(this, WID_O_ORDER_LIST);
1542 }
1543
1544 static HotkeyList hotkeys;
1545 };
1546
1547 static Hotkey order_hotkeys[] = {
1548 Hotkey('D', "skip", OHK_SKIP),
1549 Hotkey('F', "delete", OHK_DELETE),
1550 Hotkey('G', "goto", OHK_GOTO),
1551 Hotkey('H', "nonstop", OHK_NONSTOP),
1552 Hotkey('J', "fullload", OHK_FULLLOAD),
1553 Hotkey('K', "unload", OHK_UNLOAD),
1554 Hotkey((uint16)0, "nearest_depot", OHK_NEAREST_DEPOT),
1555 Hotkey((uint16)0, "always_service", OHK_ALWAYS_SERVICE),
1556 Hotkey((uint16)0, "transfer", OHK_TRANSFER),
1557 Hotkey((uint16)0, "no_unload", OHK_NO_UNLOAD),
1558 Hotkey((uint16)0, "no_load", OHK_NO_LOAD),
1559 HOTKEY_LIST_END
1560 };
1561 HotkeyList OrdersWindow::hotkeys("order", order_hotkeys);
1562
1564 static const NWidgetPart _nested_orders_train_widgets[] = {
1565 NWidget(NWID_HORIZONTAL),
1566 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1567 NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1568 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_ORDERS_TIMETABLE_VIEW, STR_ORDERS_TIMETABLE_VIEW_TOOLTIP),
1569 NWidget(WWT_SHADEBOX, COLOUR_GREY),
1570 NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
1571 NWidget(WWT_STICKYBOX, COLOUR_GREY),
1572 EndContainer(),
1573 NWidget(NWID_HORIZONTAL),
1574 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(),
1575 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_O_SCROLLBAR),
1576 EndContainer(),
1577
1578 /* First button row. */
1579 NWidget(NWID_HORIZONTAL),
1580 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_ROW_GROUNDVEHICLE),
1581 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
1582 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_NON_STOP), SetMinimalSize(93, 12), SetFill(1, 0),
1583 SetDataTip(STR_ORDER_NON_STOP, STR_ORDER_TOOLTIP_NON_STOP), SetResize(1, 0),
1584 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_LEFT),
1585 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_FULL_LOAD), SetMinimalSize(93, 12), SetFill(1, 0),
1586 SetDataTip(STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD), SetResize(1, 0),
1587 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_REFIT), SetMinimalSize(93, 12), SetFill(1, 0),
1588 SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
1589 EndContainer(),
1590 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_MIDDLE),
1591 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_UNLOAD), SetMinimalSize(93, 12), SetFill(1, 0),
1592 SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0),
1593 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_SERVICE), SetMinimalSize(93, 12), SetFill(1, 0),
1594 SetDataTip(STR_ORDER_SERVICE, STR_ORDER_SERVICE_TOOLTIP), SetResize(1, 0),
1595 EndContainer(),
1596 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_RIGHT),
1597 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_EMPTY), SetMinimalSize(93, 12), SetFill(1, 0),
1598 SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
1599 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_REFIT_DROPDOWN), SetMinimalSize(93, 12), SetFill(1, 0),
1600 SetDataTip(STR_ORDER_REFIT_AUTO, STR_ORDER_REFIT_AUTO_TOOLTIP), SetResize(1, 0),
1601 EndContainer(),
1602 EndContainer(),
1603 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
1604 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_VARIABLE), SetMinimalSize(124, 12), SetFill(1, 0),
1605 SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP), SetResize(1, 0),
1606 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
1607 SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
1608 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_COND_VALUE), SetMinimalSize(124, 12), SetFill(1, 0),
1609 SetDataTip(STR_BLACK_COMMA, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP), SetResize(1, 0),
1610 EndContainer(),
1611 EndContainer(),
1612 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_O_SHARED_ORDER_LIST), SetMinimalSize(12, 12), SetDataTip(SPR_SHARED_ORDERS_ICON, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP),
1613 EndContainer(),
1614
1615 /* Second button row. */
1616 NWidget(NWID_HORIZONTAL),
1617 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
1618 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_SKIP), SetMinimalSize(124, 12), SetFill(1, 0),
1619 SetDataTip(STR_ORDERS_SKIP_BUTTON, STR_ORDERS_SKIP_TOOLTIP), SetResize(1, 0),
1620 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_BOTTOM_MIDDLE),
1621 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_DELETE), SetMinimalSize(124, 12), SetFill(1, 0),
1622 SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0),
1623 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_STOP_SHARING), SetMinimalSize(124, 12), SetFill(1, 0),
1624 SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP), SetResize(1, 0),
1625 EndContainer(),
1626 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_GOTO), SetMinimalSize(124, 12), SetFill(1, 0),
1627 SetDataTip(STR_ORDERS_GO_TO_BUTTON, STR_ORDERS_GO_TO_TOOLTIP), SetResize(1, 0),
1628 EndContainer(),
1629 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
1630 EndContainer(),
1631 };
1632
1633 static WindowDesc _orders_train_desc(
1634 WDP_AUTO, "view_vehicle_orders_train", 384, 100,
1635 WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
1636 WDF_CONSTRUCTION,
1637 _nested_orders_train_widgets, lengthof(_nested_orders_train_widgets),
1638 &OrdersWindow::hotkeys
1639 );
1640
1642 static const NWidgetPart _nested_orders_widgets[] = {
1643 NWidget(NWID_HORIZONTAL),
1644 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1645 NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1646 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_ORDERS_TIMETABLE_VIEW, STR_ORDERS_TIMETABLE_VIEW_TOOLTIP),
1647 NWidget(WWT_SHADEBOX, COLOUR_GREY),
1648 NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
1649 NWidget(WWT_STICKYBOX, COLOUR_GREY),
1650 EndContainer(),
1651 NWidget(NWID_HORIZONTAL),
1652 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(),
1653 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_O_SCROLLBAR),
1654 EndContainer(),
1655
1656 /* First button row. */
1657 NWidget(NWID_HORIZONTAL),
1658 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_ROW),
1659 /* Load + unload + refit buttons. */
1660 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
1661 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_FULL_LOAD), SetMinimalSize(124, 12), SetFill(1, 0),
1662 SetDataTip(STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD), SetResize(1, 0),
1663 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_UNLOAD), SetMinimalSize(124, 12), SetFill(1, 0),
1664 SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0),
1665 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_REFIT_DROPDOWN), SetMinimalSize(124, 12), SetFill(1, 0),
1666 SetDataTip(STR_ORDER_REFIT_AUTO, STR_ORDER_REFIT_AUTO_TOOLTIP), SetResize(1, 0),
1667 EndContainer(),
1668 /* Refit + service buttons. */
1669 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
1670 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_REFIT), SetMinimalSize(186, 12), SetFill(1, 0),
1671 SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
1672 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_SERVICE), SetMinimalSize(124, 12), SetFill(1, 0),
1673 SetDataTip(STR_ORDER_SERVICE, STR_ORDER_SERVICE_TOOLTIP), SetResize(1, 0),
1674 EndContainer(),
1675
1676 /* Buttons for setting a condition. */
1677 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
1678 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_VARIABLE), SetMinimalSize(124, 12), SetFill(1, 0),
1679 SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP), SetResize(1, 0),
1680 NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
1681 SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
1682 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_COND_VALUE), SetMinimalSize(124, 12), SetFill(1, 0),
1683 SetDataTip(STR_BLACK_COMMA, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP), SetResize(1, 0),
1684 EndContainer(),
1685 EndContainer(),
1686
1687 NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_O_SHARED_ORDER_LIST), SetMinimalSize(12, 12), SetDataTip(SPR_SHARED_ORDERS_ICON, STR_ORDERS_VEH_WITH_SHARED_ORDERS_LIST_TOOLTIP),
1688 EndContainer(),
1689
1690 /* Second button row. */
1691 NWidget(NWID_HORIZONTAL),
1692 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_SKIP), SetMinimalSize(124, 12), SetFill(1, 0),
1693 SetDataTip(STR_ORDERS_SKIP_BUTTON, STR_ORDERS_SKIP_TOOLTIP), SetResize(1, 0),
1694 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_BOTTOM_MIDDLE),
1695 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_DELETE), SetMinimalSize(124, 12), SetFill(1, 0),
1696 SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0),
1697 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_STOP_SHARING), SetMinimalSize(124, 12), SetFill(1, 0),
1698 SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP), SetResize(1, 0),
1699 EndContainer(),
1700 NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_GOTO), SetMinimalSize(124, 12), SetFill(1, 0),
1701 SetDataTip(STR_ORDERS_GO_TO_BUTTON, STR_ORDERS_GO_TO_TOOLTIP), SetResize(1, 0),
1702 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
1703 EndContainer(),
1704 };
1705
1706 static WindowDesc _orders_desc(
1707 WDP_AUTO, "view_vehicle_orders", 384, 100,
1708 WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
1709 WDF_CONSTRUCTION,
1710 _nested_orders_widgets, lengthof(_nested_orders_widgets),
1711 &OrdersWindow::hotkeys
1712 );
1713
1715 static const NWidgetPart _nested_other_orders_widgets[] = {
1716 NWidget(NWID_HORIZONTAL),
1717 NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1718 NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1719 NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_ORDERS_TIMETABLE_VIEW, STR_ORDERS_TIMETABLE_VIEW_TOOLTIP),
1720 NWidget(WWT_SHADEBOX, COLOUR_GREY),
1721 NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
1722 NWidget(WWT_STICKYBOX, COLOUR_GREY),
1723 EndContainer(),
1724 NWidget(NWID_HORIZONTAL),
1725 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(),
1726 NWidget(NWID_VERTICAL),
1727 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_O_SCROLLBAR),
1728 NWidget(WWT_RESIZEBOX, COLOUR_GREY),
1729 EndContainer(),
1730 EndContainer(),
1731 };
1732
1733 static WindowDesc _other_orders_desc(
1734 WDP_AUTO, "view_vehicle_orders_competitor", 384, 86,
1735 WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
1736 WDF_CONSTRUCTION,
1737 _nested_other_orders_widgets, lengthof(_nested_other_orders_widgets),
1738 &OrdersWindow::hotkeys
1739 );
1740
1741 void ShowOrdersWindow(const Vehicle *v)
1742 {
1743 CloseWindowById(WC_VEHICLE_DETAILS, v->index, false);
1744 CloseWindowById(WC_VEHICLE_TIMETABLE, v->index, false);
1745 if (BringWindowToFrontById(WC_VEHICLE_ORDERS, v->index) != nullptr) return;
1746
1747 /* Using a different WindowDescs for _local_company causes problems.
1748 * Due to this we have to close order windows in ChangeWindowOwner/CloseCompanyWindows,
1749 * because we cannot change switch the WindowDescs and keeping the old WindowDesc results
1750 * in crashed due to missing widges.
1751 * TODO Rewrite the order GUI to not use different WindowDescs.
1752 */
1753 if (v->owner != _local_company) {
1754 new OrdersWindow(&_other_orders_desc, v);
1755 } else {
1756 new OrdersWindow(v->IsGroundVehicle() ? &_orders_train_desc : &_orders_desc, v);
1757 }
1758 }
VEH_AIRCRAFT
@ VEH_AIRCRAFT
Aircraft vehicle type.
Definition: vehicle_type.h:27
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:720
_nested_other_orders_widgets
static const NWidgetPart _nested_other_orders_widgets[]
Nested widget definition for competitor orders.
Definition: order_gui.cpp:1715
WID_O_COND_VALUE
@ WID_O_COND_VALUE
Choose condition value.
Definition: order_widget.h:32
DA_STOP
@ DA_STOP
Go to the depot and stop there.
Definition: order_type.h:163
ConvertSpeedToDisplaySpeed
uint ConvertSpeedToDisplaySpeed(uint speed)
Convert the given (internal) speed to the display speed.
Definition: strings.cpp:765
BaseStation::facilities
StationFacility facilities
The facilities that this station has.
Definition: base_station_base.h:63
BaseConsist::cur_implicit_order_index
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
Definition: base_consist.h:29
VehicleOrderID
byte VehicleOrderID
The index of an order within its current vehicle (not pool related)
Definition: order_type.h:15
Order::IsRefit
bool IsRefit() const
Is this order a refit order.
Definition: order_base.h:118
Order::GetWaitTime
uint16 GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not).
Definition: order_base.h:193
OUFB_UNLOAD
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
Definition: order_type.h:54
Order::IsType
bool IsType(OrderType type) const
Check whether this order is of the given type.
Definition: order_base.h:71
order_cmd.h
Pool::PoolItem<&_engine_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
ScrollMainWindowToTile
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Definition: viewport.cpp:2456
OrdersWindow::OrderClick_Delete
void OrderClick_Delete()
Handle the click on the delete button.
Definition: order_gui.cpp:697
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1208
Vehicle::PreviousShared
Vehicle * PreviousShared() const
Get the previous vehicle of the shared vehicle chain.
Definition: vehicle_base.h:698
Order::SetLoadType
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
Definition: order_base.h:158
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:40
WID_O_SEL_TOP_LEFT
@ WID_O_SEL_TOP_LEFT
NWID_SELECTION widget for left part of the top row of the 'your train' order window.
Definition: order_widget.h:33
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:667
command_func.h
OrdersWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: order_gui.cpp:831
IsRailWaypointTile
static bool IsRailWaypointTile(TileIndex t)
Is this tile a station tile and a rail waypoint?
Definition: station_map.h:123
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
ODTFB_SERVICE
@ ODTFB_SERVICE
This depot order is because of the servicing limit.
Definition: order_type.h:95
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:320
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:144
dropdown_func.h
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:92
SetTimetableParams
void SetTimetableParams(int param1, int param2, Ticks ticks)
Set the timetable parameters in the format as described by the setting.
Definition: timetable_gui.cpp:47
MOF_COND_VARIABLE
@ MOF_COND_VARIABLE
A conditional variable changes.
Definition: order_type.h:149
OrderLoadFlags
OrderLoadFlags
Flags related to the loading order.
Definition: order_type.h:62
WID_O_REFIT
@ WID_O_REFIT
Select refit.
Definition: order_widget.h:26
OrdersWindow::OrderClick_StopSharing
void OrderClick_StopSharing()
Handle the click on the 'stop sharing' button.
Definition: order_gui.cpp:714
OrdersWindow::order_over
VehicleOrderID order_over
Order over which another order is dragged, INVALID_VEH_ORDER_ID if none.
Definition: order_gui.cpp:527
OrdersWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: order_gui.cpp:1344
OUFB_TRANSFER
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
Definition: order_type.h:55
OrdersWindow::DisplayPane
DisplayPane
Displayed planes of the NWID_SELECTION widgets.
Definition: order_gui.cpp:499
FACIL_TRUCK_STOP
@ FACIL_TRUCK_STOP
Station with truck stops.
Definition: station_type.h:54
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
Scrollbar::ScrollTowards
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:778
Station
Station data structure.
Definition: station_base.h:454
Order::GetDestination
DestinationID GetDestination() const
Gets the destination of this order.
Definition: order_base.h:104
OrdersWindow::OrderClick_Skip
void OrderClick_Skip()
Handle the click on the skip button.
Definition: order_gui.cpp:684
OrdersWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: order_gui.cpp:1156
OrdersWindow::DP_ROW_LOAD
@ DP_ROW_LOAD
Display 'load' / 'unload' / 'refit' buttons in the top row of the ship/airplane order window.
Definition: order_gui.cpp:517
Order::GetConditionValue
uint16 GetConditionValue() const
Get the value to base the skip on.
Definition: order_base.h:155
DrawOrderString
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.
Definition: order_gui.cpp:219
OrdersWindow::DP_ROW_CONDITIONAL
@ DP_ROW_CONDITIONAL
Display the conditional order buttons in the top row of the ship/airplane order window.
Definition: order_gui.cpp:519
vehiclelist.h
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:99
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1771
GUISettings::new_nonstop
bool new_nonstop
ttdpatch compatible nonstop handling
Definition: settings_type.h:114
VehiclesHaveSameOrderList
bool VehiclesHaveSameOrderList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicles have the same list of orders.
Definition: vehicle.cpp:3040
OrdersWindow::OrderClick_NearestDepot
void OrderClick_NearestDepot()
Handle the click on the service in nearest depot button.
Definition: order_gui.cpp:620
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
CargoSpec::Get
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Definition: cargotype.h:118
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
Order::Free
void Free()
'Free' the order
Definition: order_cmd.cpp:63
MOF_STOP_LOCATION
@ MOF_STOP_LOCATION
Passes an OrderStopLocation.
Definition: order_type.h:145
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
INVALID_TILE
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:108
_nested_orders_widgets
static const NWidgetPart _nested_orders_widgets[]
Nested widget definition for "your" orders (non-train).
Definition: order_gui.cpp:1642
IsDepotTypeTile
static bool IsDepotTypeTile(TileIndex tile, TransportType type)
Check if a tile is a depot and it is a depot of the given type.
Definition: depot_map.h:18
Order::GetUnloadType
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
Definition: order_base.h:139
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:715
WID_O_REFIT_DROPDOWN
@ WID_O_REFIT_DROPDOWN
Open refit options.
Definition: order_widget.h:29
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:257
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:995
aircraft.h
OrderDepotTypeFlags
OrderDepotTypeFlags
Reasons that could cause us to go to the depot.
Definition: order_type.h:93
OrdersWindow::UpdateAutoRefitState
void UpdateAutoRefitState()
Cache auto-refittability of the vehicle chain.
Definition: order_gui.cpp:753
SpecializedStation< Station, false >::Get
static Station * Get(size_t index)
Gets station with given index.
Definition: base_station_base.h:218
WID_O_SCROLLBAR
@ WID_O_SCROLLBAR
Order list scrollbar.
Definition: order_widget.h:18
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:644
WC_VEHICLE_TIMETABLE
@ WC_VEHICLE_TIMETABLE
Vehicle timetable; Window numbers:
Definition: window_type.h:217
MP_INDUSTRY
@ MP_INDUSTRY
Part of an industry.
Definition: tile_type.h:56
OrdersWindow::OnMouseDrag
void OnMouseDrag(Point pt, int widget) override
An 'object' is being dragged at the provided position, highlight the target if possible.
Definition: order_gui.cpp:1518
Window::owner
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition: window_gui.h:253
SA_RIGHT
@ SA_RIGHT
Right align the text (must be a single bit).
Definition: gfx_type.h:337
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:224
Industry
Defines the internal data of a functional industry.
Definition: industry.h:66
Vehicle::IsGroundVehicle
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
Definition: vehicle_base.h:498
Vehicle::owner
Owner owner
Which company owns the vehicle?
Definition: vehicle_base.h:288
_station_load_types
static const StringID _station_load_types[][5][5]
Order load types that could be given to station orders.
Definition: order_gui.cpp:44
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:634
WID_O_NON_STOP
@ WID_O_NON_STOP
Goto non-stop to destination.
Definition: order_widget.h:22
BaseStation::owner
Owner owner
The owner of this station.
Definition: base_station_base.h:62
ShowTimetableWindow
void ShowTimetableWindow(const Vehicle *v)
Show the timetable for a given vehicle.
Definition: timetable_gui.cpp:718
MOF_NON_STOP
@ MOF_NON_STOP
Passes an OrderNonStopFlags.
Definition: order_type.h:144
_colour_gradient
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: gfx.cpp:55
Aircraft::GetRange
uint16 GetRange() const
Get the range of this aircraft.
Definition: aircraft.h:133
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
OrderStopLocation
OrderStopLocation
Where to stop the trains.
Definition: order_type.h:83
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:973
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1109
OrdersWindow::OrderClick_Goto
void OrderClick_Goto(OrderPlaceObjectState type)
Handle the click on the goto button.
Definition: order_gui.cpp:568
OrdersWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: order_gui.cpp:1538
Industry::neutral_station
Station * neutral_station
Associated neutral station.
Definition: industry.h:69
OrdersWindow::OrderClick_Nonstop
void OrderClick_Nonstop(int non_stop)
Handle the click on the nonstop button.
Definition: order_gui.cpp:662
WID_O_EMPTY
@ WID_O_EMPTY
Placeholder for refit dropdown when not owner.
Definition: order_widget.h:28
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:890
textbuf_gui.h
ShowErrorMessage
void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x=0, int y=0, const GRFFile *textref_stack_grffile=nullptr, uint textref_stack_size=0, const uint32 *textref_stack=nullptr)
Display an error message in a window.
Definition: error_gui.cpp:377
WID_O_COND_VARIABLE
@ WID_O_COND_VARIABLE
Choose condition variable.
Definition: order_widget.h:30
Order::MakeGoToDepot
void MakeGoToDepot(DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action=ODATF_SERVICE_ONLY, CargoID cargo=CT_NO_REFIT)
Makes this order a Go To Depot order.
Definition: order_cmd.cpp:90
Order::GetType
OrderType GetType() const
Get the type of order of this order.
Definition: order_base.h:77
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
Order::GetStopLocation
OrderStopLocation GetStopLocation() const
Where must we stop at the platform?
Definition: order_base.h:143
ONSF_NO_STOP_AT_ANY_STATION
@ ONSF_NO_STOP_AT_ANY_STATION
The vehicle will not stop at any stations it passes including the destination.
Definition: order_type.h:76
WindowDesc
High level window description.
Definition: window_gui.h:102
OrdersWindow::OnDragDrop
void OnDragDrop(Point pt, int widget) override
A dragged 'object' has been released.
Definition: order_gui.cpp:1387
GetOrderDistance
uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle *v, int conditional_depth)
Get the distance between two orders of a vehicle.
Definition: order_cmd.cpp:710
WID_O_SEL_TOP_MIDDLE
@ WID_O_SEL_TOP_MIDDLE
NWID_SELECTION widget for middle part of the top row of the 'your train' order window.
Definition: order_widget.h:34
WID_O_SKIP
@ WID_O_SKIP
Skip current order.
Definition: order_widget.h:19
company_cmd.h
ANIMCURSOR_PICKSTATION
static const CursorID ANIMCURSOR_PICKSTATION
716 - 718 - goto-order icon
Definition: sprites.h:1499
ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
Definition: order_type.h:74
Order::GetNonStopType
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
Definition: order_base.h:141
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:467
Vehicle::Orders
IterateWrapper Orders() const
Returns an iterable ensemble of orders of a vehicle.
Definition: vehicle_base.h:1052
FACIL_BUS_STOP
@ FACIL_BUS_STOP
Station with bus stops.
Definition: station_type.h:55
OLF_FULL_LOAD_ANY
@ OLF_FULL_LOAD_ANY
Full load a single cargo of the consist.
Definition: order_type.h:65
EF_AUTO_REFIT
@ EF_AUTO_REFIT
Automatic refitting is allowed.
Definition: engine_type.h:171
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:90
OrdersWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: order_gui.cpp:1321
Order::GetRefitCargo
CargoID GetRefitCargo() const
Get the cargo to to refit to.
Definition: order_base.h:132
timetable.h
OrdersWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: order_gui.cpp:1441
OrdersWindow::can_do_autorefit
bool can_do_autorefit
Vehicle chain can be auto-refitted.
Definition: order_gui.cpp:532
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
ONSF_STOP_EVERYWHERE
@ ONSF_STOP_EVERYWHERE
The vehicle will stop at any station it passes and the destination.
Definition: order_type.h:73
WC_VEHICLE_VIEW
@ WC_VEHICLE_VIEW
Vehicle view; Window numbers:
Definition: window_type.h:332
tilehighlight_func.h
Window::EnableWidget
void EnableWidget(byte widget_index)
Sets a widget to Enabled.
Definition: window_gui.h:340
WidgetDimensions::hsep_normal
int hsep_normal
Normal horizontal spacing.
Definition: window_gui.h:63
INVALID_VEH_ORDER_ID
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
Definition: order_type.h:21
Industry::GetByTile
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Definition: industry.h:144
_order_conditional_variable
static const OrderConditionVariable _order_conditional_variable[]
Variables for conditional orders; this defines the order of appearance in the dropdown box.
Definition: order_gui.cpp:157
Vehicle::tile
TileIndex tile
Current tile index.
Definition: vehicle_base.h:245
MOF_COND_COMPARATOR
@ MOF_COND_COMPARATOR
A comparator changes.
Definition: order_type.h:150
Order::MakeGoToWaypoint
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
Definition: order_cmd.cpp:104
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:1004
TransportType
TransportType
Available types of transport.
Definition: transport_type.h:19
OrdersWindow::OrderClick_Service
void OrderClick_Service(int i)
Handle the click on the service.
Definition: order_gui.cpp:605
OUF_UNLOAD_IF_POSSIBLE
@ OUF_UNLOAD_IF_POSSIBLE
Unload all cargo that the station accepts.
Definition: order_type.h:53
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:721
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
OrdersWindow::DP_MIDDLE_SERVICE
@ DP_MIDDLE_SERVICE
Display 'service' in the middle button of the top row of the train/rv order window.
Definition: order_gui.cpp:510
OrdersWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: order_gui.cpp:1076
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:126
OrdersWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: order_gui.cpp:794
ShowDropDownList
void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, uint width, bool auto_width, bool instant_close)
Show a drop down list.
Definition: dropdown.cpp:450
WID_O_SEL_TOP_RIGHT
@ WID_O_SEL_TOP_RIGHT
NWID_SELECTION widget for right part of the top row of the 'your train' order window.
Definition: order_widget.h:35
dropdown_type.h
ODATFB_NEAREST_DEPOT
@ ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
Definition: order_type.h:105
OrdersWindow::OrderClick_FullLoad
void OrderClick_FullLoad(OrderLoadFlags load_type, bool toggle=false)
Handle the click on the full load button.
Definition: order_gui.cpp:587
OrdersWindow::DP_GROUNDVEHICLE_ROW_NORMAL
@ DP_GROUNDVEHICLE_ROW_NORMAL
Display the row for normal/depot orders in the top row of the train/rv order window.
Definition: order_gui.cpp:501
OrdersWindow::OrderGetSel
VehicleOrderID OrderGetSel() const
Return the memorised selected order.
Definition: order_gui.cpp:539
SA_FORCE
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
Definition: gfx_type.h:347
WC_VEHICLE_DETAILS
@ WC_VEHICLE_DETAILS
Vehicle details; Window numbers:
Definition: window_type.h:193
OCC_IS_TRUE
@ OCC_IS_TRUE
Skip if the variable is true.
Definition: order_type.h:134
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:321
WL_INFO
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
Definition: error.h:22
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
industry.h
safeguards.h
ShowQueryString
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
Definition: misc_gui.cpp:1115
DA_ALWAYS_GO
@ DA_ALWAYS_GO
Always go to the depot.
Definition: order_type.h:161
OrdersWindow::GetOrderFromPt
VehicleOrderID GetOrderFromPt(int y)
Calculate the selected order.
Definition: order_gui.cpp:553
IsTileOwner
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
Definition: tile_map.h:214
StrEmpty
static bool StrEmpty(const char *s)
Check if a string buffer is empty.
Definition: string_func.h:67
ODTFB_PART_OF_ORDERS
@ ODTFB_PART_OF_ORDERS
This depot order is because of a regular order.
Definition: order_type.h:96
Order::IsGotoOrder
bool IsGotoOrder() const
Is this a 'goto' order with a real destination?
Definition: order_base.h:94
Order::GetConditionComparator
OrderConditionComparator GetConditionComparator() const
What is the comparator to use?
Definition: order_base.h:151
TC_NO_SHADE
@ TC_NO_SHADE
Do not add shading to this text colour.
Definition: gfx_type.h:281
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:58
OrdersWindow::DP_MIDDLE_UNLOAD
@ DP_MIDDLE_UNLOAD
Display 'unload' in the middle button of the top row of the train/rv order window.
Definition: order_gui.cpp:509
HT_NONE
@ HT_NONE
default
Definition: tilehighlight_type.h:20
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1058
OrdersWindow::OrderPlaceObjectState
OrderPlaceObjectState
Under what reason are we using the PlaceObject functionality?
Definition: order_gui.cpp:490
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
error.h
ShowDropDownMenu
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
Definition: dropdown.cpp:487
FACIL_DOCK
@ FACIL_DOCK
Station with a dock.
Definition: station_type.h:57
Order::MakeGoToStation
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
Definition: order_cmd.cpp:75
Order::GetConditionSkipToOrder
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
Definition: order_base.h:153
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:241
OrdersWindow::DP_RIGHT_EMPTY
@ DP_RIGHT_EMPTY
Display an empty panel in the right button of the top row of the train/rv order window.
Definition: order_gui.cpp:513
GfxFillRect
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.
Definition: gfx.cpp:116
Vehicle::IsOrderListShared
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
Definition: vehicle_base.h:710
OLF_LOAD_IF_POSSIBLE
@ OLF_LOAD_IF_POSSIBLE
Load as long as there is cargo that fits in the train.
Definition: order_type.h:63
NWidgetStacked::SetDisplayedPlane
void SetDisplayedPlane(int plane)
Select which plane to show (for NWID_SELECTION only).
Definition: widget.cpp:1409
Order::SetStopLocation
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
Definition: order_base.h:164
viewport_func.h
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:441
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
ODATFB_HALT
@ ODATFB_HALT
Service the vehicle and then halt it.
Definition: order_type.h:104
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
WID_O_SEL_BOTTOM_MIDDLE
@ WID_O_SEL_BOTTOM_MIDDLE
NWID_SELECTION widget for the middle part of the bottom row of the 'your train' order window.
Definition: order_widget.h:38
HT_VEHICLE
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
Definition: tilehighlight_type.h:27
OrdersWindow::DP_RIGHT_REFIT
@ DP_RIGHT_REFIT
Display 'refit' in the right button of the top row of the train/rv order window.
Definition: order_gui.cpp:514
HT_DRAG
@ HT_DRAG
dragging items in the depot windows
Definition: tilehighlight_type.h:24
VIWD_CONSIST_CHANGED
@ VIWD_CONSIST_CHANGED
Vehicle composition was changed.
Definition: vehicle_gui.h:36
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:993
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
OrdersWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: order_gui.cpp:1506
BaseConsist::cur_real_order_index
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
Definition: base_consist.h:28
ONSF_NO_STOP_AT_DESTINATION_STATION
@ ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
Definition: order_type.h:75
WID_O_ORDER_LIST
@ WID_O_ORDER_LIST
Order list panel.
Definition: order_widget.h:17
string_func.h
Vehicle::FirstShared
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
Definition: vehicle_base.h:704
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:105
OrderUnloadFlags
OrderUnloadFlags
Flags related to the unloading order.
Definition: order_type.h:52
IsBuoyTile
static bool IsBuoyTile(TileIndex t)
Is tile t a buoy tile?
Definition: station_map.h:316
WID_O_SHARED_ORDER_LIST
@ WID_O_SHARED_ORDER_LIST
Open list of shared vehicles.
Definition: order_widget.h:39
GUISettings::quick_goto
bool quick_goto
Allow quick access to 'goto button' in vehicle orders window.
Definition: settings_type.h:156
vehicle_func.h
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1094
OrdersWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: order_gui.cpp:1420
station_base.h
Clamp
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
Definition: math_func.hpp:77
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
OCV_MAX_SPEED
@ OCV_MAX_SPEED
Skip based on the maximum speed.
Definition: order_type.h:115
OSL_PLATFORM_FAR_END
@ OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
Definition: order_type.h:86
MOF_UNLOAD
@ MOF_UNLOAD
Passes an OrderUnloadType.
Definition: order_type.h:146
WID_O_COND_COMPARATOR
@ WID_O_COND_COMPARATOR
Choose condition type.
Definition: order_widget.h:31
NWidgetCore::SetDataTip
void SetDataTip(uint32 widget_data, StringID tool_tip)
Set data and tool tip of the nested widget.
Definition: widget.cpp:1176
HideDropDownMenu
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
Definition: dropdown.cpp:505
OCV_RELIABILITY
@ OCV_RELIABILITY
Skip based on the reliability.
Definition: order_type.h:114
FACIL_TRAIN
@ FACIL_TRAIN
Station with train station.
Definition: station_type.h:53
Window::CloseChildWindows
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
Definition: window.cpp:1091
Vehicle::GetFirstOrder
Order * GetFirstOrder() const
Get the first order of the vehicles order list.
Definition: vehicle_base.h:683
SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From
static Aircraft * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Definition: vehicle_base.h:1183
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:206
VIWD_AUTOREPLACE
@ VIWD_AUTOREPLACE
Autoreplace replaced the vehicle.
Definition: vehicle_gui.h:37
GUISettings::stop_location
uint8 stop_location
what is the default stop location of trains?
Definition: settings_type.h:115
GetOrderCmdFromTile
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
Get the order command a vehicle can do in a given tile.
Definition: order_gui.cpp:364
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1227
WID_O_SEL_TOP_ROW_GROUNDVEHICLE
@ WID_O_SEL_TOP_ROW_GROUNDVEHICLE
NWID_SELECTION widget for the top row of the 'your train' order window.
Definition: order_widget.h:36
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:686
OCV_REMAINING_LIFETIME
@ OCV_REMAINING_LIFETIME
Skip based on the remaining lifetime.
Definition: order_type.h:119
geometry_func.hpp
OUFB_NO_UNLOAD
@ OUFB_NO_UNLOAD
Totally no unloading will be done.
Definition: order_type.h:56
order_widget.h
WID_O_TIMETABLE_VIEW
@ WID_O_TIMETABLE_VIEW
Toggle timetable view.
Definition: order_widget.h:16
SetDParamMaxValue
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Definition: strings.cpp:95
WID_O_SERVICE
@ WID_O_SERVICE
Select service (at depot).
Definition: order_widget.h:27
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1012
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
Vehicle::NextShared
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
Definition: vehicle_base.h:692
OWNER_NONE
@ OWNER_NONE
The tile has no ownership.
Definition: company_type.h:25
MOF_COND_VALUE
@ MOF_COND_VALUE
The value to set the condition to.
Definition: order_type.h:151
OrdersWindow::DP_ROW_DEPOT
@ DP_ROW_DEPOT
Display 'refit' / 'service' buttons in the top row of the ship/airplane order window.
Definition: order_gui.cpp:518
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:189
CT_AUTO_REFIT
@ CT_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
Definition: cargo_type.h:67
MP_STATION
@ MP_STATION
A tile of a station.
Definition: tile_type.h:53
SpecializedStation< Station, false >::GetByTile
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
Definition: base_station_base.h:237
GetStationIndex
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
Definition: station_map.h:28
waypoint_base.h
EventState
EventState
State of handling an event.
Definition: window_type.h:719
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:676
ConvertDisplaySpeedToSpeed
uint ConvertDisplaySpeedToSpeed(uint speed)
Convert the given display speed to the (internal) speed.
Definition: strings.cpp:778
OrdersWindow
Order window code for all vehicles.
Definition: order_gui.cpp:487
Order::SetDepotOrderType
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
Definition: order_base.h:166
CargoSpec::name
StringID name
Name of this type of cargo.
Definition: cargotype.h:71
Order::IsAutoRefit
bool IsAutoRefit() const
Is this order a auto-refit order.
Definition: order_base.h:125
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1787
depot_map.h
OrdersWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: order_gui.cpp:1066
Order::SetDepotActionType
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
Definition: order_base.h:168
company_func.h
OCV_LOAD_PERCENTAGE
@ OCV_LOAD_PERCENTAGE
Skip based on the amount of load.
Definition: order_type.h:113
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:247
Order::MakeConditional
void MakeConditional(VehicleOrderID order)
Makes this order an conditional order.
Definition: order_cmd.cpp:143
WidgetDimensions::framerect
RectPadding framerect
Offsets within frame area.
Definition: window_gui.h:47
HighLightStyle
HighLightStyle
Highlighting draw styles.
Definition: tilehighlight_type.h:19
Order::GetDepotOrderType
OrderDepotTypeFlags GetDepotOrderType() const
What caused us going to the depot?
Definition: order_base.h:145
network.h
CommandHelper
Definition: command_func.h:94
Order::GetConditionVariable
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
Definition: order_base.h:149
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2427
WID_O_UNLOAD
@ WID_O_UNLOAD
Select unload.
Definition: order_widget.h:25
WID_O_CAPTION
@ WID_O_CAPTION
Caption of the window.
Definition: order_widget.h:15
OrdersWindow::OnVehicleSelect
bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end) override
Clones an order list from a vehicle list.
Definition: order_gui.cpp:1478
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1187
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:200
OrderConditionVariable
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
Definition: order_type.h:112
SetObjectToPlaceWnd
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...
Definition: viewport.cpp:3371
OrdersWindow::can_do_refit
bool can_do_refit
Vehicle chain can be refitted in depot.
Definition: order_gui.cpp:531
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1078
Order::GetLocation
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
Definition: order_cmd.cpp:683
SPR_CURSOR_MOUSE
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Definition: sprites.h:1378
WID_O_DELETE
@ WID_O_DELETE
Delete selected order.
Definition: order_widget.h:20
IsEngineRefittable
bool IsEngineRefittable(EngineID engine)
Check if an engine is refittable.
Definition: engine.cpp:1209
OrdersWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: order_gui.cpp:1135
OCV_REQUIRES_SERVICE
@ OCV_REQUIRES_SERVICE
Skip when the vehicle requires service.
Definition: order_type.h:117
Window
Data structure for an opened window.
Definition: window_gui.h:213
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
WID_O_SEL_TOP_ROW
@ WID_O_SEL_TOP_ROW
NWID_SELECTION widget for the top row of the 'your non-trains' order window.
Definition: order_widget.h:37
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:412
WID_O_FULL_LOAD
@ WID_O_FULL_LOAD
Select full load.
Definition: order_widget.h:24
Vehicle::GetOrder
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or nullptr when it doesn't exists.
Definition: vehicle_base.h:890
OrdersWindow::DP_LEFT_REFIT
@ DP_LEFT_REFIT
Display 'refit' in the left button of the top row of the train/rv order window.
Definition: order_gui.cpp:506
BaseVehicle::type
VehicleType type
Type of vehicle.
Definition: vehicle_type.h:52
OrdersWindow::OrderClick_Refit
void OrderClick_Refit(int i, bool auto_refit)
Handle the click on the refit button.
Definition: order_gui.cpp:738
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:858
AllEqual
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 ...
Definition: window_gui.h:830
FACIL_AIRPORT
@ FACIL_AIRPORT
Station with an airport.
Definition: station_type.h:56
OrdersWindow::DP_LEFT_LOAD
@ DP_LEFT_LOAD
Display 'load' in the left button of the top row of the train/rv order window.
Definition: order_gui.cpp:505
VIWD_MODIFY_ORDERS
@ VIWD_MODIFY_ORDERS
Other order modifications.
Definition: vehicle_gui.h:35
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
CanVehicleUseStation
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
Can this station be used by the given engine type?
Definition: vehicle.cpp:2861
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:78
NWidgetCore
Base class for a 'real' widget.
Definition: widget_type.h:314
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:619
VEH_SHIP
@ VEH_SHIP
Ship vehicle type.
Definition: vehicle_type.h:26
OCV_MAX_RELIABILITY
@ OCV_MAX_RELIABILITY
Skip based on the maximum reliability.
Definition: order_type.h:120
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
OrdersWindow::DP_GROUNDVEHICLE_ROW_CONDITIONAL
@ DP_GROUNDVEHICLE_ROW_CONDITIONAL
Display the row for conditional orders in the top row of the train/rv order window.
Definition: order_gui.cpp:502
CursorVars::pos
Point pos
logical mouse position
Definition: gfx_type.h:117
BringWindowToFrontById
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
Definition: window.cpp:1270
MOF_LOAD
@ MOF_LOAD
Passes an OrderLoadType.
Definition: order_type.h:147
OCC_IS_FALSE
@ OCC_IS_FALSE
Skip if the variable is false.
Definition: order_type.h:135
Vehicle::GetNumOrders
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
Definition: vehicle_base.h:716
VIWD_REMOVE_ALL_ORDERS
@ VIWD_REMOVE_ALL_ORDERS
Removed / replaced all orders (after deleting / sharing).
Definition: vehicle_gui.h:34
CT_NO_REFIT
@ CT_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
Definition: cargo_type.h:68
Order::GetDepotActionType
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
Definition: order_base.h:147
ShowVehicleRefitWindow
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
Show the refit window for a vehicle.
Definition: vehicle_gui.cpp:1243
OrdersWindow::OrderClick_Unload
void OrderClick_Unload(OrderUnloadFlags unload_type, bool toggle=false)
Handle the click on the unload button.
Definition: order_gui.cpp:637
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:331
_nested_orders_train_widgets
static const NWidgetPart _nested_orders_train_widgets[]
Nested widget definition for "your" train orders.
Definition: order_gui.cpp:1564
Order::next
Order * next
Pointer to next order. If nullptr, end of list.
Definition: order_base.h:59
WID_O_STOP_SHARING
@ WID_O_STOP_SHARING
Stop sharing orders.
Definition: order_widget.h:21
MOF_DEPOT_ACTION
@ MOF_DEPOT_ACTION
Selects the OrderDepotAction.
Definition: order_type.h:148
Order
Definition: order_base.h:36
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3434
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:382
DA_SERVICE
@ DA_SERVICE
Service only if needed.
Definition: order_type.h:162
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:49
CS_NUMERAL
@ CS_NUMERAL
Only numeric ones.
Definition: string_type.h:28
OCV_AGE
@ OCV_AGE
Skip based on the age.
Definition: order_type.h:116
Order::IsWaitTimetabled
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
Definition: order_base.h:184
Order::SetNonStopType
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
Definition: order_base.h:162
GetDepotIndex
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
Definition: depot_map.h:52
OrderConditionComparator
OrderConditionComparator
Comparator for the skip reasoning.
Definition: order_type.h:127
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
WC_VEHICLE_ORDERS
@ WC_VEHICLE_ORDERS
Vehicle orders; Window numbers:
Definition: window_type.h:205
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:604
NWID_BUTTON_DROPDOWN
@ NWID_BUTTON_DROPDOWN
Button with a drop-down.
Definition: widget_type.h:80
OCV_UNCONDITIONALLY
@ OCV_UNCONDITIONALLY
Always skip.
Definition: order_type.h:118
OLFB_NO_LOAD
@ OLFB_NO_LOAD
Do not load anything.
Definition: order_type.h:66
WWT_DROPDOWN
@ WWT_DROPDOWN
Drop down list.
Definition: widget_type.h:68
Order::GetLoadType
OrderLoadFlags GetLoadType() const
How must the consist be loaded?
Definition: order_base.h:137
engine_func.h
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
hotkeys.h
roadveh.h
WID_O_GOTO
@ WID_O_GOTO
Goto destination.
Definition: order_widget.h:23
OrdersWindow::DP_BOTTOM_MIDDLE_STOP_SHARING
@ DP_BOTTOM_MIDDLE_STOP_SHARING
Display 'stop sharing' in the middle button of the bottom row of the vehicle order window.
Definition: order_gui.cpp:523
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62
OrdersWindow::vehicle
const Vehicle * vehicle
Vehicle owning the orders being displayed and manipulated.
Definition: order_gui.cpp:529
OrdersWindow::DP_BOTTOM_MIDDLE_DELETE
@ DP_BOTTOM_MIDDLE_DELETE
Display 'delete' in the middle button of the bottom row of the vehicle order window.
Definition: order_gui.cpp:522