OpenTTD Source 20250514-master-gecc3438519
SpriteLayoutProcessor Class Reference

Add dynamic register values to a sprite layout. More...

#include <newgrf_commons.h>

Public Member Functions

 SpriteLayoutProcessor (const NewGRFSpriteLayout &raw_layout)
 Constructor for spritelayout, which do not need preprocessing.
 
 SpriteLayoutProcessor (const NewGRFSpriteLayout &raw_layout, uint32_t orig_offset, uint32_t newgrf_ground_offset, uint32_t newgrf_offset, uint constr_stage, bool separate_ground)
 Prepares a sprite layout before resolving action-1-2-3 chains.
 
SetBitIterator< uint8_t, uint32_t > Var10Values () const
 Get values for variable 10 to resolve sprites for.
 
void ProcessRegisters (const struct ResolverObject &object, uint8_t resolved_var10, uint32_t resolved_sprite)
 Evaluates the register modifiers and integrates them into the preprocessed sprite layout.
 
DrawTileSpriteSpan GetLayout () const
 Returns the result spritelayout after preprocessing.
 

Private Attributes

const NewGRFSpriteLayoutraw_layout = nullptr
 
std::vector< DrawTileSeqStructresult_seq
 
uint32_t var10_values = 0
 
bool separate_ground = false
 

Detailed Description

Add dynamic register values to a sprite layout.

Definition at line 143 of file newgrf_commons.h.

Constructor & Destructor Documentation

◆ SpriteLayoutProcessor() [1/2]

SpriteLayoutProcessor::SpriteLayoutProcessor ( const NewGRFSpriteLayout raw_layout)
inline

Constructor for spritelayout, which do not need preprocessing.

Definition at line 152 of file newgrf_commons.h.

◆ SpriteLayoutProcessor() [2/2]

SpriteLayoutProcessor::SpriteLayoutProcessor ( const NewGRFSpriteLayout raw_layout,
uint32_t  orig_offset,
uint32_t  newgrf_ground_offset,
uint32_t  newgrf_offset,
uint  constr_stage,
bool  separate_ground 
)

Prepares a sprite layout before resolving action-1-2-3 chains.

Integrates offsets into the layout and determines which chains to resolve.

Parameters
raw_layoutSprite layout in need of preprocessing.
orig_offsetOffset to apply to non-action-1 sprites.
newgrf_ground_offsetOffset to apply to action-1 ground sprites.
newgrf_offsetOffset to apply to action-1 non-ground sprites.
constr_stageConstruction stage (0-3) to apply to all action-1 sprites.
separate_groundWhether the ground sprite shall be resolved by a separate action-1-2-3 chain by default.

Definition at line 603 of file newgrf_commons.cpp.

References DrawTileSeqStruct::delta_z, TileLayoutRegisters::flags, GetConstructionStageOffset(), DrawTileSprites::ground, HasBit(), TileLayoutRegisters::max_palette_offset, TileLayoutRegisters::max_sprite_offset, TileLayoutRegisters::palette_var10, SetBit(), SPRITE_MODIFIER_CUSTOM_SPRITE, TileLayoutRegisters::sprite_var10, TLF_PALETTE, TLF_PALETTE_REG_FLAGS, TLF_PALETTE_VAR10, TLF_SPRITE, TLF_SPRITE_REG_FLAGS, and TLF_SPRITE_VAR10.

Member Function Documentation

◆ GetLayout()

DrawTileSpriteSpan SpriteLayoutProcessor::GetLayout ( ) const
inline

Returns the result spritelayout after preprocessing.

Returns
result ground sprite and spritelayout

Definition at line 168 of file newgrf_commons.h.

References DrawTileSprites::ground.

Referenced by DrawNewObjectTile(), DrawNewObjectTileInGUI(), DrawRoadStopTile(), and DrawStationTile().

◆ ProcessRegisters()

void SpriteLayoutProcessor::ProcessRegisters ( const struct ResolverObject object,
uint8_t  resolved_var10,
uint32_t  resolved_sprite 
)

◆ Var10Values()

SetBitIterator< uint8_t, uint32_t > SpriteLayoutProcessor::Var10Values ( ) const
inline

Get values for variable 10 to resolve sprites for.

NewStations only.

Definition at line 160 of file newgrf_commons.h.

Field Documentation

◆ raw_layout

const NewGRFSpriteLayout* SpriteLayoutProcessor::raw_layout = nullptr
private

Definition at line 144 of file newgrf_commons.h.

◆ result_seq

std::vector<DrawTileSeqStruct> SpriteLayoutProcessor::result_seq
private

Definition at line 145 of file newgrf_commons.h.

◆ separate_ground

bool SpriteLayoutProcessor::separate_ground = false
private

Definition at line 147 of file newgrf_commons.h.

◆ var10_values

uint32_t SpriteLayoutProcessor::var10_values = 0
private

Definition at line 146 of file newgrf_commons.h.


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