Rework the way the ReinitSeparation command is called. The old way was way too danger...
[openttd-joker.git] / src / vehicle_gui_base.h
blob5e234d3684d45a3d7975fc07bfa4b5fbb1ba82ff
1 /* $Id$ */
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 */
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"
19 #include "cargo_type.h"
21 typedef GUIList<const Vehicle*, CargoID> GUIVehicleList;
23 struct BaseVehicleListWindow : public Window {
24 GUIVehicleList vehicles; ///< The list of vehicles
25 Listing *sorting{}; ///< Pointer to the vehicle type related sorting.
26 byte unitnumber_digits{}; ///< The number of digits of the highest unit number
27 Scrollbar *vscroll{};
28 VehicleListIdentifier vli; ///< Identifier of the vehicle list we want to currently show.
29 VehicleID vehicle_sel; ///< Selected vehicle
31 /** Special cargo filter criteria */
32 enum CargoFilterSpecialType {
33 CF_ANY = CT_NO_REFIT, ///< Show all vehicles independent of carried cargo (i.e. no filtering)
34 CF_NONE = CT_INVALID, ///< Show only vehicles which do not carry cargo (e.g. train engines)
35 CF_FREIGHT = CT_AUTO_REFIT, ///< Show only vehicles which carry any freight (non-passenger) cargo
38 CargoID cargo_filter[NUM_CARGO + 3]{}; ///< Available cargo filters; CargoID or CF_ANY or CF_NONE
39 StringID cargo_filter_texts[NUM_CARGO + 4]{}; ///< Texts for filter_cargo, terminated by INVALID_STRING_ID
40 byte cargo_filter_criteria{}; ///< Selected cargo filter
42 enum ActionDropdownItem {
43 ADI_SET_ALL_ON_TIME,
44 ADI_TEMPLATE_REPLACE,
45 ADI_REPLACE,
46 ADI_SERVICE,
47 ADI_DEPOT,
48 ADI_ADD_SHARED,
49 ADI_REMOVE_ALL,
50 ADI_SELL_ALL,
51 ADI_TRACERESTRICT_SLOT_MGMT,
54 static const StringID vehicle_depot_name[];
55 static const StringID vehicle_sorter_names[];
56 static GUIVehicleList::SortFunction * const vehicle_sorter_funcs[];
57 const uint vehicle_sorter_non_ground_veh_disable_mask = (1 << 11); // STR_SORT_BY_LENGTH
59 BaseVehicleListWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc), vli(VehicleListIdentifier::UnPack(window_number))
61 this->vehicle_sel = INVALID_VEHICLE;
62 this->vehicles.SetSortFuncs(vehicle_sorter_funcs);
65 void DrawVehicleListItems(VehicleID selected_vehicle, int line_height, const Rect &r) const;
66 void SortVehicleList();
67 void BuildVehicleList();
68 void SetCargoFilterIndex(int index);
69 void SetCargoFilterArray();
70 void FilterVehicleList();
71 void OnInit() override;
72 Dimension GetActionDropdownSize(bool show_autoreplace, bool show_group, bool show_template_replace);
73 bool ShouldShowActionDropdownList() const;
74 DropDownList *BuildActionDropdownList(bool show_autoreplace, bool show_group, bool show_template_replace, bool show_sell = false);
77 uint GetVehicleListHeight(VehicleType type, uint divisor = 1);
79 struct Sorting {
80 Listing aircraft;
81 Listing roadveh;
82 Listing ship;
83 Listing train;
86 extern Sorting _sorting;
88 #endif /* VEHICLE_GUI_BASE_H */