Go to the documentation of this file.
10 #ifndef VEHICLE_GUI_BASE_H
11 #define VEHICLE_GUI_BASE_H
35 std::ptrdiff_t NumVehicles()
const
37 return std::distance(this->vehicles_begin, this->vehicles_end);
40 const Vehicle *GetSingleVehicle()
const
42 assert(this->NumVehicles() == 1);
43 return this->vehicles_begin[0];
46 Money GetDisplayProfitThisYear()
const
48 return std::accumulate(this->vehicles_begin, this->vehicles_end, (
Money)0, [](
Money acc,
const Vehicle *v) {
53 Money GetDisplayProfitLastYear()
const
55 return std::accumulate(this->vehicles_begin, this->vehicles_end, (
Money)0, [](
Money acc,
const Vehicle *v) {
60 Date GetOldestVehicleAge()
const
62 const Vehicle *oldest = *std::max_element(this->vehicles_begin, this->vehicles_end, [](
const Vehicle *v_a,
const Vehicle *v_b) {
63 return v_a->
age < v_b->
age;
103 enum ActionDropdownItem {
111 static const StringID vehicle_depot_name[];
112 static const StringID vehicle_group_by_names[];
113 static const StringID vehicle_group_none_sorter_names[];
114 static const StringID vehicle_group_shared_orders_sorter_names[];
115 static VehicleGroupSortFunction *
const vehicle_group_none_sorter_funcs[];
116 static VehicleGroupSortFunction *
const vehicle_group_shared_orders_sorter_funcs[];
122 void UpdateSortingFromGrouping();
125 void UpdateVehicleGroupBy(GroupBy group_by);
126 void SortVehicleList();
127 void BuildVehicleList();
134 const StringID *GetVehicleSorterNames()
136 switch (this->grouping) {
138 return vehicle_group_none_sorter_names;
139 case GB_SHARED_ORDERS:
140 return vehicle_group_shared_orders_sorter_names;
146 VehicleGroupSortFunction *
const *GetVehicleSorterFuncs()
148 switch (this->grouping) {
150 return vehicle_group_none_sorter_funcs;
151 case GB_SHARED_ORDERS:
152 return vehicle_group_shared_orders_sorter_funcs;
168 extern BaseVehicleListWindow::GroupBy _grouping[VLT_END][
VEH_COMPANY_END];
169 extern Sorting _sorting[BaseVehicleListWindow::GB_END];
byte cargo_filter_criteria
Selected cargo filter index.
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group)
Compute the size for the Action dropdown.
std::vector< const Vehicle * > VehicleList
A list of vehicles.
@ CF_ANY
Show all vehicles independent of carried cargo (i.e. no filtering)
Dimensions (a width and height) of a rectangle in 2D.
@ CF_FREIGHT
Show only vehicles which carry any freight (non-passenger) cargo.
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.
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.
int32 WindowNumber
Number to differentiate different windows of the same class.
void SetCargoFilterIndex(byte index)
Set cargo filter list item index.
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.
DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group)
Display the Action dropdown window.
Money GetDisplayProfitThisYear() const
Gets the profit vehicle had this year.
Data structure describing how to show the list (what sort direction and criteria).
CargoID cargo_filter[NUM_CARGO+3]
Available cargo filters; CargoID or CF_ANY or CF_FREIGHT or CF_NONE.
@ VEH_COMPANY_END
Last company-ownable type.
bool SortFunction(const GUIVehicleGroup &, const GUIVehicleGroup &)
Signature of sort function.
int32 Date
The type to store our dates in.
VehicleType
Available vehicle types.
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
Draw all the vehicle list items.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
GUIVehicleGroupList vehgroups
List of (groups of) vehicles. This stores iterators of vehicles, and should be rebuilt if vehicles is...
VehicleID vehicle_sel
Selected vehicle.
@ CT_AUTO_REFIT
Automatically choose cargo type when doing auto refitting.
@ NUM_CARGO
Maximal number of cargo types in a game.
uint32 VehicleID
The type all our vehicle IDs have.
VehicleList vehicles
List of vehicles. This is the buffer for vehgroups to point into; if this is structurally modified,...
byte CargoID
Cargo slots to indicate a cargo type within a game.
CargoFilterSpecialType
Special cargo filter criteria.
byte unitnumber_digits
The number of digits of the highest unit number.
StringID cargo_filter_texts[NUM_CARGO+4]
Texts for filter_cargo, terminated by INVALID_STRING_ID.
@ CF_NONE
Show only vehicles which do not carry cargo (e.g. train engines)
Data structure for an opened window.
@ CT_INVALID
Invalid cargo type.
Specification of a rectangle with absolute coordinates of all edges.
@ CT_NO_REFIT
Do not refit cargo of a vehicle (used in vehicle orders and auto-replace/auto-new).
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.