39#include "table/strings.h"
92 WindowClass::VehicleDepot, WindowClass::None,
100 WindowClass::VehicleDepot, WindowClass::None,
108 WindowClass::VehicleDepot, WindowClass::None,
116 WindowClass::VehicleDepot, WindowClass::None,
130 if (result.
Failed())
return;
141 if (v == wagon)
return;
143 if (wagon ==
nullptr) {
144 if (head !=
nullptr) wagon = head->
Last();
147 if (wagon ==
nullptr)
return;
150 if (wagon == v)
return;
152 Command<Commands::MoveRailVehicle>::Post(STR_ERROR_CAN_T_MOVE_VEHICLE, v->
tile, v->index, wagon ==
nullptr ? VehicleID::Invalid() : wagon->index,
_ctrl_pressed);
168 switch (image_type) {
171 default: NOT_REACHED();
177 int max_extend_left = 0;
178 int max_extend_right = 0;
182 if (!e->IsEnabled())
continue;
189 default: NOT_REACHED();
195 if (y > height) height = y;
196 if (-x_offs > max_extend_left) max_extend_left = -x_offs;
197 if ((
int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
205 int max_height = min_height + min_height / 2;
207 switch (image_type) {
219 default: NOT_REACHED();
237 if (!e->IsEnabled())
continue;
239 uint w = TRAININFO_DEFAULT_VEHICLE_WIDTH;
240 if (e->GetGRF() !=
nullptr && IsCustomVehicleSpriteNum(e->VehInfo<
RailVehicleInfo>().image_index)) {
241 w = e->GetGRF()->traininfo_vehicle_width;
242 if (w != VEHICLEINFO_FULL_VEHICLE_WIDTH) {
262static void DepotSellAllConfirmationCallback(
Window *w,
bool confirmed);
269 bool generate_list =
true;
270 bool check_unitnumber_digits =
true;
274 uint unitnumber_digits = 2;
282 bool last_overlay_state =
false;
306 void Close([[maybe_unused]]
int data = 0)
override
323 if (this->sel == VehicleID::Invalid())
return 0;
326 bool add_dragged =
false;
327 for (
const Train *u = t; u !=
nullptr; u = u->
Next()) {
328 if (u->index == this->sel)
return 0;
329 if (u->index == this->vehicle_over) add_dragged =
true;
332 if (!add_dragged)
return 0;
336 for (
Train *u =
Train::Get(this->sel); u !=
nullptr; u = _cursor.vehchain ? u->Next() : (u->HasArticulatedPart() ? u->GetNextArticulatedPart() :
nullptr)) {
337 length += u->gcache.cached_veh_length;
350 bool free_wagon =
false;
354 Rect image = r.
Indent(this->header_width, rtl).
Indent(this->count_width, !rtl);
361 uint x_space = free_wagon ?
379 default: NOT_REACHED();
415 if (this->num_columns != 1) ir = ir.
WithWidth(this->
resize.step_width, rtl);
426 Rect image = ir.
Indent(this->header_width, rtl).
Indent(this->count_width, !rtl);
427 int first_line = w + (-this->hscroll->
GetPosition()) % w;
429 for (
int x = image.right - first_line; x >= image.left; x -= w) {
433 for (
int x = image.left + first_line; x <= image.right; x += w) {
441 uint num = this->vscroll->
GetPosition() * this->num_columns;
442 uint maxval =
static_cast<uint
>(std::min<size_t>(this->vehicle_list.size(), num + (rows_in_display * this->num_columns)));
445 for (uint i = 0; i < this->num_columns && num < maxval; i++, num++) {
447 const Vehicle *v = this->vehicle_list[num];
449 cell = cell.
Translate(rtl ? -(
int)this->
resize.step_width : (
int)this->resize.step_width, 0);
453 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)));
456 for (; num < maxval; num++, ir = ir.
Translate(0, this->
resize.step_height)) {
457 const Vehicle *v = this->wagon_list[num - this->vehicle_list.size()];
492 this->RefreshVehicleList();
496 x -= matrix_widget->
pos_x;
500 uint xt = 0, xm = 0, ym = 0;
504 xt = x / this->
resize.step_width;
505 xm = x % this->
resize.step_width;
508 ym = (y - matrix_widget->
pos_y) % this->
resize.step_height;
511 uint pos = (row * this->num_columns) + xt;
513 if (row == INT32_MAX || this->vehicle_list.size() + this->wagon_list.size() <= pos) {
524 bool is_wagon =
false;
525 if (this->vehicle_list.size() > pos) {
526 vehicle = this->vehicle_list[pos];
530 pos -= (uint)this->vehicle_list.size();
531 vehicle = this->wagon_list[pos];
538 switch (this->type) {
552 default: NOT_REACHED();
560 if (xm >= matrix_widget->
current_x - this->count_width) {
566 x -= this->header_width;
570 for (; wagon !=
nullptr; wagon = wagon->
Next()) {
598 this->sel = VehicleID::Invalid();
599 TrainDepotMoveVehicle(v, sel, result.
vehicle);
600 }
else if (v !=
nullptr) {
605 this->sel = v->index;
619 default: NOT_REACHED();
646 default: NOT_REACHED();
701 this->count_width = 0;
707 min_height = std::max<uint>(unumber.height, this->flag_size.height);
713 int base_width = this->count_width + this->header_width + padding.width;
715 resize.height = std::max<uint>(this->cell_size.
height, min_height + padding.height);
719 size.height =
resize.height * 6;
725 fill.width =
resize.width;
726 fill.height =
resize.height;
737 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
739 this->generate_list =
true;
742 void RefreshVehicleList()
744 if (this->generate_list) {
748 this->generate_list =
false;
749 DepotSortList(&this->vehicle_list);
751 this->check_unitnumber_digits =
true;
757 this->RefreshVehicleList();
759 if (this->check_unitnumber_digits) {
760 this->check_unitnumber_digits =
false;
763 if (this->unitnumber_digits < new_unitnumber_digits) {
764 this->unitnumber_digits = new_unitnumber_digits;
772 for (uint num = 0; num < this->vehicle_list.size(); num++) {
775 width += v->GetDisplayImageWidth();
777 max_width = std::max(max_width,
width);
780 this->vscroll->
SetCount(this->vehicle_list.size() + this->wagon_list.size() + 1);
784 this->vscroll->
SetCount(
CeilDiv((uint)this->vehicle_list.size(), this->num_columns));
854 if (!this->vehicle_list.empty() || !this->wagon_list.empty()) {
859 DepotSellAllConfirmationCallback
869 Command<Commands::DepotMassAutoreplace>::Post(GetCmdAutoreplaceVehMsg(this->type),
TileIndex(this->
window_number), this->type);
877 if (!str.has_value())
return;
880 Command<Commands::RenameDepot>::Post(STR_ERROR_CAN_T_RENAME_DEPOT, this->
GetDestinationIndex().ToDepotID(), *str);
898 for (
const Vehicle *w = v; w !=
nullptr; w = w->
Next()) {
899 if (w->cargo_cap > 0 && w->cargo_type <
NUM_CARGO) {
900 capacity[w->cargo_type] += w->cargo_cap;
901 loaded [w->cargo_type] += w->cargo.StoredCount();
906 if (!whole_chain)
break;
911 static std::string details;
916 if (capacity[cargo_type] == 0)
continue;
918 auto params =
MakeParameters(cargo_type, loaded[cargo_type], cargo_type, capacity[cargo_type]);
919 AppendStringWithArgsInPlace(details, STR_DEPOT_VEHICLE_TOOLTIP_CARGO, params);
960 bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end)
override
1008 this->sel = VehicleID::Invalid();
1009 this->vehicle_over = VehicleID::Invalid();
1029 if (this->sel == VehicleID::Invalid())
return;
1030 if (widget != this->hovered_widget) {
1035 this->hovered_widget = widget;
1045 if (this->vehicle_over != VehicleID::Invalid()) {
1046 this->vehicle_over = VehicleID::Invalid();
1055 VehicleID new_vehicle_over = VehicleID::Invalid();
1056 if (result.
vehicle !=
nullptr) {
1057 if (result.
wagon ==
nullptr && result.
vehicle->
Last()->index != this->sel) {
1062 new_vehicle_over = result.
vehicle->index;
1064 result.
wagon->index != this->sel &&
1066 new_vehicle_over = result.
wagon->index;
1070 if (this->vehicle_over == new_vehicle_over)
return;
1072 this->vehicle_over = new_vehicle_over;
1083 this->sel = VehicleID::Invalid();
1089 Command<Commands::ReverseTrainDirection>::Post(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE,
Vehicle::Get(sel)->tile,
Vehicle::Get(sel)->index,
true);
1090 }
else if (result.
wagon ==
nullptr || result.
wagon->index != sel) {
1091 this->vehicle_over = VehicleID::Invalid();
1092 TrainDepotMoveVehicle(result.
wagon, sel, result.
vehicle);
1105 if (this->sel == VehicleID::Invalid())
return;
1110 this->sel = VehicleID::Invalid();
1119 this->sel = VehicleID::Invalid();
1124 _cursor.vehchain =
false;
1152 if (this->sel != VehicleID::Invalid()) {
1172static void DepotSellAllConfirmationCallback(
Window *win,
bool confirmed)
1178 Command<Commands::DepotMassSell>::Post(GetCmdSellAllVehMsg(vehtype), tile, vehtype);
1192 default: NOT_REACHED();
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 DrawAircraftImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type)
Draws an image of an aircraft.
static constexpr CargoType NUM_CARGO
Maximum number of cargo types in a game.
CargoType
Cargo slots to indicate a cargo type within a game.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Common return value for all commands.
bool Failed() const
Did this command fail?
static Pool::IterateWrapperFiltered< Engine, EngineTypeFilter > IterateType(VehicleType vt, size_t from=0)
Returns an iterable ensemble of all valid engines of the given type.
Iterate a range of enum values.
static constexpr int DAYS_IN_LEAP_YEAR
Functions related to commands.
Commands
List of commands.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
Base for all depots (except hangars).
Command definitions related to depots.
static VehicleTypeIndexArray< VehicleCellSize > _base_block_sizes_purchase
Cell size for vehicle images in the purchase list.
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...
static uint _consistent_train_width
Whether trains of all lengths are consistently scaled. Either TRAININFO_DEFAULT_VEHICLE_WIDTH,...
static WindowDesc _train_depot_desc(WindowPosition::Automatic, "depot_train", 362, 123, WindowClass::VehicleDepot, WindowClass::None, {}, _nested_train_depot_widgets)
Window definition for the train depot window.
static WindowDesc _road_depot_desc(WindowPosition::Automatic, "depot_roadveh", 316, 97, WindowClass::VehicleDepot, WindowClass::None, {}, _nested_train_depot_widgets)
Window definition for the road depot window.
static WindowDesc _ship_depot_desc(WindowPosition::Automatic, "depot_ship", 306, 99, WindowClass::VehicleDepot, WindowClass::None, {}, _nested_train_depot_widgets)
Window definition for the ship depot window.
void DeleteDepotHighlightOfVehicle(const Vehicle *v)
Removes the highlight of a vehicle in a depot window.
static constexpr std::initializer_list< NWidgetPart > _nested_train_depot_widgets
Nested widget definition for train depots.
static VehicleTypeIndexArray< VehicleCellSize > _base_block_sizes_depot
Cell size for vehicle images in the depot view.
static WindowDesc _aircraft_depot_desc(WindowPosition::Automatic, "depot_aircraft", 332, 99, WindowClass::VehicleDepot, WindowClass::None, {}, _nested_train_depot_widgets)
Window definition for the aircraft depot window.
void ShowDepotWindow(TileIndex tile, VehicleType type)
Opens a depot window.
VehicleCellSize GetVehicleImageCellSize(VehicleType type, EngineImageType image_type)
Get the GUI cell size for a vehicle image.
void CcCloneVehicle(Commands, const CommandCost &result, VehicleID veh_id)
This is the Callback method after the cloning attempt of a vehicle.
DestinationID GetDepotDestinationIndex(Tile t)
Get the destination index of a 'depot'.
static const uint MAX_LENGTH_DEPOT_NAME_CHARS
The maximum length of a depot name in characters including '\0'.
PoolID< uint16_t, struct EngineIDTag, 64000, 0xFFFF > EngineID
Unique identification number of an engine.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
Functions related to errors.
@ Info
Used for DoCommand-like (and some non-fatal AI GUI) errors/information.
void ShowErrorMessage(EncodedString &&summary_msg, int x, int y, CommandCost &cc)
Display an error message in a window.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
@ ForceRight
Force align to the right.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
bool _ctrl_pressed
Is Ctrl pressed?
int DrawString(int left, int right, int top, std::string_view str, ExtendedTextColour colour, Alignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Dimension GetScaledSpriteSize(SpriteID sprid)
Scale sprite size for GUI.
void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, Alignment align)
Draw a sprite within a Rect, ignoring the sprite's padding.
@ Small
Index of the small font in the font tables.
@ Normal
Index of the normal font in the font tables.
static const CursorID SPR_CURSOR_CLONE_AIRPLANE
static const CursorID SPR_CURSOR_CLONE_TRAIN
static const CursorID SPR_CURSOR_CLONE_ROADVEH
static const CursorID SPR_CURSOR_MOUSE
static const CursorID SPR_CURSOR_CLONE_SHIP
void SetDirty() const
Mark entire window as dirty (in need of re-paint).
GUI functions that shouldn't be here.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
#define Point
Macro that prevents name conflicts between included headers.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
constexpr T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
void GuiShowTooltips(Window *parent, EncodedString &&text, TooltipCloseCondition close_tooltip)
Shows a tooltip.
void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, QueryCallbackProc *callback, bool focus)
Show a confirmation window with standard 'yes' and 'no' buttons The window is aligned to the centre o...
void ShowQueryString(std::string_view str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
@ Invalid
Client is not part of anything.
Functions related to order backups.
PixelColour GetColourGradient(Colours colour, Shade shade)
Get colour gradient palette index.
@ Normal
Normal colour shade.
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 DrawRoadVehImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip)
Draws an image of a road vehicle chain.
A number of safeguards to prevent using unsafe methods.
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).
void DrawShipImage(const Vehicle *v, const Rect &r, VehicleID selection, EngineImageType image_type)
Draws an image of a ship.
void SndClickBeep()
Play a beep sound for a click event if enabled in settings.
Functions related to sound.
Types related to the sprite cache.
static const SpriteID SPR_FLAG_VEH_STOPPED
Vehicle sprite-flags (red/green).
static const SpriteID SPR_FLAG_VEH_RUNNING
Vehicle sprite-flags (red/green).
Definition of base types and functions in a cross-platform compatible way.
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
uint64_t GetParamMaxValue(uint64_t max_value, uint min_count, FontSize size)
Get some number that is suitable for string size computations.
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
TextDirection _current_text_dir
Text direction of the currently selected language.
uint64_t GetParamMaxDigits(uint count, FontSize size)
Get some number that is suitable for string size computations.
Functions related to OTTD's strings.
auto MakeParameters(Args &&... args)
Helper to create the StringParameters with its own buffer with the given parameter values.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
@ TD_RTL
Text is written right-to-left by default.
VehicleType type
Type of vehicle.
Class for storing amounts of cargo.
Specification of a cargo type.
Result of GetVehicleFromDepotWndPt that tries to determine the action to perform.
const Vehicle * wagon
The wagon to perform the action on. Only set for DragVehicle actions on trains.
DepotGUIAction action
Action to perform.
const Vehicle * vehicle
The vehicle, or head of vehicle, to perform the action on.
uint header_width
Width of unit number and flag, including separator.
void OnMouseLoop() override
Called for every mouse loop run, which is at least once per (game) tick.
VehicleID vehicle_over
Rail vehicle over which another one is dragged, VehicleID::Invalid() if none.
void OnDragDrop(Point pt, WidgetID widget) override
A dragged 'object' has been released.
DepotActionResult GetVehicleFromDepotWndPt(int x, int y)
Determine what action to take for clicking at the given location in the depot window.
DepotGUIAction
Action to perform when using the depot UI.
@ ShowVehicle
Show the vehicle window.
@ Error
Most likely clicked outside of the bounds.
@ DragVehicle
Drag a vehicle to somewhere else.
@ StartStop
Start/stop the vehicle.
uint count_width
Width of length count, including separator.
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
DestinationID GetDestinationIndex() const
Gets the DepotID of the current window.
void OnTimeout() override
Called when this window's timeout has been reached.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
uint num_columns
Number of columns.
EventState OnCTRLStateChange() override
The state of the control key has changed.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void SetupWidgetData(VehicleType type)
Function to set up vehicle specific widgets (mainly sprites and strings).
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
bool OnRightClick(Point pt, WidgetID widget) override
A click with the right mouse button has been made on the window.
void OnMouseDrag(Point pt, WidgetID widget) override
An 'object' is being dragged at the provided position, highlight the target if possible.
uint CountDraggedLength(const Train *t) const
Count the dragged selection length if appropriate for the provided train.
bool OnVehicleSelect(const Vehicle *v) override
Clones a vehicle.
Dimension flag_size
Size of start/stop flag.
void DepotClick(int x, int y)
Handle click in the depot matrix.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
Scrollbar * hscroll
Only for trains.
bool OnVehicleSelect(VehicleList::const_iterator begin, VehicleList::const_iterator end) override
Clones a vehicle from a vehicle list.
void OnResize() override
Called after the window got resized.
void OnPaint() override
The window must be repainted.
WidgetID hovered_widget
Index of the widget being hovered during drag/drop. INVALID_WIDGET if no drag is in progress.
void OnInit() override
Notification that the nested widget tree gets initialized.
void DrawVehicleInDepot(const Vehicle *v, const Rect &r) const
Draw a vehicle in the depot window in the box with the top left corner at x,y.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
VehicleCellSize cell_size
Vehicle sprite cell size.
Dimensions (a width and height) of a rectangle in 2D.
uint16_t cached_total_length
Length of the whole vehicle (valid only for the first engine).
GroundVehicleCache gcache
Cache of often calculated values.
bool IsFreeWagon() const
Check if the vehicle is a free wagon (got no engine in front of it).
static void Reset(TileIndex tile=INVALID_TILE, bool from_gui=true)
Reset the OrderBackups from GUI/game logic.
Colour for pixel/line drawing.
static Vehicle * Get(auto index)
Information about a rail vehicle.
Specification of a rectangle with absolute coordinates of all edges.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Rect WithHeight(int height, bool end=false) const
Copy Rect and set its height.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
Rect Translate(int x, int y) const
Copy and translate Rect by x,y pixels.
T * Next() const
Get next vehicle in the chain.
static Train * From(Vehicle *v)
T * GetFirstEnginePart()
Get the first part of an articulated engine.
Data structure describing a sprite.
'Train' is either a loco or a wagon.
int GetDisplayImageWidth(Point *offset=nullptr) const
Get the width of a train vehicle image in the GUI.
Dimensions of a cell in the purchase/depot windows.
uint extend_left
Extend of the cell to the left.
uint height
Vehicle cell height.
uint extend_right
Extend of the cell to the right.
The information about a vehicle list.
EngineID engine_type
The type of engine used for this vehicle.
bool IsGroundVehicle() const
Check if the vehicle is a ground vehicle.
VehStates vehstatus
Status.
Vehicle * Next() const
Get the next vehicle of this vehicle.
bool IsFrontEngine() const
Check if the vehicle is a front engine.
TimerGameCalendar::Date age
Age in calendar days.
TimerGameCalendar::Date max_age
Maximum age.
Vehicle * FirstShared() const
Get the first vehicle of this vehicle chain.
Vehicle * Previous() const
Get the previous vehicle of this vehicle.
Vehicle * Last() const
Get the last vehicle of this vehicle chain.
TileIndex tile
Current tile index.
UnitID unitnumber
unit number, for display purposes only
High level window description.
Data structure for an opened window.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void DrawWidgets() const
Paint all widgets of a window.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
ResizeInfo resize
Resize information.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void HandleButtonClick(WidgetID widget)
Do all things to make a button look clicked and mark it to be unclicked in a few ticks.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
int width
width of the window (number of pixels to the right in x direction)
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
WindowNumber window_number
Window number within the window class.
Stuff related to the text buffer GUI.
@ EnableDefault
enable the 'Default' button ("\0" is returned)
@ LengthIsInChars
the length of the string is counted in characters
bool IsTileOwner(Tile tile, Owner owner)
Checks if a tile belongs to the given owner.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
static constexpr uint TILE_SIZE
Tile size in world coordinates.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
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...
@ HT_DRAG
dragging items in the depot windows
@ HT_VEHICLE
vehicle is accepted as target as well (bitmask)
Base for the train class.
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).
Command definitions related to trains.
void DrawTrainImage(const Train *v, const Rect &r, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest)
Draws an image of a whole train.
bool VehiclesHaveSameEngineList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicle chains have the same list of engines.
bool VehiclesHaveSameOrderList(const Vehicle *v1, const Vehicle *v2)
Checks if two vehicles have the same list of orders.
@ Stopped
Vehicle is stopped by the player.
Command definitions for vehicles.
Functions related to vehicles.
bool IsCompanyBuildableVehicleType(VehicleType type)
Is the given vehicle type buildable by a company?
uint GetUnitNumberDigits(VehicleList &vehicles)
Get the number of digits the biggest unit number of a set of vehicles has.
void ShowVehicleViewWindow(const Vehicle *v)
Shows the vehicle view window of the given vehicle.
bool VehicleClicked(const Vehicle *v)
Dispatch a "vehicle selected" event if any window waits for it.
void StartStopVehicle(const Vehicle *v, bool texteffect)
Executes Commands::StartStopVehicle for given vehicle.
void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
Set the mouse cursor to look like a vehicle.
bool ShowCargoIconOverlay()
Test if cargo icon overlays should be drawn.
uint GetVehicleHeight(VehicleType type)
Get the height of a single vehicle in the GUIs.
WindowClass GetWindowClassForVehicleType(VehicleType vt)
Get WindowClass for vehicle list of given vehicle type.
EngineImageType
Visualisation contexts of vehicles and engines.
@ InDepot
Vehicle drawn in depot.
@ Purchase
Vehicle drawn in purchase list, autoreplace gui, ...
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF > VehicleID
The type all our vehicle IDs have.
VehicleType
Available vehicle types.
@ Invalid
Non-existing type of vehicle.
@ CompanyEnd
Last company-ownable type.
@ Aircraft
Aircraft vehicle type.
@ Train
Train vehicle type.
EnumIndexArray< T, VehicleType, Tend > VehicleTypeIndexArray
Array with VehicleType as index.
void BuildDepotVehicleList(VehicleType type, TileIndex tile, VehicleList *engines, VehicleList *wagons, bool individual_wagons)
Generate a list of vehicles inside a depot.
Functions and type for generating vehicle lists.
std::vector< const Vehicle * > VehicleList
A list of vehicles.
@ Depot
Index is the destination (station for hangar of aircraft, depot for others).
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
Functions related to (drawing on) viewports.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Window * BringWindowToFrontById(WindowClass cls, WindowNumber number)
Find a window and make it the relative top-window on the screen.
SpecialMouseMode _special_mouse_mode
Mode of the mouse.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Functions, definitions and such used only by the GUI.
@ RightClick
Close the tooltip when releasing the right mouse button.
bool AllEqual(It begin, It end, Pred pred)
Generic helper function that checks if all elements of the range are equal with respect to the given ...
@ DragDrop
Drag&drop an object.
@ Automatic
Find a place automatically.
EventState
State of handling an event.
@ Handled
The passed event is handled.
@ NotHandled
The passed event is not handled.
static constexpr WidgetID INVALID_WIDGET
An invalid widget index.
Functions related to zooming.
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.