OpenTTD Source 20261112-master-gbcbec5e63f
ChainField Class Referenceabstract

Base cargo chain field. More...

Inheritance diagram for ChainField:
AcceptsProducesChainField CargoChainField ConnectionChainField HeaderChainField HouseChainField IndustryChainField

Public Types

using CargoSlotMask = uint16_t
 Type representing a mask of cargo slots.
using ClickedAtResult = std::variant<std::monostate, HouseID, IndustryType, CargoType>
 Result type of testing clicked position.

Public Member Functions

template<typename T>
T * Get ()
 Get this field as a specific type implemention.
template<typename T>
const T * Get () const
 Get this field as a specific type implemention.
virtual int Width () const
 Get the width of this field.
virtual int Height () const
 Get the height of this field.
virtual void Draw (Rect r) const =0
 Draw the field.
virtual ClickedAtResult ClickedAt (Rect r, Point pt) const
 Decide which industry/house or cargo was clicked at.

Static Public Member Functions

static uint GetConnectionHeight ()
 Get the height of all cargo connections in a row.

Static Public Attributes

static constexpr uint MAX_CARGOES = 16
 Maximum number of cargoes carried in a field.
static constexpr CargoSlotMask ALL_CARGO_SLOTS {std::numeric_limits<CargoSlotMask>::max()}
 Value representing all cargo slots.
static constexpr PixelColour CARGO_LINE_COLOUR = PC_BLACK
 Line colour around the cargo.
static FontSize fontsize = FontSize::Normal
 Font size of industry chain strings.
static CargoTypes town_accepts
 Mask of cargo types accepted by towns.
static CargoTypes town_produces
 Mask of cargo types produced by towns.
static int vert_inter_industry_space
 Amount of space between two industries in a column.
static int blob_distance
 Distance of the industry legend colour from the edge of the industry box.
static Dimension legend
 Dimension of the legend blob.
static Dimension cargo_border
 Dimensions of border between cargo lines and industry boxes.
static Dimension cargo_line
 Dimensions of cargo lines.
static Dimension cargo_space
 Dimensions of space between cargo lines.
static Dimension cargo_stub
 Dimensions of cargo stub (unconnected cargo line.).
static int small_height
 Height of the header row.
static int normal_height
 Height of the non-header rows.
static int connection_field_width
 Width of a cargo connection field.
static int industry_width
 Width of an industry field.
static uint max_cargoes
 Largest number of cargoes actually on any industry.

Detailed Description

Base cargo chain field.

Definition at line 1968 of file industry_gui.cpp.

Member Typedef Documentation

◆ CargoSlotMask

using ChainField::CargoSlotMask = uint16_t

Type representing a mask of cargo slots.

Definition at line 1972 of file industry_gui.cpp.

◆ ClickedAtResult

using ChainField::ClickedAtResult = std::variant<std::monostate, HouseID, IndustryType, CargoType>

Result type of testing clicked position.

Definition at line 2046 of file industry_gui.cpp.

Member Function Documentation

◆ ClickedAt()

virtual ClickedAtResult ChainField::ClickedAt ( Rect r,
Point pt ) const
inlinevirtual

Decide which industry/house or cargo was clicked at.

Parameters
rRect of this cargo field.
ptClick position in the cargo field.
Returns
Industry/house or cargo clicked at.

Reimplemented in AcceptsProducesChainField, CargoChainField, ConnectionChainField, HouseChainField, and IndustryChainField.

Definition at line 2054 of file industry_gui.cpp.

References Point.

◆ Draw()

virtual void ChainField::Draw ( Rect r) const
pure virtual

Draw the field.

Parameters
rRect to draw within.

Implemented in AcceptsProducesChainField, CargoChainField, ConnectionChainField, HeaderChainField, HouseChainField, and IndustryChainField.

◆ Get() [1/2]

template<typename T>
T * ChainField::Get ( )
inline

Get this field as a specific type implemention.

Template Parameters
TThe type of chain field.
Returns
The field if is of the requested type.

Definition at line 2018 of file industry_gui.cpp.

References T.

◆ Get() [2/2]

template<typename T>
const T * ChainField::Get ( ) const
inline

Get this field as a specific type implemention.

