OpenTTD
vehicle_gui_base.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef VEHICLE_GUI_BASE_H
11 #define VEHICLE_GUI_BASE_H
12 
13 #include "sortlist_type.h"
14 #include "vehiclelist.h"
15 #include "window_gui.h"
16 #include "widgets/dropdown_type.h"
17 
19 
20 struct BaseVehicleListWindow : public Window {
24  Scrollbar *vscroll;
26 
27  enum ActionDropdownItem {
28  ADI_REPLACE,
29  ADI_SERVICE,
30  ADI_DEPOT,
31  ADI_ADD_SHARED,
32  ADI_REMOVE_ALL,
33  };
34 
35  static const StringID vehicle_depot_name[];
36  static const StringID vehicle_sorter_names[];
37  static GUIVehicleList::SortFunction * const vehicle_sorter_funcs[];
38 
40  {
41  this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs);
42  }
43 
44  void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const;
45  void SortVehicleList();
46  void BuildVehicleList();
47  Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group);
48  DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group);
49 };
50 
51 uint GetVehicleListHeight(VehicleType type, uint divisor = 1);
52 
53 struct Sorting {
54  Listing aircraft;
55  Listing roadveh;
56  Listing ship;
57  Listing train;
58 };
59 
60 extern Sorting _sorting;
61 
62 #endif /* VEHICLE_GUI_BASE_H */
Base types for having sorted lists in GUIs.
The information about a vehicle list.
Definition: vehiclelist.h:29
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1867
High level window description.
Definition: window_gui.h:166
Functions and type for generating vehicle lists.
Scrollbar data structure.
Definition: widget_type.h:587
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
GUIVehicleList vehicles
The list of vehicles.
Functions, definitions and such used only by the GUI.
Data structure for an opened window.
Definition: window_gui.h:276
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
Draw all the vehicle list items.
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:16
DropDownList BuildActionDropdownList(bool show_autoreplace, bool show_group)
Display the Action dropdown window.
static VehicleListIdentifier UnPack(uint32 data)
Decode a packed vehicle list identifier into a new one.
Definition: vehiclelist.cpp:53
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
uint GetVehicleListHeight(VehicleType type, uint divisor=1)
Get the height of a vehicle in the vehicle list GUIs.
VehicleListIdentifier vli
Identifier of the vehicle list we want to currently show.
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:31
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:705
Specification of a rectangle with absolute coordinates of all edges.
byte unitnumber_digits
The number of digits of the highest unit number.
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group)
Compute the size for the Action dropdown.
bool SortFunction(const T &, const T &)
Signature of sort function.
Definition: sortlist_type.h:49
Listing * sorting
Pointer to the vehicle type related sorting.
Dimensions (a width and height) of a rectangle in 2D.