OpenTTD Source: src/order_gui.cpp File Reference

OpenTTD Source 15.3

Data Structures | Enumerations | Functions | Variables
order_gui.cpp File Reference

GUI related to orders. More...

`#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 "dropdown_type.h"`
`#include "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 "vehiclelist.h"`
`#include "error.h"`
`#include "order_cmd.h"`
`#include "company_cmd.h"`
`#include "core/string_consumer.hpp"`
`#include "widgets/order_widget.h"`
`#include "table/strings.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 | OrderHotKeys : int32_t { 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. More...

## Functions
uint | ConvertSpeedToDisplaySpeed (uint speed, VehicleType type)
| Convert the given (internal) speed to the display speed.
uint | ConvertDisplaySpeedToSpeed (uint speed, VehicleType type)
| Convert the given display speed to the (internal) speed.
static OrderDepotAction | DepotActionStringIndex (const Order *order)
static StringID | GetOrderGoToString (const Order &order)
void | DrawOrderString (const Vehicle *v, const Order *order, VehicleOrderID order_index, int y, bool selected, bool timetable, int left, int middle, int right)
| Draws an order in order or timetable GUI.
static Order | GetOrderCmdFromTile (const Vehicle *v, TileIndex tile)
| Get the order command a vehicle can do in a given tile.
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_dropdown []
static const StringID | _order_full_load_dropdown []
static const StringID | _order_unload_dropdown []
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.
static const StringID | _order_conditional_condition []
static const StringID | _order_depot_action_dropdown []
static const StringID | _order_refit_action_dropdown []
static constexpr std::initializer_list< 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, WindowDefaultFlag::Construction, _nested_orders_train_widgets, &OrdersWindow::hotkeys)
static constexpr std::initializer_list< 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, WindowDefaultFlag::Construction, _nested_orders_widgets, &OrdersWindow::hotkeys)
static constexpr std::initializer_list< NWidgetPart > | _nested_other_orders_widgets
| Nested widget definition for competitor orders.
static WindowDesc | _other_orders_desc (WDP_AUTO, "view_vehicle_orders_competitor", 384, 86, WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW, WindowDefaultFlag::Construction, _nested_other_orders_widgets, &OrdersWindow::hotkeys)

## Detailed Description

GUI related to orders.

Definition in file order_gui.cpp.

## Enumeration Type Documentation

## ◆ OrderHotKeys

enum OrderHotKeys : int32_t

Hotkeys for order window.

Definition at line 444 of file order_gui.cpp.

## Function Documentation

## ◆ ConvertDisplaySpeedToSpeed()

uint ConvertDisplaySpeedToSpeed | ( | uint | speed,
|  | VehicleType | type
| ) |  |
| extern

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

Parameters

  speed | the speed to convert

Returns
  the converted speed.

Definition at line 981 of file strings.cpp.

References Units::c, UnitConversion::FromDisplay(), and GetVelocityUnits().

Referenced by OrdersWindow::OnQueryTextFinished().

## ◆ ConvertSpeedToDisplaySpeed()

uint ConvertSpeedToDisplaySpeed | ( | uint | speed,
|  | VehicleType | type
| ) |  |
| extern

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

Parameters

  speed | the speed to convert

Returns
  the converted speed.

Definition at line 968 of file strings.cpp.

References Units::c, GetVelocityUnits(), and UnitConversion::ToDisplay().

Referenced by DrawOrderString(), OrdersWindow::GetWidgetString(), and OrdersWindow::OnClick().

## ◆ DepotActionStringIndex()

static OrderDepotAction DepotActionStringIndex | ( | const Order * | order | ) |
| static

Definition at line 189 of file order_gui.cpp.

## ◆ DrawOrderString()

void DrawOrderString | ( | const Vehicle * | v,
|  | const Order * | order,
|  | VehicleOrderID | 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 223 of file order_gui.cpp.

References _current_text_dir, _settings_client, _station_load_types, AircraftCache::cached_max_range_sqr, CanVehicleUseStation(), ConvertSpeedToDisplaySpeed(), BaseConsist::cur_implicit_order_index, BaseConsist::cur_real_order_index, DrawSprite(), DrawString(), SpecializedVehicle< Aircraft, VEH_AIRCRAFT >::From(), FS_NORMAL, SpecializedStation< Station, false >::Get(), CargoSpec::Get(), GetCharacterHeight(), Order::GetConditionComparator(), Order::GetConditionSkipToOrder(), Order::GetConditionValue(), Order::GetConditionVariable(), Order::GetDepotActionType(), Order::GetDestination(), Order::GetLoadType(), OrderList::GetNext(), Order::GetNonStopType(), GetOrderDistance(), Aircraft::GetRange(), Order::GetRefitCargo(), GetSpriteSize(), Order::GetStopLocation(), GetString(), GetTimetableParameters(), Order::GetType(), Order::GetUnloadType(), Order::GetWaitTime(), ClientSettings::gui, Halt, INVALID_STRING_ID, Order::IsAutoRefit(), IsFalse, Order::IsGotoOrder(), Vehicle::IsGroundVehicle(), Order::IsRefit(), IsTrue, Order::IsType(), Order::IsWaitTimetabled(), MaxSpeed, CargoSpec::name, NearestDepot, NoDestination, NoIntermediate, Vehicle::orders, SA_FORCE, SA_RIGHT, GUISettings::stop_location, TC_NO_SHADE, TD_RTL, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), to_underlying(), BaseVehicle::type, Unbunch, Unconditionally, VEH_AIRCRAFT, and VEH_TRAIN.

Referenced by TimetableWindow::DrawTimetablePanel(), and OrdersWindow::DrawWidget().

## ◆ 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 367 of file order_gui.cpp.

References _ctrl_pressed, _local_company, _settings_client, Airport, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Any(), BusStop, Dock, BaseStation::facilities, FarEnd, Order::Free(), FullLoadAny, BaseStation::GetByTile(), Industry::GetByTile(), GetDepotDestinationIndex(), GetStationIndex(), ClientSettings::gui, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, IsBuoyTile(), IsDepotTypeTile(), Vehicle::IsGroundVehicle(), IsRailWaypointTile(), IsRoadWaypointTile(), IsTileOwner(), IsTileType(), Order::MakeGoToDepot(), Order::MakeGoToStation(), Order::MakeGoToWaypoint(), MP_INDUSTRY, MP_STATION, Industry::neutral_station, GUISettings::new_nonstop, NoDestination, NoIntermediate, BaseStation::owner, OWNER_NONE, PartOfOrders, Order::SetDepotActionType(), Order::SetLoadType(), Order::SetNonStopType(), Order::SetStopLocation(), GUISettings::stop_location, Train, TruckStop, BaseVehicle::type, Unbunch, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by OrdersWindow::OnPlaceObject().

## ◆ GetOrderGoToString()

static StringID GetOrderGoToString | ( | const Order & | order | ) |
| static

Definition at line 202 of file order_gui.cpp.

## ◆ ShowOrdersWindow()

void ShowOrdersWindow | ( | const Vehicle * | v | ) |

Definition at line 1739 of file order_gui.cpp.

## Variable Documentation

## ◆ _nested_orders_train_widgets

constexpr std::initializer_list<NWidgetPart> _nested_orders_train_widgets
| staticconstexpr

Nested widget definition for "your" train orders.

Definition at line 1563 of file order_gui.cpp.

## ◆ _nested_orders_widgets

constexpr std::initializer_list<NWidgetPart> _nested_orders_widgets
| staticconstexpr

Nested widget definition for "your" orders (non-train).

Definition at line 1640 of file order_gui.cpp.

## ◆ _nested_other_orders_widgets

constexpr std::initializer_list<NWidgetPart> _nested_other_orders_widgets
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_O_CAPTION), SetStringTip(STR_ORDERS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_O_TIMETABLE_VIEW), SetMinimalSize(61, 14), SetStringTip(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), SetToolTip(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(),
}
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition widget_type.h:1402
SetStringTip
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
Definition widget_type.h:1243
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition widget_type.h:1159
SetToolTip
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
Definition widget_type.h:1321
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1232
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1427
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition widget_type.h:1148
WID_O_TIMETABLE_VIEW
@ WID_O_TIMETABLE_VIEW
Toggle timetable view.
Definition order_widget.h:16
WID_O_SCROLLBAR
@ WID_O_SCROLLBAR
Order list scrollbar.
Definition order_widget.h:18
WID_O_ORDER_LIST
@ WID_O_ORDER_LIST
Order list panel.
Definition order_widget.h:17
WID_O_CAPTION
@ WID_O_CAPTION
Caption of the window.
Definition order_widget.h:15
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition widget_type.h:105
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:57
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition widget_type.h:55
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition widget_type.h:76
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
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:56

Nested widget definition for competitor orders.

Definition at line 1713 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,
}

Definition at line 168 of file order_gui.cpp.

## ◆ _order_conditional_variable

const OrderConditionVariable _order_conditional_variable[]
| static

Initial value:
= {
OrderConditionVariable::LoadPercentage,
OrderConditionVariable::Reliability,
OrderConditionVariable::MaxReliability,
OrderConditionVariable::MaxSpeed,
OrderConditionVariable::Age,
OrderConditionVariable::RemainingLifetime,
OrderConditionVariable::RequiresService,
OrderConditionVariable::Unconditionally,
}
OrderConditionVariable::Unconditionally
@ Unconditionally
Always skip.
OrderConditionVariable::MaxSpeed
@ MaxSpeed
Skip based on the maximum speed.
OrderConditionVariable::Reliability
@ Reliability
Skip based on the reliability.
OrderConditionVariable::MaxReliability
@ MaxReliability
Skip based on the maximum reliability.
OrderConditionVariable::RequiresService
@ RequiresService
Skip when the vehicle requires service.
OrderConditionVariable::LoadPercentage
@ LoadPercentage
Skip based on the amount of load.
OrderConditionVariable::Age
@ Age
Skip based on the age.
OrderConditionVariable::RemainingLifetime
@ RemainingLifetime
Skip based on the remaining lifetime.

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

Definition at line 157 of file order_gui.cpp.

Referenced by OrdersWindow::OnClick(), and 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,
STR_ORDER_DROP_UNBUNCH,
}

Definition at line 182 of file order_gui.cpp.

## ◆ _order_full_load_dropdown

const StringID _order_full_load_dropdown[]
| 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,
}

Definition at line 126 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,
}

Definition at line 142 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,
}

Definition at line 149 of file order_gui.cpp.

## ◆ _order_non_stop_dropdown

const StringID _order_non_stop_dropdown[]
| static

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

Definition at line 119 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,
}

Definition at line 197 of file order_gui.cpp.

## ◆ _order_unload_dropdown

const StringID _order_unload_dropdown[]
| static

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

Definition at line 134 of file order_gui.cpp.

## ◆ _station_load_types

const StringID _station_load_types[][5][5]
| static

Order load types that could be given to station orders.

Definition at line 47 of file order_gui.cpp.

Referenced by DrawOrderString().