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)
123 if (result.
Failed())
return;
134 if (v == wagon)
return;
137 if (head != NULL) wagon = head->
Last();
140 if (wagon == NULL)
return;
143 if (wagon == v)
return;
161 switch (image_type) {
162 case EIT_IN_DEPOT:
return _base_block_sizes_depot[type];
163 case EIT_PURCHASE:
return _base_block_sizes_purchase[type];
164 default: NOT_REACHED();
170 int max_extend_left = 0;
171 int max_extend_right = 0;
175 FOR_ALL_ENGINES_OF_TYPE(e, type) {
183 default: NOT_REACHED();
189 if (y > max_height) max_height = y;
190 if (-x_offs > max_extend_left) max_extend_left = -x_offs;
191 if ((
int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
197 switch (image_type) {
200 _base_block_sizes_depot[type].
extend_left =
Clamp(max_extend_left, min_extend, max_extend);
201 _base_block_sizes_depot[type].
extend_right =
Clamp(max_extend_right, min_extend, max_extend);
205 _base_block_sizes_purchase[type].
extend_left =
Clamp(max_extend_left, min_extend, max_extend);
206 _base_block_sizes_purchase[type].
extend_right =
Clamp(max_extend_right, min_extend, max_extend);
209 default: NOT_REACHED();
230 uint w = TRAININFO_DEFAULT_VEHICLE_WIDTH;
231 if (e->
GetGRF() != NULL && is_custom_sprite(e->u.rail.image_index)) {
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;
312 bool free_wagon =
false;
316 int image_left = rtl ? left + this->count_width : left + this->header_width;
317 int image_right = rtl ? right - this->header_width : right - this->count_width;
324 uint x_space = free_wagon ?
328 DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
341 default: NOT_REACHED();
354 int text_left = rtl ? right - this->header_width - 1 : left + diff_x;
355 int text_right = rtl ? right - diff_x : left + this->header_width - 1;
358 DrawString(text_left, text_right, y + 2, STR_DEPOT_NO_ENGINE);
384 int image_left = rtl ? r.left + this->count_width : r.left + this->header_width;
385 int image_right = rtl ? r.right - this->header_width : r.right - this->count_width;
386 int first_line = w + (-this->hscroll->
GetPosition()) % w;
388 for (
int x = image_right - first_line; x >= image_left; x -= w) {
389 GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
392 for (
int x = image_left + first_line; x <= image_right; x += w) {
393 GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
404 for (byte i = 0; i < this->num_columns && num < maxval; i++, num++) {
406 const Vehicle *v = this->vehicle_list[num];
407 if (this->num_columns == 1) {
410 int x = r.left + (rtl ? (this->num_columns - i - 1) : i) * this->
resize.
step_width;
420 const Vehicle *v = this->wagon_list[num - this->vehicle_list.
Length()];
440 enum DepotGUIAction {
453 uint xt = 0, xm = 0, ym = 0;
459 if (xt >= this->num_columns)
return MODE_ERROR;
464 if (row >= this->vscroll->
GetCapacity())
return MODE_ERROR;
466 uint pos = ((row + this->vscroll->
GetPosition()) * this->num_columns) + xt;
468 if (this->vehicle_list.
Length() + this->wagon_list.
Length() <= pos) {
474 return MODE_DRAG_VEHICLE;
481 if (this->vehicle_list.
Length() > pos) {
482 *veh = this->vehicle_list[pos];
486 pos -= this->vehicle_list.
Length();
487 *veh = this->wagon_list[pos];
493 const Train *v = NULL;
496 d->head = d->wagon = v;
499 if (xm <= this->header_width) {
500 switch (this->type) {
502 if (wagon)
return MODE_ERROR;
506 if (xm <= this->flag_width)
return MODE_START_STOP;
514 default: NOT_REACHED();
516 return MODE_SHOW_VEHICLE;
519 if (this->type !=
VEH_TRAIN)
return MODE_DRAG_VEHICLE;
522 if (xm >= matrix_widget->
current_x - this->count_width)
return wagon ? MODE_ERROR : MODE_SHOW_VEHICLE;
525 x -= this->header_width;
528 for (; v != NULL; v = v->
Next()) {
535 return MODE_DRAG_VEHICLE;
547 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
549 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
555 case MODE_DRAG_VEHICLE: {
562 TrainDepotMoveVehicle(v, sel, gdvp.head);
563 }
else if (v != NULL) {
568 this->sel = v->
index;
574 case MODE_SHOW_VEHICLE:
578 case MODE_START_STOP:
582 default: NOT_REACHED();
594 this->GetWidget<NWidgetCore>(
WID_D_STOP_ALL)->tool_tip = STR_DEPOT_MASS_STOP_DEPOT_TRAIN_TOOLTIP + type;
595 this->GetWidget<NWidgetCore>(
WID_D_START_ALL)->tool_tip = STR_DEPOT_MASS_START_DEPOT_TRAIN_TOOLTIP + type;
596 this->GetWidget<NWidgetCore>(
WID_D_SELL)->tool_tip = STR_DEPOT_TRAIN_SELL_TOOLTIP + type;
597 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->tool_tip = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TOOLTIP + type;
599 this->GetWidget<NWidgetCore>(
WID_D_BUILD)->
SetDataTip(STR_DEPOT_TRAIN_NEW_VEHICLES_BUTTON + type, STR_DEPOT_TRAIN_NEW_VEHICLES_TOOLTIP + type);
600 this->GetWidget<NWidgetCore>(
WID_D_CLONE)->
SetDataTip(STR_DEPOT_CLONE_TRAIN + type, STR_DEPOT_CLONE_TRAIN_DEPOT_INFO + type);
602 this->GetWidget<NWidgetCore>(
WID_D_LOCATION)->tool_tip = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type;
603 this->GetWidget<NWidgetCore>(
WID_D_VEHICLE_LIST)->tool_tip = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type;
604 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->tool_tip = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type;
605 this->GetWidget<NWidgetCore>(
WID_D_MATRIX)->tool_tip = STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type;
608 default: NOT_REACHED();
614 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_TRAIN;
615 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_TRAIN;
616 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_TRAIN;
623 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_ROADVEH;
624 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_ROADVEH;
625 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_ROADVEH;
632 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_SHIP;
633 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_SHIP;
641 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_AIRCRAFT;
642 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_AIRCRAFT;
643 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_AIRCRAFT;
664 this->count_width = 0;
680 int base_width = this->count_width + this->header_width;
686 size->height = resize->height * 6;
689 size->width = resize->width * (this->type ==
VEH_ROAD ? 5 : 3);
690 size->height = resize->height * (this->type ==
VEH_ROAD ? 5 : 3);
692 fill->width = resize->width;
693 fill->height = resize->height;
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;
728 uint max_width =
ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
729 for (uint num = 0; num < this->vehicle_list.
Length(); num++) {
732 width += v->GetDisplayImageWidth();
734 max_width =
max(max_width, width);
780 static const CursorID clone_icons[] = {
781 SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
782 SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
814 if (this->vehicle_list.
Length() != 0 || this->wagon_list.
Length() != 0) {
816 byte vehtype = this->type;
822 STR_DEPOT_SELL_CONFIRMATION_TEXT,
824 DepotSellAllConfirmationCallback
830 ShowVehicleListWindow(
GetTileOwner(this->window_number), this->type, (
TileIndex)this->window_number);
842 if (str == NULL)
return;
855 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, &gdvp);
857 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
859 if (v == NULL || mode != MODE_DRAG_VEHICLE)
return false;
868 for (
const Vehicle *w = v; w != NULL; w = w->Next()) {
869 if (w->cargo_cap > 0 && w->cargo_type <
NUM_CARGO) {
870 capacity[w->cargo_type] += w->cargo_cap;
871 loaded [w->cargo_type] += w->cargo.StoredCount();
874 if (w->type ==
VEH_TRAIN && !w->HasArticulatedPart()) {
876 if (!whole_chain)
break;
881 static char details[1024];
886 if (capacity[cargo_type] == 0)
continue;
892 pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO,
lastof(details));
898 args[1] = (uint64)(
size_t)details;
899 GuiShowTooltips(
this, whole_chain ? STR_DEPOT_VEHICLE_TOOLTIP_CHAIN : STR_DEPOT_VEHICLE_TOOLTIP, 2, args, TCC_RIGHT_CLICK);
928 if (this->hovered_widget != -1) {
931 this->hovered_widget = -1;
938 if (widget != this->hovered_widget) {
943 this->hovered_widget = widget;
960 NWidgetBase *matrix = this->GetWidget<NWidgetBase>(widget);
964 if (this->GetVehicleFromDepotWndPt(pt.x - matrix->
pos_x, pt.y - matrix->
pos_y, &v, &gdvp) != MODE_DRAG_VEHICLE)
return;
967 if (gdvp.head != NULL) {
968 if (gdvp.wagon == NULL && gdvp.head->
Last()->
index != this->sel) {
973 new_vehicle_over = gdvp.head->
index;
974 }
else if (gdvp.wagon != NULL && gdvp.head != gdvp.wagon &&
975 gdvp.wagon->
index != this->sel &&
977 new_vehicle_over = gdvp.wagon->
index;
981 if (this->vehicle_over == new_vehicle_over)
return;
983 this->vehicle_over = new_vehicle_over;
1001 if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel !=
INVALID_VEHICLE) {
1005 }
else if (gdvp.wagon == NULL || gdvp.wagon->
index != sel) {
1007 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
1008 }
else if (gdvp.head != NULL && gdvp.head->
IsFrontEngine()) {
1012 }
else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v, NULL) == MODE_DRAG_VEHICLE && v != NULL && sel == v->
index) {
1038 this->hovered_widget = -1;
1077 static void DepotSellAllConfirmationCallback(
Window *win,
bool confirmed)
1082 byte vehtype = w->type;
1098 default: NOT_REACHED();
1099 case VEH_TRAIN: desc = &_train_depot_desc;
break;
1100 case VEH_ROAD: desc = &_road_depot_desc;
break;
1101 case VEH_SHIP: desc = &_ship_depot_desc;
break;
1102 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:
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 CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
This is the Callback method after the cloning attempt of a vehicle.
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.
Maximal number of cargo types in a game.
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.
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.