OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
38 #include "table/strings.h"
110 WDP_AUTO,
"depot_aircraft", 332, 99,
125 if (result.
Failed())
return;
136 if (v == wagon)
return;
138 if (wagon ==
nullptr) {
139 if (head !=
nullptr) wagon = head->
Last();
142 if (wagon ==
nullptr)
return;
145 if (wagon == v)
return;
163 switch (image_type) {
166 default: NOT_REACHED();
172 int max_extend_left = 0;
173 int max_extend_right = 0;
177 if (!e->IsEnabled())
continue;
184 default: NOT_REACHED();
190 if (y > max_height) max_height = y;
191 if (-x_offs > max_extend_left) max_extend_left = -x_offs;
192 if ((
int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
198 switch (image_type) {
210 default: NOT_REACHED();
228 if (!e->IsEnabled())
continue;
230 uint w = TRAININFO_DEFAULT_VEHICLE_WIDTH;
231 if (e->GetGRF() !=
nullptr && is_custom_sprite(e->u.rail.image_index)) {
232 w = e->GetGRF()->traininfo_vehicle_width;
233 if (w != VEHICLEINFO_FULL_VEHICLE_WIDTH) {
253 static void DepotSellAllConfirmationCallback(
Window *w,
bool confirmed);
264 uint unitnumber_digits;
275 this->generate_list =
true;
276 this->hovered_widget = -1;
278 this->num_columns = 1;
279 this->unitnumber_digits = 2;
297 void Close([[maybe_unused]]
int data = 0)
override
312 bool free_wagon =
false;
323 uint x_space = free_wagon ?
340 default: NOT_REACHED();
366 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
389 int first_line = w + (-this->hscroll->
GetPosition()) % w;
391 for (
int x = image.right - first_line; x >= image.left; x -= w) {
395 for (
int x = image.left + first_line; x <= image.right; x += w) {
404 uint maxval =
static_cast<uint
>(std::min<size_t>(this->vehicle_list.size(), num + (rows_in_display * this->num_columns)));
407 for (uint i = 0; i < this->num_columns && num < maxval; i++, num++) {
409 const Vehicle *v = this->vehicle_list[num];
415 maxval =
static_cast<uint
>(std::min<size_t>(this->vehicle_list.size() + this->wagon_list.size(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns)));
419 const Vehicle *v = this->wagon_list[num - this->vehicle_list.size()];
424 void SetStringParameters(
WidgetID widget)
const override
437 enum DepotGUIAction {
444 DepotGUIAction GetVehicleFromDepotWndPt(
int x,
int y,
const Vehicle **veh, GetDepotVehiclePtData *d)
const
448 x -= matrix_widget->
pos_x;
452 uint xt = 0, xm = 0, ym = 0;
458 if (xt >= this->num_columns)
return MODE_ERROR;
462 int32_t row = this->vscroll->GetScrolledRowFromWidget(y,
this,
WID_D_MATRIX);
465 if (row == INT32_MAX || this->vehicle_list.size() + this->wagon_list.size() <= pos) {
471 return MODE_DRAG_VEHICLE;
478 if (this->vehicle_list.size() > pos) {
479 *veh = this->vehicle_list[pos];
483 pos -= (uint)this->vehicle_list.size();
484 *veh = this->wagon_list[pos];
490 const Train *v =
nullptr;
493 d->head = d->wagon = v;
497 switch (this->type) {
499 if (wagon)
return MODE_ERROR;
503 if (xm <= this->
flag_size.width)
return MODE_START_STOP;
511 default: NOT_REACHED();
513 return MODE_SHOW_VEHICLE;
516 if (this->type !=
VEH_TRAIN)
return MODE_DRAG_VEHICLE;
519 if (xm >= matrix_widget->
current_x - this->count_width)
return wagon ? MODE_ERROR : MODE_SHOW_VEHICLE;
525 for (; v !=
nullptr; v = v->
Next()) {
532 return MODE_DRAG_VEHICLE;
544 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
546 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
552 case MODE_DRAG_VEHICLE: {
559 TrainDepotMoveVehicle(v, sel, gdvp.head);
560 }
else if (v !=
nullptr) {
565 this->sel = v->
index;
571 case MODE_SHOW_VEHICLE:
575 case MODE_START_STOP:
579 default: NOT_REACHED();
591 this->GetWidget<NWidgetCore>(
WID_D_STOP_ALL)->tool_tip = STR_DEPOT_MASS_STOP_DEPOT_TRAIN_TOOLTIP + type;
592 this->GetWidget<NWidgetCore>(
WID_D_START_ALL)->tool_tip = STR_DEPOT_MASS_START_DEPOT_TRAIN_TOOLTIP + type;
593 this->GetWidget<NWidgetCore>(
WID_D_SELL)->tool_tip = STR_DEPOT_TRAIN_SELL_TOOLTIP + type;
594 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->tool_tip = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TOOLTIP + type;
596 this->GetWidget<NWidgetCore>(
WID_D_BUILD)->SetDataTip(STR_DEPOT_TRAIN_NEW_VEHICLES_BUTTON + type, STR_DEPOT_TRAIN_NEW_VEHICLES_TOOLTIP + type);
597 this->GetWidget<NWidgetCore>(
WID_D_CLONE)->SetDataTip(STR_DEPOT_CLONE_TRAIN + type, STR_DEPOT_CLONE_TRAIN_DEPOT_INFO + type);
599 this->GetWidget<NWidgetCore>(
WID_D_LOCATION)->tool_tip = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type;
600 this->GetWidget<NWidgetCore>(
WID_D_VEHICLE_LIST)->tool_tip = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type;
601 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->tool_tip = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type;
602 this->GetWidget<NWidgetCore>(
WID_D_MATRIX)->tool_tip = STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type;
605 default: NOT_REACHED();
611 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_TRAIN;
612 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_TRAIN;
613 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_TRAIN;
620 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_ROADVEH;
621 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_ROADVEH;
622 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_ROADVEH;
629 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_SHIP;
630 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_SHIP;
638 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_AIRCRAFT;
639 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_AIRCRAFT;
640 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_AIRCRAFT;
667 this->count_width = 0;
674 min_height = std::max<uint>(unumber.height, this->flag_size.height);
680 int base_width = this->count_width + this->header_width + padding.width;
682 resize.height = std::max<uint>(this->cell_size.
height, min_height + padding.height);
686 size.height =
resize.height * 6;
692 fill.width =
resize.width;
693 fill.height =
resize.height;
704 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
706 this->generate_list =
true;
711 if (this->generate_list) {
715 this->generate_list =
false;
716 DepotSortList(&this->vehicle_list);
720 if (this->unitnumber_digits < new_unitnumber_digits) {
721 this->unitnumber_digits = new_unitnumber_digits;
729 for (uint num = 0; num < this->vehicle_list.size(); num++) {
734 max_width = std::max(max_width,
width);
737 this->vscroll->
SetCount(this->vehicle_list.size() + this->wagon_list.size() + 1);
741 this->vscroll->
SetCount(
CeilDiv((uint)this->vehicle_list.size(), this->num_columns));
760 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
777 static const CursorID clone_icons[] = {
778 SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
779 SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
811 if (!this->vehicle_list.empty() || !this->wagon_list.empty()) {
816 STR_DEPOT_SELL_CONFIRMATION_TEXT,
818 DepotSellAllConfirmationCallback
834 void OnQueryTextFinished(std::optional<std::string> str)
override
836 if (!str.has_value())
return;
842 bool OnRightClick([[maybe_unused]]
Point pt,
WidgetID widget)
override
846 GetDepotVehiclePtData gdvp = {
nullptr,
nullptr };
848 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp);
850 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
852 if (v ==
nullptr || mode != MODE_DRAG_VEHICLE)
return false;
861 for (
const Vehicle *w = v; w !=
nullptr; w = w->
Next()) {
862 if (w->cargo_cap > 0 && w->cargo_type <
NUM_CARGO) {
863 capacity[w->cargo_type] += w->cargo_cap;
864 loaded [w->cargo_type] += w->cargo.StoredCount();
867 if (w->type ==
VEH_TRAIN && !w->HasArticulatedPart()) {
869 if (!whole_chain)
break;
874 static std::string details;
878 CargoID cargo_type = cs->Index();
879 if (capacity[cargo_type] == 0)
continue;
885 details +=
GetString(STR_DEPOT_VEHICLE_TOOLTIP_CARGO);
891 GuiShowTooltips(
this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, TCC_RIGHT_CLICK, 2);
922 bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end)
override
934 ShowErrorMessage(STR_ERROR_CAN_T_BUY_TRAIN + (*begin)->type, STR_ERROR_CAN_T_COPY_ORDER_VEHICLE_LIST,
WL_INFO);
949 ShowErrorMessage(STR_ERROR_CAN_T_BUY_TRAIN + (*begin)->type, STR_ERROR_CAN_T_SHARE_ORDER_VEHICLE_LIST,
WL_INFO);
970 if (this->hovered_widget != -1) {
973 this->hovered_widget = -1;
980 if (widget != this->hovered_widget) {
985 this->hovered_widget = widget;
1003 GetDepotVehiclePtData gdvp = {
nullptr,
nullptr};
1005 if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) != MODE_DRAG_VEHICLE)
return;
1008 if (gdvp.head !=
nullptr) {
1009 if (gdvp.wagon ==
nullptr && gdvp.head->Last()->index != this->sel) {
1014 new_vehicle_over = gdvp.head->index;
1015 }
else if (gdvp.wagon !=
nullptr && gdvp.head != gdvp.wagon &&
1016 gdvp.wagon->index != this->sel &&
1017 gdvp.wagon->Previous()->index != this->sel) {
1018 new_vehicle_over = gdvp.wagon->index;
1022 if (this->vehicle_over == new_vehicle_over)
return;
1024 this->vehicle_over = new_vehicle_over;
1039 GetDepotVehiclePtData gdvp = {
nullptr,
nullptr };
1041 if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel !=
INVALID_VEHICLE) {
1042 if (gdvp.wagon !=
nullptr && gdvp.wagon->index == sel &&
_ctrl_pressed) {
1044 }
else if (gdvp.wagon ==
nullptr || gdvp.wagon->index != sel) {
1046 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
1047 }
else if (gdvp.head !=
nullptr && gdvp.head->IsFrontEngine()) {
1051 }
else if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v,
nullptr) == MODE_DRAG_VEHICLE && v !=
nullptr && sel == v->
index) {
1077 this->hovered_widget = -1;
1126 static void DepotSellAllConfirmationCallback(
Window *win,
bool confirmed)
1146 default: NOT_REACHED();
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a train vehicle image in the GUI.
@ ES_HANDLED
The passed event is handled.
void CcCloneVehicle(Commands, const CommandCost &result, VehicleID veh_id)
This is the Callback method after the cloning attempt of a vehicle.
uint8_t GetColourGradient(Colours colour, ColourShade shade)
Get colour gradient palette index.
void OnTimeout() override
Called when this window's timeout has been reached.
static Pool::IterateWrapperFiltered< Engine, EngineTypeFilter > IterateType(VehicleType vt, size_t from=0)
Returns an iterable ensemble of all valid engines of the given type.
uint height
Vehicle cell height.
std::vector< const Vehicle * > VehicleList
A list of vehicles.
static Titem * Get(size_t index)
Returns Titem with given index.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
void SetDParamMaxDigits(size_t n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Dimensions (a width and height) of a rectangle in 2D.
void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc)
Display an error message in a window.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
The information about a vehicle list.
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
static uint _consistent_train_width
Whether trains of all lengths are consistently scaled. Either TRAININFO_DEFAULT_VEHICLE_WIDTH,...
Vehicle * Next() const
Get the next vehicle of this vehicle.
T * Next() const
Get next vehicle in the chain.
void OnInit() override
Notification that the nested widget tree gets initialized.
VehicleCellSize cell_size
Vehicle sprite cell size.
bool vehchain
vehicle chain is dragged
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
bool VehiclesHaveSameOrderList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicles have the same list of orders.
Tindex index
Index of this pool item.
Scrollbar * hscroll
Only for trains.
@ EIT_PURCHASE
Vehicle drawn in purchase list, autoreplace gui, ...
@ VEH_TRAIN
Train vehicle type.
Class for storing amounts of cargo.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
bool _ctrl_pressed
Is Ctrl pressed?
@ VEH_ROAD
Road vehicle type.
uint GetUnitNumberDigits(VehicleList &vehicles)
Get the number of digits the biggest unit number of a set of vehicles has.
static const uint TILE_SIZE
Tile size in world coordinates.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Specification of a cargo type.
uint extend_right
Extend of the cell to the right.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
EngineImageType
Visualisation contexts of vehicles and engines.
@ SA_RIGHT
Right align the text (must be a single bit).
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end) override
Clones a vehicle from a vehicle list.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
debug_inline bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a ship sprite heading west (used for lists).
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
Get the GUI cell size for a vehicle image.
uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
@ QSF_LEN_IN_CHARS
the length of the string is counted in characters
High level window description.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
void DepotClick(int x, int y)
Handle click in the depot matrix.
void SetupWidgetData(VehicleType type)
Function to set up vehicle specific widgets (mainly sprites and strings).
@ WDP_AUTO
Find a place automatically.
static constexpr int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
ResizeInfo resize
Resize information.
Common return value for all commands.
@ FS_NORMAL
Index of the normal font in the font tables.
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
uint16_t GetDepotIndex() const
Gets the DepotID of the current window.
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
TileIndex tile
Current tile index.
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
static VehicleCellSize _base_block_sizes_purchase[VEH_COMPANY_END]
Cell size for vehicle images in the purchase list.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
EngineID engine_type
The type of engine used for this vehicle.
@ FS_SMALL
Index of the small font in the font tables.
@ ES_NOT_HANDLED
The passed event is not handled.
bool Failed() const
Did this command fail?
EventState OnCTRLStateChange() override
The state of the control key has changed.
@ VEH_SHIP
Ship vehicle type.
GroundVehicleCache gcache
Cache of often calculated values.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
@ VS_STOPPED
Vehicle is stopped by the player.
@ WL_INFO
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engines, VehicleList *wagons, bool individual_wagons)
Generate a list of vehicles inside a depot.
WidgetID hovered_widget
Index of the widget being hovered during drag/drop. -1 if no drag is in progress.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
bool VehiclesHaveSameEngineList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicle chains have the same list of engines.
'Train' is either a loco or a wagon.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
uint32_t CursorID
The number of the cursor (sprite)
static constexpr NWidgetPart _nested_train_depot_widgets[]
Nested widget definition for train depots.
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
uint32_t VehicleID
The type all our vehicle IDs have.
Coordinates of a point in 2D.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
@ WSM_DRAGDROP
Drag&drop an object.
void DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a road vehicle chain.
WindowNumber window_number
Window number within the window class.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
uint step_height
Step-size of height resize changes.
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
@ EIT_IN_DEPOT
Vehicle drawn in depot.
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
@ HT_DRAG
dragging items in the depot windows
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount)
Shows a tooltip.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
void GetAircraftSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of an aircraft sprite heading west (used for lists).
uint step_width
Step-size of width resize changes.
TimerGameCalendar::Date max_age
Maximum age.
@ WC_BUILD_VEHICLE
Build vehicle; Window numbers:
static const uint MAX_LENGTH_DEPOT_NAME_CHARS
The maximum length of a depot name in characters including '\0'.
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
void OnResize() override
Called after the window got resized.
void GetTrainSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a train sprite heading west, or both heads (used for lists).
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
StationID GetStationIndex(Tile t)
Get StationID from a tile.
void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type)
Get the size of the sprite of a road vehicle sprite heading west (used for lists).
uint header_width
Width of unit number and flag, including separator.
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
TimerGameCalendar::Date age
Age in calendar days.
static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END]
Cell size for vehicle images in the depot view.
EventState
State of handling an event.
void InitDepotWindowBlockSizes()
Set the size of the blocks in the window so we can be sure that they are big enough for the vehicle s...
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
@ INVALID_CLIENT_ID
Client is not part of anything.
UnitID unitnumber
unit number, for display purposes only
Dimensions of a cell in the purchase/depot windows.
uint count_width
Width of length count, including separator.
Vehicle * Last()
Get the last vehicle of this vehicle chain.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
@ SA_CENTER
Center both horizontally and vertically.
void DrawShipImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
int width
width of the window (number of pixels to the right in x direction)
VehicleType
Available vehicle types.
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.
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...
@ VEH_AIRCRAFT
Aircraft vehicle type.
bool OnVehicleSelect(const Vehicle *v) override
Clones a vehicle.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
uint16_t EngineID
Unique identification number of an engine.
Data structure for an opened window.
Commands
List of commands.
bool IsFreeWagon() const
Check if the vehicle is a free wagon (got no engine in front of it).
void DrawAircraftImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
VehicleType type
Type of vehicle.
void DrawWidgets() const
Paint all widgets of a window.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
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 ...
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
void DeleteDepotHighlightOfVehicle(const Vehicle *v)
Removes the highlight of a vehicle in a depot window.
Specification of a rectangle with absolute coordinates of all edges.
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Data structure describing a sprite.
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
uint16_t cached_total_length
Length of the whole vehicle (valid only for the first engine).
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void OnPaint() override
The window must be repainted.
@ TD_RTL
Text is written right-to-left by default.
TextDirection _current_text_dir
Text direction of the currently selected language.
void DrawVehicleInDepot(const Vehicle *v, const Rect &r) const
Draw a vehicle in the depot window in the box with the top left corner at x,y.
T * GetFirstEnginePart()
Get the first part of an articulated engine.
uint num_columns
Number of columns.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
uint extend_left
Extend of the cell to the left.
Dimension flag_size
Size of start/stop flag.
WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
@ VEH_COMPANY_END
Last company-ownable type.
void DrawTrainImage(const Train *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
Draws an image of a whole train.
VehicleID vehicle_over
Rail vehicle over which another one is dragged, INVALID_VEHICLE if none.