OpenTTD Source
20240919-master-gdf0233f4c2
|
Go to the documentation of this file.
10 #ifndef VEHICLE_GUI_BASE_H
11 #define VEHICLE_GUI_BASE_H
31 std::ptrdiff_t NumVehicles()
const
33 return std::distance(this->vehicles_begin, this->vehicles_end);
36 const Vehicle *GetSingleVehicle()
const
38 assert(this->NumVehicles() == 1);
39 return this->vehicles_begin[0];
42 Money GetDisplayProfitThisYear()
const
44 return std::accumulate(this->vehicles_begin, this->vehicles_end, (
Money)0, [](
Money acc,
const Vehicle *v) {
49 Money GetDisplayProfitLastYear()
const
51 return std::accumulate(this->vehicles_begin, this->vehicles_end, (
Money)0, [](
Money acc,
const Vehicle *v) {
56 TimerGameEconomy::Date GetOldestVehicleAge()
const
58 const Vehicle *oldest = *std::max_element(this->vehicles_begin, this->vehicles_end, [](
const Vehicle *v_a,
const Vehicle *v_b) {
69 enum GroupBy : uint8_t {
86 CargoTypes used_cargoes;
91 enum ActionDropdownItem {
100 static const StringID vehicle_depot_name[];
101 static const std::initializer_list<const StringID> vehicle_group_by_names;
102 static const std::initializer_list<const StringID> vehicle_group_none_sorter_names_calendar;
103 static const std::initializer_list<const StringID> vehicle_group_none_sorter_names_wallclock;
104 static const std::initializer_list<const StringID> vehicle_group_shared_orders_sorter_names_calendar;
105 static const std::initializer_list<const StringID> vehicle_group_shared_orders_sorter_names_wallclock;
106 static const std::initializer_list<VehicleGroupSortFunction * const> vehicle_group_none_sorter_funcs;
107 static const std::initializer_list<VehicleGroupSortFunction * const> vehicle_group_shared_orders_sorter_funcs;
113 void UpdateSortingFromGrouping();
116 void UpdateVehicleGroupBy(GroupBy group_by);
117 void SortVehicleList();
118 void BuildVehicleList();
127 std::span<const StringID> GetVehicleSorterNames();
129 std::span<VehicleGroupSortFunction * const> GetVehicleSorterFuncs()
131 switch (this->grouping) {
133 return vehicle_group_none_sorter_funcs;
134 case GB_SHARED_ORDERS:
135 return vehicle_group_shared_orders_sorter_funcs;
151 extern BaseVehicleListWindow::GroupBy _grouping[VLT_END][
VEH_COMPANY_END];
152 extern Sorting _sorting[BaseVehicleListWindow::GB_END];
std::vector< const Vehicle * > VehicleList
A list of vehicles.
Dimensions (a width and height) of a rectangle in 2D.
DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group, bool show_create)
Display the Action dropdown window.
GroupBy grouping
How we want to group the list.
The information about a vehicle list.
uint order_arrow_width
Width of the arrow in the small order list.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
List template of 'things' T to sort in a GUI.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
uint GetVehicleListHeight(VehicleType type, uint divisor=1)
Get the height of a vehicle in the vehicle list GUIs.
Listing * sorting
Pointer to the vehicle type related sorting.
VehicleList::const_iterator vehicles_begin
Pointer to beginning element of this vehicle group.
void SetCargoFilterArray()
Populate the filter list and set the cargo filter criteria.
void OnInit() override
Notification that the nested widget tree gets initialized.
High level window description.
void FilterVehicleList()
Filter the engine list against the currently selected cargo filter.
VehicleListIdentifier vli
Identifier of the vehicle list we want to currently show.
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
Data structure describing how to show the list (what sort direction and criteria).
int32_t WindowNumber
Number to differentiate different windows of the same class.
std::conditional_t< std::is_same_v< std::nullptr_t, std::nullptr_t >, bool(const GUIVehicleGroup &, const GUIVehicleGroup &), bool(const GUIVehicleGroup &, const GUIVehicleGroup &, const std::nullptr_t)> SortFunction
Signature of sort function.
DropDownList BuildCargoDropDownList(bool full) const
Build drop down list for cargo filter selection.
uint32_t VehicleID
The type all our vehicle IDs have.
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group, bool show_create)
Compute the size for the Action dropdown.
CargoID cargo_filter_criteria
Selected cargo filter index.
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
Draw all the vehicle list items.
GUIVehicleGroupList vehgroups
List of (groups of) vehicles. This stores iterators of vehicles, and should be rebuilt if vehicles is...
TimerGameEconomy::Date economy_age
Age in economy days.
VehicleID vehicle_sel
Selected vehicle.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
void SetCargoFilter(uint8_t index)
Set cargo filter for the vehicle group list.
VehicleList vehicles
List of vehicles. This is the buffer for vehgroups to point into; if this is structurally modified,...
uint8_t unitnumber_digits
The number of digits of the highest unit number.
VehicleType
Available vehicle types.
Data structure for an opened window.
Specification of a rectangle with absolute coordinates of all edges.
Money GetDisplayProfitLastYear() const
Gets the profit vehicle had last year.
VehicleList::const_iterator vehicles_end
Pointer to past-the-end element of this vehicle group.
@ VEH_COMPANY_END
Last company-ownable type.