OpenTTD Source 20260208-master-g43af8e94d0
sprite.h File Reference

Base for drawing complex sprites. More...

#include "core/geometry_type.hpp"
#include "transparency.h"
#include "table/sprites.h"

Go to the source code of this file.

Data Structures

struct  SpriteBounds
struct  DrawTileSeqStruct
 A tile child sprite and palette to draw for stations etc, with 3D bounding box. More...
struct  DrawTileSprites
 Ground palette sprite of a tile, together with its sprite layout. More...
struct  DrawTileSpriteSpan
 Ground palette sprite of a tile, together with its sprite layout. More...
struct  DrawBuildingsTileStruct
 This structure is the same for both Industries and Houses. More...

Functions

void DrawCommonTileSeq (const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32_t orig_offset, uint32_t newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned)
void DrawCommonTileSeqInGUI (int x, int y, const DrawTileSprites *dts, int32_t orig_offset, uint32_t newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned)
 Draws a tile sprite sequence in the GUI.
void DrawRailTileSeq (const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
 Draw tile sprite sequence on tile with railroad specifics.
void DrawRailTileSeqInGUI (int x, int y, const DrawTileSprites *dts, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
 Draw tile sprite sequence in GUI with railroad specifics.
void DrawOrigTileSeq (const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, PaletteID default_palette)
 Draw TTD sprite sequence on tile.
void DrawOrigTileSeqInGUI (int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
 Draw TTD sprite sequence in GUI.
void DrawNewGRFTileSeq (const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32_t stage, PaletteID default_palette)
 Draw NewGRF industrytile or house sprite layout.
void DrawNewGRFTileSeqInGUI (int x, int y, const DrawTileSprites *dts, uint32_t stage, PaletteID default_palette)
 Draw NewGRF object in GUI.
PaletteID SpriteLayoutPaletteTransform (SpriteID image, PaletteID pal, PaletteID default_pal)
 Applies PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOUR to a palette entry of a sprite layout entry.
PaletteID GroundSpritePaletteTransform (SpriteID image, PaletteID pal, PaletteID default_pal)
 Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.
static PaletteID GetColourPalette (Colours colour)
 Get recolour palette for a colour.

Detailed Description

Base for drawing complex sprites.

Definition in file sprite.h.

Function Documentation

◆ DrawCommonTileSeqInGUI()

void DrawCommonTileSeqInGUI ( int x,
int y,
const DrawTileSprites * dts,
int32_t orig_offset,
uint32_t newgrf_offset,
PaletteID default_palette,
bool child_offset_is_unsigned )

Draws a tile sprite sequence in the GUI.

Parameters
xX position to draw to
yY position to draw to
dtsSprite and subsprites to draw
orig_offsetSprite-Offset for original sprites
newgrf_offsetSprite-Offset for NewGRF defined sprites
default_paletteThe default recolour sprite to use (typically company colour)
child_offset_is_unsignedWhether child sprite offsets are interpreted signed or unsigned

Definition at line 86 of file sprite.cpp.

References DrawSprite(), GB(), HasBit(), Normal, Point, RemapCoords(), ScaleSpriteTrad(), SPRITE_MASK, SPRITE_MODIFIER_CUSTOM_SPRITE, SPRITE_WIDTH, SpriteLayoutPaletteTransform(), UnScaleGUI(), Coord2D< T >::x, Sprite::x_offs, Coord2D< T >::y, and Sprite::y_offs.

Referenced by DrawNewGRFTileSeqInGUI(), DrawOrigTileSeqInGUI(), DrawRailTileSeqInGUI(), and DrawRoadStopTile().

◆ DrawNewGRFTileSeq()

void DrawNewGRFTileSeq ( const struct TileInfo * ti,
const DrawTileSprites * dts,
TransparencyOption to,
uint32_t stage,
PaletteID default_palette )
inline

Draw NewGRF industrytile or house sprite layout.

Parameters
tiTile to draw to.
dtsSprite and subsprites to draw.
toTransparency settings for the sprite.
stageSprite inside the Action1 spritesets to use, i.e. construction stage.
default_paletteThe default recolour sprite to use (typically company colour).

Definition at line 150 of file sprite.h.

References DrawCommonTileSeq().

Referenced by DrawTileLayout().

◆ DrawNewGRFTileSeqInGUI()

void DrawNewGRFTileSeqInGUI ( int x,
int y,
const DrawTileSprites * dts,
uint32_t stage,
PaletteID default_palette )
inline

Draw NewGRF object in GUI.

Parameters
xX position to draw to.
yY position to draw to.
dtsSprite and subsprites to draw.
stageSprite inside the Action1 spritesets to use, i.e. construction stage.
default_paletteThe default recolour sprite to use (typically company colour)

Definition at line 163 of file sprite.h.

References DrawCommonTileSeqInGUI().

Referenced by DrawNewHouseTileInGUI(), and DrawNewObjectTileInGUI().

◆ DrawOrigTileSeq()

void DrawOrigTileSeq ( const struct TileInfo * ti,
const DrawTileSprites * dts,
TransparencyOption to,
PaletteID default_palette )
inline

Draw TTD sprite sequence on tile.

Parameters
tiTile to draw to.
dtsSprite and subsprites to draw.
toTransparency settings for the sprite.
default_paletteThe default recolour sprite to use (typically company colour).

Definition at line 125 of file sprite.h.

References DrawCommonTileSeq().

◆ DrawOrigTileSeqInGUI()

void DrawOrigTileSeqInGUI ( int x,
int y,
const DrawTileSprites * dts,
PaletteID default_palette )
inline

Draw TTD sprite sequence in GUI.

Parameters
xX position to draw to.
yY position to draw to.
dtsSprite and subsprites to draw.
default_paletteThe default recolour sprite to use (typically company colour).

Definition at line 137 of file sprite.h.

References DrawCommonTileSeqInGUI().

Referenced by ObjectPickerCallbacks::DrawType(), and BuildObjectWindow::DrawWidget().

◆ DrawRailTileSeq()

void DrawRailTileSeq ( const struct TileInfo * ti,
const DrawTileSprites * dts,
TransparencyOption to,
int32_t total_offset,
uint32_t newgrf_offset,
PaletteID default_palette )
inline

Draw tile sprite sequence on tile with railroad specifics.

Parameters
tiTile to draw to.
dtsSprite and subsprites to draw.
toTransparency settings for the sprite.
total_offsetSpriteoffset from normal rail to current railtype.
newgrf_offsetStartsprite of the Action1 to use.
default_paletteThe default recolour sprite to use (typically company colour).

Definition at line 99 of file sprite.h.

References DrawCommonTileSeq().

Referenced by DrawTile_Road().

◆ DrawRailTileSeqInGUI()

void DrawRailTileSeqInGUI ( int x,
int y,
const DrawTileSprites * dts,
int32_t total_offset,
uint32_t newgrf_offset,
PaletteID default_palette )
inline

Draw tile sprite sequence in GUI with railroad specifics.

Parameters
xX position to draw to.
yY position to draw to.
dtsSprite and subsprites to draw.
total_offsetSpriteoffset from normal rail to current railtype.
newgrf_offsetStartsprite of the Action1 to use.
default_paletteThe default recolour sprite to use (typically company colour).

Definition at line 113 of file sprite.h.

References DrawCommonTileSeqInGUI().

Referenced by DrawRoadDepotSprite(), and DrawStationTile().

◆ GetColourPalette()

PaletteID GetColourPalette ( Colours colour)
inlinestatic

Get recolour palette for a colour.

Parameters
colourColour.
Returns
Recolour palette.

Definition at line 212 of file sprite.h.

References PALETTE_RECOLOUR_START.

Referenced by DrawCompanyManagerFace(), DrawNewHouseTileInGUI(), DrawRoadTypeCatenary(), SelectCompanyLiveryWindow::DrawWidget(), GetCompanyPalette(), and SetupColoursAndInitialWindow().

◆ GroundSpritePaletteTransform()

PaletteID GroundSpritePaletteTransform ( SpriteID image,
PaletteID pal,
PaletteID default_pal )
inline

Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.

Note
Not usable for OTTD internal spritelayouts from table/xxx_land.h as PALETTE_MODIFIER_TRANSPARENT is only set when to use the default palette.
Parameters
imageThe sprite to draw
palThe palette from the sprite layout
default_palThe default recolour sprite to use (typically company colour resp. random industry/house colour)
Returns
The palette to use

Definition at line 198 of file sprite.h.

References HasBit(), and PALETTE_MODIFIER_COLOUR.

Referenced by DrawNewHouseTileInGUI(), DrawNewObjectTileInGUI(), DrawRoadStopTile(), DrawStationTile(), and DrawTileLayout().

◆ SpriteLayoutPaletteTransform()

PaletteID SpriteLayoutPaletteTransform ( SpriteID image,
PaletteID pal,
PaletteID default_pal )
inline

Applies PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOUR to a palette entry of a sprite layout entry.

Note
for ground sprites use GroundSpritePaletteTransform
Not usable for OTTD internal spritelayouts from table/xxx_land.h as PALETTE_MODIFIER_TRANSPARENT is only set when to use the default palette.
Parameters
imageThe sprite to draw
palThe palette from the sprite layout
default_palThe default recolour sprite to use (typically company colour resp. random industry/house colour)
Returns
The palette to use

Definition at line 179 of file sprite.h.

References HasBit(), PALETTE_MODIFIER_COLOUR, and PALETTE_MODIFIER_TRANSPARENT.

Referenced by DrawCommonTileSeq(), and DrawCommonTileSeqInGUI().