CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
Classes | Public Member Functions | Friends | List of all members
sprite_sheet Class Reference

Sheet of sprites. More...

#include <th_gfx_sdl.h>

Public Member Functions

 sprite_sheet ()=default
 
 ~sprite_sheet ()
 
void set_palette (const ::palette *pPalette)
 Set the palette to use for the sprites in the sheet.
 
bool load_from_th_file (const uint8_t *pTableData, size_t iTableDataLength, const uint8_t *pChunkData, size_t iChunkDataLength, bool bComplexChunks, render_target *pEventualCanvas)
 
bool set_sprite_data (size_t iSprite, const uint8_t *pData, bool bTakeData, size_t iDataLength, int iWidth, int iHeight)
 Set the data of a sprite.
 
void set_sprite_alt_palette_map (size_t iSprite, const uint8_t *pMap, uint32_t iAlt32)
 Supply a new mapped palette to a sprite.
 
size_t get_sprite_count () const
 Get the number of sprites at the sheet.
 
bool set_sprite_count (size_t iCount, render_target *pCanvas)
 Set the number of sprites in the sheet.
 
bool get_sprite_size (size_t iSprite, int *pWidth, int *pHeight) const
 Get size of a sprite.
 
void get_sprite_size_unchecked (size_t iSprite, int *pWidth, int *pHeight) const
 Get size of a sprite, assuming all input is correctly supplied.
 
bool get_sprite_average_colour (size_t iSprite, argb_colour *pColour) const
 Get the best colour to represent the sprite.
 
bool is_sprite_visible (size_t iSprite) const
 Return whether the given sprite show any pixel when displayed.
 
void draw_sprite (render_target *pCanvas, size_t iSprite, int iX, int iY, uint32_t iFlags, size_t effect_ticks=0u, animation_effect effect=animation_effect::none, int scale_factor=1)
 Draw a sprite onto the canvas.
 
bool hit_test_sprite (size_t iSprite, int iX, int iY, uint32_t iFlags) const
 Test whether a sprite was hit.
 
void wx_draw_sprite (size_t iSprite, uint8_t *pRGBData, uint8_t *pAData)
 Draw a sprite into wxImage data arrays (for the Map Editor)
 

Friends

class cursor
 

Detailed Description

Sheet of sprites.

Constructor & Destructor Documentation

◆ sprite_sheet()

sprite_sheet::sprite_sheet ( )
default

◆ ~sprite_sheet()

sprite_sheet::~sprite_sheet ( )

Member Function Documentation

◆ draw_sprite()

void sprite_sheet::draw_sprite ( render_target pCanvas,
size_t  iSprite,
int  iX,
int  iY,
uint32_t  iFlags,
size_t  effect_ticks = 0u,
animation_effect  effect = animation_effect::none,
int  scale_factor = 1 
)

Draw a sprite onto the canvas.

Parameters
pCanvasCanvas to draw on.
iSpriteSprite to draw.
iXX position to draw the sprite.
iYY position to draw the sprite.
iFlagsFlags to apply for drawing.
effect_ticksThe number of ticks into the effect animation.
effectThe animation effect to apply to the sprite.
scale_factorHow much to scale the sprite when drawing.

◆ get_sprite_average_colour()

bool sprite_sheet::get_sprite_average_colour ( size_t  iSprite,
argb_colour pColour 
) const

Get the best colour to represent the sprite.

Parameters
iSpriteSprite number to analyze.
pColour[out] Resulting colour.
Returns
Best colour could be established.

◆ get_sprite_count()

size_t sprite_sheet::get_sprite_count ( ) const

Get the number of sprites at the sheet.

Returns
The number of sprites available at the sheet.

◆ get_sprite_size()

bool sprite_sheet::get_sprite_size ( size_t  iSprite,
int pWidth,
int pHeight 
) const

Get size of a sprite.

