OpenTTD Source  20241121-master-g67a0fccfad
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, CargoIDGUIVehicleList
 
typedef GUIList< GUIVehicleGroup, std::nullptr_t, CargoIDGUIVehicleGroupList
 

Functions

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

Variables

BaseVehicleListWindow::GroupBy _grouping [VLT_END][VEH_COMPANY_END]
 
Sorting _sorting [BaseVehicleListWindow::GB_END]
 

Detailed Description

Functions/classes shared between the different vehicle list GUIs.

Definition in 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
overlaysList of overlays.
xHorizontal position.
widthWidth available.
vVehicle to add.

Definition at line 348 of file vehicle_gui.cpp.

◆ DrawCargoIconOverlay()

void DrawCargoIconOverlay ( int  x,
int  y,
CargoID  cid 
)

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

Parameters
xHorizontal position from left.
yVertical position from top.
cidCargo ID to draw icon for.

Definition at line 371 of file vehicle_gui.cpp.

◆ DrawCargoIconOverlays()

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

Draw a list of cargo icon overlays.

Parameters
overlaysList of overlays.
yVertical position.

Definition at line 400 of file vehicle_gui.cpp.

◆ GetVehicleListHeight()

uint GetVehicleListHeight ( VehicleType  type,
uint  divisor 
)

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

Parameters
typethe vehicle type to look at
divisorthe resulting height must be dividable by this
Returns
the height

Definition at line 1751 of file vehicle_gui.cpp.

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

◆ ShowCargoIconOverlay()

bool ShowCargoIconOverlay ( )

Test if cargo icon overlays should be drawn.

Returns
true iff cargo icon overlays should be drawn.

Definition at line 336 of file vehicle_gui.cpp.

References _ctrl_pressed, and _shift_pressed.

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