OpenTTD

vehicle_gui_base.h
Go to the documentation of this file.
1 /* $Id: vehicle_gui_base.h 27677 2016-11-05 19:16:59Z frosch $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #ifndef VEHICLE_GUI_BASE_H
13 #define VEHICLE_GUI_BASE_H
14
15 #include "sortlist_type.h"
16 #include "vehiclelist.h"
17 #include "window_gui.h"
18 #include "widgets/dropdown_type.h"
19
20 typedef GUIList<const Vehicle*> GUIVehicleList;
21
22 struct BaseVehicleListWindow : public Window {
23 GUIVehicleList vehicles;
24 Listing *sorting;
25 byte unitnumber_digits;
26 Scrollbar *vscroll;
27 VehicleListIdentifier vli;
28
29 enum ActionDropdownItem {
30 ADI_REPLACE,
31 ADI_SERVICE,
32 ADI_DEPOT,
33 ADI_ADD_SHARED,
34 ADI_REMOVE_ALL,
35 };
36
37 static const StringID vehicle_depot_name[];
38 static const StringID vehicle_sorter_names[];
39 static GUIVehicleList::SortFunction * const vehicle_sorter_funcs[];
40
41 BaseVehicleListWindow(WindowDesc *desc, WindowNumber wno) : Window(desc), vli(VehicleListIdentifier::UnPack(wno))
42 {
43 this->vehicles.SetSortFuncs(this->vehicle_sorter_funcs);
44 }
45
46 void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const;
47 void SortVehicleList();
48 void BuildVehicleList();
49 Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group);
50 DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group);
51 };
52
53 uint GetVehicleListHeight(VehicleType type, uint divisor = 1);
54
55 struct Sorting {
56 Listing aircraft;
57 Listing roadveh;
58 Listing ship;
59 Listing train;
60 };
61
62 extern Sorting _sorting;
63
64 #endif /* VEHICLE_GUI_BASE_H */
sortlist_type.h
Base types for having sorted lists in GUIs.
GUIList< const Vehicle * >
BaseVehicleListWindow::BuildActionDropdownList
DropDownList * BuildActionDropdownList(bool show_autoreplace, bool show_group)
Display the Action dropdown window.
Definition: vehicle_gui.cpp:167
VehicleListIdentifier
The information about a vehicle list.
Definition: vehiclelist.h:31
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1843
WindowDesc
High level window description.
Definition: window_gui.h:168
vehiclelist.h
Functions and type for generating vehicle lists.
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:589
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:286
BaseVehicleListWindow::vehicles
GUIVehicleList vehicles
The list of vehicles.
Definition: vehicle_gui_base.h:23
BaseVehicleListWindow
Definition: vehicle_gui_base.h:22
window_gui.h
Functions, definitions and such used only by the GUI.
Window
Data structure for an opened window.
Definition: window_gui.h:271
BaseVehicleListWindow::DrawVehicleListItems
void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const
Draw all the vehicle list items.
Definition: vehicle_gui.cpp:1370
Sorting
Definition: vehicle_gui_base.h:55
VehicleType
VehicleType
Available vehicle types.
Definition: vehicle_type.h:21
VehicleID
uint32 VehicleID
The type all our vehicle IDs have.
Definition: vehicle_type.h:18
AutoDeleteSmallVector
Simple vector template class, with automatic delete.
Definition: smallvec_type.hpp:401
VehicleListIdentifier::UnPack
static VehicleListIdentifier UnPack(uint32 data)
Decode a packed vehicle list identifier into a new one.
Definition: vehiclelist.cpp:55
dropdown_type.h
Types related to the drop down widget.
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
GetVehicleListHeight
uint GetVehicleListHeight(VehicleType type, uint divisor=1)
Get the height of a vehicle in the vehicle list GUIs.
Definition: vehicle_gui.cpp:1350
GUIList::SortFunction
int CDECL SortFunction(const T *, const T *)
Signature of sort function.
Definition: sortlist_type.h:52
BaseVehicleListWindow::vli
VehicleListIdentifier vli
Identifier of the vehicle list we want to currently show.
Definition: vehicle_gui_base.h:27
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:34
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:695
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:40
BaseVehicleListWindow::unitnumber_digits
byte unitnumber_digits
The number of digits of the highest unit number.
Definition: vehicle_gui_base.h:25
BaseVehicleListWindow::GetActionDropdownSize
Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group)
Compute the size for the Action dropdown.
Definition: vehicle_gui.cpp:145
BaseVehicleListWindow::sorting
Listing * sorting
Pointer to the vehicle type related sorting.
Definition: vehicle_gui_base.h:24
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:34