OpenTTD Source
20241121-master-g67a0fccfad
|
Engine GUI functions, used by build_vehicle_gui and autoreplace_gui More...
#include "engine_type.h"
#include "group_type.h"
#include "sortlist_type.h"
#include "gfx_type.h"
#include "vehicle_type.h"
#include "engine_base.h"
Go to the source code of this file.
Data Structures | |
struct | GUIEngineListItem |
Typedefs | |
typedef GUIList< GUIEngineListItem, std::nullptr_t, CargoID > | GUIEngineList |
typedef bool | EngList_SortTypeFunction(const GUIEngineListItem &, const GUIEngineListItem &) |
argument type for EngList_Sort. | |
Functions | |
void | EngList_Sort (GUIEngineList &el, EngList_SortTypeFunction compare) |
Sort all items using quick sort and given 'CompareItems' function. More... | |
void | EngList_SortPartial (GUIEngineList &el, EngList_SortTypeFunction compare, size_t begin, size_t num_items) |
Sort selected range of items (on indices @ <begin, begin+num_items-1>) More... | |
StringID | GetEngineCategoryName (EngineID engine) |
Return the category of an engine. More... | |
StringID | GetEngineInfoString (EngineID engine) |
Get a multi-line string with some technical data, describing the engine. More... | |
void | DrawVehicleEngine (int left, int right, int preferred_x, int y, EngineID engine, PaletteID pal, EngineImageType image_type) |
Draw an engine. More... | |
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) |
Draw a road vehicle engine. More... | |
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) |
uint | GetEngineListHeight (VehicleType type) |
Get the height of a single 'entry' in the engine lists. More... | |
void | DisplayVehicleSortDropDown (Window *w, VehicleType vehicle_type, int selected, WidgetID button) |
Display the dropdown for the vehicle sort criteria. More... | |
void | DrawEngineList (VehicleType type, const Rect &r, const GUIEngineList &eng_list, const Scrollbar &sb, EngineID selected_id, bool show_count, GroupID selected_group) |
Engine drawing loop. More... | |
void | GUIEngineListAddChildren (GUIEngineList &dst, const GUIEngineList &src, EngineID parent=INVALID_ENGINE, uint8_t indent=0) |
Add children to GUI engine list to build a hierarchical tree. More... | |
Variables | |
bool | _engine_sort_direction |
false = descending, true = ascending. | |
uint8_t | _engine_sort_last_criteria [] |
Last set sort criteria, for each vehicle type. | |
bool | _engine_sort_last_order [] |
Last set direction of the sort order, for each vehicle type. | |
bool | _engine_sort_show_hidden_engines [] |
Last set 'show hidden engines' setting for each vehicle type. | |
const std::initializer_list< const StringID > | _engine_sort_listing [] |
Dropdown menu strings for the vehicle sort criteria. | |
EngList_SortTypeFunction *const | _engine_sort_functions [][11] |
Sort functions for the vehicle sort criteria, for each vehicle type. | |
Engine GUI functions, used by build_vehicle_gui and autoreplace_gui
Definition in file engine_gui.h.
void DisplayVehicleSortDropDown | ( | Window * | w, |
VehicleType | vehicle_type, | ||
int | selected, | ||
WidgetID | button | ||
) |
Display the dropdown for the vehicle sort criteria.
w | Parent window (holds the dropdown button). |
vehicle_type | Vehicle type being sorted. |
selected | Currently selected sort criterium. |
button | Widget button. |
Definition at line 1107 of file build_vehicle_gui.cpp.
References _settings_game, VehicleSettings::roadveh_acceleration_model, VEH_ROAD, and GameSettings::vehicle.
void DrawEngineList | ( | VehicleType | type, |
const Rect & | r, | ||
const GUIEngineList & | eng_list, | ||
const Scrollbar & | sb, | ||
EngineID | selected_id, | ||
bool | show_count, | ||
GroupID | selected_group | ||
) |
Engine drawing loop.
type | Type of vehicle (VEH_*) |
r | The Rect of the list |
eng_list | What engines to draw |
sb | Scrollbar of list. |
selected_id | what engine to highlight as selected, if any |
show_count | Whether to show the amount of engines or not |
selected_group | the group to list the engines of |
Definition at line 1003 of file build_vehicle_gui.cpp.
References _current_text_dir, EIT_PURCHASE, VehicleCellSize::extend_left, VehicleCellSize::extend_right, GetEngineListHeight(), GetScaledSpriteSize(), GetVehicleImageCellSize(), Scrollbar::GetVisibleRangeIterators(), and TD_RTL.
void DrawRoadVehEngine | ( | int | left, |
int | right, | ||
int | preferred_x, | ||
int | y, | ||
EngineID | engine, | ||
PaletteID | pal, | ||
EngineImageType | image_type | ||
) |
Draw a road vehicle engine.
left | Left edge to draw within. |
right | Right edge to draw within. |
preferred_x | Preferred position of the engine. |
y | Vertical position of the engine. |
engine | Engine to draw |
pal | Palette to use. |
Definition at line 148 of file roadveh_cmd.cpp.
void DrawVehicleEngine | ( | int | left, |
int | right, | ||
int | preferred_x, | ||
int | y, | ||
EngineID | engine, | ||
PaletteID | pal, | ||
EngineImageType | image_type | ||
) |
Draw an engine.
left | Minimum horizontal position to use for drawing the engine |
right | Maximum horizontal position to use for drawing the engine |
preferred_x | Horizontal position to use for drawing the engine. |
y | Vertical position to use for drawing the engine. |
engine | Engine to draw. |
pal | Palette to use for drawing. |
Definition at line 303 of file engine_gui.cpp.
void EngList_Sort | ( | GUIEngineList & | el, |
EngList_SortTypeFunction | compare | ||
) |
Sort all items using quick sort and given 'CompareItems' function.
el | list to be sorted |
compare | function for evaluation of the quicksort |
Definition at line 333 of file engine_gui.cpp.
Referenced by ReplaceVehicleWindow::GenerateReplaceVehList().
void EngList_SortPartial | ( | GUIEngineList & | el, |
EngList_SortTypeFunction | compare, | ||
size_t | begin, | ||
size_t | num_items | ||
) |
Sort selected range of items (on indices @ <begin, begin+num_items-1>)
el | list to be sorted |
compare | function for evaluation of the quicksort |
begin | start of sorting |
num_items | count of items to be sorted |
Definition at line 346 of file engine_gui.cpp.
Return the category of an engine.
engine | Engine to examine. |
Definition at line 40 of file engine_gui.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), and Engine::type.
Referenced by NewVehicleAvailable().
Get a multi-line string with some technical data, describing the engine.
engine | Engine to describe. |
DParam
array is set up for printing the string. Definition at line 273 of file engine_gui.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), Engine::type, and VEH_TRAIN.
uint GetEngineListHeight | ( | VehicleType | type | ) |
Get the height of a single 'entry' in the engine lists.
type | the vehicle type to get the height of |
Definition at line 53 of file build_vehicle_gui.cpp.
References EIT_PURCHASE, FS_NORMAL, GetCharacterHeight(), GetVehicleImageCellSize(), and WidgetDimensions::scaled.
Referenced by DrawEngineList().
void GUIEngineListAddChildren | ( | GUIEngineList & | dst, |
const GUIEngineList & | src, | ||
EngineID | parent, | ||
uint8_t | indent | ||
) |
Add children to GUI engine list to build a hierarchical tree.
dst | Destination list. |
src | Source list. |
parent | Current tree parent (set by self with recursion). |
indent | Current tree indentation level (set by self with recursion). |
Definition at line 1130 of file build_vehicle_gui.cpp.
References Engine::display_last_variant, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Get(), HasFlag(), HasVariants, INVALID_ENGINE, IsFolded, None, and Shaded.
Referenced by ReplaceVehicleWindow::GenerateReplaceVehList().