OpenTTD Source  1.11.0-beta1
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 
33 #include "widgets/order_widget.h"
34 
35 #include "safeguards.h"
36 
37 
39 static const StringID _station_load_types[][5][5] = {
40  {
41  /* No refitting. */
42  {
43  STR_EMPTY,
45  STR_ORDER_FULL_LOAD,
46  STR_ORDER_FULL_LOAD_ANY,
47  STR_ORDER_NO_LOAD,
48  }, {
49  STR_ORDER_UNLOAD,
51  STR_ORDER_UNLOAD_FULL_LOAD,
52  STR_ORDER_UNLOAD_FULL_LOAD_ANY,
53  STR_ORDER_UNLOAD_NO_LOAD,
54  }, {
55  STR_ORDER_TRANSFER,
57  STR_ORDER_TRANSFER_FULL_LOAD,
58  STR_ORDER_TRANSFER_FULL_LOAD_ANY,
59  STR_ORDER_TRANSFER_NO_LOAD,
60  }, {
61  /* Unload and transfer do not work together. */
66  }, {
67  STR_ORDER_NO_UNLOAD,
69  STR_ORDER_NO_UNLOAD_FULL_LOAD,
70  STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
71  STR_ORDER_NO_UNLOAD_NO_LOAD,
72  }
73  }, {
74  /* With auto-refitting. No loading and auto-refitting do not work together. */
75  {
76  STR_ORDER_AUTO_REFIT,
78  STR_ORDER_FULL_LOAD_REFIT,
79  STR_ORDER_FULL_LOAD_ANY_REFIT,
81  }, {
82  STR_ORDER_UNLOAD_REFIT,
84  STR_ORDER_UNLOAD_FULL_LOAD_REFIT,
85  STR_ORDER_UNLOAD_FULL_LOAD_ANY_REFIT,
87  }, {
88  STR_ORDER_TRANSFER_REFIT,
90  STR_ORDER_TRANSFER_FULL_LOAD_REFIT,
91  STR_ORDER_TRANSFER_FULL_LOAD_ANY_REFIT,
93  }, {
94  /* Unload and transfer do not work together. */
99  }, {
100  STR_ORDER_NO_UNLOAD_REFIT,
102  STR_ORDER_NO_UNLOAD_FULL_LOAD_REFIT,
103  STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY_REFIT,
105  }
106  }
107 };
108 
109 static const StringID _order_non_stop_drowdown[] = {
110  STR_ORDER_GO_TO,
111  STR_ORDER_GO_NON_STOP_TO,
112  STR_ORDER_GO_VIA,
113  STR_ORDER_GO_NON_STOP_VIA,
115 };
116 
117 static const StringID _order_full_load_drowdown[] = {
118  STR_ORDER_DROP_LOAD_IF_POSSIBLE,
119  STR_EMPTY,
120  STR_ORDER_DROP_FULL_LOAD_ALL,
121  STR_ORDER_DROP_FULL_LOAD_ANY,
122  STR_ORDER_DROP_NO_LOADING,
124 };
125 
126 static const StringID _order_unload_drowdown[] = {
127  STR_ORDER_DROP_UNLOAD_IF_ACCEPTED,
128  STR_ORDER_DROP_UNLOAD,
129  STR_ORDER_DROP_TRANSFER,
130  STR_EMPTY,
131  STR_ORDER_DROP_NO_UNLOADING,
133 };
134 
135 static const StringID _order_goto_dropdown[] = {
136  STR_ORDER_GO_TO,
137  STR_ORDER_GO_TO_NEAREST_DEPOT,
138  STR_ORDER_CONDITIONAL,
139  STR_ORDER_SHARE,
141 };
142 
143 static const StringID _order_goto_dropdown_aircraft[] = {
144  STR_ORDER_GO_TO,
145  STR_ORDER_GO_TO_NEAREST_HANGAR,
146  STR_ORDER_CONDITIONAL,
147  STR_ORDER_SHARE,
149 };
150 
157  OCV_AGE,
161 };
162 
163 static const StringID _order_conditional_condition[] = {
164  STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS,
165  STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS,
166  STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN,
167  STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS,
168  STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN,
169  STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS,
170  STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE,
171  STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE,
173 };
174 
175 extern uint ConvertSpeedToDisplaySpeed(uint speed);
176 extern uint ConvertDisplaySpeedToSpeed(uint speed);
177 
178 static const StringID _order_depot_action_dropdown[] = {
179  STR_ORDER_DROP_GO_ALWAYS_DEPOT,
180  STR_ORDER_DROP_SERVICE_DEPOT,
181  STR_ORDER_DROP_HALT_DEPOT,
183 };
184 
185 static int DepotActionStringIndex(const Order *order)
186 {
187  if (order->GetDepotActionType() & ODATFB_HALT) {
188  return DA_STOP;
189  } else if (order->GetDepotOrderType() & ODTFB_SERVICE) {
190  return DA_SERVICE;
191  } else {
192  return DA_ALWAYS_GO;
193  }
194 }
195 
196 static const StringID _order_refit_action_dropdown[] = {
197  STR_ORDER_DROP_REFIT_AUTO,
198  STR_ORDER_DROP_REFIT_AUTO_ANY,
200 };
201 
214 void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable, int left, int middle, int right)
215 {
216  bool rtl = _current_text_dir == TD_RTL;
217 
218  SpriteID sprite = rtl ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT;
219  Dimension sprite_size = GetSpriteSize(sprite);
220  if (v->cur_real_order_index == order_index) {
221  DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
222  DrawSprite(sprite, PAL_NONE, rtl ? right - 2 * sprite_size.width : left + sprite_size.width, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
223  } else if (v->cur_implicit_order_index == order_index) {
224  DrawSprite(sprite, PAL_NONE, rtl ? right - sprite_size.width : left, y + ((int)FONT_HEIGHT_NORMAL - (int)sprite_size.height) / 2);
225  }
226 
227  TextColour colour = TC_BLACK;
228  if (order->IsType(OT_IMPLICIT)) {
229  colour = (selected ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
230  } else if (selected) {
231  colour = TC_WHITE;
232  }
233 
234  SetDParam(0, order_index + 1);
235  DrawString(left, rtl ? right - 2 * sprite_size.width - 3 : middle, y, STR_ORDER_INDEX, colour, SA_RIGHT | SA_FORCE);
236 
237  SetDParam(5, STR_EMPTY);
238  SetDParam(8, STR_EMPTY);
239 
240  /* Check range for aircraft. */
241  if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->GetRange() > 0 && order->IsGotoOrder()) {
242  const Order *next = order->next != nullptr ? order->next : v->GetFirstOrder();
243  if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(8, STR_ORDER_OUT_OF_RANGE);
244  }
245 
246  switch (order->GetType()) {
247  case OT_DUMMY:
248  SetDParam(0, STR_INVALID_ORDER);
249  SetDParam(1, order->GetDestination());
250  break;
251 
252  case OT_IMPLICIT:
253  SetDParam(0, STR_ORDER_GO_TO_STATION);
254  SetDParam(1, STR_ORDER_GO_TO);
255  SetDParam(2, order->GetDestination());
256  SetDParam(3, timetable ? STR_EMPTY : STR_ORDER_IMPLICIT);
257  break;
258 
259  case OT_GOTO_STATION: {
260  OrderLoadFlags load = order->GetLoadType();
261  OrderUnloadFlags unload = order->GetUnloadType();
262  bool valid_station = CanVehicleUseStation(v, Station::Get(order->GetDestination()));
263 
264  SetDParam(0, valid_station ? STR_ORDER_GO_TO_STATION : STR_ORDER_GO_TO_STATION_CAN_T_USE_STATION);
265  SetDParam(1, STR_ORDER_GO_TO + (v->IsGroundVehicle() ? order->GetNonStopType() : 0));
266  SetDParam(2, order->GetDestination());
267 
268  if (timetable) {
269  SetDParam(3, STR_EMPTY);
270 
271  if (order->GetWaitTime() > 0) {
272  SetDParam(5, order->IsWaitTimetabled() ? STR_TIMETABLE_STAY_FOR : STR_TIMETABLE_STAY_FOR_ESTIMATED);
273  SetTimetableParams(6, 7, order->GetWaitTime());
274  }
275  } else {
276  SetDParam(3, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[order->IsRefit()][unload][load]);
277  if (order->IsRefit()) {
278  SetDParam(4, order->IsAutoRefit() ? STR_ORDER_AUTO_REFIT_ANY : CargoSpec::Get(order->GetRefitCargo())->name);
279  }
280  if (v->type == VEH_TRAIN && (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) == 0) {
281  SetDParam(5, order->GetStopLocation() + STR_ORDER_STOP_LOCATION_NEAR_END);
282  }
283  }
284  break;
285  }
286 
287  case OT_GOTO_DEPOT:
288  if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) {
289  SetDParam(0, STR_ORDER_GO_TO_NEAREST_DEPOT_FORMAT);
290  if (v->type == VEH_AIRCRAFT) {
291  SetDParam(2, STR_ORDER_NEAREST_HANGAR);
292  SetDParam(3, STR_EMPTY);
293  } else {
294  SetDParam(2, STR_ORDER_NEAREST_DEPOT);
295  SetDParam(3, STR_ORDER_TRAIN_DEPOT + v->type);
296  }
297  } else {
298  SetDParam(0, STR_ORDER_GO_TO_DEPOT_FORMAT);
299  SetDParam(2, v->type);
300  SetDParam(3, order->GetDestination());
301  }
302 
303  if (order->GetDepotOrderType() & ODTFB_SERVICE) {
304  SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_SERVICE_NON_STOP_AT : STR_ORDER_SERVICE_AT);
305  } else {
306  SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO);
307  }
308 
309  if (!timetable && (order->GetDepotActionType() & ODATFB_HALT)) {
310  SetDParam(5, STR_ORDER_STOP_ORDER);
311  }
312 
313  if (!timetable && order->IsRefit()) {
314  SetDParam(5, (order->GetDepotActionType() & ODATFB_HALT) ? STR_ORDER_REFIT_STOP_ORDER : STR_ORDER_REFIT_ORDER);
316  }
317  break;
318 
319  case OT_GOTO_WAYPOINT:
320  SetDParam(0, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO_WAYPOINT : STR_ORDER_GO_TO_WAYPOINT);
321  SetDParam(1, order->GetDestination());
322  break;
323 
324  case OT_CONDITIONAL:
325  SetDParam(1, order->GetConditionSkipToOrder() + 1);
326  if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) {
327  SetDParam(0, STR_ORDER_CONDITIONAL_UNCONDITIONAL);
328  } else {
330  SetDParam(0, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_ORDER_CONDITIONAL_TRUE_FALSE : STR_ORDER_CONDITIONAL_NUM);
331  SetDParam(2, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable());
332  SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ);
333 
334  uint value = order->GetConditionValue();
335  if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
336  SetDParam(4, value);
337  }
338 
339  if (timetable && order->GetWaitTime() > 0) {
340  SetDParam(5, order->IsWaitTimetabled() ? STR_TIMETABLE_AND_TRAVEL_FOR : STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED);
341  SetTimetableParams(6, 7, order->GetWaitTime());
342  } else {
343  SetDParam(5, STR_EMPTY);
344  }
345  break;
346 
347  default: NOT_REACHED();
348  }
349 
350  DrawString(rtl ? left : middle, rtl ? middle : right, y, STR_ORDER_TEXT, colour);
351 }
352 
360 {
361  /* Hack-ish; unpack order 0, so everything gets initialised with either zero
362  * or a suitable default value for the variable. Then also override the index
363  * as it is not coming from a pool, so would be initialised. */
364  Order order(0);
365  order.index = 0;
366 
367  /* check depot first */
368  if (IsDepotTypeTile(tile, (TransportType)(uint)v->type) && IsTileOwner(tile, _local_company)) {
369  order.MakeGoToDepot(v->type == VEH_AIRCRAFT ? GetStationIndex(tile) : GetDepotIndex(tile),
372 
374 
375  return order;
376  }
377 
378  /* check rail waypoint */
379  if (IsRailWaypointTile(tile) &&
380  v->type == VEH_TRAIN &&
381  IsTileOwner(tile, _local_company)) {
382  order.MakeGoToWaypoint(GetStationIndex(tile));
384  return order;
385  }
386 
387  /* check buoy (no ownership) */
388  if (IsBuoyTile(tile) && v->type == VEH_SHIP) {
389  order.MakeGoToWaypoint(GetStationIndex(tile));
390  return order;
391  }
392 
393  /* check for station or industry with neutral station */
394  if (IsTileType(tile, MP_STATION) || IsTileType(tile, MP_INDUSTRY)) {
395  const Station *st = nullptr;
396 
397  if (IsTileType(tile, MP_STATION)) {
398  st = Station::GetByTile(tile);
399  } else {
400  const Industry *in = Industry::GetByTile(tile);
401  st = in->neutral_station;
402  }
403  if (st != nullptr && (st->owner == _local_company || st->owner == OWNER_NONE)) {
404  byte facil;
405  switch (v->type) {
406  case VEH_SHIP: facil = FACIL_DOCK; break;
407  case VEH_TRAIN: facil = FACIL_TRAIN; break;
408  case VEH_AIRCRAFT: facil = FACIL_AIRPORT; break;
409  case VEH_ROAD: facil = FACIL_BUS_STOP | FACIL_TRUCK_STOP; break;
410  default: NOT_REACHED();
411  }
412  if (st->facilities & facil) {
413  order.MakeGoToStation(st->index);
417  return order;
418  }
419  }
420  }
421 
422  /* not found */
423  order.Free();
424  return order;
425 }
426 
428 enum {
429  OHK_SKIP,
430  OHK_DELETE,
431  OHK_GOTO,
432  OHK_NONSTOP,
433  OHK_FULLLOAD,
434  OHK_UNLOAD,
435  OHK_NEAREST_DEPOT,
436  OHK_ALWAYS_SERVICE,
437  OHK_TRANSFER,
438  OHK_NO_UNLOAD,
439  OHK_NO_LOAD,
440 };
441 
482 struct OrdersWindow : public Window {
483 private:
486  OPOS_NONE,
487  OPOS_GOTO,
488  OPOS_CONDITIONAL,
489  OPOS_SHARE,
490  OPOS_END,
491  };
492 
494  enum DisplayPane {
495  /* WID_O_SEL_TOP_ROW_GROUNDVEHICLE */
498 
499  /* WID_O_SEL_TOP_LEFT */
502 
503  /* WID_O_SEL_TOP_MIDDLE */
506 
507  /* WID_O_SEL_TOP_RIGHT */
510 
511  /* WID_O_SEL_TOP_ROW */
515 
516  /* WID_O_SEL_BOTTOM_MIDDLE */
519  };
520 
521  int selected_order;
523  OrderPlaceObjectState goto_type;
524  const Vehicle *vehicle;
525  Scrollbar *vscroll;
528 
535  {
536  int num = this->selected_order;
537  return (num >= 0 && num < vehicle->GetNumOrders()) ? num : vehicle->GetNumOrders();
538  }
539 
549  {
550  NWidgetBase *nwid = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST);
551  int sel = (y - nwid->pos_y - WD_FRAMERECT_TOP) / nwid->resize_y; // Selected line in the WID_O_ORDER_LIST panel.
552 
553  if ((uint)sel >= this->vscroll->GetCapacity()) return INVALID_VEH_ORDER_ID;
554 
555  sel += this->vscroll->GetPosition();
556 
557  return (sel <= vehicle->GetNumOrders() && sel >= 0) ? sel : INVALID_VEH_ORDER_ID;
558  }
559 
564  {
565  assert(type > OPOS_NONE && type < OPOS_END);
566 
567  static const HighLightStyle goto_place_style[OPOS_END - 1] = {
568  HT_RECT | HT_VEHICLE, // OPOS_GOTO
569  HT_NONE, // OPOS_CONDITIONAL
570  HT_VEHICLE, // OPOS_SHARE
571  };
572  SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, goto_place_style[type - 1], this);
573  this->goto_type = type;
574  this->SetWidgetDirty(WID_O_GOTO);
575  }
576 
581  void OrderClick_FullLoad(int load_type)
582  {
583  VehicleOrderID sel_ord = this->OrderGetSel();
584  const Order *order = this->vehicle->GetOrder(sel_ord);
585 
586  if (order == nullptr || order->GetLoadType() == load_type) return;
587 
588  if (load_type < 0) {
590  }
591  DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (load_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
592  }
593 
598  {
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;
613  }
614  DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_DEPOT_ACTION | (i << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
615  }
616 
621  {
622  Order order;
623  order.next = nullptr;
624  order.index = 0;
628 
629  DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
630  }
631 
635  void OrderClick_Unload(int unload_type)
636  {
637  VehicleOrderID sel_ord = this->OrderGetSel();
638  const Order *order = this->vehicle->GetOrder(sel_ord);
639 
640  if (order == nullptr || order->GetUnloadType() == unload_type) return;
641 
642  if (unload_type < 0) {
644  }
645 
646  DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_UNLOAD | (unload_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
647 
648  /* Transfer orders with leave empty as default */
649  if (unload_type == OUFB_TRANSFER) {
650  DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (OLFB_NO_LOAD << 4), CMD_MODIFY_ORDER);
652  }
653  }
654 
659  {
661  }
662 
667  {
669  }
670 
675  void OrderClick_Nonstop(int non_stop)
676  {
677  if (!this->vehicle->IsGroundVehicle()) return;
678 
679  VehicleOrderID sel_ord = this->OrderGetSel();
680  const Order *order = this->vehicle->GetOrder(sel_ord);
681 
682  if (order == nullptr || order->GetNonStopType() == non_stop) return;
683 
684  /* Keypress if negative, so 'toggle' to the next */
685  if (non_stop < 0) {
687  }
688 
690  DoCommandP(this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_NON_STOP | non_stop << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
691  }
692 
698  {
699  /* Don't skip when there's nothing to skip */
700  if (_ctrl_pressed && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return;
701  if (this->vehicle->GetNumOrders() <= 1) return;
702 
703  DoCommandP(this->vehicle->tile, this->vehicle->index, _ctrl_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()),
704  CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER));
705  }
706 
711  {
712  /* When networking, move one order lower */
713  int selected = this->selected_order + (int)_networking;
714 
715  if (DoCommandP(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), CMD_DELETE_ORDER | CMD_MSG(STR_ERROR_CAN_T_DELETE_THIS_ORDER))) {
716  this->selected_order = selected >= this->vehicle->GetNumOrders() ? -1 : selected;
717  this->UpdateButtonState();
718  }
719  }
720 
728  {
729  /* Don't try to stop sharing orders if 'End of Shared Orders' isn't selected. */
730  if (!this->vehicle->IsOrderListShared() || this->selected_order != this->vehicle->GetNumOrders()) return;
731  /* If Ctrl is pressed, delete the order list as if we clicked the 'Delete' button. */
732  if (_ctrl_pressed) {
733  this->OrderClick_Delete();
734  return;
735  }
736 
737  /* Get another vehicle that share orders with this vehicle. */
738  Vehicle *other_shared = (this->vehicle->FirstShared() == this->vehicle) ? this->vehicle->NextShared() : this->vehicle->PreviousShared();
739  /* Copy the order list of the other vehicle. */
740  if (DoCommandP(this->vehicle->tile, this->vehicle->index | CO_COPY << 30, other_shared->index, CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST))) {
741  this->UpdateButtonState();
742  }
743  }
744 
751  void OrderClick_Refit(int i, bool auto_refit)
752  {
753  if (_ctrl_pressed) {
754  /* Cancel refitting */
755  DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, CMD_ORDER_REFIT);
756  } else {
757  if (i == 1) { // Auto-refit to available cargo type.
758  DoCommandP(this->vehicle->tile, this->vehicle->index, (this->OrderGetSel() << 16) | CT_AUTO_REFIT, CMD_ORDER_REFIT);
759  } else {
760  ShowVehicleRefitWindow(this->vehicle, this->OrderGetSel(), this, auto_refit);
761  }
762  }
763  }
764 
767  {
768  this->can_do_refit = false;
769  this->can_do_autorefit = false;
770  for (const Vehicle *w = this->vehicle; w != nullptr; w = w->IsGroundVehicle() ? w->Next() : nullptr) {
771  if (IsEngineRefittable(w->engine_type)) this->can_do_refit = true;
772  if (HasBit(Engine::Get(w->engine_type)->info.misc_flags, EF_AUTO_REFIT)) this->can_do_autorefit = true;
773  }
774  }
775 
776 public:
777  OrdersWindow(WindowDesc *desc, const Vehicle *v) : Window(desc)
778  {
779  this->vehicle = v;
780 
781  this->CreateNestedTree();
782  this->vscroll = this->GetScrollbar(WID_O_SCROLLBAR);
783  this->FinishInitNested(v->index);
784  if (v->owner == _local_company) {
785  this->DisableWidget(WID_O_EMPTY);
786  }
787 
788  this->selected_order = -1;
789  this->order_over = INVALID_VEH_ORDER_ID;
790  this->goto_type = OPOS_NONE;
791  this->owner = v->owner;
792 
793  this->UpdateAutoRefitState();
794 
796  /* If there are less than 2 station, make Go To active. */
797  int station_orders = 0;
798  for(const Order *order : v->Orders()) {
799  if (order->IsType(OT_GOTO_STATION)) station_orders++;
800  }
801 
802  if (station_orders < 2) this->OrderClick_Goto(OPOS_GOTO);
803  }
805  }
806 
807  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
808  {
809  switch (widget) {
810  case WID_O_ORDER_LIST:
811  resize->height = FONT_HEIGHT_NORMAL;
812  size->height = 6 * resize->height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
813  break;
814 
815  case WID_O_COND_VARIABLE: {
816  Dimension d = {0, 0};
817  for (uint i = 0; i < lengthof(_order_conditional_variable); i++) {
818  d = maxdim(d, GetStringBoundingBox(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i]));
819  }
820  d.width += padding.width;
821  d.height += padding.height;
822  *size = maxdim(*size, d);
823  break;
824  }
825 
826  case WID_O_COND_COMPARATOR: {
827  Dimension d = {0, 0};
828  for (int i = 0; _order_conditional_condition[i] != INVALID_STRING_ID; i++) {
829  d = maxdim(d, GetStringBoundingBox(_order_conditional_condition[i]));
830  }
831  d.width += padding.width;
832  d.height += padding.height;
833  *size = maxdim(*size, d);
834  break;
835  }
836  }
837  }
838 
844  void OnInvalidateData(int data = 0, bool gui_scope = true) override
845  {
848 
849  switch (data) {
850  case VIWD_AUTOREPLACE:
851  /* Autoreplace replaced the vehicle */
852  this->vehicle = Vehicle::Get(this->window_number);
853  FALLTHROUGH;
854 
856  /* Vehicle composition was changed. */
857  this->UpdateAutoRefitState();
858  break;
859 
861  /* Removed / replaced all orders (after deleting / sharing) */
862  if (this->selected_order == -1) break;
863 
864  this->DeleteChildWindows();
865  HideDropDownMenu(this);
866  this->selected_order = -1;
867  break;
868 
869  case VIWD_MODIFY_ORDERS:
870  /* Some other order changes */
871  break;
872 
873  default:
874  if (data < 0) break;
875 
876  if (gui_scope) break; // only do this once; from command scope
877  from = GB(data, 0, 8);
878  to = GB(data, 8, 8);
879  /* Moving an order. If one of these is INVALID_VEH_ORDER_ID, then
880  * the order is being created / removed */
881  if (this->selected_order == -1) break;
882 
883  if (from == to) break; // no need to change anything
884 
885  if (from != this->selected_order) {
886  /* Moving from preceding order? */
887  this->selected_order -= (int)(from <= this->selected_order);
888  /* Moving to preceding order? */
889  this->selected_order += (int)(to <= this->selected_order);
890  break;
891  }
892 
893  /* Now we are modifying the selected order */
894  if (to == INVALID_VEH_ORDER_ID) {
895  /* Deleting selected order */
896  this->DeleteChildWindows();
897  HideDropDownMenu(this);
898  this->selected_order = -1;
899  break;
900  }
901 
902  /* Moving selected order */
903  this->selected_order = to;
904  break;
905  }
906 
907  this->vscroll->SetCount(this->vehicle->GetNumOrders() + 1);
908  if (gui_scope) this->UpdateButtonState();
909 
910  /* Scroll to the new order. */
911  if (from == INVALID_VEH_ORDER_ID && to != INVALID_VEH_ORDER_ID && !this->vscroll->IsVisible(to)) {
912  this->vscroll->ScrollTowards(to);
913  }
914  }
915 
916  void UpdateButtonState()
917  {
918  if (this->vehicle->owner != _local_company) return; // No buttons are displayed with competitor order windows.
919 
920  bool shared_orders = this->vehicle->IsOrderListShared();
921  VehicleOrderID sel = this->OrderGetSel();
922  const Order *order = this->vehicle->GetOrder(sel);
923 
924  /* Second row. */
925  /* skip */
926  this->SetWidgetDisabledState(WID_O_SKIP, this->vehicle->GetNumOrders() <= 1);
927 
928  /* delete / stop sharing */
929  NWidgetStacked *delete_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_BOTTOM_MIDDLE);
930  if (shared_orders && this->selected_order == this->vehicle->GetNumOrders()) {
931  /* The 'End of Shared Orders' order is selected, show the 'stop sharing' button. */
933  } else {
934  /* The 'End of Shared Orders' order isn't selected, show the 'delete' button. */
937  (uint)this->vehicle->GetNumOrders() + ((shared_orders || this->vehicle->GetNumOrders() != 0) ? 1 : 0) <= (uint)this->selected_order);
938 
939  /* Set the tooltip of the 'delete' button depending on whether the
940  * 'End of Orders' order or a regular order is selected. */
941  NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_O_DELETE);
942  if (this->selected_order == this->vehicle->GetNumOrders()) {
943  nwi->SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_ALL_TOOLTIP);
944  } else {
945  nwi->SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP);
946  }
947  }
948 
949  /* First row. */
951  this->RaiseWidget(WID_O_UNLOAD);
952  this->RaiseWidget(WID_O_SERVICE);
953 
954  /* Selection widgets. */
955  /* Train or road vehicle. */
956  NWidgetStacked *train_row_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_ROW_GROUNDVEHICLE);
957  NWidgetStacked *left_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_LEFT);
958  NWidgetStacked *middle_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_MIDDLE);
959  NWidgetStacked *right_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_RIGHT);
960  /* Ship or airplane. */
961  NWidgetStacked *row_sel = this->GetWidget<NWidgetStacked>(WID_O_SEL_TOP_ROW);
962  assert(row_sel != nullptr || (train_row_sel != nullptr && left_sel != nullptr && middle_sel != nullptr && right_sel != nullptr));
963 
964 
965  if (order == nullptr) {
966  if (row_sel != nullptr) {
967  row_sel->SetDisplayedPlane(DP_ROW_LOAD);
968  } else {
970  left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
971  middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
972  right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
975  }
979  } else {
982 
983  switch (order->GetType()) {
984  case OT_GOTO_STATION:
985  if (row_sel != nullptr) {
986  row_sel->SetDisplayedPlane(DP_ROW_LOAD);
987  } else {
989  left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
990  middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
991  right_sel->SetDisplayedPlane(DP_RIGHT_REFIT);
994  }
997 
998  /* Can only do refitting when stopping at the destination and loading cargo.
999  * Also enable the button if a refit is already set to allow clearing it. */
1002  ((!this->can_do_refit || !this->can_do_autorefit) && !order->IsRefit()));
1003 
1004  break;
1005 
1006  case OT_GOTO_WAYPOINT:
1007  if (row_sel != nullptr) {
1008  row_sel->SetDisplayedPlane(DP_ROW_LOAD);
1009  } else {
1011  left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
1012  middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
1013  right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
1016  }
1018  this->DisableWidget(WID_O_UNLOAD);
1020  break;
1021 
1022  case OT_GOTO_DEPOT:
1023  if (row_sel != nullptr) {
1024  row_sel->SetDisplayedPlane(DP_ROW_DEPOT);
1025  } else {
1027  left_sel->SetDisplayedPlane(DP_LEFT_REFIT);
1028  middle_sel->SetDisplayedPlane(DP_MIDDLE_SERVICE);
1029  right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
1032  }
1033  /* Disable refit button if the order is no 'always go' order.
1034  * However, keep the service button enabled for refit-orders to allow clearing refits (without knowing about ctrl). */
1036  (order->GetDepotOrderType() & ODTFB_SERVICE) || (order->GetDepotActionType() & ODATFB_HALT) ||
1037  (!this->can_do_refit && !order->IsRefit()));
1039  break;
1040 
1041  case OT_CONDITIONAL: {
1042  if (row_sel != nullptr) {
1044  } else {
1046  }
1048  /* Set the strings for the dropdown boxes. */
1049  this->GetWidget<NWidgetCore>(WID_O_COND_VARIABLE)->widget_data = STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + ocv;
1050  this->GetWidget<NWidgetCore>(WID_O_COND_COMPARATOR)->widget_data = _order_conditional_condition[order->GetConditionComparator()];
1053  break;
1054  }
1055 
1056  default: // every other order
1057  if (row_sel != nullptr) {
1058  row_sel->SetDisplayedPlane(DP_ROW_LOAD);
1059  } else {
1061  left_sel->SetDisplayedPlane(DP_LEFT_LOAD);
1062  middle_sel->SetDisplayedPlane(DP_MIDDLE_UNLOAD);
1063  right_sel->SetDisplayedPlane(DP_RIGHT_EMPTY);
1065  }
1067  this->DisableWidget(WID_O_UNLOAD);
1069  break;
1070  }
1071  }
1072 
1073  /* Disable list of vehicles with the same shared orders if there is no list */
1074  this->SetWidgetDisabledState(WID_O_SHARED_ORDER_LIST, !shared_orders);
1075 
1076  this->SetDirty();
1077  }
1078 
1079  void OnPaint() override
1080  {
1081  if (this->vehicle->owner != _local_company) {
1082  this->selected_order = -1; // Disable selection any selected row at a competitor order window.
1083  } else {
1084  this->SetWidgetLoweredState(WID_O_GOTO, this->goto_type != OPOS_NONE);
1085  }
1086  this->DrawWidgets();
1087  }
1088 
1089  void DrawWidget(const Rect &r, int widget) const override
1090  {
1091  if (widget != WID_O_ORDER_LIST) return;
1092 
1093  bool rtl = _current_text_dir == TD_RTL;
1094  SetDParamMaxValue(0, this->vehicle->GetNumOrders(), 2);
1095  int index_column_width = GetStringBoundingBox(STR_ORDER_INDEX).width + 2 * GetSpriteSize(rtl ? SPR_ARROW_RIGHT : SPR_ARROW_LEFT).width + 3;
1096  int middle = rtl ? r.right - WD_FRAMETEXT_RIGHT - index_column_width : r.left + WD_FRAMETEXT_LEFT + index_column_width;
1097 
1098  int y = r.top + WD_FRAMERECT_TOP;
1099  int line_height = this->GetWidget<NWidgetBase>(WID_O_ORDER_LIST)->resize_y;
1100 
1101  int i = this->vscroll->GetPosition();
1102  const Order *order = this->vehicle->GetOrder(i);
1103  /* First draw the highlighting underground if it exists. */
1104  if (this->order_over != INVALID_VEH_ORDER_ID) {
1105  while (order != nullptr) {
1106  /* Don't draw anything if it extends past the end of the window. */
1107  if (!this->vscroll->IsVisible(i)) break;
1108 
1109  if (i != this->selected_order && i == this->order_over) {
1110  /* Highlight dragged order destination. */
1111  int top = (this->order_over < this->selected_order ? y : y + line_height) - WD_FRAMERECT_TOP;
1112  int bottom = std::min(top + 2, r.bottom - WD_FRAMERECT_BOTTOM);
1113  top = std::max(top - 3, r.top + WD_FRAMERECT_TOP);
1114  GfxFillRect(r.left + WD_FRAMETEXT_LEFT, top, r.right - WD_FRAMETEXT_RIGHT, bottom, _colour_gradient[COLOUR_GREY][7]);
1115  break;
1116  }
1117  y += line_height;
1118 
1119  i++;
1120  order = order->next;
1121  }
1122 
1123  /* Reset counters for drawing the orders. */
1124  y = r.top + WD_FRAMERECT_TOP;
1125  i = this->vscroll->GetPosition();
1126  order = this->vehicle->GetOrder(i);
1127  }
1128 
1129  /* Draw the orders. */
1130  while (order != nullptr) {
1131  /* Don't draw anything if it extends past the end of the window. */
1132  if (!this->vscroll->IsVisible(i)) break;
1133 
1134  DrawOrderString(this->vehicle, order, i, y, i == this->selected_order, false, r.left + WD_FRAMETEXT_LEFT, middle, r.right - WD_FRAMETEXT_RIGHT);
1135  y += line_height;
1136 
1137  i++;
1138  order = order->next;
1139  }
1140 
1141  if (this->vscroll->IsVisible(i)) {
1142  StringID str = this->vehicle->IsOrderListShared() ? STR_ORDERS_END_OF_SHARED_ORDERS : STR_ORDERS_END_OF_ORDERS;
1143  DrawString(rtl ? r.left + WD_FRAMETEXT_LEFT : middle, rtl ? middle : r.right - WD_FRAMETEXT_RIGHT, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
1144  }
1145  }
1146 
1147  void SetStringParameters(int widget) const override
1148  {
1149  switch (widget) {
1150  case WID_O_COND_VALUE: {
1151  VehicleOrderID sel = this->OrderGetSel();
1152  const Order *order = this->vehicle->GetOrder(sel);
1153 
1154  if (order != nullptr && order->IsType(OT_CONDITIONAL)) {
1155  uint value = order->GetConditionValue();
1156  if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
1157  SetDParam(0, value);
1158  }
1159  break;
1160  }
1161 
1162  case WID_O_CAPTION:
1163  SetDParam(0, this->vehicle->index);
1164  break;
1165  }
1166  }
1167 
1168  void OnClick(Point pt, int widget, int click_count) override
1169  {
1170  switch (widget) {
1171  case WID_O_ORDER_LIST: {
1172  if (this->goto_type == OPOS_CONDITIONAL) {
1173  VehicleOrderID order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
1174  if (order_id != INVALID_VEH_ORDER_ID) {
1175  Order order;
1176  order.next = nullptr;
1177  order.index = 0;
1178  order.MakeConditional(order_id);
1179 
1180  DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER));
1181  }
1183  break;
1184  }
1185 
1186  VehicleOrderID sel = this->GetOrderFromPt(pt.y);
1187 
1188  if (_ctrl_pressed && sel < this->vehicle->GetNumOrders()) {
1189  TileIndex xy = this->vehicle->GetOrder(sel)->GetLocation(this->vehicle);
1190  if (xy != INVALID_TILE) ScrollMainWindowToTile(xy);
1191  return;
1192  }
1193 
1194  /* This order won't be selected any more, close all child windows and dropdowns */
1195  this->DeleteChildWindows();
1196  HideDropDownMenu(this);
1197 
1198  if (sel == INVALID_VEH_ORDER_ID || this->vehicle->owner != _local_company) {
1199  /* Deselect clicked order */
1200  this->selected_order = -1;
1201  } else if (sel == this->selected_order) {
1202  if (this->vehicle->type == VEH_TRAIN && sel < this->vehicle->GetNumOrders()) {
1203  DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 20),
1204  MOF_STOP_LOCATION | ((this->vehicle->GetOrder(sel)->GetStopLocation() + 1) % OSL_END) << 4,
1205  CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
1206  }
1207  } else {
1208  /* Select clicked order */
1209  this->selected_order = sel;
1210 
1211  if (this->vehicle->owner == _local_company) {
1212  /* Activate drag and drop */
1213  SetObjectToPlaceWnd(SPR_CURSOR_MOUSE, PAL_NONE, HT_DRAG, this);
1214  }
1215  }
1216 
1217  this->UpdateButtonState();
1218  break;
1219  }
1220 
1221  case WID_O_SKIP:
1222  this->OrderClick_Skip();
1223  break;
1224 
1225  case WID_O_DELETE:
1226  this->OrderClick_Delete();
1227  break;
1228 
1229  case WID_O_STOP_SHARING:
1230  this->OrderClick_StopSharing();
1231  break;
1232 
1233  case WID_O_NON_STOP:
1234  if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1235  this->OrderClick_Nonstop(-1);
1236  } else {
1237  const Order *o = this->vehicle->GetOrder(this->OrderGetSel());
1238  ShowDropDownMenu(this, _order_non_stop_drowdown, o->GetNonStopType(), WID_O_NON_STOP, 0,
1239  o->IsType(OT_GOTO_STATION) ? 0 : (o->IsType(OT_GOTO_WAYPOINT) ? 3 : 12));
1240  }
1241  break;
1242 
1243  case WID_O_GOTO:
1244  if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1245  if (this->goto_type != OPOS_NONE) {
1247  } else {
1248  this->OrderClick_Goto(OPOS_GOTO);
1249  }
1250  } else {
1251  int sel;
1252  switch (this->goto_type) {
1253  case OPOS_NONE: sel = -1; break;
1254  case OPOS_GOTO: sel = 0; break;
1255  case OPOS_CONDITIONAL: sel = 2; break;
1256  case OPOS_SHARE: sel = 3; break;
1257  default: NOT_REACHED();
1258  }
1259  ShowDropDownMenu(this, this->vehicle->type == VEH_AIRCRAFT ? _order_goto_dropdown_aircraft : _order_goto_dropdown, sel, WID_O_GOTO, 0, 0);
1260  }
1261  break;
1262 
1263  case WID_O_FULL_LOAD:
1264  if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1265  this->OrderClick_FullLoad(-1);
1266  } else {
1267  ShowDropDownMenu(this, _order_full_load_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetLoadType(), WID_O_FULL_LOAD, 0, 2);
1268  }
1269  break;
1270 
1271  case WID_O_UNLOAD:
1272  if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1273  this->OrderClick_Unload(-1);
1274  } else {
1275  ShowDropDownMenu(this, _order_unload_drowdown, this->vehicle->GetOrder(this->OrderGetSel())->GetUnloadType(), WID_O_UNLOAD, 0, 8);
1276  }
1277  break;
1278 
1279  case WID_O_REFIT:
1280  this->OrderClick_Refit(0, false);
1281  break;
1282 
1283  case WID_O_SERVICE:
1284  if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1285  this->OrderClick_Service(-1);
1286  } else {
1287  ShowDropDownMenu(this, _order_depot_action_dropdown, DepotActionStringIndex(this->vehicle->GetOrder(this->OrderGetSel())), WID_O_SERVICE, 0, 0);
1288  }
1289  break;
1290 
1291  case WID_O_REFIT_DROPDOWN:
1292  if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1293  this->OrderClick_Refit(0, true);
1294  } else {
1295  ShowDropDownMenu(this, _order_refit_action_dropdown, 0, WID_O_REFIT_DROPDOWN, 0, 0);
1296  }
1297  break;
1298 
1299  case WID_O_TIMETABLE_VIEW:
1300  ShowTimetableWindow(this->vehicle);
1301  break;
1302 
1303  case WID_O_COND_VARIABLE: {
1304  DropDownList list;
1305  for (uint i = 0; i < lengthof(_order_conditional_variable); i++) {
1306  list.emplace_back(new DropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + _order_conditional_variable[i], _order_conditional_variable[i], false));
1307  }
1308  ShowDropDownList(this, std::move(list), this->vehicle->GetOrder(this->OrderGetSel())->GetConditionVariable(), WID_O_COND_VARIABLE);
1309  break;
1310  }
1311 
1312  case WID_O_COND_COMPARATOR: {
1313  const Order *o = this->vehicle->GetOrder(this->OrderGetSel());
1314  ShowDropDownMenu(this, _order_conditional_condition, o->GetConditionComparator(), WID_O_COND_COMPARATOR, 0, (o->GetConditionVariable() == OCV_REQUIRES_SERVICE) ? 0x3F : 0xC0);
1315  break;
1316  }
1317 
1318  case WID_O_COND_VALUE: {
1319  const Order *order = this->vehicle->GetOrder(this->OrderGetSel());
1320  uint value = order->GetConditionValue();
1321  if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value);
1322  SetDParam(0, value);
1323  ShowQueryString(STR_JUST_INT, STR_ORDER_CONDITIONAL_VALUE_CAPT, 5, this, CS_NUMERAL, QSF_NONE);
1324  break;
1325  }
1326 
1328  ShowVehicleListWindow(this->vehicle);
1329  break;
1330  }
1331  }
1332 
1333  void OnQueryTextFinished(char *str) override
1334  {
1335  if (!StrEmpty(str)) {
1336  VehicleOrderID sel = this->OrderGetSel();
1337  uint value = atoi(str);
1338 
1339  switch (this->vehicle->GetOrder(sel)->GetConditionVariable()) {
1340  case OCV_MAX_SPEED:
1341  value = ConvertDisplaySpeedToSpeed(value);
1342  break;
1343 
1344  case OCV_RELIABILITY:
1345  case OCV_LOAD_PERCENTAGE:
1346  value = Clamp(value, 0, 100);
1347  break;
1348 
1349  default:
1350  break;
1351  }
1352  DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 20), MOF_COND_VALUE | Clamp(value, 0, 2047) << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
1353  }
1354  }
1355 
1356  void OnDropdownSelect(int widget, int index) override
1357  {
1358  switch (widget) {
1359  case WID_O_NON_STOP:
1360  this->OrderClick_Nonstop(index);
1361  break;
1362 
1363  case WID_O_FULL_LOAD:
1364  this->OrderClick_FullLoad(index);
1365  break;
1366 
1367  case WID_O_UNLOAD:
1368  this->OrderClick_Unload(index);
1369  break;
1370 
1371  case WID_O_GOTO:
1372  switch (index) {
1373  case 0: this->OrderClick_Goto(OPOS_GOTO); break;
1374  case 1: this->OrderClick_NearestDepot(); break;
1375  case 2: this->OrderClick_Goto(OPOS_CONDITIONAL); break;
1376  case 3: this->OrderClick_Goto(OPOS_SHARE); break;
1377  default: NOT_REACHED();
1378  }
1379  break;
1380 
1381  case WID_O_SERVICE:
1382  this->OrderClick_Service(index);
1383  break;
1384 
1385  case WID_O_REFIT_DROPDOWN:
1386  this->OrderClick_Refit(index, true);
1387  break;
1388 
1389  case WID_O_COND_VARIABLE:
1390  DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VARIABLE | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
1391  break;
1392 
1393  case WID_O_COND_COMPARATOR:
1394  DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_COMPARATOR | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER));
1395  break;
1396  }
1397  }
1398 
1399  void OnDragDrop(Point pt, int widget) override
1400  {
1401  switch (widget) {
1402  case WID_O_ORDER_LIST: {
1403  VehicleOrderID from_order = this->OrderGetSel();
1404  VehicleOrderID to_order = this->GetOrderFromPt(pt.y);
1405 
1406  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()) &&
1407  DoCommandP(this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16), CMD_MOVE_ORDER | CMD_MSG(STR_ERROR_CAN_T_MOVE_THIS_ORDER))) {
1408  this->selected_order = -1;
1409  this->UpdateButtonState();
1410  }
1411  break;
1412  }
1413 
1414  case WID_O_DELETE:
1415  this->OrderClick_Delete();
1416  break;
1417 
1418  case WID_O_STOP_SHARING:
1419  this->OrderClick_StopSharing();
1420  break;
1421  }
1422 
1424 
1425  if (this->order_over != INVALID_VEH_ORDER_ID) {
1426  /* End of drag-and-drop, hide dragged order destination highlight. */
1427  this->order_over = INVALID_VEH_ORDER_ID;
1429  }
1430  }
1431 
1432  EventState OnHotkey(int hotkey) override
1433  {
1434  if (this->vehicle->owner != _local_company) return ES_NOT_HANDLED;
1435 
1436  switch (hotkey) {
1437  case OHK_SKIP: this->OrderClick_Skip(); break;
1438  case OHK_DELETE: this->OrderClick_Delete(); break;
1439  case OHK_GOTO: this->OrderClick_Goto(OPOS_GOTO); break;
1440  case OHK_NONSTOP: this->OrderClick_Nonstop(-1); break;
1441  case OHK_FULLLOAD: this->OrderClick_FullLoad(-1); break;
1442  case OHK_UNLOAD: this->OrderClick_Unload(-1); break;
1443  case OHK_NEAREST_DEPOT: this->OrderClick_NearestDepot(); break;
1444  case OHK_ALWAYS_SERVICE: this->OrderClick_Service(-1); break;
1445  case OHK_TRANSFER: this->OrderHotkey_Transfer(); break;
1446  case OHK_NO_UNLOAD: this->OrderHotkey_NoUnload(); break;
1447  case OHK_NO_LOAD: this->OrderHotkey_NoLoad(); break;
1448  default: return ES_NOT_HANDLED;
1449  }
1450  return ES_HANDLED;
1451  }
1452 
1453  void OnPlaceObject(Point pt, TileIndex tile) override
1454  {
1455  if (this->goto_type == OPOS_GOTO) {
1456  const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
1457  if (cmd.IsType(OT_NOTHING)) return;
1458 
1459  if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER))) {
1460  /* With quick goto the Go To button stays active */
1462  }
1463  }
1464  }
1465 
1466  bool OnVehicleSelect(const Vehicle *v) override
1467  {
1468  /* v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet.
1469  * We disallow copying orders of other vehicles if we already have at least one order entry
1470  * ourself as it easily copies orders of vehicles within a station when we mean the station.
1471  * Obviously if you press CTRL on a non-empty orders vehicle you know what you are doing
1472  * TODO: give a warning message */
1473  bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE;
1474  if (this->vehicle->GetNumOrders() != 0 && !share_order) return false;
1475 
1476  if (DoCommandP(this->vehicle->tile, this->vehicle->index | (share_order ? CO_SHARE : CO_COPY) << 30, v->index,
1477  share_order ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST))) {
1478  this->selected_order = -1;
1480  }
1481  return true;
1482  }
1483 
1484  void OnPlaceObjectAbort() override
1485  {
1486  this->goto_type = OPOS_NONE;
1487  this->SetWidgetDirty(WID_O_GOTO);
1488 
1489  /* Remove drag highlighting if it exists. */
1490  if (this->order_over != INVALID_VEH_ORDER_ID) {
1491  this->order_over = INVALID_VEH_ORDER_ID;
1493  }
1494  }
1495 
1496  void OnMouseDrag(Point pt, int widget) override
1497  {
1498  if (this->selected_order != -1 && widget == WID_O_ORDER_LIST) {
1499  /* An order is dragged.. */
1500  VehicleOrderID from_order = this->OrderGetSel();
1501  VehicleOrderID to_order = this->GetOrderFromPt(pt.y);
1502  uint num_orders = this->vehicle->GetNumOrders();
1503 
1504  if (from_order != INVALID_VEH_ORDER_ID && from_order <= num_orders) {
1505  if (to_order != INVALID_VEH_ORDER_ID && to_order <= num_orders) { // ..over an existing order.
1506  this->order_over = to_order;
1507  this->SetWidgetDirty(widget);
1508  } else if (from_order != to_order && this->order_over != INVALID_VEH_ORDER_ID) { // ..outside of the order list.
1509  this->order_over = INVALID_VEH_ORDER_ID;
1510  this->SetWidgetDirty(widget);
1511  }
1512  }
1513  }
1514  }
1515 
1516  void OnResize() override
1517  {
1518  /* Update the scroll bar */
1519  this->vscroll->SetCapacityFromWidget(this, WID_O_ORDER_LIST);
1520  }
1521 
1522  static HotkeyList hotkeys;
1523 };
1524 
1525 static Hotkey order_hotkeys[] = {
1526  Hotkey('D', "skip", OHK_SKIP),
1527  Hotkey('F', "delete", OHK_DELETE),
1528  Hotkey('G', "goto", OHK_GOTO),
1529  Hotkey('H', "nonstop", OHK_NONSTOP),
1530  Hotkey('J', "fullload", OHK_FULLLOAD),
1531  Hotkey('K', "unload", OHK_UNLOAD),
1532  Hotkey((uint16)0, "nearest_depot", OHK_NEAREST_DEPOT),
1533  Hotkey((uint16)0, "always_service", OHK_ALWAYS_SERVICE),
1534  Hotkey((uint16)0, "transfer", OHK_TRANSFER),
1535  Hotkey((uint16)0, "no_unload", OHK_NO_UNLOAD),
1536  Hotkey((uint16)0, "no_load", OHK_NO_LOAD),
1537  HOTKEY_LIST_END
1538 };
1539 HotkeyList OrdersWindow::hotkeys("order", order_hotkeys);
1540 
1544  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1545  NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1546  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_ORDERS_TIMETABLE_VIEW, STR_ORDERS_TIMETABLE_VIEW_TOOLTIP),
1547  NWidget(WWT_SHADEBOX, COLOUR_GREY),
1548  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
1549  NWidget(WWT_STICKYBOX, COLOUR_GREY),
1550  EndContainer(),
1552  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(),
1553  NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_O_SCROLLBAR),
1554  EndContainer(),
1555 
1556  /* First button row. */
1560  NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_NON_STOP), SetMinimalSize(93, 12), SetFill(1, 0),
1561  SetDataTip(STR_ORDER_NON_STOP, STR_ORDER_TOOLTIP_NON_STOP), SetResize(1, 0),
1562  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_LEFT),
1563  NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_FULL_LOAD), SetMinimalSize(93, 12), SetFill(1, 0),
1564  SetDataTip(STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD), SetResize(1, 0),
1565  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_REFIT), SetMinimalSize(93, 12), SetFill(1, 0),
1566  SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
1567  EndContainer(),
1568  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_MIDDLE),
1569  NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_UNLOAD), SetMinimalSize(93, 12), SetFill(1, 0),
1570  SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0),
1571  NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_SERVICE), SetMinimalSize(93, 12), SetFill(1, 0),
1572  SetDataTip(STR_ORDER_SERVICE, STR_ORDER_SERVICE_TOOLTIP), SetResize(1, 0),
1573  EndContainer(),
1574  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_RIGHT),
1575  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_O_EMPTY), SetMinimalSize(93, 12), SetFill(1, 0),
1576  SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
1578  SetDataTip(STR_ORDER_REFIT_AUTO, STR_ORDER_REFIT_AUTO_TOOLTIP), SetResize(1, 0),
1579  EndContainer(),
1580  EndContainer(),
1582  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_VARIABLE), SetMinimalSize(124, 12), SetFill(1, 0),
1583  SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP), SetResize(1, 0),
1584  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
1585  SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
1586  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_COND_VALUE), SetMinimalSize(124, 12), SetFill(1, 0),
1587  SetDataTip(STR_BLACK_COMMA, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP), SetResize(1, 0),
1588  EndContainer(),
1589  EndContainer(),
1590  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),
1591  EndContainer(),
1592 
1593  /* Second button row. */
1596  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_SKIP), SetMinimalSize(124, 12), SetFill(1, 0),
1597  SetDataTip(STR_ORDERS_SKIP_BUTTON, STR_ORDERS_SKIP_TOOLTIP), SetResize(1, 0),
1599  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_DELETE), SetMinimalSize(124, 12), SetFill(1, 0),
1600  SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0),
1601  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_STOP_SHARING), SetMinimalSize(124, 12), SetFill(1, 0),
1602  SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP), SetResize(1, 0),
1603  EndContainer(),
1604  NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_GOTO), SetMinimalSize(124, 12), SetFill(1, 0),
1605  SetDataTip(STR_ORDERS_GO_TO_BUTTON, STR_ORDERS_GO_TO_TOOLTIP), SetResize(1, 0),
1606  EndContainer(),
1607  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
1608  EndContainer(),
1609 };
1610 
1611 static WindowDesc _orders_train_desc(
1612  WDP_AUTO, "view_vehicle_orders_train", 384, 100,
1616  &OrdersWindow::hotkeys
1617 );
1618 
1622  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1623  NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1624  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_ORDERS_TIMETABLE_VIEW, STR_ORDERS_TIMETABLE_VIEW_TOOLTIP),
1625  NWidget(WWT_SHADEBOX, COLOUR_GREY),
1626  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
1627  NWidget(WWT_STICKYBOX, COLOUR_GREY),
1628  EndContainer(),
1630  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(),
1631  NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_O_SCROLLBAR),
1632  EndContainer(),
1633 
1634  /* First button row. */
1636  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_O_SEL_TOP_ROW),
1637  /* Load + unload + refit buttons. */
1639  NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_FULL_LOAD), SetMinimalSize(124, 12), SetFill(1, 0),
1640  SetDataTip(STR_ORDER_TOGGLE_FULL_LOAD, STR_ORDER_TOOLTIP_FULL_LOAD), SetResize(1, 0),
1641  NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_UNLOAD), SetMinimalSize(124, 12), SetFill(1, 0),
1642  SetDataTip(STR_ORDER_TOGGLE_UNLOAD, STR_ORDER_TOOLTIP_UNLOAD), SetResize(1, 0),
1644  SetDataTip(STR_ORDER_REFIT_AUTO, STR_ORDER_REFIT_AUTO_TOOLTIP), SetResize(1, 0),
1645  EndContainer(),
1646  /* Refit + service buttons. */
1648  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_REFIT), SetMinimalSize(186, 12), SetFill(1, 0),
1649  SetDataTip(STR_ORDER_REFIT, STR_ORDER_REFIT_TOOLTIP), SetResize(1, 0),
1650  NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_SERVICE), SetMinimalSize(124, 12), SetFill(1, 0),
1651  SetDataTip(STR_ORDER_SERVICE, STR_ORDER_SERVICE_TOOLTIP), SetResize(1, 0),
1652  EndContainer(),
1653 
1654  /* Buttons for setting a condition. */
1656  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_VARIABLE), SetMinimalSize(124, 12), SetFill(1, 0),
1657  SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_VARIABLE_TOOLTIP), SetResize(1, 0),
1658  NWidget(WWT_DROPDOWN, COLOUR_GREY, WID_O_COND_COMPARATOR), SetMinimalSize(124, 12), SetFill(1, 0),
1659  SetDataTip(STR_NULL, STR_ORDER_CONDITIONAL_COMPARATOR_TOOLTIP), SetResize(1, 0),
1660  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_COND_VALUE), SetMinimalSize(124, 12), SetFill(1, 0),
1661  SetDataTip(STR_BLACK_COMMA, STR_ORDER_CONDITIONAL_VALUE_TOOLTIP), SetResize(1, 0),
1662  EndContainer(),
1663  EndContainer(),
1664 
1665  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),
1666  EndContainer(),
1667 
1668  /* Second button row. */
1670  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_SKIP), SetMinimalSize(124, 12), SetFill(1, 0),
1671  SetDataTip(STR_ORDERS_SKIP_BUTTON, STR_ORDERS_SKIP_TOOLTIP), SetResize(1, 0),
1673  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_DELETE), SetMinimalSize(124, 12), SetFill(1, 0),
1674  SetDataTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP), SetResize(1, 0),
1675  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_STOP_SHARING), SetMinimalSize(124, 12), SetFill(1, 0),
1676  SetDataTip(STR_ORDERS_STOP_SHARING_BUTTON, STR_ORDERS_STOP_SHARING_TOOLTIP), SetResize(1, 0),
1677  EndContainer(),
1678  NWidget(NWID_BUTTON_DROPDOWN, COLOUR_GREY, WID_O_GOTO), SetMinimalSize(124, 12), SetFill(1, 0),
1679  SetDataTip(STR_ORDERS_GO_TO_BUTTON, STR_ORDERS_GO_TO_TOOLTIP), SetResize(1, 0),
1680  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
1681  EndContainer(),
1682 };
1683 
1684 static WindowDesc _orders_desc(
1685  WDP_AUTO, "view_vehicle_orders", 384, 100,
1689  &OrdersWindow::hotkeys
1690 );
1691 
1695  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1696  NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1697  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_ORDERS_TIMETABLE_VIEW, STR_ORDERS_TIMETABLE_VIEW_TOOLTIP),
1698  NWidget(WWT_SHADEBOX, COLOUR_GREY),
1699  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
1700  NWidget(WWT_STICKYBOX, COLOUR_GREY),
1701  EndContainer(),
1703  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(),
1705  NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_O_SCROLLBAR),
1706  NWidget(WWT_RESIZEBOX, COLOUR_GREY),
1707  EndContainer(),
1708  EndContainer(),
1709 };
1710 
1711 static WindowDesc _other_orders_desc(
1712  WDP_AUTO, "view_vehicle_orders_competitor", 384, 86,
1716  &OrdersWindow::hotkeys
1717 );
1718 
1719 void ShowOrdersWindow(const Vehicle *v)
1720 {
1723  if (BringWindowToFrontById(WC_VEHICLE_ORDERS, v->index) != nullptr) return;
1724 
1725  /* Using a different WindowDescs for _local_company causes problems.
1726  * Due to this we have to close order windows in ChangeWindowOwner/DeleteCompanyWindows,
1727  * because we cannot change switch the WindowDescs and keeping the old WindowDesc results
1728  * in crashed due to missing widges.
1729  * TODO Rewrite the order GUI to not use different WindowDescs.
1730  */
1731  if (v->owner != _local_company) {
1732  new OrdersWindow(&_other_orders_desc, v);
1733  } else {
1734  new OrdersWindow(v->IsGroundVehicle() ? &_orders_train_desc : &_orders_desc, v);
1735  }
1736 }
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:718
_nested_other_orders_widgets
static const NWidgetPart _nested_other_orders_widgets[]
Nested widget definition for competitor orders.
Definition: order_gui.cpp:1693
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
OrdersWindow::OrderClick_Unload
void OrderClick_Unload(int unload_type)
Handle the click on the unload button.
Definition: order_gui.cpp:635
ConvertSpeedToDisplaySpeed
uint ConvertSpeedToDisplaySpeed(uint speed)
Convert the given (internal) speed to the display speed.
Definition: strings.cpp:733
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:108
WD_FRAMERECT_TOP
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:62
CMD_MSG
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:372
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
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:183
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:61
CMD_SKIP_TO_ORDER
@ CMD_SKIP_TO_ORDER
skip an order to the next of specific one
Definition: command_type.h:226
Pool::PoolItem<&_engine_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:329
ScrollMainWindowToTile
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Definition: viewport.cpp:2443
OrdersWindow::OrderClick_Delete
void OrderClick_Delete()
Handle the click on the delete button.
Definition: order_gui.cpp:710
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1094
Vehicle::PreviousShared
Vehicle * PreviousShared() const
Get the previous vehicle of the shared vehicle chain.
Definition: vehicle_base.h:680
Order::SetLoadType
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
Definition: order_base.h:148
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:40
CMD_ORDER_REFIT
@ CMD_ORDER_REFIT
change the refit information of an order (for "goto depot" )
Definition: command_type.h:272
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
MOF_DEPOT_ACTION
@ MOF_DEPOT_ACTION
Selects the OrderDepotAction.
Definition: order_type.h:148
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:621
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:844
MOF_LOAD
@ MOF_LOAD
Passes an OrderLoadType.
Definition: order_type.h:147
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
Window::DeleteChildWindows
void DeleteChildWindows(WindowClass wc=WC_INVALID) const
Delete all children a window might have in a head-recursive manner.
Definition: window.cpp:1072
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:309
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:208
dropdown_func.h
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:45
MOF_COND_VALUE
@ MOF_COND_VALUE
The value to set the condition to.
Definition: order_type.h:151
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:727
OrdersWindow::order_over
VehicleOrderID order_over
Order over which another order is dragged, INVALID_VEH_ORDER_ID if none.
Definition: order_gui.cpp:522
OrdersWindow::OnDropdownSelect
void OnDropdownSelect(int widget, int index) override
A dropdown option associated to this window has been selected.
Definition: order_gui.cpp:1356
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:494
FACIL_TRUCK_STOP
@ FACIL_TRUCK_STOP
Station with truck stops.
Definition: station_type.h:53
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:730
Station
Station data structure.
Definition: station_base.h:450
Order::GetDestination
DestinationID GetDestination() const
Gets the destination of this order.
Definition: order_base.h:94
OrdersWindow::OrderClick_Skip
void OrderClick_Skip()
Handle the click on the skip button.
Definition: order_gui.cpp:697
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:1168
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:512
SA_RIGHT
@ SA_RIGHT
Right align the text (must be a single bit).
Definition: gfx_func.h:96
Order::GetConditionValue
uint16 GetConditionValue() const
Get the value to base the skip on.
Definition: order_base.h:145
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:214
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:514
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:1832
GUISettings::new_nonstop
bool new_nonstop
ttdpatch compatible nonstop handling
Definition: settings_type.h:90
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:227
CargoSpec::Get
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
Definition: cargotype.h:117
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
MOF_UNLOAD
@ MOF_UNLOAD
Passes an OrderUnloadType.
Definition: order_type.h:146
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:62
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
_nested_orders_widgets
static const NWidgetPart _nested_orders_widgets[]
Nested widget definition for "your" orders (non-train).
Definition: order_gui.cpp:1620
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:129
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:669
CMD_MOVE_ORDER
@ CMD_MOVE_ORDER
move an order
Definition: command_type.h:330
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:35
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:250
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:929
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:766
SpecializedStation< Station, false >::Get
static Station * Get(size_t index)
Gets station with given index.
Definition: base_station_base.h:219
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:79
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:636
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:49
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:1496
Window::owner
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
Definition: window_gui.h:324
CMD_INSERT_ORDER
@ CMD_INSERT_ORDER
insert a new order
Definition: command_type.h:228
TransportType
TransportType
Available types of transport.
Definition: transport_type.h:19
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
Vehicle
Vehicle data structure.
Definition: vehicle_base.h:222
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:482
SA_FORCE
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
Definition: gfx_func.h:106
Vehicle::owner
Owner owner
Which company owns the vehicle?
Definition: vehicle_base.h:283
_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:39
MOF_COND_COMPARATOR
@ MOF_COND_COMPARATOR
A comparator changes.
Definition: order_type.h:150
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:588
WD_FRAMETEXT_LEFT
@ WD_FRAMETEXT_LEFT
Left offset of the text of the frame.
Definition: window_gui.h:70
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:708
_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:52
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:199
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:909
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
OrdersWindow::OrderClick_Goto
void OrderClick_Goto(OrderPlaceObjectState type)
Handle the click on the goto button.
Definition: order_gui.cpp:563
OrdersWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: order_gui.cpp:1516
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:675
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:838
textbuf_gui.h
WID_O_COND_VARIABLE
@ WID_O_COND_VARIABLE
Choose condition variable.
Definition: order_widget.h:30
Order::Pack
uint32 Pack() const
Pack this order into a 32 bits integer, or actually only the type, flags and destination.
Definition: order_cmd.cpp:197
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:89
Order::GetType
OrderType GetType() const
Get the type of order of this order.
Definition: order_base.h:67
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:133
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:166
OrdersWindow::OnDragDrop
void OnDragDrop(Point pt, int widget) override
A dragged 'object' has been released.
Definition: order_gui.cpp:1399
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:707
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
ANIMCURSOR_PICKSTATION
static const CursorID ANIMCURSOR_PICKSTATION
716 - 718 - goto-order icon
Definition: sprites.h:1495
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:131
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:428
Vehicle::Orders
IterateWrapper Orders() const
Returns an iterable ensemble of orders of a vehicle.
Definition: vehicle_base.h:1034
FACIL_BUS_STOP
@ FACIL_BUS_STOP
Station with bus stops.
Definition: station_type.h:54
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:158
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:154
OrdersWindow::OnQueryTextFinished
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
Definition: order_gui.cpp:1333
Order::GetRefitCargo
CargoID GetRefitCargo() const
Get the cargo to to refit to.
Definition: order_base.h:122
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:1453
OrdersWindow::can_do_autorefit
bool can_do_autorefit
Vehicle chain can be auto-refitted.
Definition: order_gui.cpp:527
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
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
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:541
Window::EnableWidget
void EnableWidget(byte widget_index)
Sets a widget to Enabled.
Definition: window_gui.h:411
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:152
Vehicle::tile
TileIndex tile
Current tile index.
Definition: vehicle_base.h:240
Order::MakeGoToWaypoint
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
Definition: order_cmd.cpp:103
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
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:719
WD_FRAMERECT_BOTTOM
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:63
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:102
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:505
OrdersWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: order_gui.cpp:1089
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
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:807
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:453
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::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:496
OrdersWindow::OrderGetSel
VehicleOrderID OrderGetSel() const
Return the memorised selected order.
Definition: order_gui.cpp:534
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:392
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:45
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:1131
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:548
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:60
OrdersWindow::OrderHotkey_NoUnload
void OrderHotkey_NoUnload()
Handle the 'no unload' hotkey.
Definition: order_gui.cpp:666
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:84
Order::GetConditionComparator
OrderConditionComparator GetConditionComparator() const
What is the comparator to use?
Definition: order_base.h:141
TC_NO_SHADE
@ TC_NO_SHADE
Do not add shading to this text colour.
Definition: gfx_type.h:274
_networking
bool _networking
are we in networking mode?
Definition: network.cpp:52
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:504
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:974
OrdersWindow::OrderPlaceObjectState
OrderPlaceObjectState
Under what reason are we using the PlaceObject functionality?
Definition: order_gui.cpp:485
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
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:494
FACIL_DOCK
@ FACIL_DOCK
Station with a dock.
Definition: station_type.h:56
Order::MakeGoToStation
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
Definition: order_cmd.cpp:74
Order::GetConditionSkipToOrder
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
Definition: order_base.h:143
WD_FRAMETEXT_RIGHT
@ WD_FRAMETEXT_RIGHT
Right offset of the text of the frame.
Definition: window_gui.h:71
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:312
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:508
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:110
Vehicle::IsOrderListShared
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
Definition: vehicle_base.h:692
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:1091
Order::SetStopLocation
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
Definition: order_base.h:154
viewport_func.h
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:404
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:509
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:34
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:909
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:1484
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:686
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:103
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:128
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:998
OrdersWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: order_gui.cpp:1432
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
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1165
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
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:892
HideDropDownMenu
int HideDropDownMenu(Window *pw)
Delete the drop-down menu from window pw.
Definition: dropdown.cpp:512
OCV_RELIABILITY
@ OCV_RELIABILITY
Skip based on the reliability.
Definition: order_type.h:114
MOF_STOP_LOCATION
@ MOF_STOP_LOCATION
Passes an OrderStopLocation.
Definition: order_type.h:145
FACIL_TRAIN
@ FACIL_TRAIN
Station with train station.
Definition: station_type.h:52
Vehicle::GetFirstOrder
Order * GetFirstOrder() const
Get the first order of the vehicles order list.
Definition: vehicle_base.h:665
SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From
static Aircraft * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
Definition: vehicle_base.h:1162
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:177
VIWD_AUTOREPLACE
@ VIWD_AUTOREPLACE
Autoreplace replaced the vehicle.
Definition: vehicle_gui.h:35
GUISettings::stop_location
uint8 stop_location
what is the default stop location of trains?
Definition: settings_type.h:91
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:359
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
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:640
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:104
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:946
CMD_MODIFY_ORDER
@ CMD_MODIFY_ORDER
modify an order (like set full-load)
Definition: command_type.h:225
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:674
CMD_DELETE_ORDER
@ CMD_DELETE_ORDER
delete an order
Definition: command_type.h:227
OWNER_NONE
@ OWNER_NONE
The tile has no ownership.
Definition: company_type.h:25
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:513
NWidgetBase::resize_y
uint resize_y
Vertical resize step (0 means not resizable).
Definition: widget_type.h:165
CT_AUTO_REFIT
@ CT_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
Definition: cargo_type.h:66
MP_STATION
@ MP_STATION
A tile of a station.
Definition: tile_type.h:46
MOF_NON_STOP
@ MOF_NON_STOP
Passes an OrderNonStopFlags.
Definition: order_type.h:144
SpecializedStation< Station, false >::GetByTile
static Station * GetByTile(TileIndex tile)
Get the station belonging to a specific tile.
Definition: base_station_base.h:238
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:717
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:630
ConvertDisplaySpeedToSpeed
uint ConvertDisplaySpeedToSpeed(uint speed)
Convert the given display speed to the (internal) speed.
Definition: strings.cpp:746
OrdersWindow
Order window code for all vehicles.
Definition: order_gui.cpp:482
Order::SetDepotOrderType
void SetDepotOrderType(OrderDepotTypeFlags depot_order_type)
Set the cause to go to the depot.
Definition: order_base.h:156
CargoSpec::name
StringID name
Name of this type of cargo.
Definition: cargotype.h:70
Order::IsAutoRefit
bool IsAutoRefit() const
Is this order a auto-refit order.
Definition: order_base.h:115
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1848
depot_map.h
OrdersWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: order_gui.cpp:1079
Order::SetDepotActionType
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
Definition: order_base.h:158
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:318
Order::MakeConditional
void MakeConditional(VehicleOrderID order)
Makes this order an conditional order.
Definition: order_cmd.cpp:142
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:135
network.h
Order::GetConditionVariable
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
Definition: order_base.h:139
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:377
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:1980
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
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:176
OrderConditionVariable
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
Definition: order_type.h:112
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:83
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:3358
OrdersWindow::can_do_refit
bool can_do_refit
Vehicle chain can be refitted in depot.
Definition: order_gui.cpp:526
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
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:680
SPR_CURSOR_MOUSE
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Definition: sprites.h:1374
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:1164
OrdersWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: order_gui.cpp:1147
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:276
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:483
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:872
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:501
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:751
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:602
FACIL_AIRPORT
@ FACIL_AIRPORT
Station with an airport.
Definition: station_type.h:55
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:500
OrdersWindow::OrderHotkey_NoLoad
void OrderHotkey_NoLoad()
Handle the 'no loading' hotkey.
Definition: order_gui.cpp:597
VIWD_MODIFY_ORDERS
@ VIWD_MODIFY_ORDERS
Other order modifications.
Definition: vehicle_gui.h:33
CanVehicleUseStation
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
Can this station be used by the given engine type?
Definition: vehicle.cpp:2838
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:282
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:597
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:47
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:497
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:1262
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:698
OrdersWindow::OrderHotkey_Transfer
void OrderHotkey_Transfer()
Handle the transfer hotkey.
Definition: order_gui.cpp:658
VIWD_REMOVE_ALL_ORDERS
@ VIWD_REMOVE_ALL_ORDERS
Removed / replaced all orders (after deleting / sharing).
Definition: vehicle_gui.h:32
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:67
Order::GetDepotActionType
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
Definition: order_base.h:137
ShowVehicleRefitWindow
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
Show the refit window for a vehicle.
Definition: vehicle_gui.cpp:1125
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:402
_nested_orders_train_widgets
static const NWidgetPart _nested_orders_train_widgets[]
Nested widget definition for "your" train orders.
Definition: order_gui.cpp:1542
Order::next
Order * next
Pointer to next order. If nullptr, end of list.
Definition: order_base.h:49
WID_O_STOP_SHARING
@ WID_O_STOP_SHARING
Stop sharing orders.
Definition: order_widget.h:21
Order
Definition: order_base.h:32
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3421
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:453
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:48
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:174
Order::SetNonStopType
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
Definition: order_base.h:152
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:565
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:127
MOF_COND_VARIABLE
@ MOF_COND_VARIABLE
A conditional variable changes.
Definition: order_type.h:149
engine_func.h
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
CMD_CLONE_ORDER
@ CMD_CLONE_ORDER
clone (and share) an order
Definition: command_type.h:273
hotkeys.h
roadveh.h
WID_O_GOTO
@ WID_O_GOTO
Goto destination.
Definition: order_widget.h:23
OrdersWindow::OrderClick_FullLoad
void OrderClick_FullLoad(int load_type)
Handle the click on the full load button.
Definition: order_gui.cpp:581
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:518
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:524
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:517