OpenTTD Source: src/order_gui.cpp File Reference

OpenTTD Source 12.0-beta1

Data Structures | Enumerations | Functions | Variables
order_gui.cpp File Reference
`#include "stdafx.h"`
`#include "command_func.h"`
`#include "viewport_func.h"`
`#include "depot_map.h"`
`#include "roadveh.h"`
`#include "timetable.h"`
`#include "strings_func.h"`
`#include "company_func.h"`
`#include "widgets/dropdown_type.h"`
`#include "widgets/dropdown_func.h"`
`#include "textbuf_gui.h"`
`#include "string_func.h"`
`#include "tilehighlight_func.h"`
`#include "network/network.h"`
`#include "station_base.h"`
`#include "industry.h"`
`#include "waypoint_base.h"`
`#include "core/geometry_func.hpp"`
`#include "hotkeys.h"`
`#include "aircraft.h"`
`#include "engine_func.h"`
`#include "vehicle_func.h"`
`#include "widgets/order_widget.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | OrdersWindow
| Order window code for all vehicles. More...

## Enumerations
enum | { OHK_SKIP, OHK_DELETE, OHK_GOTO, OHK_NONSTOP, OHK_FULLLOAD, OHK_UNLOAD, OHK_NEAREST_DEPOT, OHK_ALWAYS_SERVICE, OHK_TRANSFER, OHK_NO_UNLOAD, OHK_NO_LOAD }
| Hotkeys for order window.

## Functions
uint | ConvertSpeedToDisplaySpeed (uint speed)
| Convert the given (internal) speed to the display speed. More...
uint | ConvertDisplaySpeedToSpeed (uint speed)
| Convert the given display speed to the (internal) speed. More...
static int | DepotActionStringIndex (const Order *order)
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. More...
static Order | GetOrderCmdFromTile (const Vehicle *v, TileIndex tile)
| Get the order command a vehicle can do in a given tile. More...
void | ShowOrdersWindow (const Vehicle *v)

## Variables
static const StringID | _station_load_types [][5][5]
| Order load types that could be given to station orders.
static const StringID | _order_non_stop_drowdown []
static const StringID | _order_full_load_drowdown []
static const StringID | _order_unload_drowdown []
static const StringID | _order_goto_dropdown []
static const StringID | _order_goto_dropdown_aircraft []
static const OrderConditionVariable | _order_conditional_variable []
| Variables for conditional orders; this defines the order of appearance in the dropdown box. More...
static const StringID | _order_conditional_condition []
static const StringID | _order_depot_action_dropdown []
static const StringID | _order_refit_action_dropdown []
static Hotkey | order_hotkeys []
static const NWidgetPart | _nested_orders_train_widgets []
| Nested widget definition for "your" train orders.
static WindowDesc | _orders_train_desc (WDP_AUTO, "view_vehicle_orders_train", 384, 100, WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, _nested_orders_train_widgets, lengthof(_nested_orders_train_widgets), &OrdersWindow::hotkeys)
static const NWidgetPart | _nested_orders_widgets []
| Nested widget definition for "your" orders (non-train).
static WindowDesc | _orders_desc (WDP_AUTO, "view_vehicle_orders", 384, 100, WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, _nested_orders_widgets, lengthof(_nested_orders_widgets), &OrdersWindow::hotkeys)
static const NWidgetPart | _nested_other_orders_widgets []
| Nested widget definition for competitor orders. More...
static WindowDesc | _other_orders_desc (WDP_AUTO, "view_vehicle_orders_competitor", 384, 86, WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, WDF_CONSTRUCTION, _nested_other_orders_widgets, lengthof(_nested_other_orders_widgets), &OrdersWindow::hotkeys)

## Detailed Description

GUI related to orders.

Definition in file order_gui.cpp.

## Function Documentation

## ◆ ConvertDisplaySpeedToSpeed()

uint ConvertDisplaySpeedToSpeed | ( | uint | speed | ) |

Convert the given display speed to the (internal) speed.

Parameters

  speed | the speed to convert

Returns
  the converted speed.

Definition at line 764 of file strings.cpp.

References _settings_game, _units_velocity, Units::c, UnitConversion::FromDisplay(), GameSettings::locale, and LocaleSettings::units_velocity.

Referenced by OrdersWindow::OnQueryTextFinished().

## ◆ ConvertSpeedToDisplaySpeed()

uint ConvertSpeedToDisplaySpeed | ( | uint | speed | ) |

Convert the given (internal) speed to the display speed.

Parameters

  speed | the speed to convert

Returns
  the converted speed.

Definition at line 751 of file strings.cpp.

References _settings_game, _units_velocity, Units::c, GameSettings::locale, UnitConversion::ToDisplay(), and LocaleSettings::units_velocity.

## ◆ 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.

Parameters

  v | Vehicle the order belongs to
  order | The order to draw
  order_index | Index of the order in the orders of the vehicle
  y | Y position for drawing
  selected | True, if the order is selected
  timetable | True, when drawing in the timetable GUI
  left | Left border for text drawing
  middle | X position between order index and order text
  right | Right border for text drawing

Definition at line 214 of file order_gui.cpp.

## ◆ GetOrderCmdFromTile()

static Order GetOrderCmdFromTile | ( | const Vehicle * | v,
|  | TileIndex | tile
| ) |  |
| static

Get the order command a vehicle can do in a given tile.

Parameters

  v | Vehicle involved.
  tile | Tile being queried.

Returns
  The order associated to vehicle v in given tile (or empty order if vehicle can do nothing in the tile).

Definition at line 359 of file order_gui.cpp.

References _ctrl_pressed, _local_company, _settings_client, FACIL_AIRPORT, FACIL_BUS_STOP, FACIL_DOCK, FACIL_TRAIN, FACIL_TRUCK_STOP, Industry::GetByTile(), SpecializedStation< Station, false >::GetByTile(), GetDepotIndex(), Order::GetDepotOrderType(), GetStationIndex(), ClientSettings::gui, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsBuoyTile(), IsDepotTypeTile(), Vehicle::IsGroundVehicle(), IsRailWaypointTile(), IsTileOwner(), IsTileType(), Order::MakeGoToDepot(), Order::MakeGoToWaypoint(), MP_INDUSTRY, MP_STATION, Industry::neutral_station, GUISettings::new_nonstop, ODTFB_PART_OF_ORDERS, ODTFB_SERVICE, ONSF_NO_STOP_AT_ANY_STATION, ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, ONSF_STOP_EVERYWHERE, BaseStation::owner, OWNER_NONE, Order::SetDepotOrderType(), Order::SetNonStopType(), BaseVehicle::type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by OrdersWindow::OnPlaceObject().

## Variable Documentation

## ◆ _nested_other_orders_widgets

const NWidgetPart _nested_other_orders_widgets[]
| static

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetDataTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetDataTip(STR_ORDERS_TIMETABLE_VIEW, STR_ORDERS_TIMETABLE_VIEW_TOOLTIP),
NWidget(WWT_SHADEBOX, COLOUR_GREY),
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
NWidget(WWT_STICKYBOX, COLOUR_GREY),
EndContainer(),
NWidget(NWID_HORIZONTAL),
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(),
NWidget(NWID_VERTICAL),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_O_SCROLLBAR),
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
EndContainer(),
EndContainer(),
}

Nested widget definition for competitor orders.

Definition at line 1675 of file order_gui.cpp.

## ◆ _order_conditional_condition

const StringID _order_conditional_condition[]
| static

Initial value:
= {
STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS,
STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS,
STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN,
STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS,
STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN,
STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS,
STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE,
STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE,
INVALID_STRING_ID,
}

Definition at line 163 of file order_gui.cpp.

## ◆ _order_conditional_variable

const OrderConditionVariable _order_conditional_variable[]
| static

Initial value:
= {
OCV_LOAD_PERCENTAGE,
OCV_RELIABILITY,
OCV_MAX_RELIABILITY,
OCV_MAX_SPEED,
OCV_AGE,
OCV_REMAINING_LIFETIME,
OCV_REQUIRES_SERVICE,
OCV_UNCONDITIONALLY,
}

Variables for conditional orders; this defines the order of appearance in the dropdown box.

Definition at line 152 of file order_gui.cpp.

Referenced by OrdersWindow::UpdateWidgetSize().

## ◆ _order_depot_action_dropdown

const StringID _order_depot_action_dropdown[]
| static

Initial value:
= {
STR_ORDER_DROP_GO_ALWAYS_DEPOT,
STR_ORDER_DROP_SERVICE_DEPOT,
STR_ORDER_DROP_HALT_DEPOT,
INVALID_STRING_ID
}

Definition at line 178 of file order_gui.cpp.

## ◆ _order_full_load_drowdown

const StringID _order_full_load_drowdown[]
| static

Initial value:
= {
STR_ORDER_DROP_LOAD_IF_POSSIBLE,
STR_EMPTY,
STR_ORDER_DROP_FULL_LOAD_ALL,
STR_ORDER_DROP_FULL_LOAD_ANY,
STR_ORDER_DROP_NO_LOADING,
INVALID_STRING_ID
}

Definition at line 117 of file order_gui.cpp.

## ◆ _order_goto_dropdown

const StringID _order_goto_dropdown[]
| static

Initial value:
= {
STR_ORDER_GO_TO,
STR_ORDER_GO_TO_NEAREST_DEPOT,
STR_ORDER_CONDITIONAL,
STR_ORDER_SHARE,
INVALID_STRING_ID
}

Definition at line 135 of file order_gui.cpp.

## ◆ _order_goto_dropdown_aircraft

const StringID _order_goto_dropdown_aircraft[]
| static

Initial value:
= {
STR_ORDER_GO_TO,
STR_ORDER_GO_TO_NEAREST_HANGAR,
STR_ORDER_CONDITIONAL,
STR_ORDER_SHARE,
INVALID_STRING_ID
}

Definition at line 143 of file order_gui.cpp.

## ◆ _order_non_stop_drowdown

const StringID _order_non_stop_drowdown[]
| static

Initial value:
= {
STR_ORDER_GO_TO,
STR_ORDER_GO_NON_STOP_TO,
STR_ORDER_GO_VIA,
STR_ORDER_GO_NON_STOP_VIA,
INVALID_STRING_ID
}

Definition at line 109 of file order_gui.cpp.

## ◆ _order_refit_action_dropdown

const StringID _order_refit_action_dropdown[]
| static

Initial value:
= {
STR_ORDER_DROP_REFIT_AUTO,
STR_ORDER_DROP_REFIT_AUTO_ANY,
INVALID_STRING_ID
}

Definition at line 196 of file order_gui.cpp.

## ◆ _order_unload_drowdown

const StringID _order_unload_drowdown[]
| static

Initial value:
= {
STR_ORDER_DROP_UNLOAD_IF_ACCEPTED,
STR_ORDER_DROP_UNLOAD,
STR_ORDER_DROP_TRANSFER,
STR_EMPTY,
STR_ORDER_DROP_NO_UNLOADING,
INVALID_STRING_ID
}

Definition at line 126 of file order_gui.cpp.

## ◆ order_hotkeys

Hotkey order_hotkeys[]
| static

Initial value:
= {
Hotkey('D', "skip", OHK_SKIP),
Hotkey('F', "delete", OHK_DELETE),
Hotkey('G', "goto", OHK_GOTO),
Hotkey('H', "nonstop", OHK_NONSTOP),
Hotkey('J', "fullload", OHK_FULLLOAD),
Hotkey('K', "unload", OHK_UNLOAD),
Hotkey((uint16)0, "nearest_depot", OHK_NEAREST_DEPOT),
Hotkey((uint16)0, "always_service", OHK_ALWAYS_SERVICE),
Hotkey((uint16)0, "transfer", OHK_TRANSFER),
Hotkey((uint16)0, "no_unload", OHK_NO_UNLOAD),
Hotkey((uint16)0, "no_load", OHK_NO_LOAD),
HOTKEY_LIST_END
}

Definition at line 1507 of file order_gui.cpp.

SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1188
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
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
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:993
WID_O_SCROLLBAR
@ WID_O_SCROLLBAR
Order list scrollbar.
Definition: order_widget.h:18
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1107
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:104
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
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
WID_O_ORDER_LIST
@ WID_O_ORDER_LIST
Order list panel.
Definition: order_widget.h:17
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1092
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
OCV_MAX_SPEED
@ OCV_MAX_SPEED
Skip based on the maximum speed.
Definition: order_type.h:115
OCV_RELIABILITY
@ OCV_RELIABILITY
Skip based on the reliability.
Definition: order_type.h:114
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1207
OCV_REMAINING_LIFETIME
@ OCV_REMAINING_LIFETIME
Skip based on the remaining lifetime.
Definition: order_type.h:119
WID_O_TIMETABLE_VIEW
@ WID_O_TIMETABLE_VIEW
Toggle timetable view.
Definition: order_widget.h:16
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1010
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
OCV_LOAD_PERCENTAGE
@ OCV_LOAD_PERCENTAGE
Skip based on the amount of load.
Definition: order_type.h:113
WID_O_CAPTION
@ WID_O_CAPTION
Caption of the window.
Definition: order_widget.h:15
OCV_REQUIRES_SERVICE
@ OCV_REQUIRES_SERVICE
Skip when the vehicle requires service.
Definition: order_type.h:117
OCV_MAX_RELIABILITY
@ OCV_MAX_RELIABILITY
Skip based on the maximum reliability.
Definition: order_type.h:120
OCV_AGE
@ OCV_AGE
Skip based on the age.
Definition: order_type.h:116
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
OCV_UNCONDITIONALLY
@ OCV_UNCONDITIONALLY
Always skip.
Definition: order_type.h:118
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62