OpenTTD Source 20260206-master-g4d4e37dbf1
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 139 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 148 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 600 of file newgrf_commons.cpp.

References GetConstructionStageOffset(), HasBit(), SetBit(), SPRITE_MODIFIER_CUSTOM_SPRITE, 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 164 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 )

Evaluates the register modifiers and integrates them into the preprocessed sprite layout.

Parameters
objectResolverObject owning the temporary storage.
resolved_var10The value of var10 the action-1-2-3 chain was evaluated for.
resolved_spriteResult sprite of the action-1-2-3 chain.

Definition at line 662 of file newgrf_commons.cpp.

References TileLayoutRegisters::child, TileLayoutRegisters::dodraw, TileLayoutRegisters::flags, HasBit(), TileLayoutRegisters::palette, TileLayoutRegisters::palette_var10, TileLayoutRegisters::parent, TileLayoutRegisters::sprite, SPRITE_MODIFIER_CUSTOM_SPRITE, TileLayoutRegisters::sprite_var10, TLF_BB_XY_OFFSET, TLF_BB_Z_OFFSET, TLF_CHILD_X_OFFSET, TLF_CHILD_Y_OFFSET, TLF_DODRAW, TLF_PALETTE, TLF_PALETTE_REG_FLAGS, TLF_PALETTE_VAR10, TLF_SPRITE, TLF_SPRITE_REG_FLAGS, and TLF_SPRITE_VAR10.

Referenced by TileLayoutSpriteGroup::ProcessRegisters().

◆ Var10Values()

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

Get values for variable 10 to resolve sprites for.

NewStations only.

Definition at line 156 of file newgrf_commons.h.

Field Documentation

◆ raw_layout

const NewGRFSpriteLayout* SpriteLayoutProcessor::raw_layout = nullptr
private

Definition at line 140 of file newgrf_commons.h.

◆ result_seq

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

Definition at line 141 of file newgrf_commons.h.

◆ separate_ground

bool SpriteLayoutProcessor::separate_ground = false
private

Definition at line 143 of file newgrf_commons.h.

◆ var10_values

uint32_t SpriteLayoutProcessor::var10_values = 0
private

Definition at line 142 of file newgrf_commons.h.


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