Parameters
iSpriteSprite to get info from.
pWidth[out] If not nullptr, the sprite width is stored in the destination.
pHeight[out] If not nullptr, the sprite height is stored in the destination.
Returns
Size could be provided for the sprite.

◆ get_sprite_size_unchecked()

void sprite_sheet::get_sprite_size_unchecked ( size_t  iSprite,
int pWidth,
int pHeight 
) const

Get size of a sprite, assuming all input is correctly supplied.

Parameters
iSpriteSprite to get info from.
pWidth[out] The sprite width is stored in the destination.
pHeight[out] The sprite height is stored in the destination.

◆ hit_test_sprite()

bool sprite_sheet::hit_test_sprite ( size_t  iSprite,
int  iX,
int  iY,
uint32_t  iFlags 
) const

Test whether a sprite was hit.

Parameters
iSpriteSprite being tested.
iXX position of the point to test relative to the origin of the sprite.
iYY position of the point to test relative to the origin of the sprite.
iFlagsDraw flags to apply to the sprite before testing.
Returns
Whether the sprite covers the give point.

◆ is_sprite_visible()

bool sprite_sheet::is_sprite_visible ( size_t  iSprite) const

Return whether the given sprite show any pixel when displayed.

Parameters
iSpriteSprite number to analyze.
Returns
Whether any pixel of the sprite is visible.

◆ load_from_th_file()

bool sprite_sheet::load_from_th_file ( const uint8_t *  pTableData,
size_t  iTableDataLength,
const uint8_t *  pChunkData,
size_t  iChunkDataLength,
bool  bComplexChunks,
render_target pEventualCanvas 
)

Load the sprites from the supplied data (using the palette supplied earlier).

Parameters
pTableDataStart of table data with TH sprite information (see th_sprite_properties).
iTableDataLengthLength of the table data.
pChunkDataStart of image data (chunks).
iChunkDataLengthLength of the chunk data.
bComplexChunksWhether the supplied chunks are 'complex'.
pEventualCanvasCanvas to draw at.
Returns
Loading succeeded.

◆ set_palette()

void sprite_sheet::set_palette ( const ::palette pPalette)

Set the palette to use for the sprites in the sheet.

Parameters
pPalettePalette to use for the sprites at the sheet.

◆ set_sprite_alt_palette_map()

void sprite_sheet::set_sprite_alt_palette_map ( size_t  iSprite,
const uint8_t *  pMap,
uint32_t  iAlt32 
)

Supply a new mapped palette to a sprite.

Parameters
iSpriteSprite getting the mapped palette.
pMapThe palette map to apply.
iAlt32What to do for a 32bpp sprite (thdf_alt32_mask bits).

◆ set_sprite_count()

bool sprite_sheet::set_sprite_count ( size_t  iCount,
render_target pCanvas 
)

Set the number of sprites in the sheet.

Parameters
iCountThe desired number of sprites.
pCanvasCanvas to draw at.
Returns
Whether the number of sprites could be allocated.

◆ set_sprite_data()

bool sprite_sheet::set_sprite_data ( size_t  iSprite,
const uint8_t *  pData,
bool  bTakeData,
size_t  iDataLength,
int  iWidth,
int  iHeight 
)

Set the data of a sprite.

Parameters
iSpriteNumber of the sprite to set.
pDataData of the sprite.
bTakeDataWhether the data block may be taken (must be new[] then).
iDataLengthLength of the data.
iWidthWidth of the sprite.
iHeightHeight of the sprite.
Returns
Setting the sprite succeeded.

◆ wx_draw_sprite()

void sprite_sheet::wx_draw_sprite ( size_t  iSprite,
uint8_t *  pRGBData,
uint8_t *  pAData 
)

Draw a sprite into wxImage data arrays (for the Map Editor)

Parameters
iSpriteSprite number to draw.
pRGBDataOutput RGB data array.
pADataOutput Alpha channel array.

Friends And Related Symbol Documentation

◆ cursor


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