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/>.
10 /** @file vehicle_gui_base.h Functions/classes shared between the different vehicle list GUIs. */
12 #ifndef VEHICLE_GUI_BASE_H
13 #define VEHICLE_GUI_BASE_H
15 #include "sortlist_type.h"
16 #include "vehiclelist.h"
17 #include "window_gui.h"
18 #include "widgets/dropdown_type.h"
20 typedef GUIList
<const Vehicle
*> GUIVehicleList
;
22 struct BaseVehicleListWindow
: public Window
{
23 GUIVehicleList vehicles
; ///< The list of vehicles
24 Listing
*sorting
; ///< Pointer to the vehicle type related sorting.
25 byte unitnumber_digits
; ///< The number of digits of the highest unit number
27 VehicleListIdentifier vli
; ///< Identifier of the vehicle list we want to currently show.
29 enum ActionDropdownItem
{
37 static const StringID vehicle_depot_name
[];
38 static const StringID vehicle_sorter_names
[];
39 static GUIVehicleList::SortFunction
* const vehicle_sorter_funcs
[];
41 BaseVehicleListWindow(WindowDesc
*desc
, WindowNumber wno
) : Window(desc
), vli(VehicleListIdentifier::UnPack(wno
))
43 this->vehicles
.SetSortFuncs(this->vehicle_sorter_funcs
);
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
);
53 uint
GetVehicleListHeight(VehicleType type
, uint divisor
= 1);
62 extern Sorting _sorting
;
64 #endif /* VEHICLE_GUI_BASE_H */