34 #include "table/strings.h" 88 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
95 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
102 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
106 WDP_AUTO,
"depot_aircraft", 332, 99,
109 _nested_train_depot_widgets,
lengthof(_nested_train_depot_widgets)
124 if (result.
Failed())
return;
135 if (v == wagon)
return;
138 if (head != NULL) wagon = head->
Last();
141 if (wagon == NULL)
return;
144 if (wagon == v)
return;
162 switch (image_type) {
163 case EIT_IN_DEPOT:
return _base_block_sizes_depot[type];
164 case EIT_PURCHASE:
return _base_block_sizes_purchase[type];
165 default: NOT_REACHED();
171 int max_extend_left = 0;
172 int max_extend_right = 0;
176 FOR_ALL_ENGINES_OF_TYPE(e, type) {
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) {
201 _base_block_sizes_depot[type].
extend_left =
Clamp(max_extend_left, min_extend, max_extend);
202 _base_block_sizes_depot[type].
extend_right =
Clamp(max_extend_right, min_extend, max_extend);
206 _base_block_sizes_purchase[type].
extend_left =
Clamp(max_extend_left, min_extend, max_extend);
207 _base_block_sizes_purchase[type].
extend_right =
Clamp(max_extend_right, min_extend, max_extend);
210 default: NOT_REACHED();
231 uint w = TRAININFO_DEFAULT_VEHICLE_WIDTH;
232 if (e->
GetGRF() != NULL && is_custom_sprite(e->u.rail.image_index)) {
234 if (w != VEHICLEINFO_FULL_VEHICLE_WIDTH) {
254 static void DepotSellAllConfirmationCallback(
Window *w,
bool confirmed);
265 uint unitnumber_digits;
276 this->generate_list =
true;
277 this->hovered_widget = -1;
279 this->num_columns = 1;
280 this->unitnumber_digits = 2;
313 bool free_wagon =
false;
317 int image_left = rtl ? left + this->count_width : left + this->header_width;
318 int image_right = rtl ? right - this->header_width : right - this->count_width;
325 uint x_space = free_wagon ?
329 DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
342 default: NOT_REACHED();
355 int text_left = rtl ? right - this->header_width - 1 : left + diff_x;
356 int text_right = rtl ? right - diff_x : left + this->header_width - 1;
359 DrawString(text_left, text_right, y + 2, STR_DEPOT_NO_ENGINE);
385 int image_left = rtl ? r.left + this->count_width : r.left + this->header_width;
386 int image_right = rtl ? r.right - this->header_width : r.right - this->count_width;
387 int first_line = w + (-this->hscroll->
GetPosition()) % w;
389 for (
int x = image_right - first_line; x >= image_left; x -= w) {
390 GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
393 for (
int x = image_left + first_line; x <= image_right; x += w) {
394 GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
405 for (byte i = 0; i < this->num_columns && num < maxval; i++, num++) {
407 const Vehicle *v = this->vehicle_list[num];
408 if (this->num_columns == 1) {
411 int x = r.left + (rtl ? (this->num_columns - i - 1) : i) * this->
resize.
step_width;
421 const Vehicle *v = this->wagon_list[num - this->vehicle_list.
Length()];
441 enum DepotGUIAction {
454 uint xt = 0, xm = 0, ym = 0;
460 if (xt >= this->num_columns)
return MODE_ERROR;
465 if (row >= this->vscroll->
GetCapacity())
return MODE_ERROR;
467 uint pos = ((row + this->vscroll->
GetPosition()) * this->num_columns) + xt;
469 if (this->vehicle_list.
Length() + this->wagon_list.
Length() <= pos) {
475 return MODE_DRAG_VEHICLE;
482 if (this->vehicle_list.
Length() > pos) {
483 *veh = this->vehicle_list[pos];
487 pos -= this->vehicle_list.
Length();
488 *veh = this->wagon_list[pos];
494 const Train *v = NULL;
497 d->head = d->wagon = v;
500 if (xm <= this->header_width) {
501 switch (this->type) {
503 if (wagon)
return MODE_ERROR;
507 if (xm <= this->flag_width)
return MODE_START_STOP;
515 default: NOT_REACHED();
517 return MODE_SHOW_VEHICLE;
520 if (this->type !=
VEH_TRAIN)
return MODE_DRAG_VEHICLE;
523 if (xm >= matrix_widget->
current_x - this->count_width)
return wagon ? MODE_ERROR : MODE_SHOW_VEHICLE;
526 x -= this->header_width;
529 for (; v != NULL; v = v->
Next()) {
536 return MODE_DRAG_VEHICLE;
548 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
550 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
556 case MODE_DRAG_VEHICLE: {
563 TrainDepotMoveVehicle(v, sel, gdvp.head);
564 }
else if (v != NULL) {
569 this->sel = v->
index;
575 case MODE_SHOW_VEHICLE:
579 case MODE_START_STOP:
583 default: NOT_REACHED();
595 this->GetWidget<NWidgetCore>(
WID_D_STOP_ALL)->tool_tip = STR_DEPOT_MASS_STOP_DEPOT_TRAIN_TOOLTIP + type;
596 this->GetWidget<NWidgetCore>(
WID_D_START_ALL)->tool_tip = STR_DEPOT_MASS_START_DEPOT_TRAIN_TOOLTIP + type;
597 this->GetWidget<NWidgetCore>(
WID_D_SELL)->tool_tip = STR_DEPOT_TRAIN_SELL_TOOLTIP + type;
598 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->tool_tip = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TOOLTIP + type;
600 this->GetWidget<NWidgetCore>(
WID_D_BUILD)->
SetDataTip(STR_DEPOT_TRAIN_NEW_VEHICLES_BUTTON + type, STR_DEPOT_TRAIN_NEW_VEHICLES_TOOLTIP + type);
601 this->GetWidget<NWidgetCore>(
WID_D_CLONE)->
SetDataTip(STR_DEPOT_CLONE_TRAIN + type, STR_DEPOT_CLONE_TRAIN_DEPOT_INFO + type);
603 this->GetWidget<NWidgetCore>(
WID_D_LOCATION)->tool_tip = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type;
604 this->GetWidget<NWidgetCore>(
WID_D_VEHICLE_LIST)->tool_tip = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type;
605 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->tool_tip = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type;
606 this->GetWidget<NWidgetCore>(
WID_D_MATRIX)->tool_tip = STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type;
609 default: NOT_REACHED();
615 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_TRAIN;
616 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_TRAIN;
617 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_TRAIN;
624 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_ROADVEH;
625 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_ROADVEH;
626 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_ROADVEH;
633 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_SHIP;
634 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_SHIP;
642 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_AIRCRAFT;
643 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_AIRCRAFT;
644 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_AIRCRAFT;
665 this->count_width = 0;
681 int base_width = this->count_width + this->header_width;
687 size->height = resize->height * 6;
690 size->width = resize->width * (this->type ==
VEH_ROAD ? 5 : 3);
691 size->height = resize->height * (this->type ==
VEH_ROAD ? 5 : 3);
693 fill->width = resize->width;
694 fill->height = resize->height;
707 this->generate_list =
true;
712 if (this->generate_list) {
716 this->generate_list =
false;
717 DepotSortList(&this->vehicle_list);
721 if (this->unitnumber_digits < new_unitnumber_digits) {
722 this->unitnumber_digits = new_unitnumber_digits;
729 uint max_width =
ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
730 for (uint num = 0; num < this->vehicle_list.
Length(); num++) {
733 width += v->GetDisplayImageWidth();
735 max_width =
max(max_width, width);
781 static const CursorID clone_icons[] = {
782 SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
783 SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
815 if (this->vehicle_list.
Length() != 0 || this->wagon_list.
Length() != 0) {
817 byte vehtype = this->type;
823 STR_DEPOT_SELL_CONFIRMATION_TEXT,
825 DepotSellAllConfirmationCallback
831 ShowVehicleListWindow(
GetTileOwner(this->window_number), this->type, (
TileIndex)this->window_number);
843 if (str == NULL)
return;
856 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, &gdvp);
858 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
860 if (v == NULL || mode != MODE_DRAG_VEHICLE)
return false;
869 for (
const Vehicle *w = v; w != NULL; w = w->Next()) {
870 if (w->cargo_cap > 0 && w->cargo_type <
NUM_CARGO) {
871 capacity[w->cargo_type] += w->cargo_cap;
872 loaded [w->cargo_type] += w->cargo.StoredCount();
875 if (w->type ==
VEH_TRAIN && !w->HasArticulatedPart()) {
877 if (!whole_chain)
break;
882 static char details[1024];
887 if (capacity[cargo_type] == 0)
continue;
893 pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO,
lastof(details));
899 args[1] = (uint64)(
size_t)details;
900 GuiShowTooltips(
this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
936 if (this->hovered_widget != -1) {
939 this->hovered_widget = -1;
946 if (widget != this->hovered_widget) {
951 this->hovered_widget = widget;
968 NWidgetBase *matrix = this->GetWidget<NWidgetBase>(widget);
972 if (this->GetVehicleFromDepotWndPt(pt.x - matrix->
pos_x, pt.y - matrix->
pos_y, &v, &gdvp) != MODE_DRAG_VEHICLE)
return;
975 if (gdvp.head != NULL) {
976 if (gdvp.wagon == NULL && gdvp.head->
Last()->
index != this->sel) {
981 new_vehicle_over = gdvp.head->
index;
982 }
else if (gdvp.wagon != NULL && gdvp.head != gdvp.wagon &&
983 gdvp.wagon->
index != this->sel &&
985 new_vehicle_over = gdvp.wagon->
index;
989 if (this->vehicle_over == new_vehicle_over)
return;
991 this->vehicle_over = new_vehicle_over;
1009 if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel !=
INVALID_VEHICLE) {
1013 }
else if (gdvp.wagon == NULL || gdvp.wagon->
index != sel) {
1015 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
1016 }
else if (gdvp.head != NULL && gdvp.head->
IsFrontEngine()) {
1020 }
else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, NULL) == MODE_DRAG_VEHICLE && v != NULL && sel == v->
index) {
1046 this->hovered_widget = -1;
1085 static void DepotSellAllConfirmationCallback(
Window *win,
bool confirmed)
1090 byte vehtype = w->type;
1106 default: NOT_REACHED();
1107 case VEH_TRAIN: desc = &_train_depot_desc;
break;
1108 case VEH_ROAD: desc = &_road_depot_desc;
break;
1109 case VEH_SHIP: desc = &_ship_depot_desc;
break;
1110 case VEH_AIRCRAFT: desc = &_aircraft_depot_desc;
break;
EventState
State of handling an event.
Functions related to OTTD's strings.
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'.
virtual EventState OnCTRLStateChange()
The state of the control key has changed.
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.
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.
bool IsEnabled() const
Checks whether the engine is a valid (non-articulated part of an) engine.
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.
virtual void OnPaint()
The window must be repainted.
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.
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
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.
Last company-ownable type.
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.
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.
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.
virtual void OnMouseDrag(Point pt, int widget)
An 'object' is being dragged at the provided position, highlight the target if possible.
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.
The most basic (normal) sprite.
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.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
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.
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
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)
virtual bool OnRightClick(Point pt, int widget)
A click with the right mouse button has been made on the window.
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.
Offset at bottom of a matrix cell.
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
UnitID unitnumber
unit number, for display purposes only
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
uint Length() const
Get the number of items in the list.
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.
VehicleType
Available vehicle types.
uint32 VehicleID
The type all our vehicle IDs have.
void SetStringParameters(int widget) const
Initialize string parameters for a widget.
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.
virtual void OnResize()
Called after the window got resized.
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).
virtual void OnTimeout()
Called when this window's timeout has been reached.
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.
uint traininfo_vehicle_width
Width (in pixels) of a 8/8 train vehicle in depot GUI and vehicle details.
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.
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.
Functions to cache sprites in memory.
bool Failed() const
Did this command fail?
int GetDisplayImageWidth(Point *offset=NULL) const
Get the width of a train vehicle image in the GUI.
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.
force the autoreplace to take action in a given depot
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.
virtual void OnDragDrop(Point pt, int widget)
A dragged 'object' has been released.
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).
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.
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.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
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.
const GRFFile * GetGRF() const
Retrieve the NewGRF the engine is tied to.
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.
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.
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.
virtual bool OnVehicleSelect(const Vehicle *v)
Clones a vehicle.
#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.
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.
void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
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.
virtual void OnQueryTextFinished(char *str)
The query window opened from this window has closed.
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)...
static bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
VehicleTypeByte type
Type of vehicle.
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.