OpenTTD Source: SpriteLayoutProcessor Class Reference

OpenTTD Source 15.0-RC2

Public Member Functions | Private Attributes
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 NewGRFSpriteLayout * | raw_layout = nullptr
std::vector< DrawTileSeqStruct > | result_seq
uint32_t | var10_values = 0
bool | separate_ground = false

## Detailed Description

Add dynamic register values to a sprite layout.

Definition at line 142 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 151 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_layout | Sprite layout in need of preprocessing.
  orig_offset | Offset to apply to non-action-1 sprites.
  newgrf_ground_offset | Offset to apply to action-1 ground sprites.
  newgrf_offset | Offset to apply to action-1 non-ground sprites.
  constr_stage | Construction stage (0-3) to apply to all action-1 sprites.
  separate_ground | Whether 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 TileLayoutRegisters::flags, GetConstructionStageOffset(), DrawTileSprites::ground, HasBit(), TileLayoutRegisters::max_palette_offset, TileLayoutRegisters::max_sprite_offset, SpriteBounds::origin, 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, TLF_SPRITE_VAR10, and Coord3D< T >::z.

## Member Function Documentation

## ◆ GetLayout()

DrawTileSpriteSpan SpriteLayoutProcessor::GetLayout | ( |  | ) | const
| inline

Returns the result spritelayout after preprocessing.

Returns
  result ground sprite and spritelayout

Definition at line 167 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

  object | ResolverObject owning the temporary storage.
  resolved_var10 | The value of var10 the action-1-2-3 chain was evaluated for.
  resolved_sprite | Result sprite of the action-1-2-3 chain.

Definition at line 665 of file newgrf_commons.cpp.

References TileLayoutRegisters::child, TileLayoutRegisters::dodraw, TileLayoutRegisters::flags, HasBit(), TileLayoutRegisters::max_palette_offset, TileLayoutRegisters::max_sprite_offset, 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 159 of file newgrf_commons.h.

## Field Documentation

## ◆ raw_layout

const NewGRFSpriteLayout* SpriteLayoutProcessor::raw_layout = nullptr
| private

Definition at line 143 of file newgrf_commons.h.

## ◆ result_seq

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

Definition at line 144 of file newgrf_commons.h.

## ◆ separate_ground

bool SpriteLayoutProcessor::separate_ground = false
| private

Definition at line 146 of file newgrf_commons.h.

## ◆ var10_values

uint32_t SpriteLayoutProcessor::var10_values = 0
| private

Definition at line 145 of file newgrf_commons.h.

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

- src/newgrf_commons.h
- src/newgrf_commons.cpp