OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
32 #include "table/strings.h"
104 WDP_AUTO,
"depot_aircraft", 332, 99,
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) {
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) {
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;
310 bool free_wagon =
false;
314 int image_left = rtl ?
left + this->count_width :
left + this->header_width;
315 int image_right = rtl ? right - this->header_width : right - this->count_width;
322 uint x_space = free_wagon ?
326 DrawTrainImage(u, image_left + (rtl ? 0 : x_space), image_right - (rtl ? x_space : 0), sprite_y - 1,
339 default: NOT_REACHED();
352 int text_left = rtl ? right - this->header_width - 1 :
left + diff_x;
353 int text_right = rtl ? right - diff_x :
left + this->header_width - 1;
356 DrawString(text_left, text_right, y + 2, STR_DEPOT_NO_ENGINE);
382 int image_left = rtl ? r.left + this->count_width : r.left + this->header_width;
383 int image_right = rtl ? r.right - this->header_width : r.right - this->count_width;
384 int first_line = w + (-this->hscroll->
GetPosition()) % w;
386 for (
int x = image_right - first_line; x >= image_left; x -= w) {
387 GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
390 for (
int x = image_left + first_line; x <= image_right; x += w) {
391 GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
399 uint maxval =
static_cast<uint
>(std::min<size_t>(this->vehicle_list.size(), num + (rows_in_display * this->num_columns)));
402 for (
byte i = 0; i < this->num_columns && num < maxval; i++, num++) {
404 const Vehicle *v = this->vehicle_list[num];
405 if (this->num_columns == 1) {
408 int x = r.left + (rtl ? (this->num_columns - i - 1) : i) * this->
resize.
step_width;
414 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)));
418 const Vehicle *v = this->wagon_list[num - this->vehicle_list.size()];
436 enum DepotGUIAction {
443 DepotGUIAction GetVehicleFromDepotWndPt(
int x,
int y,
const Vehicle **veh, GetDepotVehiclePtData *d)
const
449 uint xt = 0, xm = 0, ym = 0;
455 if (xt >= this->num_columns)
return MODE_ERROR;
460 if (row >= this->vscroll->
GetCapacity())
return MODE_ERROR;
462 uint pos = ((row + this->vscroll->
GetPosition()) * this->num_columns) + xt;
464 if (this->vehicle_list.size() + this->wagon_list.size() <= pos) {
470 return MODE_DRAG_VEHICLE;
477 if (this->vehicle_list.size() > pos) {
478 *veh = this->vehicle_list[pos];
482 pos -= (uint)this->vehicle_list.size();
483 *veh = this->wagon_list[pos];
489 const Train *v =
nullptr;
492 d->head = d->wagon = v;
495 if (xm <= this->header_width) {
496 switch (this->type) {
498 if (wagon)
return MODE_ERROR;
502 if (xm <= this->flag_width)
return MODE_START_STOP;
510 default: NOT_REACHED();
512 return MODE_SHOW_VEHICLE;
515 if (this->type !=
VEH_TRAIN)
return MODE_DRAG_VEHICLE;
518 if (xm >= matrix_widget->
current_x - this->count_width)
return wagon ? MODE_ERROR : MODE_SHOW_VEHICLE;
521 x -= this->header_width;
524 for (; v !=
nullptr; v = v->
Next()) {
531 return MODE_DRAG_VEHICLE;
543 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(x, y, &v, &gdvp);
545 if (this->type ==
VEH_TRAIN) v = gdvp.wagon;
551 case MODE_DRAG_VEHICLE: {
558 TrainDepotMoveVehicle(v, sel, gdvp.head);
559 }
else if (v !=
nullptr) {
564 this->sel = v->
index;
570 case MODE_SHOW_VEHICLE:
574 case MODE_START_STOP:
578 default: NOT_REACHED();
590 this->GetWidget<NWidgetCore>(
WID_D_STOP_ALL)->tool_tip = STR_DEPOT_MASS_STOP_DEPOT_TRAIN_TOOLTIP + type;
591 this->GetWidget<NWidgetCore>(
WID_D_START_ALL)->tool_tip = STR_DEPOT_MASS_START_DEPOT_TRAIN_TOOLTIP + type;
592 this->GetWidget<NWidgetCore>(
WID_D_SELL)->tool_tip = STR_DEPOT_TRAIN_SELL_TOOLTIP + type;
593 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->tool_tip = STR_DEPOT_SELL_ALL_BUTTON_TRAIN_TOOLTIP + type;
595 this->GetWidget<NWidgetCore>(
WID_D_BUILD)->SetDataTip(STR_DEPOT_TRAIN_NEW_VEHICLES_BUTTON + type, STR_DEPOT_TRAIN_NEW_VEHICLES_TOOLTIP + type);
596 this->GetWidget<NWidgetCore>(
WID_D_CLONE)->SetDataTip(STR_DEPOT_CLONE_TRAIN + type, STR_DEPOT_CLONE_TRAIN_DEPOT_INFO + type);
598 this->GetWidget<NWidgetCore>(
WID_D_LOCATION)->tool_tip = STR_DEPOT_TRAIN_LOCATION_TOOLTIP + type;
599 this->GetWidget<NWidgetCore>(
WID_D_VEHICLE_LIST)->tool_tip = STR_DEPOT_VEHICLE_ORDER_LIST_TRAIN_TOOLTIP + type;
600 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->tool_tip = STR_DEPOT_AUTOREPLACE_TRAIN_TOOLTIP + type;
601 this->GetWidget<NWidgetCore>(
WID_D_MATRIX)->tool_tip = STR_DEPOT_TRAIN_LIST_TOOLTIP + this->type;
604 default: NOT_REACHED();
610 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_TRAIN;
611 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_TRAIN;
612 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_TRAIN;
619 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_ROADVEH;
620 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_ROADVEH;
621 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_ROADVEH;
628 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_SHIP;
629 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_SHIP;
637 this->GetWidget<NWidgetCore>(
WID_D_SELL)->widget_data = SPR_SELL_AIRCRAFT;
638 this->GetWidget<NWidgetCore>(
WID_D_SELL_ALL)->widget_data = SPR_SELL_ALL_AIRCRAFT;
639 this->GetWidget<NWidgetCore>(
WID_D_AUTOREPLACE)->widget_data = SPR_REPLACE_AIRCRAFT;
660 this->count_width = 0;
674 this->header_width = std::max<uint>(unumber.width, this->flag_width) +
WD_FRAMERECT_RIGHT;
676 int base_width = this->count_width + this->header_width;
682 size->height =
resize->height * 6;
688 fill->width =
resize->width;
689 fill->height =
resize->height;
702 this->generate_list =
true;
707 if (this->generate_list) {
711 this->generate_list =
false;
712 DepotSortList(&this->vehicle_list);
716 if (this->unitnumber_digits < new_unitnumber_digits) {
717 this->unitnumber_digits = new_unitnumber_digits;
724 uint max_width =
ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
725 for (uint num = 0; num < this->vehicle_list.size(); num++) {
730 max_width = std::max(max_width,
width);
733 this->vscroll->
SetCount((uint)this->vehicle_list.size() + (uint)this->wagon_list.size() + 1);
737 this->vscroll->
SetCount(
CeilDiv((uint)this->vehicle_list.size(), this->num_columns));
776 static const CursorID clone_icons[] = {
777 SPR_CURSOR_CLONE_TRAIN, SPR_CURSOR_CLONE_ROADVEH,
778 SPR_CURSOR_CLONE_SHIP, SPR_CURSOR_CLONE_AIRPLANE
810 if (this->vehicle_list.size() != 0 || this->wagon_list.size() != 0) {
815 STR_DEPOT_SELL_CONFIRMATION_TEXT,
817 DepotSellAllConfirmationCallback
823 ShowVehicleListWindow(
GetTileOwner(this->window_number), this->type, (
TileIndex)this->window_number);
835 if (str ==
nullptr)
return;
848 DepotGUIAction mode = this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_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 char details[1024];
879 if (capacity[cargo_type] == 0)
continue;
885 pos = GetString(pos, STR_DEPOT_VEHICLE_TOOLTIP_CARGO,
lastof(details));
891 args[1] = (uint64)(
size_t)details;
892 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 !=
nullptr) {
968 if (gdvp.wagon ==
nullptr && gdvp.head->
Last()->
index != this->sel) {
973 new_vehicle_over = gdvp.head->
index;
974 }
else if (gdvp.wagon !=
nullptr && 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 ==
nullptr || gdvp.wagon->
index != sel) {
1007 TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
1008 }
else if (gdvp.head !=
nullptr && gdvp.head->
IsFrontEngine()) {
1012 }
else if (this->GetVehicleFromDepotWndPt(pt.x - nwi->
pos_x, pt.y - nwi->
pos_y, &v,
nullptr) == MODE_DRAG_VEHICLE && v !=
nullptr && sel == v->
index) {
1038 this->hovered_widget = -1;
1087 static void DepotSellAllConfirmationCallback(
Window *win,
bool confirmed)
1092 byte vehtype = w->type;
1108 default: NOT_REACHED();
1109 case VEH_TRAIN: desc = &_train_depot_desc;
break;
1110 case VEH_ROAD: desc = &_road_depot_desc;
break;
1111 case VEH_SHIP: desc = &_ship_depot_desc;
break;
1112 case VEH_AIRCRAFT: desc = &_aircraft_depot_desc;
break;
@ VEH_AIRCRAFT
Aircraft vehicle type.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a train vehicle image in the GUI.
@ ES_HANDLED
The passed event is handled.
bool OnRightClick(Point pt, int widget) override
A click with the right mouse button has been made on the window.
static bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
#define CMD_MSG(x)
Used to combine a StringID with the command.
uint32 TileIndex
The index/ID of a Tile.
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.
@ CMD_REVERSE_TRAIN_DIRECTION
turn a train around
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.
@ CMD_MOVE_RAIL_VEHICLE
move a rail vehicle (in the depot)
Dimensions (a width and height) of a rectangle in 2D.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
The information about a vehicle list.
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
static uint _consistent_train_width
Whether trains of all lengths are consistently scaled. Either TRAININFO_DEFAULT_VEHICLE_WIDTH,...
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Vehicle * Next() const
Get the next vehicle of this vehicle.
T * Next() const
Get next vehicle in the chain.
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
bool vehchain
vehicle chain is dragged
@ SA_RIGHT
Right align the text (must be a single bit).
void OnQueryTextFinished(char *str) override
The query window opened from this window has closed.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Tindex index
Index of this pool item.
Scrollbar * hscroll
Only for trains.
@ EIT_PURCHASE
Vehicle drawn in purchase list, autoreplace gui, ...
Class for storing amounts of cargo.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
static int UnScaleGUI(int value)
Short-hand to apply GUI zoom level.
uint16 height
Height of the sprite.
bool _ctrl_pressed
Is Ctrl pressed?
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.
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.
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.
@ ST_NORMAL
The most basic (normal) sprite.
EngineImageType
Visualisation contexts of vehicles and engines.
@ VEH_ROAD
Road vehicle type.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
void HandleButtonClick(byte widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
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).
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
Get the GUI cell size for a vehicle image.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
@ QSF_LEN_IN_CHARS
the length of the string is counted in characters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
High level window description.
@ CMD_DEPOT_MASS_AUTOREPLACE
force the autoreplace to take action in a given depot
void DepotClick(int x, int y)
Handle click in the depot matrix.
uint16 EngineID
Unique identification number of an engine.
uint16 cached_total_length
Length of the whole vehicle (valid only for the first engine).
void SetupWidgetData(VehicleType type)
Function to set up vehicle specific widgets (mainly sprites and strings).
@ WDP_AUTO
Find a place automatically.
ResizeInfo resize
Resize information.
static uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
Common return value for all commands.
uint16 GetDepotIndex() const
Gets the DepotID of the current window.
void GuiShowTooltips(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip)
Shows a tooltip.
uint32 CursorID
The number of the cursor (sprite)
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes CMD_START_STOP_VEHICLE for given vehicle.
@ VEH_COMPANY_END
Last company-ownable type.
int height
Height of the window (number of pixels down in y direction)
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)
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.
EngineID engine_type
The type of engine used for this vehicle.
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
@ FS_SMALL
Index of the small font in the font tables.
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
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.
@ 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.
GroundVehicleCache gcache
Cache of often calculated values.
uint32 Pack() const
Pack a VehicleListIdentifier in a single uint32.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
int hovered_widget
Index of the widget being hovered during drag/drop. -1 if no drag is in progress.
@ VS_STOPPED
Vehicle is stopped by the player.
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.
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
int left
x position of left edge of the window
static const NWidgetPart _nested_train_depot_widgets[]
Nested widget definition for train depots.
uint16 width
Width of the sprite.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
'Train' is either a loco or a wagon.
static const uint32 MAKE_ORDER_BACKUP_FLAG
Flag to pass to the vehicle construction command when an order should be preserved.
static bool IsTileOwner(TileIndex tile, Owner owner)
Checks if a tile belongs to the given owner.
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
void OnMouseDrag(Point pt, int widget) override
An 'object' is being dragged at the provided position, highlight the target if possible.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Coordinates of a point in 2D.
void DrawShipImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
@ WSM_DRAGDROP
Drag&drop an object.
static const int DAYS_IN_LEAP_YEAR
sometimes, you need one day more...
WindowNumber window_number
Window number within the window class.
VehicleType
Available vehicle types.
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.
@ EIT_IN_DEPOT
Vehicle drawn in depot.
NWidgetBase ** nested_array
Array of pointers into the tree. Do not access directly, use Window::GetWidget() instead.
static Owner GetTileOwner(TileIndex tile)
Returns the owner of a tile.
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
@ HT_DRAG
dragging items in the depot windows
static WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
void OnDragDrop(Point pt, int widget) override
A dragged 'object' has been released.
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 T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
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).
@ CMD_CLONE_VEHICLE
clone a vehicle
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
uint step_width
Step-size of width resize changes.
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.
@ CMD_MASS_START_STOP
start/stop all vehicles (in a depot)
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
@ 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'.
static Train * From(Vehicle *v)
Converts a Vehicle to SpecializedVehicle with type checking.
void OnResize() override
Called after the window got resized.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
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 int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
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.
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).
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
@ WC_VEHICLE_DEPOT
Depot view; Window numbers:
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
@ NUM_CARGO
Maximal number of cargo types in a game.
static StationID GetStationIndex(TileIndex t)
Get StationID from a tile.
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...
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
UnitID unitnumber
unit number, for display purposes only
Dimensions of a cell in the purchase/depot windows.
@ CMD_RENAME_DEPOT
rename a depot
Vehicle * Last()
Get the last vehicle of this vehicle chain.
uint32 VehicleID
The type all our vehicle IDs have.
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
#define lengthof(x)
Return the length of an fixed size array.
int width
width of the window (number of pixels to the right in x direction)
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.
byte CargoID
Cargo slots to indicate a cargo type within a game.
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...
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.
bool OnVehicleSelect(const Vehicle *v) override
Clones a vehicle.
static const CursorID SPR_CURSOR_MOUSE
Cursor sprite numbers.
static uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
Data structure for an opened window.
bool IsFreeWagon() const
Check if the vehicle is a free wagon (got no engine in front of it).
@ VEH_TRAIN
Train vehicle type.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
VehicleType type
Type of vehicle.
void DrawWidgets() const
Paint all widgets of a window.
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void DeleteDepotHighlightOfVehicle(const Vehicle *v)
Removes the highlight of a vehicle in a depot window.
@ VEH_SHIP
Ship vehicle type.
Specification of a rectangle with absolute coordinates of all edges.
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
void DrawAircraftImage(const Vehicle *v, int left, int right, int y, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
Data structure describing a sprite.
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
#define lastof(x)
Get the last element of an fixed size array.
void SetDParamMaxDigits(uint n, uint count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
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.
@ CMD_DEPOT_SELL_ALL_VEHICLES
sell all vehicles which are in a given depot
T * GetFirstEnginePart()
Get the first part of an articulated engine.
uint num_columns
Number of columns.
uint extend_left
Extend of the cell to the left.
VehicleID vehicle_over
Rail vehicle over which another one is dragged, INVALID_VEHICLE if none.