41#include "table/strings.h"
54 STR_ORDER_FULL_LOAD_ANY,
59 STR_ORDER_UNLOAD_FULL_LOAD,
60 STR_ORDER_UNLOAD_FULL_LOAD_ANY,
61 STR_ORDER_UNLOAD_NO_LOAD,
65 STR_ORDER_TRANSFER_FULL_LOAD,
66 STR_ORDER_TRANSFER_FULL_LOAD_ANY,
67 STR_ORDER_TRANSFER_NO_LOAD,
78 STR_ORDER_NO_UNLOAD_FULL_LOAD,
79 STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY,
80 STR_ORDER_NO_UNLOAD_NO_LOAD,
87 STR_ORDER_FULL_LOAD_REFIT,
88 STR_ORDER_FULL_LOAD_ANY_REFIT,
91 STR_ORDER_UNLOAD_REFIT,
93 STR_ORDER_UNLOAD_FULL_LOAD_REFIT,
94 STR_ORDER_UNLOAD_FULL_LOAD_ANY_REFIT,
97 STR_ORDER_TRANSFER_REFIT,
99 STR_ORDER_TRANSFER_FULL_LOAD_REFIT,
100 STR_ORDER_TRANSFER_FULL_LOAD_ANY_REFIT,
110 STR_ORDER_NO_UNLOAD_REFIT,
112 STR_ORDER_NO_UNLOAD_FULL_LOAD_REFIT,
113 STR_ORDER_NO_UNLOAD_FULL_LOAD_ANY_REFIT,
119static const StringID _order_non_stop_drowdown[] = {
121 STR_ORDER_GO_NON_STOP_TO,
123 STR_ORDER_GO_NON_STOP_VIA,
126static const StringID _order_full_load_drowdown[] = {
127 STR_ORDER_DROP_LOAD_IF_POSSIBLE,
129 STR_ORDER_DROP_FULL_LOAD_ALL,
130 STR_ORDER_DROP_FULL_LOAD_ANY,
131 STR_ORDER_DROP_NO_LOADING,
134static const StringID _order_unload_drowdown[] = {
135 STR_ORDER_DROP_UNLOAD_IF_ACCEPTED,
136 STR_ORDER_DROP_UNLOAD,
137 STR_ORDER_DROP_TRANSFER,
139 STR_ORDER_DROP_NO_UNLOADING,
142static const StringID _order_goto_dropdown[] = {
144 STR_ORDER_GO_TO_NEAREST_DEPOT,
145 STR_ORDER_CONDITIONAL,
149static const StringID _order_goto_dropdown_aircraft[] = {
151 STR_ORDER_GO_TO_NEAREST_HANGAR,
152 STR_ORDER_CONDITIONAL,
168static const StringID _order_conditional_condition[] = {
169 STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS,
170 STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS,
171 STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN,
172 STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS,
173 STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN,
174 STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS,
175 STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE,
176 STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE,
182static const StringID _order_depot_action_dropdown[] = {
183 STR_ORDER_DROP_GO_ALWAYS_DEPOT,
184 STR_ORDER_DROP_SERVICE_DEPOT,
185 STR_ORDER_DROP_HALT_DEPOT,
186 STR_ORDER_DROP_UNBUNCH,
189static int DepotActionStringIndex(
const Order *order)
202static const StringID _order_refit_action_dropdown[] = {
203 STR_ORDER_DROP_REFIT_AUTO,
204 STR_ORDER_DROP_REFIT_AUTO_ANY,
232 SpriteID sprite = rtl ? SPR_ARROW_LEFT : SPR_ARROW_RIGHT;
244 if (order->
IsType(OT_IMPLICIT)) {
245 colour = (selected ? TC_SILVER : TC_GREY) |
TC_NO_SHADE;
246 }
else if (selected) {
261 if (!timetable) line +=
GetString(STR_ORDER_IMPLICIT);
264 case OT_GOTO_STATION: {
305 line =
GetString(STR_ORDER_GO_TO_NEAREST_HANGAR_FORMAT, GetOrderGoToString(*order));
308 line =
GetString(STR_ORDER_GO_TO_NEAREST_DEPOT_FORMAT, GetOrderGoToString(*order), STR_ORDER_TRAIN_DEPOT + v->
type);
317 if (!timetable && order->
IsRefit()) {
323 line +=
GetString(STR_ORDER_WAIT_TO_UNBUNCH);
327 case OT_GOTO_WAYPOINT:
343 STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ,
349 line +=
GetString(order->
IsWaitTimetabled() ? STR_TIMETABLE_AND_TRAVEL_FOR : STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED, str, value);
353 default: NOT_REACHED();
359 line +=
GetString(STR_ORDER_OUT_OF_RANGE);
363 DrawString(rtl ? left : middle, rtl ? middle : right, y, line, colour);
453 default: NOT_REACHED();
564 int selected_order = -1;
579 int num = this->selected_order;
605 assert(type > OPOS_NONE && type < OPOS_END);
613 this->goto_type = type;
627 if (order ==
nullptr)
return;
646 if (order ==
nullptr)
return;
675 if (order ==
nullptr)
return;
702 if (order ==
nullptr || order->
GetNonStopType() == non_stop)
return;
733 int selected = this->selected_order + (int)
_networking;
736 this->selected_order = selected >= this->vehicle->
GetNumOrders() ? -1 : selected;
737 this->UpdateButtonState();
750 if (!this->vehicle->
IsOrderListShared() || this->selected_order != this->vehicle->GetNumOrders())
return;
761 this->UpdateButtonState();
788 this->can_do_refit =
false;
789 this->can_do_autorefit =
false;
804 nwid->SetToolTip(STR_ORDER_TRAIN_DEPOT_ACTION_TOOLTIP + v->
type);
814 int station_orders = std::ranges::count_if(v->Orders(), [](
const Order &order) { return order.IsType(OT_GOTO_STATION); });
826 size.height = 6 *
resize.height + padding.height;
834 d.width += padding.width;
835 d.height += padding.height;
842 d.width += padding.width;
843 d.height += padding.height;
855 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
873 if (this->selected_order == -1)
break;
876 this->selected_order = -1;
886 if (gui_scope)
break;
887 from =
GB(data, 0, 8);
891 if (this->selected_order == -1)
break;
893 if (from == to)
break;
895 if (from != this->selected_order) {
897 this->selected_order -= (int)(from <= this->selected_order);
899 this->selected_order += (int)(to <= this->selected_order);
907 this->selected_order = -1;
912 this->selected_order = to;
917 if (gui_scope) this->UpdateButtonState();
855 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override {
…}
925 void UpdateButtonState()
939 if (shared_orders && this->selected_order == this->vehicle->
GetNumOrders()) {
946 (uint)this->vehicle->
GetNumOrders() + ((shared_orders || this->vehicle->GetNumOrders() != 0) ? 1 : 0) <= (uint)this->selected_order);
951 if (this->selected_order == this->vehicle->
GetNumOrders()) {
952 nwi->
SetStringTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_ALL_TOOLTIP);
954 nwi->
SetStringTip(STR_ORDERS_DELETE_BUTTON, STR_ORDERS_DELETE_TOOLTIP);
970 assert(row_sel !=
nullptr || (train_row_sel !=
nullptr && left_sel !=
nullptr && middle_sel !=
nullptr && right_sel !=
nullptr));
973 if (order ==
nullptr) {
974 if (row_sel !=
nullptr) {
992 case OT_GOTO_STATION:
993 if (row_sel !=
nullptr) {
1010 ((!this->can_do_refit || !this->can_do_autorefit) && !order->
IsRefit()));
1014 case OT_GOTO_WAYPOINT:
1015 if (row_sel !=
nullptr) {
1031 if (row_sel !=
nullptr) {
1045 (!this->can_do_refit && !order->
IsRefit()));
1048 case OT_CONDITIONAL: {
1049 if (row_sel !=
nullptr) {
1056 this->GetWidget<NWidgetCore>(
WID_O_COND_VARIABLE)->SetString(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + ocv);
1064 if (row_sel !=
nullptr) {
1089 this->selected_order = -1;
1104 int middle = rtl ? ir.right - index_column_width : ir.left + index_column_width;
1107 int line_height = this->GetWidget<NWidgetBase>(
WID_O_ORDER_LIST)->resize_y;
1114 while (i < num_orders) {
1116 if (!this->vscroll->
IsVisible(i))
break;
1118 if (i != this->selected_order && i == this->order_over) {
1121 int bottom = std::min(
top + 2, ir.bottom);
1122 top = std::max(
top - 3, ir.top);
1137 while (i < num_orders) {
1139 if (!this->vscroll->
IsVisible(i))
break;
1141 DrawOrderString(this->vehicle, this->vehicle->
GetOrder(i), i, y, i == this->selected_order,
false, ir.left, middle, ir.right);
1149 DrawString(rtl ? ir.left : middle, rtl ? middle : ir.right, y, str, (i == this->selected_order) ? TC_WHITE : TC_BLACK);
1160 if (order !=
nullptr && order->
IsType(OT_CONDITIONAL)) {
1163 return GetString(STR_JUST_COMMA, value);
1174 if (order ==
nullptr || !order->
IsType(OT_GOTO_DEPOT))
return {};
1181 return GetString(STR_ORDER_DROP_GO_ALWAYS_DEPOT);
1193 if (this->goto_type == OPOS_CONDITIONAL) {
1218 this->selected_order = -1;
1219 }
else if (sel == this->selected_order && click_count > 1) {
1222 this->vehicle->
tile, this->vehicle->index, sel,
1223 MOF_STOP_LOCATION, (this->vehicle->GetOrder(sel)->GetStopLocation() + 1) % OSL_END);
1227 this->selected_order = sel;
1235 this->UpdateButtonState();
1252 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1256 assert(o !=
nullptr);
1258 o->
IsType(OT_GOTO_STATION) ? 0 : (o->
IsType(OT_GOTO_WAYPOINT) ? 3 : 12));
1263 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1264 if (this->goto_type != OPOS_NONE) {
1271 switch (this->goto_type) {
1272 case OPOS_NONE: sel = -1;
break;
1273 case OPOS_GOTO: sel = 0;
break;
1274 case OPOS_CONDITIONAL: sel = 2;
break;
1275 case OPOS_SHARE: sel = 3;
break;
1276 default: NOT_REACHED();
1283 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1291 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1307 if (this->GetWidget<NWidgetLeaf>(widget)->ButtonHit(pt)) {
1321 list.push_back(MakeDropDownListStringItem(STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + ocv, ocv));
1329 assert(o !=
nullptr);
1336 assert(order !=
nullptr);
1344 ShowVehicleListWindow(this->vehicle);
1351 if (!str.has_value() || str->empty())
return;
1355 if (!value.has_value())
return;
1364 value =
Clamp(*value, 0, 100);
1394 default: NOT_REACHED();
1425 this->selected_order = -1;
1426 this->UpdateButtonState();
1472 if (this->goto_type == OPOS_GOTO) {
1474 if (cmd.
IsType(OT_NOTHING))
return;
1483 bool OnVehicleSelect(
const Vehicle *v)
override
1490 bool share_order =
_ctrl_pressed || this->goto_type == OPOS_SHARE;
1491 if (this->vehicle->
GetNumOrders() != 0 && !share_order)
return false;
1494 this->
vehicle->tile, share_order ? CO_SHARE : CO_COPY, this->
vehicle->index, v->index)) {
1495 this->selected_order = -1;
1507 bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end)
override
1509 bool share_order =
_ctrl_pressed || this->goto_type == OPOS_SHARE;
1510 if (this->vehicle->
GetNumOrders() != 0 && !share_order)
return false;
1517 OnVehicleSelect(*begin);
1526 OnVehicleSelect(*begin);
1537 this->goto_type = OPOS_NONE;
1557 this->order_over = to_order;
1574 Hotkey(
'D',
"skip", OHK_SKIP),
1575 Hotkey(
'F',
"delete", OHK_DELETE),
1576 Hotkey(
'G',
"goto", OHK_GOTO),
1577 Hotkey(
'H',
"nonstop", OHK_NONSTOP),
1578 Hotkey(
'J',
"fullload", OHK_FULLLOAD),
1579 Hotkey(
'K',
"unload", OHK_UNLOAD),
1580 Hotkey(0,
"nearest_depot", OHK_NEAREST_DEPOT),
1581 Hotkey(0,
"always_service", OHK_ALWAYS_SERVICE),
1582 Hotkey(0,
"transfer", OHK_TRANSFER),
1583 Hotkey(0,
"no_unload", OHK_NO_UNLOAD),
1584 Hotkey(0,
"no_load", OHK_NO_LOAD),
1599 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_O_ORDER_LIST),
SetMinimalSize(372, 62),
SetToolTip(STR_ORDERS_LIST_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_O_SCROLLBAR),
EndContainer(),
1658 WDP_AUTO,
"view_vehicle_orders_train", 384, 100,
1662 &OrdersWindow::hotkeys
1676 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_O_ORDER_LIST),
SetMinimalSize(372, 62),
SetToolTip(STR_ORDERS_LIST_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_O_SCROLLBAR),
EndContainer(),
1731 WDP_AUTO,
"view_vehicle_orders", 384, 100,
1735 &OrdersWindow::hotkeys
1749 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(),
1758 WDP_AUTO,
"view_vehicle_orders_competitor", 384, 86,
1762 &OrdersWindow::hotkeys
1765void ShowOrdersWindow(
const Vehicle *v)
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
static const CargoType CARGO_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
static const CargoType CARGO_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-renew).
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
Functions related to commands.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Command definitions related to companies.
Functions related to companies.
static constexpr Owner OWNER_NONE
The tile has no ownership.
Map related accessors for depots.
bool IsDepotTypeTile(Tile tile, TransportType type)
Check if a tile is a depot and it is a depot of the given type.
DestinationID GetDepotDestinationIndex(Tile t)
Get the destination index of a 'depot'.
void ShowDropDownMenu(Window *w, std::span< const StringID > strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
bool IsEngineRefittable(EngineID engine)
Check if an engine is refittable.
Functions related to engines.
@ AutoRefit
Automatic refitting is allowed.
Functions related to errors.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Dimension GetStringListBoundingBox(std::span< const StringID > list, FontSize fontsize)
Get maximum dimension of a list of strings.
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
bool _ctrl_pressed
Is Ctrl pressed?
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.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ FS_NORMAL
Index of the normal font in the font tables.
@ SA_RIGHT
Right align the text (must be a single bit).
@ SA_FORCE
Force the alignment, i.e. don't swap for RTL languages.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
@ TC_NO_SHADE
Do not add shading to this text colour.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Hotkey related functions.
constexpr bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void ShowQueryString(std::string_view str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
bool _networking
are we in networking mode?
Basic functions/variables used all over the place.
uint GetOrderDistance(VehicleOrderID prev, VehicleOrderID cur, const Vehicle *v, int conditional_depth)
Get the distance between two orders of a vehicle.
Command definitions related to orders.
uint ConvertSpeedToDisplaySpeed(uint speed, VehicleType type)
Convert the given (internal) speed to the display speed.
static constexpr NWidgetPart _nested_other_orders_widgets[]
Nested widget definition for competitor orders.
static constexpr NWidgetPart _nested_orders_train_widgets[]
Nested widget definition for "your" train orders.
static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
Get the order command a vehicle can do in a given tile.
static const OrderConditionVariable _order_conditional_variable[]
Variables for conditional orders; this defines the order of appearance in the dropdown box.
OrderHotKeys
Hotkeys for order window.
static const StringID _station_load_types[][5][5]
Order load types that could be given to station orders.
static constexpr NWidgetPart _nested_orders_widgets[]
Nested widget definition for "your" orders (non-train).
uint ConvertDisplaySpeedToSpeed(uint speed, VehicleType type)
Convert the given display speed to the (internal) speed.
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.
OrderConditionVariable
Variables (of a vehicle) to 'cause' skipping on.
@ OCV_AGE
Skip based on the age.
@ OCV_UNCONDITIONALLY
Always skip.
@ OCV_MAX_SPEED
Skip based on the maximum speed.
@ OCV_LOAD_PERCENTAGE
Skip based on the amount of load.
@ OCV_REQUIRES_SERVICE
Skip when the vehicle requires service.
@ OCV_RELIABILITY
Skip based on the reliability.
@ OCV_REMAINING_LIFETIME
Skip based on the remaining lifetime.
@ OCV_MAX_RELIABILITY
Skip based on the maximum reliability.
OrderStopLocation
Where to stop the trains.
@ OSL_PLATFORM_FAR_END
Stop at the far end of the platform.
@ MOF_COND_VARIABLE
A conditional variable changes.
@ MOF_LOAD
Passes an OrderLoadType.
@ MOF_UNLOAD
Passes an OrderUnloadType.
@ MOF_STOP_LOCATION
Passes an OrderStopLocation.
@ MOF_COND_COMPARATOR
A comparator changes.
@ MOF_COND_VALUE
The value to set the condition to.
@ MOF_DEPOT_ACTION
Selects the OrderDepotAction.
@ MOF_NON_STOP
Passes an OrderNonStopFlags.
OrderUnloadFlags
Flags related to the unloading order.
@ OUFB_TRANSFER
Transfer all cargo onto the platform.
@ OUFB_NO_UNLOAD
Totally no unloading will be done.
@ OUF_UNLOAD_IF_POSSIBLE
Unload all cargo that the station accepts.
@ OUFB_UNLOAD
Force unloading all cargo onto the platform, possibly not getting paid.
@ DA_SERVICE
Service only if needed.
@ DA_STOP
Go to the depot and stop there.
@ DA_ALWAYS_GO
Always go to the depot.
@ DA_UNBUNCH
Go to the depot and unbunch.
@ ODTFB_PART_OF_ORDERS
This depot order is because of a regular order.
@ ODTFB_SERVICE
This depot order is because of the servicing limit.
uint8_t VehicleOrderID
The index of an order within its current vehicle (not pool related)
@ ODATFB_UNBUNCH
Service the vehicle and then unbunch it.
@ ODATFB_NEAREST_DEPOT
Send the vehicle to the nearest depot.
@ ODATFB_HALT
Service the vehicle and then halt it.
OrderLoadFlags
Flags related to the loading order.
@ OLFB_NO_LOAD
Do not load anything.
@ OLF_LOAD_IF_POSSIBLE
Load as long as there is cargo that fits in the train.
@ OLF_FULL_LOAD_ANY
Full load a single cargo of the consist.
static const VehicleOrderID INVALID_VEH_ORDER_ID
Invalid vehicle order index (sentinel)
OrderConditionComparator
Comparator for the skip reasoning.
@ OCC_IS_TRUE
Skip if the variable is true.
@ OCC_IS_FALSE
Skip if the variable is false.
@ ONSF_NO_STOP_AT_ANY_STATION
The vehicle will not stop at any stations it passes including the destination.
@ ONSF_NO_STOP_AT_DESTINATION_STATION
The vehicle will stop at any station it passes except the destination.
@ ONSF_STOP_EVERYWHERE
The vehicle will stop at any station it passes and the destination.
@ ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS
The vehicle will not stop at any stations it passes except the destination.
uint8_t GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
A number of safeguards to prevent using unsafe methods.
ClientSettings _settings_client
The current settings for this game.
static const CursorID ANIMCURSOR_PICKSTATION
716 - 718 - goto-order icon
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
Base classes/functions for stations.
bool IsRailWaypointTile(Tile t)
Is this tile a station tile and a rail waypoint?
StationID GetStationIndex(Tile t)
Get StationID from a tile.
bool IsRoadWaypointTile(Tile t)
Is this tile a station tile and a road waypoint?
bool IsBuoyTile(Tile t)
Is tile t a buoy tile?
@ Dock
Station with a dock.
@ TruckStop
Station with truck stops.
@ Train
Station with train station.
@ Airport
Station with an airport.
@ BusStop
Station with bus stops.
Definition of base types and functions in a cross-platform compatible way.
static std::optional< T > ParseInteger(std::string_view arg, int base=10, bool clamp=false)
Change a string into its number representation.
Functions related to low-level strings.
@ CS_NUMERAL
Only numeric ones.
uint64_t GetParamMaxValue(uint64_t max_value, uint min_count, FontSize size)
Get some number that is suitable for string size computations.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
TextDirection _current_text_dir
Text direction of the currently selected language.
Functions related to OTTD's strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
@ TD_RTL
Text is written right-to-left by default.
uint32_t cached_max_range_sqr
Cached squared maximum range.
uint16_t GetRange() const
Get the range of this aircraft.
VehicleOrderID cur_real_order_index
The index to the current real (non-implicit) order.
VehicleOrderID cur_implicit_order_index
The index to the current implicit order.
StationFacilities facilities
The facilities that this station has.
Owner owner
The owner of this station.
static BaseStation * GetByTile(TileIndex tile)
Get the base station belonging to a specific tile.
VehicleType type
Type of vehicle.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo type.
StringID name
Name of this type of cargo.
GUISettings gui
settings related to the GUI
Point pos
logical mouse position
Dimensions (a width and height) of a rectangle in 2D.
bool new_nonstop
ttdpatch compatible nonstop handling
bool quick_goto
Allow quick access to 'goto button' in vehicle orders window.
uint8_t stop_location
what is the default stop location of trains?
List of hotkeys for a window.
All data for a single hotkey.
Defines the internal data of a functional industry.
static Industry * GetByTile(TileIndex tile)
Get the industry of the given tile.
Station * neutral_station
Associated neutral station.
VehicleOrderID GetNext(VehicleOrderID cur) const
Get the order after the given one or the first one, if the given one is the last one.
TileIndex GetLocation(const Vehicle *v, bool airport=false) const
Returns a tile somewhat representing the order destination (not suitable for pathfinding).
bool IsGotoOrder() const
Is this a 'goto' order with a real destination?
OrderDepotTypeFlags GetDepotOrderType() const
What caused us going to the depot?
OrderConditionVariable GetConditionVariable() const
What variable do we have to compare?
void SetLoadType(OrderLoadFlags load_type)
Set how the consist must be loaded.
DestinationID GetDestination() const
Gets the destination of this order.
bool IsType(OrderType type) const
Check whether this order is of the given type.
void SetNonStopType(OrderNonStopFlags non_stop_type)
Set whether we must stop at stations or not.
VehicleOrderID GetConditionSkipToOrder() const
Get the order to skip to.
OrderStopLocation GetStopLocation() const
Where must we stop at the platform?
uint16_t GetWaitTime() const
Get the time in ticks a vehicle will probably wait at the destination (timetabled or not).
CargoType GetRefitCargo() const
Get the cargo to to refit to.
OrderType GetType() const
Get the type of order of this order.
void MakeGoToStation(StationID destination)
Makes this order a Go To Station order.
OrderLoadFlags GetLoadType() const
How must the consist be loaded?
void SetStopLocation(OrderStopLocation stop_location)
Set where we must stop at the platform.
void MakeGoToWaypoint(StationID destination)
Makes this order a Go To Waypoint order.
bool IsWaitTimetabled() const
Does this order have an explicit wait time set?
void MakeConditional(VehicleOrderID order)
Makes this order an conditional order.
void SetDepotActionType(OrderDepotActionFlags depot_service_type)
Set what we are going to do in the depot.
OrderDepotActionFlags GetDepotActionType() const
What are we going to do when in the depot.
void Free()
'Free' the order
bool IsAutoRefit() const
Is this order a auto-refit order.
OrderUnloadFlags GetUnloadType() const
How must the consist be unloaded?
OrderConditionComparator GetConditionComparator() const
What is the comparator to use?
OrderNonStopFlags GetNonStopType() const
At which stations must we stop?
bool IsRefit() const
Is this order a refit order.
uint16_t GetConditionValue() const
Get the value to base the skip on.
void MakeGoToDepot(DestinationID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action=ODATF_SERVICE_ONLY, CargoType cargo=CARGO_NO_REFIT)
Makes this order a Go To Depot order.
Order window code for all vehicles.
void OrderClick_Refit(int i, bool auto_refit)
Handle the click on the refit button.
void OrderClick_FullLoad(OrderLoadFlags load_type, bool toggle=false)
Handle the click on the full load button.
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
void OrderClick_Delete()
Handle the click on the delete button.
void OnResize() override
Called after the window got resized.
void OrderClick_Skip()
Handle the click on the skip button.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end) override
Clones an order list from a vehicle list.
const Vehicle * vehicle
Vehicle owning the orders being displayed and manipulated.
void OrderClick_Service(int i)
Handle the click on the service.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OrderClick_Nonstop(int non_stop)
Handle the click on the nonstop button.
bool can_do_refit
Vehicle chain can be refitted in depot.
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
DisplayPane
Displayed planes of the NWID_SELECTION widgets.
@ DP_BOTTOM_MIDDLE_DELETE
Display 'delete' in the middle button of the bottom row of the vehicle order window.
@ DP_ROW_CONDITIONAL
Display the conditional order buttons in the top row of the ship/airplane order window.
@ DP_ROW_DEPOT
Display 'refit' / 'service' buttons in the top row of the ship/airplane order window.
@ DP_BOTTOM_MIDDLE_STOP_SHARING
Display 'stop sharing' in the middle button of the bottom row of the vehicle order window.
@ DP_MIDDLE_UNLOAD
Display 'unload' in the middle button of the top row of the train/rv order window.
@ DP_LEFT_LOAD
Display 'load' in the left button of the top row of the train/rv order window.
@ DP_RIGHT_EMPTY
Display an empty panel in the right button of the top row of the train/rv order window.
@ DP_RIGHT_REFIT
Display 'refit' in the right button of the top row of the train/rv order window.
@ DP_ROW_LOAD
Display 'load' / 'unload' / 'refit' buttons in the top row of the ship/airplane order window.
@ DP_MIDDLE_SERVICE
Display 'service' in the middle button of the top row of the train/rv order window.
@ DP_GROUNDVEHICLE_ROW_CONDITIONAL
Display the row for conditional orders in the top row of the train/rv order window.
@ DP_LEFT_REFIT
Display 'refit' in the left button of the top row of the train/rv order window.
@ DP_GROUNDVEHICLE_ROW_NORMAL
Display the row for normal/depot orders in the top row of the train/rv order window.
void OrderClick_NearestDepot()
Handle the click on the service in nearest depot button.
void OrderClick_StopSharing()
Handle the click on the 'stop sharing' button.
VehicleOrderID OrderGetSel() const
Return the memorised selected order.
void UpdateAutoRefitState()
Cache auto-refittability of the vehicle chain.
void OnPaint() override
The window must be repainted.
void OnDragDrop(Point pt, WidgetID widget) override
A dragged 'object' has been released.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnMouseDrag(Point pt, WidgetID widget) override
An 'object' is being dragged at the provided position, highlight the target if possible.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
OrderPlaceObjectState
Under what reason are we using the PlaceObject functionality?
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
void OrderClick_Unload(OrderUnloadFlags unload_type, bool toggle=false)
Handle the click on the unload button.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
VehicleOrderID GetOrderFromPt(int y)
Calculate the selected order.
bool can_do_autorefit
Vehicle chain can be auto-refitted.
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
void OrderClick_Goto(OrderPlaceObjectState type)
Handle the click on the goto button.
VehicleOrderID order_over
Order over which another order is dragged, INVALID_VEH_ORDER_ID if none.
Coordinates of a point in 2D.
static Titem * Get(auto index)
Returns Titem with given index.
Tindex index
Index of this pool item.
Specification of a rectangle with absolute coordinates of all edges.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
static Station * Get(auto index)
Gets station with given index.
static Aircraft * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
bool IsOrderListShared() const
Check if we share our orders with another vehicle.
Order * GetOrder(int index) const
Returns order 'index' of a vehicle or nullptr when it doesn't exists.
bool HasUnbunchingOrder() const
Check if the current vehicle has an unbunching order.
VehicleOrderID GetNumOrders() const
Get the number of orders this vehicle has.
OrderList * orders
Pointer to the order list for this vehicle.
Vehicle * NextShared() const
Get the next vehicle of the shared vehicle chain.
bool HasFullLoadOrder() const
Check if the current vehicle has a full load order.
Vehicle * PreviousShared() const
Get the previous vehicle of the shared vehicle chain.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
debug_inline bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
TileIndex tile
Current tile index.
bool HasConditionalOrder() const
Check if the current vehicle has a conditional order.
Owner owner
Which company owns the vehicle?
High level window description.
Data structure for an opened window.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void DrawWidgets() const
Paint all widgets of a window.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
ResizeInfo resize
Resize information.
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
void EnableWidget(WidgetID widget_index)
Sets a widget to Enabled.
int top
y position of top edge of the window
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
int width
width of the window (number of pixels to the right in x direction)
WindowNumber window_number
Window number within the window class.
Stuff related to the text buffer GUI.
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ MP_STATION
A tile of a station.
@ MP_INDUSTRY
Part of an industry.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
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...
HighLightStyle
Highlighting draw styles.
@ HT_DRAG
dragging items in the depot windows
@ HT_RECT
rectangle (stations, depots, ...)
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
TransportType
Available types of transport.
bool VehiclesHaveSameOrderList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicles have the same list of orders.
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
Can this station be used by the given engine type?
Functions related to vehicles.
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order, Window *parent, bool auto_refit)
Show the refit window for a vehicle.
@ VIWD_CONSIST_CHANGED
Vehicle composition was changed.
@ VIWD_AUTOREPLACE
Autoreplace replaced the vehicle.
@ VIWD_MODIFY_ORDERS
Other order modifications.
@ VIWD_REMOVE_ALL_ORDERS
Removed / replaced all orders (after deleting / sharing).
VehicleType
Available vehicle types.
@ VEH_ROAD
Road vehicle type.
@ VEH_AIRCRAFT
Aircraft vehicle type.
@ VEH_SHIP
Ship vehicle type.
@ VEH_TRAIN
Train vehicle type.
Functions and type for generating vehicle lists.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Functions related to (drawing on) viewports.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
@ Construction
This window is used for construction; close it whenever changing company.
bool AllEqual(It begin, It end, Pred pred)
Generic helper function that checks if all elements of the range are equal with respect to the given ...
@ WDP_AUTO
Find a place automatically.
EventState
State of handling an event.
@ ES_HANDLED
The passed event is handled.
@ ES_NOT_HANDLED
The passed event is not handled.
@ WC_VEHICLE_ORDERS
Vehicle orders; Window numbers:
@ WC_VEHICLE_DETAILS
Vehicle details; Window numbers:
@ WC_VEHICLE_VIEW
Vehicle view; Window numbers:
@ WC_VEHICLE_TIMETABLE
Vehicle timetable; Window numbers: