2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2012-01-01 17:22:32 +00:00
|
|
|
/** @file engine_gui.h %Engine GUI functions, used by build_vehicle_gui and autoreplace_gui */
|
2008-05-27 12:24:23 +00:00
|
|
|
|
|
|
|
#ifndef ENGINE_GUI_H
|
|
|
|
#define ENGINE_GUI_H
|
|
|
|
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "engine_type.h"
|
2008-05-28 17:29:27 +00:00
|
|
|
#include "sortlist_type.h"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "gfx_type.h"
|
2012-01-03 20:26:05 +00:00
|
|
|
#include "vehicle_type.h"
|
2019-02-27 07:04:17 +00:00
|
|
|
#include "engine_base.h"
|
2023-03-24 21:56:11 +00:00
|
|
|
#include "window_type.h"
|
2008-05-27 12:24:23 +00:00
|
|
|
|
2019-02-27 07:04:17 +00:00
|
|
|
struct GUIEngineListItem {
|
|
|
|
EngineID engine_id; ///< Engine to display in build purchase list
|
|
|
|
EngineID variant_id; ///< Variant group of the engine.
|
|
|
|
EngineDisplayFlags flags; ///< Flags for toggling/drawing (un)folded status and controlling indentation.
|
|
|
|
int8 indent; ///< Display indentation level.
|
2008-05-27 12:24:23 +00:00
|
|
|
|
2019-02-27 07:04:17 +00:00
|
|
|
GUIEngineListItem(EngineID engine_id, EngineID variant_id, EngineDisplayFlags flags, int indent) : engine_id(engine_id), variant_id(variant_id), flags(flags), indent(indent) {}
|
|
|
|
|
|
|
|
/* Used when searching list only by engine_id. */
|
|
|
|
bool operator == (const EngineID &other) const { return this->engine_id == other; }
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef GUIList<GUIEngineListItem, CargoID> GUIEngineList;
|
|
|
|
|
|
|
|
typedef bool EngList_SortTypeFunction(const GUIEngineListItem&, const GUIEngineListItem&); ///< argument type for #EngList_Sort.
|
2012-01-01 17:22:32 +00:00
|
|
|
void EngList_Sort(GUIEngineList *el, EngList_SortTypeFunction compare);
|
2023-01-19 19:07:10 +00:00
|
|
|
void EngList_SortPartial(GUIEngineList *el, EngList_SortTypeFunction compare, size_t begin, size_t num_items);
|
2008-05-27 12:24:23 +00:00
|
|
|
|
2009-08-30 17:54:11 +00:00
|
|
|
StringID GetEngineCategoryName(EngineID engine);
|
2009-08-30 18:41:03 +00:00
|
|
|
StringID GetEngineInfoString(EngineID engine);
|
2009-11-16 17:15:42 +00:00
|
|
|
|
2011-11-01 16:51:47 +00:00
|
|
|
void DrawVehicleEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
|
|
|
|
void DrawTrainEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
|
|
|
|
void DrawRoadVehEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
|
|
|
|
void DrawShipEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
|
|
|
|
void DrawAircraftEngine(int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type);
|
2009-08-30 17:38:28 +00:00
|
|
|
|
2014-09-07 16:10:27 +00:00
|
|
|
extern bool _engine_sort_direction;
|
|
|
|
extern byte _engine_sort_last_criteria[];
|
|
|
|
extern bool _engine_sort_last_order[];
|
2014-09-07 16:14:06 +00:00
|
|
|
extern bool _engine_sort_show_hidden_engines[];
|
2022-01-30 22:09:16 +00:00
|
|
|
extern const StringID _engine_sort_listing[][14];
|
|
|
|
extern EngList_SortTypeFunction * const _engine_sort_functions[][13];
|
2014-09-07 16:10:27 +00:00
|
|
|
|
|
|
|
uint GetEngineListHeight(VehicleType type);
|
|
|
|
void DisplayVehicleSortDropDown(Window *w, VehicleType vehicle_type, int selected, int button);
|
|
|
|
|
2008-05-27 12:24:23 +00:00
|
|
|
#endif /* ENGINE_GUI_H */
|