34#include "table/strings.h"
73static const StringID _start_replace_dropdown[] = {
74 STR_REPLACE_VEHICLES_NOW,
75 STR_REPLACE_VEHICLES_WHEN_OLD,
81class ReplaceVehicleWindow :
public Window {
94 std::array<Scrollbar *, 2> vscroll{};
125 EngineID selected_engine = EngineID::Invalid();
127 uint8_t side = draw_left ? 0 : 1;
132 if (!draw_left && !this->show_hidden_engines && e->IsVariantHidden(
_local_company))
continue;
159 list.emplace_back(eid, e->info.variant_id, (side == 0) ?
EngineDisplayFlags{} : e->display_flags, 0);
167 if (eid == this->sel_engine[side]) selected_engine = eid;
172 for (
const auto &variant : variants) {
180 this->sel_engine[side] = selected_engine;
188 this->engines[side].clear();
192 this->engines[side].swap(list);
201 if (this->engines[0].NeedRebuild()) {
204 this->vscroll[0]->SetCount(this->engines[0].size());
205 if (this->reset_sel_engine && this->sel_engine[0] == EngineID::Invalid() && !this->engines[0].empty()) {
206 this->sel_engine[0] = this->engines[0][0].engine_id;
210 if (this->engines[1].NeedRebuild() || e != this->sel_engine[0]) {
212 if (this->sel_engine[0] == EngineID::Invalid()) {
214 this->engines[1].clear();
215 this->sel_engine[1] = EngineID::Invalid();
216 this->vscroll[1]->SetCount(this->engines[1].size());
218 if (this->reset_sel_engine && this->sel_engine[0] != EngineID::Invalid()) {
225 this->vscroll[1]->SetCount(this->engines[1].size());
226 if (this->reset_sel_engine && this->sel_engine[1] != EngineID::Invalid()) {
228 for (
const auto &item : this->engines[1]) {
229 if (item.engine_id == this->sel_engine[1])
break;
232 this->vscroll[1]->ScrollTowards(position);
237 this->engines[0].RebuildDone();
238 this->engines[1].RebuildDone();
239 this->reset_sel_engine =
false;
248 EngineID veh_from = this->sel_engine[0];
249 EngineID veh_to = this->sel_engine[1];
250 Command<Commands::SetAutoreplace>::Post(this->sel_group, veh_from, veh_to, replace_when_old);
259 this->vscroll[0]->SetPosition(0);
260 this->vscroll[1]->SetPosition(0);
262 this->engines[0].ForceRebuild();
263 this->engines[1].ForceRebuild();
264 this->reset_sel_engine =
true;
271 this->vehicle_type = vehicletype;
272 this->engines[0].ForceRebuild();
273 this->engines[1].ForceRebuild();
275 this->sel_engine[0] = EngineID::Invalid();
276 this->sel_engine[1] = EngineID::Invalid();
285 widget->
SetLowered(this->show_hidden_engines);
291 this->sel_group = id_g;
305 d.
height += padding.height;
326 d.
width += padding.width;
327 d.
height += padding.height;
335 d.
width += padding.width;
336 d.
height += padding.height;
344 d.
width += padding.width;
345 d.
height += padding.height;
355 d.
width += padding.width;
356 d.
height += padding.height;
366 d.
width += padding.width;
367 d.
height += padding.height;
375 d.
width += padding.width;
376 d.
height += padding.height;
387 switch (this->sel_group.base()) {
407 return GetString(STR_REPLACE_REMOVE_WAGON, STR_GROUP_NAME,
sel_group, remove_wagon ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
411 return GetString(STR_REPLACE_REMOVE_WAGON, STR_GROUP_DEFAULT_TRAINS + this->
window_number, std::monostate{}, remove_wagon ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF);
416 return GetString(this->replace_engines ? STR_REPLACE_ENGINES : STR_REPLACE_WAGONS);
439 if (this->sel_engine[0] != EngineID::Invalid()) {
441 str =
GetString(STR_REPLACE_NOT_REPLACING);
443 bool when_old =
false;
448 str =
GetString(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED);
460 DrawEngineList(this->
window_number, r, this->engines[side], *this->vscroll[side], this->sel_engine[side], side == 0, this->sel_group, this->badge_classes, this->sort_criteria);
468 if (this->engines[0].NeedRebuild() || this->engines[1].NeedRebuild()) this->
GenerateLists();
476 this->sel_engine[0] == EngineID::Invalid() || this->sel_engine[1] == EngineID::Invalid() ||
EngineReplacementForCompany(c, this->sel_engine[1], this->sel_group) != EngineID::Invalid());
486 int needed_height = this->details_height;
488 for (
int side = 0; side < 2; side++) {
489 if (this->sel_engine[side] != EngineID::Invalid()) {
494 ted.FillDefaultCapacities(e);
502 if (needed_height != this->details_height) {
503 this->details_height = needed_height;
514 this->descending_sort_order ^=
true;
516 this->engines[1].ForceRebuild();
521 this->show_hidden_engines ^=
true;
523 this->engines[1].ForceRebuild();
541 static std::string railtype_filter;
547 static std::string roadtype_filter;
575 EngineID veh_from = this->sel_engine[0];
576 Command<Commands::SetAutoreplace>::Post(this->sel_group, veh_from, EngineID::Invalid(),
false);
590 const auto it = this->vscroll[click_side]->GetScrolledItemFromWidget(this->engines[click_side], pt.y,
this, widget);
591 if (it != this->engines[click_side].end()) {
592 const auto &item = *it;
596 assert(item.variant_id != EngineID::Invalid());
609 if (click_side == 0 &&
IsCtrlPressed() && e != EngineID::Invalid() &&
612 Command<Commands::SetAutoreplace>::Post(this->sel_group, veh_from, EngineID::Invalid(),
false);
616 if (e == this->sel_engine[click_side])
break;
617 this->sel_engine[click_side] = e;
618 if (click_side == 0) {
619 this->engines[1].ForceRebuild();
620 this->reset_sel_engine =
true;
632 if (this->sort_criteria != index) {
633 this->sort_criteria = index;
635 this->engines[1].ForceRebuild();
642 if (temp == this->sel_railtype)
return;
643 this->sel_railtype = temp;
650 if (temp == this->sel_roadtype)
return;
651 this->sel_roadtype = temp;
657 this->replace_engines = index != 0;
658 this->engines[0].ForceRebuild();
659 this->reset_sel_engine =
true;
693 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
697 this->engines[0].ForceRebuild();
699 this->engines[1].ForceRebuild();
704static constexpr std::initializer_list<NWidgetPart> _nested_replace_rail_vehicle_widgets = {
714 NWidget(
WWT_LABEL,
Colours::Invalid),
SetStringTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP),
SetFill(1, 1),
SetMinimalTextLines(1,
WidgetDimensions::unscaled.framerect.Vertical()),
SetResize(1, 0),
717 NWidget(
WWT_LABEL,
Colours::Invalid),
SetStringTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP),
SetFill(1, 1),
SetMinimalTextLines(1,
WidgetDimensions::unscaled.framerect.Vertical()),
SetResize(1, 0),
723 NWidget(
WWT_DROPDOWN,
Colours::Grey,
WID_RV_RAIL_TYPE_DROPDOWN),
SetMinimalSize(136, 12),
SetToolTip(STR_REPLACE_RAILTYPE_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
740 NWidget(
WWT_MATRIX,
Colours::Grey,
WID_RV_LEFT_MATRIX),
SetMinimalSize(216, 0),
SetFill(1, 1),
SetMatrixDataTip(1, 0, STR_REPLACE_LEFT_ARRAY_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_RV_LEFT_SCROLLBAR),
742 NWidget(
WWT_MATRIX,
Colours::Grey,
WID_RV_RIGHT_MATRIX),
SetMinimalSize(216, 0),
SetFill(1, 1),
SetMatrixDataTip(1, 0, STR_REPLACE_RIGHT_ARRAY_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_RV_RIGHT_SCROLLBAR),
749 NWidget(
WWT_PUSHTXTBTN,
Colours::Grey,
WID_RV_TRAIN_WAGONREMOVE_TOGGLE),
SetMinimalSize(138, 12),
SetToolTip(STR_REPLACE_REMOVE_WAGON_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
764 WindowClass::ReplaceVehicle, WindowClass::None,
766 _nested_replace_rail_vehicle_widgets
769static constexpr std::initializer_list<NWidgetPart> _nested_replace_road_vehicle_widgets = {
779 NWidget(
WWT_LABEL,
Colours::Invalid),
SetStringTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP),
SetFill(1, 1),
SetMinimalTextLines(1,
WidgetDimensions::unscaled.framerect.Vertical()),
SetResize(1, 0),
782 NWidget(
WWT_LABEL,
Colours::Invalid),
SetStringTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP),
SetFill(1, 1),
SetMinimalTextLines(1,
WidgetDimensions::unscaled.framerect.Vertical()),
SetResize(1, 0),
787 NWidget(
WWT_DROPDOWN,
Colours::Grey,
WID_RV_ROAD_TYPE_DROPDOWN),
SetMinimalSize(136, 12),
SetToolTip(STR_REPLACE_ROADTYPE_TOOLTIP),
SetFill(1, 0),
SetResize(1, 0),
802 NWidget(
WWT_MATRIX,
Colours::Grey,
WID_RV_LEFT_MATRIX),
SetMinimalSize(216, 0),
SetFill(1, 1),
SetMatrixDataTip(1, 0, STR_REPLACE_LEFT_ARRAY_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_RV_LEFT_SCROLLBAR),
804 NWidget(
WWT_MATRIX,
Colours::Grey,
WID_RV_RIGHT_MATRIX),
SetMinimalSize(216, 0),
SetFill(1, 1),
SetMatrixDataTip(1, 0, STR_REPLACE_RIGHT_ARRAY_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_RV_RIGHT_SCROLLBAR),
823 WindowClass::ReplaceVehicle, WindowClass::None,
825 _nested_replace_road_vehicle_widgets
828static constexpr std::initializer_list<NWidgetPart> _nested_replace_vehicle_widgets = {
838 NWidget(
WWT_LABEL,
Colours::Invalid),
SetStringTip(STR_REPLACE_VEHICLE_VEHICLES_IN_USE, STR_REPLACE_VEHICLE_VEHICLES_IN_USE_TOOLTIP),
SetFill(1, 1),
SetMinimalTextLines(1,
WidgetDimensions::unscaled.framerect.Vertical()),
SetResize(1, 0),
841 NWidget(
WWT_LABEL,
Colours::Invalid),
SetStringTip(STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES, STR_REPLACE_VEHICLE_AVAILABLE_VEHICLES_TOOLTIP),
SetFill(1, 1),
SetMinimalTextLines(1,
WidgetDimensions::unscaled.framerect.Vertical()),
SetResize(1, 0),
858 NWidget(
WWT_MATRIX,
Colours::Grey,
WID_RV_LEFT_MATRIX),
SetMinimalSize(216, 0),
SetFill(1, 1),
SetMatrixDataTip(1, 0, STR_REPLACE_LEFT_ARRAY_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_RV_LEFT_SCROLLBAR),
860 NWidget(
WWT_MATRIX,
Colours::Grey,
WID_RV_RIGHT_MATRIX),
SetMinimalSize(216, 0),
SetFill(1, 1),
SetMatrixDataTip(1, 0, STR_REPLACE_RIGHT_ARRAY_TOOLTIP),
SetResize(1, 1),
SetScrollbar(
WID_RV_RIGHT_SCROLLBAR),
878 WindowClass::ReplaceVehicle, WindowClass::None,
880 _nested_replace_vehicle_widgets
891 switch (vehicletype) {
bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
Checks some basic properties whether autoreplace is allowed.
Command definitions related to autoreplace.
Functions related to autoreplacing.
bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
Check if a company has a replacement set up for the given engine when it gets old.
EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old=nullptr)
Retrieve the engine replacement for the given company and original engine type.
bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
Check if a company has a replacement set up for the given engine.
void ShowReplaceGroupVehicleWindow(GroupID id_g, VehicleType vehicletype)
Show the autoreplace configuration window for a particular group.
static WindowDesc _replace_road_vehicle_desc(WindowPosition::Automatic, "replace_vehicle_road", 500, 140, WindowClass::ReplaceVehicle, WindowClass::None, WindowDefaultFlag::Construction, _nested_replace_road_vehicle_widgets)
Window definition for the replace road vehicle window.
static bool EngineNumberSorter(const GUIEngineListItem &a, const GUIEngineListItem &b)
Compare the (NewGRF) list position.
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
Rebuild the left autoreplace list if an engine is removed or added.
void AddRemoveEngineFromAutoreplaceAndBuildWindows(VehicleType type)
When an engine is made buildable or is removed from being buildable, add/remove it from the build/aut...
static WindowDesc _replace_vehicle_desc(WindowPosition::Automatic, "replace_vehicle", 456, 118, WindowClass::ReplaceVehicle, WindowClass::None, WindowDefaultFlag::Construction, _nested_replace_vehicle_widgets)
Window definition for the replace ship/aircraft window.
static WindowDesc _replace_rail_vehicle_desc(WindowPosition::Automatic, "replace_vehicle_train", 500, 140, WindowClass::ReplaceVehicle, WindowClass::None, WindowDefaultFlag::Construction, _nested_replace_rail_vehicle_widgets)
Window definition for the replace rail vehicle window.
void GUIEngineListAddChildren(GUIEngineList &dst, const GUIEngineList &src, EngineID parent, uint8_t indent)
Add children to GUI engine list to build a hierarchical tree.
std::span< StringID const > GetEngineSortNames(VehicleType vehicle_type)
Get the engine sorter names for a VehicleType.
void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, const Scrollbar &sb, EngineID selected_id, bool show_count, GroupID selected_group, const GUIBadgeClasses &badge_classes, uint8_t sort_criteria)
Engine drawing loop.
uint GetEngineListHeight(VehicleType type)
Get the height of a single 'entry' in the engine lists.
int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, TestedEngineDetails &te)
Draw the purchase info details of a vehicle at a given location.
VehicleTypeIndexArray< uint8_t > _engine_sort_last_criteria
Last set sort criteria, for each vehicle type.
void DisplayVehicleSortDropDown(Window *w, VehicleType vehicle_type, int selected, WidgetID button)
Display the dropdown for the vehicle sort criteria.
bool _engine_sort_direction
false = descending, true = ascending.
std::span< EngList_SortTypeFunction *const > GetEngineSortFunctions(VehicleType vehicle_type)
Get the engine sorter functions for a VehicleType.
VehicleTypeIndexArray< bool > _engine_sort_last_order
Last set direction of the sort order, for each vehicle type.
VehicleTypeIndexArray< bool > _engine_sort_show_hidden_engines
Last set 'show hidden engines' setting for each vehicle type.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Timpl & Flip()
Flip all bits.
static Pool::IterateWrapperFiltered< Engine, EngineTypeFilter > IterateType(VehicleType vt, size_t from=0)
Returns an iterable ensemble of all valid engines of the given type.
EngineDisplayFlags display_flags
NOSAVE client-side-only display flags for build engine list.
Flat set implementation that uses a sorted vector for storage.
std::pair< const_iterator, bool > insert(const Tkey &key)
Insert a key into the set, if it does not already exist.
StringID replace_text
Text used in the autoreplace GUI.
Window for the autoreplacing of vehicles.
void OnInit() override
Notification that the nested widget tree gets initialized.
void OnResize() override
Called after the window got resized.
bool GenerateReplaceRailList(EngineID e, bool draw_left, bool show_engines)
Figure out if an engine should be added to a list.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void ReplaceClick_StartReplace(bool replace_when_old)
Handle click on the start replace button.
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
Event to display a custom tooltip.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
uint8_t sort_criteria
Criteria of sorting vehicles.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
RailType sel_railtype
Type of rail tracks selected. INVALID_RAILTYPE to show all.
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.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
bool replace_engines
If true, engines are replaced, if false, wagons are replaced (only for trains).
bool reset_sel_engine
Also reset sel_engine while updating left and/or right and no valid engine selected.
void OnPaint() override
The window must be repainted.
bool show_hidden_engines
Whether to show the hidden engines.
void GenerateLists()
Generate the lists.
RoadType sel_roadtype
Type of road selected. INVALID_ROADTYPE to show all.
std::array< GUIEngineList, 2 > engines
Left and right list of engines.
VehicleType vehicle_type
Type of vehicle in this window.
int details_height
Minimal needed height of the details panels, in text lines (found so far).
void GenerateReplaceVehList(bool draw_left)
Generate an engines list.
GroupID sel_group
Group selected to replace.
std::array< EngineID, 2 > sel_engine
Selected engine left and right.
bool descending_sort_order
Order of sorting vehicles.
void OnRailRoadTypeChange()
Perform tasks after rail or road type is changed.
StringID replace_text
Text used in the autoreplace GUI.
Functions related to commands.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
void ShowDropDownMenu(Window *w, std::span< const StringID > strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width, DropDownOptions options, std::string *const persistent_filter_text)
Show a dropdown menu window near a widget of the parent window.
std::unique_ptr< DropDownListItem > MakeDropDownListStringItem(StringID str, int value, bool masked, bool shaded)
Creates new DropDownListStringItem.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, DropDownOptions options, std::string *const persistent_filter_text)
Show a drop down list.
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
@ Filterable
Set if the dropdown is filterable.
EnumBitSet< EngineDisplayFlag, uint8_t > EngineDisplayFlags
Bitset of EngineDisplayFlag elements.
@ HasVariants
Set if engine has variants.
@ IsFolded
Set if display of variants should be folded (hidden).
@ Shaded
Set if engine should be masked.
void EngList_Sort(GUIEngineList &el, EngList_SortTypeFunction compare)
Sort all items using quick sort and given 'CompareItems' function.
Engine GUI functions, used by build_vehicle_gui and autoreplace_gui.
PoolID< uint16_t, struct EngineIDTag, 64000, 0xFFFF > EngineID
Unique identification number of an engine.
uint64_t PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32_t extra_data=0)
Combine an engine ID and a name context to an engine name StringParameter.
@ PurchaseList
Name is shown in the purchase list (including autoreplace window 'Available vehicles' panel).
@ Wagon
simple wagon, not motorized
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
fluid_settings_t * settings
FluidSynth settings handle.
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.
@ Centre
Align to the centre.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Dimension GetStringListBoundingBox(std::span< const StringID > list, FontSize fontsize)
Get maximum dimension of a list of strings.
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.
bool IsCtrlPressed()
Test if the ctrl key is pressed.
@ Normal
Index of the normal font in the font tables.
@ ReplaceWagonRemoval
If set, autoreplace will perform wagon removal on vehicles in this group.
uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e)
Get the number of engines with EngineID id_e in the group with GroupID id_g and its sub-groups.
Command definitions related to engine groups.
void SetDirty() const
Mark entire window as dirty (in need of re-paint).
static constexpr GroupID DEFAULT_GROUP
Ungrouped vehicles are in this group.
static constexpr GroupID ALL_GROUP
All vehicles are in this group.
#define Point
Macro that prevents name conflicts between included headers.
constexpr bool IsInsideMM(const size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
void GuiShowTooltips(Window *parent, EncodedString &&text, TooltipCloseCondition close_tooltip)
Shows a tooltip.
GrfSpecFeature GetGrfSpecFeature(VehicleType type)
Get the GrfSpecFeature associated with a VehicleType.
std::vector< RailType > _sorted_railtypes
Sorted list of rail types.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
RailType
Enumeration for all possible railtypes.
@ INVALID_RAILTYPE
Flag for invalid railtype.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
std::vector< RoadType > _sorted_roadtypes
Sorted list of road types.
Functions/types related to the road GUIs.
static constexpr RoadTramTypes ROADTRAMTYPES_ALL
All possible RoadTramTypes.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
A number of safeguards to prevent using unsafe methods.
Command definitions related to settings.
Functions related to setting/changing the settings.
Definition of base types and functions in a cross-platform compatible way.
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.
Functions related to OTTD's strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
@ TD_RTL
Text is written right-to-left by default.
CompanySettings settings
settings specific for each company
bool renew_keep_length
sell some wagons if after autoreplace the train is longer than before
Dimensions (a width and height) of a rectangle in 2D.
value_type height
The height of the rectangle.
value_type width
The width of the rectangle.
EngineID variant_id
Engine variant ID. If set, will be treated specially in purchase lists.
EngineID engine_id
Engine to display in build purchase list.
GroupFlags flags
Group flags.
static Engine * Get(auto index)
static bool IsValidID(auto index)
static Group * GetIfValid(auto index)
Information about a rail vehicle.
RailTypes railtypes
Railtypes, mangled if elrail is disabled.
RailVehicleType railveh_type
Type of 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.
Information about a road vehicle.
RoadType roadtype
Road type.
Extra information about refitted cargo and capacity.
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.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
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.
Window * parent
Parent window.
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
ResizeInfo resize
Resize information.
void DrawSortButton(WidgetID widget, bool descending) const
Draw a sort button's up or down arrow symbol.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
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.
bool IsShaded() const
Is window shaded currently?
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.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
WindowNumber window_number
Window number within the window class.
Functions related to the vehicle's GUIs.
VehicleType
Available vehicle types.
@ Invalid
Non-existing type of vehicle.
@ Train
Train vehicle type.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
void InvalidateWindowClassesData(WindowClass cls, int data, bool gui_scope)
Mark window data of all windows of a given class as invalid (in need of re-computing) Note that by de...
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ Construction
This window is used for construction; close it whenever changing company.
@ Automatic
Find a place automatically.