OpenTTD
Data Structures | Macros | Functions
sprite.h File Reference

Base for drawing complex sprites. More...

#include "transparency.h"
#include "table/sprites.h"

Go to the source code of this file.

Data Structures

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  DrawBuildingsTileStruct
 This structure is the same for both Industries and Houses. More...
 

Macros

#define GENERAL_SPRITE_COLOUR(colour)   ((colour) + PALETTE_RECOLOUR_START)
 
#define COMPANY_SPRITE_COLOUR(owner)   (GENERAL_SPRITE_COLOUR(_company_colours[owner]))
 
#define foreach_draw_tile_seq(idx, list)   for (idx = list; !idx->IsTerminator(); idx++)
 Iterate through all DrawTileSeqStructs in DrawTileSprites. More...
 

Functions

void DrawCommonTileSeq (const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned)
 
void DrawCommonTileSeqInGUI (int x, int y, const DrawTileSprites *dts, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned)
 Draws a tile sprite sequence in the GUI. More...
 
static void DrawRailTileSeq (const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
 Draw tile sprite sequence on tile with railroad specifics. More...
 
static void DrawRailTileSeqInGUI (int x, int y, const DrawTileSprites *dts, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette)
 Draw tile sprite sequence in GUI with railroad specifics. More...
 
static void DrawOrigTileSeq (const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, PaletteID default_palette)
 Draw TTD sprite sequence on tile.
 
static void DrawOrigTileSeqInGUI (int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
 Draw TTD sprite sequence in GUI.
 
static void DrawNewGRFTileSeq (const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32 stage, PaletteID default_palette)
 Draw NewGRF industrytile or house sprite layout. More...
 
static void DrawNewGRFTileSeqInGUI (int x, int y, const DrawTileSprites *dts, uint32 stage, PaletteID default_palette)
 Draw NewGRF object in GUI. More...
 
static 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. More...
 
static PaletteID GroundSpritePaletteTransform (SpriteID image, PaletteID pal, PaletteID default_pal)
 Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite. More...
 

Detailed Description

Base for drawing complex sprites.

Definition in file sprite.h.

Macro Definition Documentation

◆ foreach_draw_tile_seq

#define foreach_draw_tile_seq (   idx,
  list 
)    for (idx = list; !idx->IsTerminator(); idx++)

Iterate through all DrawTileSeqStructs in DrawTileSprites.

Definition at line 81 of file sprite.h.

Referenced by NewGRFSpriteLayout::Clone(), DrawCommonTileSeq(), and NewGRFSpriteLayout::ProcessRegisters().

Function Documentation

◆ DrawCommonTileSeqInGUI()

void DrawCommonTileSeqInGUI ( int  x,
int  y,
const DrawTileSprites dts,
int32  orig_offset,
uint32  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 94 of file sprite.cpp.

◆ DrawNewGRFTileSeq()

static void DrawNewGRFTileSeq ( const struct TileInfo ti,
const DrawTileSprites dts,
TransparencyOption  to,
uint32  stage,
PaletteID  default_palette 
)
inlinestatic

Draw NewGRF industrytile or house sprite layout.

Parameters
stageSprite inside the Action1 spritesets to use, i.e. construction stage.

Definition at line 126 of file sprite.h.

References DrawCommonTileSeq().

◆ DrawNewGRFTileSeqInGUI()

static void DrawNewGRFTileSeqInGUI ( int  x,
int  y,
const DrawTileSprites dts,
uint32  stage,
PaletteID  default_palette 
)
inlinestatic

Draw NewGRF object in GUI.

Parameters
stageSprite inside the Action1 spritesets to use, i.e. construction stage.

Definition at line 135 of file sprite.h.

◆ DrawRailTileSeq()

static void DrawRailTileSeq ( const struct TileInfo ti,
const DrawTileSprites dts,
TransparencyOption  to,
int32  total_offset,
uint32  newgrf_offset,
PaletteID  default_palette 
)
inlinestatic

Draw tile sprite sequence on tile with railroad specifics.

Parameters
total_offsetSpriteoffset from normal rail to current railtype.
newgrf_offsetStartsprite of the Action1 to use.

Definition at line 91 of file sprite.h.

References DrawCommonTileSeq().

◆ DrawRailTileSeqInGUI()

static void DrawRailTileSeqInGUI ( int  x,
int  y,
const DrawTileSprites dts,
int32  total_offset,
uint32  newgrf_offset,
PaletteID  default_palette 
)
inlinestatic

Draw tile sprite sequence in GUI with railroad specifics.

Parameters
total_offsetSpriteoffset from normal rail to current railtype.
newgrf_offsetStartsprite of the Action1 to use.

Definition at line 101 of file sprite.h.

◆ GroundSpritePaletteTransform()

static PaletteID GroundSpritePaletteTransform ( SpriteID  image,
PaletteID  pal,
PaletteID  default_pal 
)
inlinestatic

Applies PALETTE_MODIFIER_COLOUR to a palette entry of a ground sprite.

Note
Not useable 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 170 of file sprite.h.

References HasBit(), and PALETTE_MODIFIER_COLOUR.

◆ SpriteLayoutPaletteTransform()

static PaletteID SpriteLayoutPaletteTransform ( SpriteID  image,
PaletteID  pal,
PaletteID  default_pal 
)
inlinestatic

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

Note
for ground sprites use GroundSpritePaletteTransform
Not useable 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 151 of file sprite.h.

References HasBit(), PALETTE_MODIFIER_COLOUR, and PALETTE_MODIFIER_TRANSPARENT.

Referenced by DrawCommonTileSeq().