32 #include "table/strings.h" 86 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
93 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
100 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
104 WDP_AUTO,
"depot_aircraft", 332, 99,
107 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
122 if (result.
Failed())
return;
133 if (v == wagon)
return;
135 if (wagon ==
nullptr) {
136 if (head !=
nullptr) wagon = head->
Last();
139 if (wagon ==
nullptr)
return;
142 if (wagon == v)
return;
160 switch (image_type) {
161 case EIT_IN_DEPOT:
return _base_block_sizes_depot[type];
162 case EIT_PURCHASE:
return _base_block_sizes_purchase[type];
163 default: NOT_REACHED();
169 int max_extend_left = 0;
170 int max_extend_right = 0;
174 if (!e->IsEnabled())
continue;
181 default: NOT_REACHED();
187 if (y > max_height) max_height = y;
188 if (-x_offs > max_extend_left) max_extend_left = -x_offs;
189 if ((
int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
195 switch (image_type) {
198 _base_block_sizes_depot[type].
extend_left =
Clamp(max_extend_left, min_extend, max_extend);
199 _base_block_sizes_depot[type].
extend_right =
Clamp(max_extend_right, min_extend, max_extend);
203 _base_block_sizes_purchase[type].
extend_left =
Clamp(max_extend_left, min_extend, max_extend);
204 _base_block_sizes_purchase[type].
extend_right =
Clamp(max_extend_right, min_extend, max_extend);
207 default: NOT_REACHED();
225 if (!e->IsEnabled())
continue;
227 uint w = TRAININFO_DEFAULT_VEHICLE_WIDTH;
228 if (e->GetGRF() !=
nullptr && is_custom_sprite(e->u.rail.image_index)) {
229 w = e->GetGRF()->traininfo_vehicle_width;
230 if (w != VEHICLEINFO_FULL_VEHICLE_WIDTH) {
250 static void DepotSellAllConfirmationCallback(
Window *w,
bool confirmed);
261 uint unitnumber_digits;
272 this->generate_list =
true;
273 this->hovered_widget = -1;
275 this->num_columns = 1;
276 this->unitnumber_digits = 2;
309 bool free_wagon =
false;
313 int image_left = rtl ? left + this->count_width : left + this->header_width;
314 int image_right = rtl ? right - this->header_width : right - this->count_width;
321 uint x_space = free_wagon ?
325 DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
338 default: NOT_REACHED();
351 int text_left = rtl ? right - this->header_width - 1 : left + diff_x;
352 int text_right = rtl ? right - diff_x : left + this->header_width - 1;
355 DrawString(text_left, text_right, y + 2, STR_DEPOT_NO_ENGINE);
381 int image_left = rtl ? r.left + this->count_width : r.left + this->header_width;
382 int image_right = rtl ? r.right - this->header_width : r.right - this->count_width;
383 int first_line = w + (-this->hscroll->
GetPosition()) % w;
385 for (
int x = image_right - first_line; x >= image_left; x -= w) {
386 GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
389 for (
int x = image_left + first_line; x <= image_right; x += w) {
390 GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
398 int maxval =
min((uint)this->vehicle_list.size(), num + (rows_in_display * this->
num_columns));
401 for (byte i = 0; i < this->num_columns && num < maxval; i++, num++) {
403 const Vehicle *v = this->vehicle_list[num];
404 if (this->num_columns == 1) {
407 int x = r.left + (rtl ? (this->num_columns - i - 1) : i) * this->
resize.
step_width;
413 maxval =
min((uint)this->vehicle_list.size() + (uint)this->wagon_list.size(), (this->vscroll->
GetPosition() * this->
num_columns) + (rows_in_display * this->num_columns));
417 const Vehicle *v = this->wagon_list[num - this->vehicle_list.size()];
437 enum DepotGUIAction {
450 uint xt = 0, xm = 0, ym = 0;
456 if (xt >= this->num_columns)
return MODE_ERROR;
461 if (row >= this->vscroll->
GetCapacity())
return MODE_ERROR;
463 uint pos = ((row + this->vscroll->
GetPosition()) * this->num_columns) + xt;
465 if (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;
496 if (xm <= this->header_width) {
497 switch (this->type) {
499 if (wagon)
return MODE_ERROR;
503 if (xm <= this->flag_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;
522 x -= this->header_width;
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;
661 this->count_width = 0;
677 int base_width = this->count_width + this->header_width;
683 size->height = resize->height * 6;
686 size->width = resize->width * (this->type ==
VEH_ROAD ? 5 : 3);
687 size->height = resize->height * (this->type ==
VEH_ROAD ? 5 : 3);
689 fill->width = resize->width;
690 fill->height = resize->height;
703 this->generate_list =
true;
708 if (this->generate_list) {
712 this->generate_list =
false;
713 DepotSortList(&this->vehicle_list);
717 if (this->unitnumber_digits < new_unitnumber_digits) {
718 this->unitnumber_digits = new_unitnumber_digits;
725 uint max_width =
ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
726 for (uint num = 0; num < this->vehicle_list.size(); num++) {
729 width += v->GetDisplayImageWidth();
731 max_width =
max(max_width, width);
734 this->vscroll->
SetCount((uint)this->vehicle_list.size() + (uint)this->wagon_list.size() + 1);
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.size() != 0 || this->wagon_list.size() != 0) {
813 byte vehtype = this->type;
819 STR_DEPOT_SELL_CONFIRMATION_TEXT,
821 DepotSellAllConfirmationCallback
827 ShowVehicleListWindow(
GetTileOwner(this->window_number), this->type, (
TileIndex)this->window_number);
839 if (str ==
nullptr)
return;
852 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, &gdvp);
854 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
856 if (v ==
nullptr || mode != MODE_DRAG_VEHICLE)
return false;
865 for (
const Vehicle *w = v; w !=
nullptr; w = w->Next()) {
866 if (w->cargo_cap > 0 && w->cargo_type <
NUM_CARGO) {
867 capacity[w->cargo_type] += w->cargo_cap;
868 loaded [w->cargo_type] += w->cargo.StoredCount();
871 if (w->type ==
VEH_TRAIN && !w->HasArticulatedPart()) {
873 if (!whole_chain)
break;
878 static char details[1024];
883 if (capacity[cargo_type] == 0)
continue;
889 pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO,
lastof(details));
895 args[1] = (uint64)(
size_t)details;
896 GuiShowTooltips(
this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
932 if (this->hovered_widget != -1) {
935 this->hovered_widget = -1;
942 if (widget != this->hovered_widget) {
947 this->hovered_widget = widget;
964 NWidgetBase *matrix = this->GetWidget<NWidgetBase>(widget);
968 if (this->GetVehicleFromDepotWndPt(pt.x - matrix->
pos_x, pt.y - matrix->
pos_y, &v, &gdvp) != MODE_DRAG_VEHICLE)
return;
971 if (gdvp.head !=
nullptr) {
972 if (gdvp.wagon ==
nullptr && gdvp.head->
Last()->
index != this->sel) {
977 new_vehicle_over = gdvp.head->
index;
978 }
else if (gdvp.wagon !=
nullptr && gdvp.head != gdvp.wagon &&
979 gdvp.wagon->
index != this->sel &&
981 new_vehicle_over = gdvp.wagon->
index;
985 if (this->vehicle_over == new_vehicle_over)
return;
987 this->vehicle_over = new_vehicle_over;
1005 if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel !=
INVALID_VEHICLE) {
1009 }
else if (gdvp.wagon ==
nullptr || gdvp.wagon->
index != sel) {
1011 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
1012 }
else if (gdvp.head !=
nullptr && gdvp.head->
IsFrontEngine()) {
1016 }
else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v,
nullptr) == MODE_DRAG_VEHICLE && v !=
nullptr && sel == v->
index) {
1042 this->hovered_widget = -1;
1081 static void DepotSellAllConfirmationCallback(
Window *win,
bool confirmed)
1086 byte vehtype = w->type;
1102 default: NOT_REACHED();
1103 case VEH_TRAIN: desc = &_train_depot_desc;
break;
1104 case VEH_ROAD: desc = &_road_depot_desc;
break;
1105 case VEH_SHIP: desc = &_ship_depot_desc;
break;
1106 case VEH_AIRCRAFT: desc = &_aircraft_depot_desc;
break;
EventState
State of handling an event.
Functions related to OTTD's strings.
void OnDragDrop(Point pt, int widget) override
A dragged 'object' has been released.
Last company-ownable type.
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
Vehicle is stopped by the player.
static const uint MAX_LENGTH_DEPOT_NAME_CHARS
The maximum length of a depot name in characters including '\0'.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
The information about a vehicle list.
ResizeInfo resize
Resize information.
static uint _consistent_train_width
Whether trains of all lengths are consistently scaled. Either TRAININFO_DEFAULT_VEHICLE_WIDTH, VEHICLEINFO_FULL_VEHICLE_WIDTH, or 0.
bool OnVehicleSelect(const Vehicle *v) override
Clones a vehicle.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
High level window description.
Functions and type for generating vehicle lists.
int left
x position of left edge of the window
bool vehchain
vehicle chain is dragged
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
void DrawWidgets() const
Paint all widgets of a window.
static Titem * Get(size_t index)
Returns Titem with given index.
Base for the train class.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Normal amount of vertical space between two paragraphs of text.
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
The passed event is not handled.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Data structure describing a sprite.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Depot view; Window numbers:
Maximal number of cargo types in a game.
void DeleteDepotHighlightOfVehicle(const Vehicle *v)
Removes the highlight of a vehicle in a depot window.
VehicleType
Available vehicle types.
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
Shows a tooltip.
uint extend_right
Extend of the cell to the right.
void OnMouseDrag(Point pt, int widget) override
An 'object' is being dragged at the provided position, highlight the target if possible.
Functions related to vehicles.
Build vehicle; Window numbers:
Base for all depots (except hangars)
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
Get the GUI cell size for a vehicle image.
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
uint height
Vehicle cell height.
Tindex index
Index of this pool item.
void OnTimeout() override
Called when this window's timeout has been reached.
Offset at top of a matrix cell.
void SetupWidgetData(VehicleType type)
Function to set up vehicle specific widgets (mainly sprites and strings).
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engines, VehicleList *wagons, bool individual_wagons)
Generate a list of vehicles inside a depot.
#define lastof(x)
Get the last element of an fixed size array.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
uint num_columns
Number of columns.
Stuff related to the text buffer GUI.
T * GetFirstEnginePart()
Get the first part of an articulated engine.
Common return value for all commands.
Vehicle drawn in purchase list, autoreplace gui, ...
static const VehicleID INVALID_VEHICLE
Constant representing a non-existing vehicle.
static T max(const T a, const T b)
Returns the maximum of two values.
EngineImageType
Visualisation contexts of vehicles and engines.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
static const uint TILE_SIZE
Tile size in world coordinates.
Functions, definitions and such used only by the GUI.
Functions related to (drawing on) viewports.
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
static VehicleCellSize _base_block_sizes_purchase[VEH_COMPANY_END]
Cell size for vehicle images in the purchase list.
Data structure for an opened window.
bool _ctrl_pressed
Is Ctrl pressed?
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
dragging items in the depot windows
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
enable the 'Default' button ("\0" is returned)
static const uint32 MAKE_ORDER_BACKUP_FLAG
Flag to pass to the vehicle construction command when an order should be preserved.
NWidgetBase ** nested_array
Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Offset at bottom of a matrix cell.
UnitID unitnumber
unit number, for display purposes only
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallbackProc *callback)
Show a modal confirmation window with standard 'yes' and 'no' buttons The window is aligned to the ce...
static const NWidgetPart _nested_train_depot_widgets[]
Nested widget definition for train depots.
uint32 VehicleID
The type all our vehicle IDs have.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
T * Next() const
Get next vehicle in the chain.
Definition of base types and functions in a cross-platform compatible way.
int hovered_widget
Index of the widget being hovered during drag/drop. -1 if no drag is in progress. ...
the length of the string is counted in characters
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
Draws an image of a whole train.
A number of safeguards to prevent using unsafe methods.
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
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).
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
uint step_height
Step-size of height resize changes.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
EventState OnCTRLStateChange() override
The state of the control key has changed.
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Functions related to order backups.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
TileIndex tile
Current tile index.
void OnPaint() override
The window must be repainted.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
void DrawRoadVehImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a road vehicle chain.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
#define lengthof(x)
Return the length of an fixed size array.
static T min(const T a, const T b)
Returns the minimum of two values.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Functions to cache sprites in memory.
bool Failed() const
Did this command fail?
static DepotID GetDepotIndex(TileIndex t)
Get the index of which depot is attached to the tile.
Scrollbar * hscroll
Only for trains.
uint16 height
Height of the sprite.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
The most basic (normal) sprite.
force the autoreplace to take action in a given depot
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void ShowExtraViewPortWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
'Train' is either a loco or a wagon.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
void OnResize() override
Called after the window got resized.
uint16 width
Width of the sprite.
Functions related to companies.
uint GetUnitNumberDigits(VehicleList &vehicles)
Get the number of digits the biggest unit number of a set of vehicles has.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a train vehicle image in the GUI.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
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...
Class for storing amounts of cargo.
Both numeric and alphabetic and spaces and stuff.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
uint16 EngineID
Unique identification number of an engine.
uint32 TileIndex
The index/ID of a Tile.
uint32 Pack() const
Pack a VehicleListIdentifier in a single uint32.
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
TextDirection _current_text_dir
Text direction of the currently selected language.
void DrawVehicleInDepot(const Vehicle *v, int left, int right, int y) const
Draw a vehicle in the depot window in the box with the top left corner at x,y.
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
uint16 cached_total_length
Length of the whole vehicle (valid only for the first engine).
Functions related to zooming.
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...
Dimensions of a cell in the purchase/depot windows.
VehicleType type
Type of vehicle.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
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).
static uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
uint step_width
Step-size of width resize changes.
sell all vehicles which are in a given depot
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Functions related to commands.
uint32 CursorID
The number of the cursor (sprite)
Coordinates of a point in 2D.
Index of the small font in the font tables.
start/stop all vehicles (in a depot)
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable...
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
bool IsFreeWagon() const
Check if the vehicle is a free wagon (got no engine in front of it).
vehicle is accepted as target as well (bitmask)
Offset at right to draw the frame rectangular area.
EngineID engine_type
The type of engine used for this vehicle.
int width
width of the window (number of pixels to the right in x direction)
void DepotClick(int x, int y)
Handle click in the depot matrix.
#define CMD_MSG(x)
Used to combine a StringID with the command.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Specification of a rectangle with absolute coordinates of all edges.
byte CargoID
Cargo slots to indicate a cargo type within a game.
The passed event is handled.
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).
Text is written right-to-left by default.
Right align the text (must be a single bit).
WindowNumber window_number
Window number within the window class.
uint extend_left
Extend of the cell to the left.
static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END]
Cell size for vehicle images in the depot view.
Functions related to tile highlights.
bool OnRightClick(Point pt, int widget) override
A click with the right mouse button has been made on the window.
VehicleID vehicle_over
Rail vehicle over which another one is dragged, INVALID_VEHICLE if none.
Vehicle * Last()
Get the last vehicle of this vehicle chain.
Find a place automatically.
std::vector< const Vehicle * > VehicleList
A list of vehicles.
move a rail vehicle (in the depot)
GUI functions that shouldn't be here.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
This is the Callback method after the cloning attempt of a vehicle.
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)...
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
static bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
Dimensions (a width and height) of a rectangle in 2D.
Offset at left to draw the frame rectangular area.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window 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.
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
GroundVehicleCache gcache
Cache of often calculated values.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
static Pool::IterateWrapper< Engine > IterateType(VehicleType vt, size_t from=0)
Returns an iterable ensemble of all valid engines of the given type.