23#ifndef CORSIX_TH_TH_GFX_H_
24#define CORSIX_TH_TH_GFX_H_
134 int drawing_layer{0};
150 chunk_renderer(
int width,
int height, std::vector<uint8_t>::iterator start);
160 void decode_chunks(
const uint8_t* pData,
int iDataLen,
bool bComplex);
163 void chunk_copy(
int npixels,
const uint8_t* in_data);
175 inline bool is_done()
const {
return ptr == end; }
176 inline void fix_n_pixels(
int& npixels)
const;
177 inline void increment_position(
int npixels);
179 std::vector<uint8_t>::iterator ptr, end;
182 bool skip_eol{
false};
327 size_t patient_effect_offset = 0)
const;
376 int primary_marker_x;
378 int primary_marker_y;
380 int secondary_marker_x;
382 int secondary_marker_y;
400 std::vector<size_t> first_frames;
401 std::vector<frame> frames;
402 std::vector<uint16_t> element_list;
403 std::vector<element> elements;
404 std::vector<sprite_sheet>
411 size_t animation_count{0};
412 size_t frame_count{0};
413 size_t element_list_count{0};
414 size_t element_count{0};
417 size_t game_ticks{0};
423 void set_bounding_box(frame&
oFrame);
579 size_t animation_index{};
580 size_t frame_index{};
589 size_t sound_to_play{};
595 size_t patient_effect_offset;
610 bool is_dead()
const {
return lifetime == 0; }
637 std::vector<sprite> sprites{};
647 bool use_intermediate_buffer{
false};
659 L,
idx, {
"animation",
"spriteList"});
void remove_from_tile()
Definition th_gfx.cpp:1141
const xy_pair & get_pixel_offset() const
Definition th_gfx.h:472
void set_tile(const xy_pair &tile_pos)
Definition th_gfx.h:476
xy_pair pixel_offset
Offset in pixels relative to the center of the animation tile.
Definition th_gfx.h:489
xy_pair tile
Tile containing the animation. A negative x or y means it is not active.
Definition th_gfx.h:486
uint32_t get_flags() const
Definition th_gfx.h:471
void attach_to_tile(const xy_pair &tile_pos, map_tile *node, int layer)
Definition th_gfx.cpp:1146
void set_flags(uint32_t iFlags)
Definition th_gfx.h:475
void set_layer(int iLayer, int iId)
Definition th_gfx.cpp:1174
const xy_pair & get_tile() const
Definition th_gfx.h:473
void set_pixel_offset(int x, int y)
Definition th_gfx.h:477
animation_base()
Definition th_gfx.cpp:1139
void set_layers_from(const animation_base *pSrc)
Definition th_gfx.h:482
Theme Hospital sprite animation manager.
Definition th_gfx.h:234
size_t get_frame_sound(size_t iFrame)
Definition th_gfx.cpp:984
bool load_from_th_file(const uint8_t *pStartData, size_t iStartDataLength, const uint8_t *pFrameData, size_t iFrameDataLength, const uint8_t *pListData, size_t iListDataLength, const uint8_t *pElementData, size_t iElementDataLength)
Load original animations.
Definition th_gfx.cpp:188
void set_sprite_sheet(sprite_sheet *pSpriteSheet)
Definition th_gfx.cpp:143
bool set_frame_secondary_marker(size_t iFrame, int iX, int iY)
Definition th_gfx.cpp:815
void set_animation_alt_palette_map(size_t iAnimation, const uint8_t *pMap, uint32_t iAlt32)
Set the palette remap data for an animation.
Definition th_gfx.cpp:777
void get_frame_extent(size_t iFrame, const ::layers &oLayers, int *pMinX, int *pMaxX, int *pMinY, int *pMaxY, uint32_t iFlags) const
Definition th_gfx.cpp:992
animation_manager()=default
bool hit_test(size_t iFrame, const ::layers &oLayers, int iX, int iY, uint32_t iFlags, int iTestX, int iTestY) const
Definition th_gfx.cpp:850
size_t get_next_frame(size_t iFrame) const
Get the index of the frame after a given frame.
Definition th_gfx.cpp:769
bool get_frame_primary_marker(size_t iFrame, int *pX, int *pY)
Definition th_gfx.cpp:826
void draw_frame(render_target *pCanvas, size_t iFrame, const ::layers &oLayers, int iX, int iY, uint32_t iFlags, animation_effect patient_effect=animation_effect::none, size_t patient_effect_offset=0) const
Draw an animation frame.
Definition th_gfx.cpp:919
size_t get_frame_count() const
Get the total number of animation frames.
Definition th_gfx.cpp:759
void tick()
Notified every world tick to allow tracking rate of game time passage.
Definition th_gfx.cpp:848
bool get_frame_secondary_marker(size_t iFrame, int *pX, int *pY)
Definition th_gfx.cpp:837
bool set_frame_primary_marker(size_t iFrame, int iX, int iY)
Definition th_gfx.cpp:804
const animation_start_frames & get_named_animations(std::string_view sName, int iTilesize) const
Retrieve a custom animation by name and tile size.
Definition th_gfx.cpp:740
size_t get_animation_count() const
Get the total number of animations.
Definition th_gfx.cpp:755
size_t get_first_frame(size_t iAnimation) const
Get the index of the first frame of an animation.
Definition th_gfx.cpp:761
bool load_custom_animations(const uint8_t *pData, size_t iDataLength)
Load free animations.
Definition th_gfx.cpp:498
void set_canvas(render_target *pCanvas)
Set the video target.
Definition th_gfx.cpp:370
void draw_fn(render_target *canvas, const xy_pair &draw_pos) override
Draw the object at a specific point on a render target.
Definition th_gfx.h:509
bool hit_test_fn(const xy_pair &draw_pos, const xy_pair &obj_pos) override
Perform a hit test against the object.
Definition th_gfx.h:530
animation()
Definition th_gfx.cpp:1188
void tick()
Definition th_gfx.cpp:1548
void depersist(lua_persist_reader *reader)
Definition th_gfx.cpp:1378
bool hit_test_child(const xy_pair &draw_pos, const xy_pair &obj_pos)
Definition th_gfx.cpp:1236
void draw(render_target *canvas, const xy_pair &draw_pos)
Definition th_gfx.cpp:1190
void set_animation_kind(animation_kind anim_kind)
Definition th_gfx.cpp:1483
bool hit_test_morph(const xy_pair &draw_pos, const xy_pair &obj_pos)
Definition th_gfx.cpp:1289
size_t get_frame() const
Definition th_gfx.h:554
xy_pair speed
Speed in pixels per tick.
Definition th_gfx.h:582
void set_frame(size_t new_frame)
Definition th_gfx.cpp:1710
void set_crop_column(int column)
Definition th_gfx.h:565
void draw_child(render_target *canvas, const xy_pair &draw_pos, bool use_primary)
Definition th_gfx.cpp:1216
void set_speed(int x, int y)
Definition th_gfx.h:561
int get_crop_column() const
Definition th_gfx.h:555
bool hit_test(const xy_pair &draw_pos, const xy_pair &obj_pos)
Definition th_gfx.cpp:1275
void draw_morph(render_target *canvas, const xy_pair &draw_pos)
Definition th_gfx.cpp:1242
void set_animation(animation_manager *mgr, size_t anim)
Definition th_gfx.cpp:1589
size_t get_animation() const
Definition th_gfx.h:551
bool get_primary_marker(int *pX, int *pY)
Definition th_gfx.cpp:1600
void persist(lua_persist_writer *writer) const
Definition th_gfx.cpp:1305
void set_parent(animation *parent_anim, bool use_primary)
Definition th_gfx.cpp:1573
bool is_multiple_frame_animation_fn() override
Definition th_gfx.h:543
void set_morph_target(animation *target, int duration=1)
Definition th_gfx.cpp:1659
animation_manager * get_animation_manager()
Definition th_gfx.h:574
link_list * get_previous()
Definition th_gfx.h:550
animation_kind get_animation_kind()
Definition th_gfx.h:572
animation * parent
Definition th_gfx.h:586
void set_patient_effect(animation_effect patient_effect)
Definition th_gfx.cpp:1479
bool get_secondary_marker(int *pX, int *pY)
Definition th_gfx.cpp:1614
void chunk_fill_to_end_of_line(uint8_t value)
Perform a "fill to end of line" chunk (normally called by decodeChunks)
Definition th_gfx.cpp:1038
void chunk_copy(int npixels, const uint8_t *in_data)
Perform a "copy" chunk (normally called by decodeChunks)
Definition th_gfx.cpp:1057
void decode_chunks(const uint8_t *pData, int iDataLen, bool bComplex)
Convert a stream of chunks into a raw bitmap.
Definition th_gfx.cpp:1079
void chunk_fill(int npixels, uint8_t value)
Perform a "fill" chunk (normally called by decodeChunks)
Definition th_gfx.cpp:1049
void chunk_finish(uint8_t value)
Perform a "fill to end of file" chunk (normally called by decodeChunks)
Definition th_gfx.cpp:1045
Generic linked list class (for inheriting from)
Definition th.h:30
link_list * prev
Definition th.h:35
Interface used for depersisting Lua objects.
Definition persist_lua.h:107
Interface used for persisting Lua objects.
Definition persist_lua.h:44
Definition th_gfx_sdl.h:247
bool hit_test(const xy_pair &draw_pos, const xy_pair &obj_pos)
Definition th_gfx.cpp:1752
void append_sprite(size_t spr_num, int xpos, int ypos)
Definition th_gfx.cpp:1769
bool is_multiple_frame_animation_fn() override
Definition th_gfx.h:627
void persist(lua_persist_writer *writer) const
Definition th_gfx.cpp:1774
void depersist(lua_persist_reader *reader)
Definition th_gfx.cpp:1813
bool is_dead() const
Definition th_gfx.h:610
void set_use_intermediate_buffer()
Definition th_gfx.cpp:1765
void draw_fn(render_target *canvas, const xy_pair &draw_pos) override
Draw the object at a specific point on a render target.
Definition th_gfx.h:617
bool hit_test_fn(const xy_pair &draw_pos, const xy_pair &obj_pos) override
Perform a hit test against the object.
Definition th_gfx.h:623
void set_speed(int x_speed, int y_speed)
Definition th_gfx.h:603
void set_lifetime(int life_time)
Definition th_gfx.cpp:1758
void tick()
Definition th_gfx.cpp:1712
void set_sheet(sprite_sheet *new_sheet)
Definition th_gfx.h:602
void draw(render_target *canvas, const xy_pair &draw_pos)
Definition th_gfx.cpp:1720
Sheet of sprites.
Definition th_gfx_sdl.h:504
int tile_size
Size of a tile.
Definition th_gfx.h:197
std::string name
Name of the animations.
Definition th_gfx.h:196
long north
Animation start frame for the 'north' view.
Definition th_gfx.h:216
long south
Animation start frame for the 'south' view.
Definition th_gfx.h:218
long west
Animation start frame for the 'west' view.
Definition th_gfx.h:219
long east
Animation start frame for the 'east' view.
Definition th_gfx.h:217
Definition th_gfx_sdl.h:43
virtual void draw_fn(render_target *canvas, const xy_pair &draw_pos)=0
Draw the object at a specific point on a render target.
virtual bool is_multiple_frame_animation_fn()=0
int get_drawing_layer()
Definition th_gfx.h:127
void set_drawing_layer(int layer)
Definition th_gfx.h:128
virtual bool hit_test_fn(const xy_pair &draw_pos, const xy_pair &obj_pos)=0
Perform a hit test against the object.
uint32_t flags
Drawing flags (zero or more list flags from draw_flags).
Definition th_gfx.h:131
Layer information (see animation_manager::draw_frame)
Definition th_gfx.h:190
uint8_t layer_contents[max_number_of_layers]
Definition th_gfx.h:191
int x
Value of the X coordinate.
Definition th_gfx.h:96
int y
Value of the Y coordinate.
Definition th_gfx.h:97
bool operator<(const animation_key &oK, const animation_key &oL)
Less-than operator for map-sorting.
Definition th_gfx.h:206
std::map< animation_key, animation_start_frames > named_animations_map
Definition th_gfx.h:223
draw_flags
Bitflags for drawing operations.
Definition th_gfx.h:50
@ thdf_alt32_blue_red_swap
Draw the sprite with red and blue colours swapped.
Definition th_gfx.h:80
@ thdf_alt_palette
Draw using a remapped palette.
Definition th_gfx.h:65
@ thdf_flip_horizontal
Draw with the left becoming the right and vice versa.
Definition th_gfx.h:55
@ thdf_alt32_start
Lowest bit of the field.
Definition th_gfx.h:71
@ thdf_bound_box_hit_test
Hit-test using bounding-box precision rather than pixel-perfect.
Definition th_gfx.h:87
@ thdf_flip_vertical
Draw with the top becoming the bottom and vice versa.
Definition th_gfx.h:57
@ thdf_early_list
Attach to the early sprite list (right-to-left pass)
Definition th_gfx.h:84
@ thdf_alpha_50
Definition th_gfx.h:60
@ thdf_alt32_grey_scale
Draw the sprite in grey scale.
Definition th_gfx.h:78
@ thdf_alpha_75
Definition th_gfx.h:63
@ thdf_alt32_plain
Draw the sprite with the normal palette (fallback option).
Definition th_gfx.h:76
@ thdf_nearest
Draw using nearest pixel hinting.
Definition th_gfx.h:91
@ thdf_crop
Apply a cropping operation prior to drawing.
Definition th_gfx.h:89
@ thdf_alt32_mask
Mask for the 32bpp alternative drawing values.
Definition th_gfx.h:73
std::pair< animation_key, animation_start_frames > named_animation_pair
Definition th_gfx.h:226
animation_kind
The kind of animation.
Definition th_gfx.h:495
scaled_items
Definition th_gfx.h:45
const int max_number_of_layers
Number of available layers, must be less or equal to 16 as it is stored in.
Definition th_gfx.h:187
void clip_rect_intersection(clip_rect &rcClip, const clip_rect &rcIntersect)
animation_base * luaT_toanimationbase(lua_State *L, int idx)
Definition th_gfx.h:657
animation_effect
Animation Effect for drawing a sprite with a special effect applied.
Definition th_gfx_common.h:30