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