OpenTTD Source: src/vehicle_gui_base.h File Reference

OpenTTD Source 15.3

Data Structures | Typedefs | Functions
vehicle_gui_base.h File Reference

Functions/classes shared between the different vehicle list GUIs. More...

`#include "cargo_type.h"`
`#include "timer/timer_game_calendar.h"`
`#include "economy_type.h"`
`#include "sortlist_type.h"`
`#include "vehicle_base.h"`
`#include "vehiclelist.h"`
`#include "window_gui.h"`
`#include "dropdown_type.h"`

Go to the source code of this file.

## Data Structures
struct | GUIVehicleGroup
struct | BaseVehicleListWindow
struct | CargoIconOverlay
struct | Sorting

## Typedefs
typedef GUIList< const Vehicle *, std::nullptr_t, CargoType > | GUIVehicleList
typedef GUIList< GUIVehicleGroup, std::nullptr_t, CargoType > | GUIVehicleGroupList

## Functions
bool | ShowCargoIconOverlay ()
| Test if cargo icon overlays should be drawn.
void | AddCargoIconOverlay (std::vector< CargoIconOverlay > &overlays, int x, int width, const Vehicle *v)
| Add a cargo icon to the list of overlays.
void | DrawCargoIconOverlay (int x, int y, CargoType cargo_type)
| Draw a cargo icon overlaying an existing sprite, with a black contrast outline.
void | DrawCargoIconOverlays (std::span< const CargoIconOverlay > overlays, int y)
| Draw a list of cargo icon overlays.
uint | GetVehicleListHeight (VehicleType type, uint divisor=1)
| Get the height of a vehicle in the vehicle list GUIs.

## Detailed Description

Functions/classes shared between the different vehicle list GUIs.

Definition in file vehicle_gui_base.h.

## Typedef Documentation

## ◆ GUIVehicleGroupList

typedef GUIList<GUIVehicleGroup, std::nullptr_t, CargoType> GUIVehicleGroupList

Definition at line 65 of file vehicle_gui_base.h.

## ◆ GUIVehicleList

typedef GUIList<const Vehicle*, std::nullptr_t, CargoType> GUIVehicleList

Definition at line 22 of file vehicle_gui_base.h.

## Function Documentation

## ◆ AddCargoIconOverlay()

void AddCargoIconOverlay | ( | std::vector< CargoIconOverlay > & | overlays,
|  | int | x,
|  | int | width,
|  | const Vehicle * | v
| ) |  |

Add a cargo icon to the list of overlays.

Parameters

  overlays | List of overlays.
  x | Horizontal position.
  width | Width available.
  v | Vehicle to add.

Definition at line 349 of file vehicle_gui.cpp.

References _current_text_dir, Vehicle::cargo_cap, Vehicle::cargo_type, Vehicle::IsArticulatedPart(), Vehicle::Previous(), and TD_RTL.

Referenced by DrawRoadVehImage(), and DrawTrainImage().

## ◆ DrawCargoIconOverlay()

void DrawCargoIconOverlay | ( | int | x,
|  | int | y,
|  | CargoType | cargo_type
| ) |  |

Draw a cargo icon overlaying an existing sprite, with a black contrast outline.

Parameters

  x | Horizontal position from left.
  y | Vertical position from top.
  cargo_type | Cargo type to draw icon for.

Definition at line 372 of file vehicle_gui.cpp.

References DrawSprite(), CargoSpec::Get(), CargoSpec::GetCargoIcon(), GetSpriteSize(), IsValidCargoType(), PALETTE_ALL_BLACK, ScaleGUITrad(), and ShowCargoIconOverlay().

Referenced by DrawAircraftImage(), DrawCargoIconOverlays(), and DrawShipImage().

## ◆ DrawCargoIconOverlays()

void DrawCargoIconOverlays | ( | std::span< const CargoIconOverlay > | overlays,
|  | int | y
| ) |  |

Draw a list of cargo icon overlays.

Parameters

  overlays | List of overlays.
  y | Vertical position.

Definition at line 401 of file vehicle_gui.cpp.

References DrawCargoIconOverlay().

Referenced by DrawRoadVehImage(), and DrawTrainImage().

## ◆ GetVehicleListHeight()

uint GetVehicleListHeight | ( | VehicleType | type,
|  | uint | divisor
| ) |  |

Get the height of a vehicle in the vehicle list GUIs.

Parameters

  type | the vehicle type to look at
  divisor | the resulting height must be dividable by this

Returns
  the height

Definition at line 1727 of file vehicle_gui.cpp.

References FS_SMALL, GetCharacterHeight(), GetVehicleHeight(), WidgetDimensions::matrix, WidgetDimensions::scaled, ScaleGUITrad(), VEH_SHIP, and RectPadding::Vertical().

Referenced by VehicleGroupWindow::UpdateWidgetSize(), and VehicleListWindow::UpdateWidgetSize().

## ◆ ShowCargoIconOverlay()

bool ShowCargoIconOverlay | ( |  | ) |

Test if cargo icon overlays should be drawn.

Returns
  true iff cargo icon overlays should be drawn.

Definition at line 337 of file vehicle_gui.cpp.

References _ctrl_pressed, and _shift_pressed.

Referenced by DrawCargoIconOverlay(), DrawRoadVehImage(), DrawTrainImage(), DepotWindow::OnMouseLoop(), VehicleGroupWindow::OnMouseLoop(), and VehicleListWindow::OnMouseLoop().