Template Parameters
TThe type of chain field.
Returns
The field if is of the requested type.

Definition at line 2025 of file industry_gui.cpp.

References T.

◆ GetConnectionHeight()

uint ChainField::GetConnectionHeight ( )
inlinestatic

Get the height of all cargo connections in a row.

Returns
The height of all cargo connections.

Definition at line 2006 of file industry_gui.cpp.

References cargo_line, cargo_space, and max_cargoes.

Referenced by AcceptsProducesChainField::ClickedAt(), CargoChainField::ClickedAt(), ConnectionChainField::ClickedAt(), AcceptsProducesChainField::Draw(), CargoChainField::Draw(), ConnectionChainField::Draw(), and IndustryCargoesWindow::OnInit().

◆ Height()

virtual int ChainField::Height ( ) const
inlinevirtual

Get the height of this field.

Returns
The height.

Reimplemented in HeaderChainField.

Definition at line 2037 of file industry_gui.cpp.

References normal_height.

◆ Width()

virtual int ChainField::Width ( ) const
inlinevirtual

Get the width of this field.

Returns
The width.

Reimplemented in ConnectionChainField.

Definition at line 2031 of file industry_gui.cpp.

References industry_width.

Field Documentation

◆ ALL_CARGO_SLOTS

CargoSlotMask ChainField::ALL_CARGO_SLOTS {std::numeric_limits<CargoSlotMask>::max()}
staticconstexpr

Value representing all cargo slots.

Definition at line 1975 of file industry_gui.cpp.

Referenced by ConnectionChainField::ClickedAt(), ConnectionChainField::Draw(), and IndustryCargoesWindow::ShortenConnectionsColumn().

◆ blob_distance

int ChainField::blob_distance
inlinestatic

Distance of the industry legend colour from the edge of the industry box.

Definition at line 1988 of file industry_gui.cpp.

Referenced by IndustryChainField::Draw(), and IndustryCargoesWindow::OnInit().

◆ cargo_border

Dimension ChainField::cargo_border
inlinestatic

Dimensions of border between cargo lines and industry boxes.

Definition at line 1991 of file industry_gui.cpp.

Referenced by IndustryCargoesWindow::OnInit().

◆ cargo_line

◆ CARGO_LINE_COLOUR

PixelColour ChainField::CARGO_LINE_COLOUR = PC_BLACK
staticconstexpr

Line colour around the cargo.

Definition at line 1980 of file industry_gui.cpp.

Referenced by AcceptsProducesChainField::Draw(), and ConnectionChainField::Draw().

◆ cargo_space

◆ cargo_stub

Dimension ChainField::cargo_stub
inlinestatic

Dimensions of cargo stub (unconnected cargo line.).

Definition at line 1994 of file industry_gui.cpp.

Referenced by AcceptsProducesChainField::ClickedAt(), AcceptsProducesChainField::Draw(), IndustryCargoesWindow::OnInit(), and IndustryCargoesWindow::UpdateWidgetSize().

◆ connection_field_width

int ChainField::connection_field_width
inlinestatic

◆ fontsize

◆ industry_width

int ChainField::industry_width
inlinestatic

◆ legend

Dimension ChainField::legend
inlinestatic

Dimension of the legend blob.

Definition at line 1990 of file industry_gui.cpp.

Referenced by IndustryChainField::Draw(), and IndustryCargoesWindow::OnInit().

◆ MAX_CARGOES

uint ChainField::MAX_CARGOES = 16
staticconstexpr

Maximum number of cargoes carried in a field.

Definition at line 1970 of file industry_gui.cpp.

Referenced by CargoChainField::Draw().

◆ max_cargoes

uint ChainField::max_cargoes
inlinestatic

◆ normal_height

int ChainField::normal_height
inlinestatic

Height of the non-header rows.

Definition at line 1997 of file industry_gui.cpp.

Referenced by Height(), IndustryCargoesWindow::OnInit(), and IndustryCargoesWindow::UpdateWidgetSize().

◆ small_height

int ChainField::small_height
inlinestatic

◆ town_accepts

◆ town_produces

◆ vert_inter_industry_space

int ChainField::vert_inter_industry_space
inlinestatic

The documentation for this class was generated from the following file: