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 (const WindowDesc
*desc
, WindowNumber wno
)
42 : Window (desc
), vehicles(), sorting (NULL
),
43 unitnumber_digits (0), vscroll (NULL
),
44 vli (VehicleListIdentifier::UnPack(wno
))
46 this->vehicles
.SetSortFuncs(this->vehicle_sorter_funcs
);
49 void DrawVehicleListItems (BlitArea
*dpi
, VehicleID selected_vehicle
, int line_height
, const Rect
&r
) const;
50 void SortVehicleList();
51 void BuildVehicleList();
52 Dimension
GetActionDropdownSize(bool show_autoreplace
, bool show_group
);
53 DropDownList
*BuildActionDropdownList(bool show_autoreplace
, bool show_group
);
56 uint
GetVehicleListHeight(VehicleType type
, uint divisor
= 1);
65 extern Sorting _sorting
;
67 #endif /* VEHICLE_GUI_BASE_H */