tbx
0.7.5
|
A SpriteArea holds zero or more user sprites. More...
#include <sprite.h>
Classes | |
class | iterator |
Iterator class for iterating through UserSprites in a sprite area. More... | |
Public Member Functions | |
SpriteArea () | |
Construct an uninitialised sprite area. | |
~SpriteArea () | |
Destructor deletes the RISC OS sprite area if it owns it. | |
SpriteArea (OsSpriteAreaPtr data, bool ownsarea=false) | |
Construct a SpriteArea from a RISC OS sprite area pointer. More... | |
SpriteArea (int size) | |
Construct an empty sprite area with the initial capacity. More... | |
SpriteArea (const SpriteArea &other) | |
Constructs a sprite area that is a copy of the given area. | |
SpriteArea & | operator= (const SpriteArea &other) |
Deletes current area and replaces it with a copy of the given area. | |
void | set (OsSpriteAreaPtr data, bool ownsarea=false) |
Assign this sprite area to a sprite area pointer. More... | |
bool | is_valid () const |
Returns true if area is valid. | |
bool | initialise (int size) |
Initialise a new user sprite area. More... | |
bool | load (const std::string &file_name) |
Load a sprite area from a file. More... | |
bool | merge (const std::string &file_name) |
Merge a sprite area from a file into this sprite area. More... | |
bool | save (const std::string &file_name) const |
Save the sprite area to a file. More... | |
int | size () const |
Get the size of the sprite area. More... | |
int | free_space () const |
Get the free space in the sprite area. More... | |
bool | resize (int new_size) |
Resize the sprite area. More... | |
int | sprite_count () const |
Return the number of sprites in the sprite area. | |
UserSprite | get_sprite (const std::string &name) |
Get a sprite from this sprite area by name. More... | |
UserSprite | create_sprite (const std::string &name, int width, int height, int mode, bool palette=false) |
Create a new sprite. More... | |
UserSprite | create_sprite_pixels (const std::string &name, int width, int height, int mode, bool palette=false) |
Create a new sprite, size measured in pixels. More... | |
OsSpriteAreaPtr | pointer () const |
Return pointer to underlying sprite are that can be used when using low-level area manipulation. | |
bool | rename (UserSprite &sprite, const std::string &newname) |
Rename a sprite in a sprite area. More... | |
bool | erase (UserSprite &sprite) |
Erase a sprite from the sprite area. More... | |
bool | erase (const std::string name) |
Erase the a sprite from the sprite area. More... | |
iterator | begin () |
Return an iterator to the first sprite in the sprite area. | |
iterator | end () |
Return an iterator to the sprite after the last one in the sprite area. More... | |
UserSprite | get_sprite (OsSpritePtr sprite_ptr) |
Get sprite for area given a pointer to it. More... | |
Static Public Member Functions | |
static int | calculate_memory (int width, int height, int mode, bool withPalette) |
Calculate the memory required to create a sprite. More... | |
static int | calculate_mask_size (int width, int height, int mode) |
Calculate the size required for a sprite mask. More... | |
static int | get_bits_per_pixel (int mode) |
Calculate the number of bits required for one pixel for the given mode. More... | |
A SpriteArea holds zero or more user sprites.
New sprites can be created within it.
SpriteArea::SpriteArea | ( | OsSpriteAreaPtr | data, |
bool | ownsarea = false |
||
) |
Construct a SpriteArea from a RISC OS sprite area pointer.
data | RISC OS sprite area pointer |
ownsarea | true if the SpriteArea now looks after the area |
SpriteArea::SpriteArea | ( | int | size | ) |
Construct an empty sprite area with the initial capacity.
size | size of area in bytes. |
|
static |
Calculate the size required for a sprite mask.
width | width of sprite in pixels |
height | height of sprite in pixels |
mode | screen mode for sprite |
|
static |
Calculate the memory required to create a sprite.
width | width of sprite in pixels |
height | height of sprite in pixels |
mode | screen mode to create the sprite for |
withPalette | true to create a palette for the sprite |
UserSprite SpriteArea::create_sprite | ( | const std::string & | name, |
int | width, | ||
int | height, | ||
int | mode, | ||
bool | palette = false |
||
) |
Create a new sprite.
name | name of sprite (max length 12) |
width | Width of sprite in OS units |
height | Height of sprite in OS units |
mode | - Use SpriteFormat enum or value returned from SpriteMode |
palette | - true to create with a palette |
UserSprite SpriteArea::create_sprite_pixels | ( | const std::string & | name, |
int | width, | ||
int | height, | ||
int | mode, | ||
bool | palette = false |
||
) |
Create a new sprite, size measured in pixels.
name | name of sprite (max length 12) |
width | Width of sprite in pixels |
height | Height of sprite in pixels |
mode | - Use SpriteFormat enum or value returned from SpriteMode |
palette | - true to create with a palette |
SpriteArea::iterator SpriteArea::end | ( | ) |
Return an iterator to the sprite after the last one in the sprite area.
This is always an invalid sprite
bool SpriteArea::erase | ( | UserSprite & | s | ) |
Erase a sprite from the sprite area.
s | sprite to erase |
bool SpriteArea::erase | ( | const std::string | name | ) |
Erase the a sprite from the sprite area.
name | Name of sprite to erase |
int SpriteArea::free_space | ( | ) | const |
Get the free space in the sprite area.
|
static |
Calculate the number of bits required for one pixel for the given mode.
mode | screen mode number |
UserSprite SpriteArea::get_sprite | ( | const std::string & | name | ) |
Get a sprite from this sprite area by name.
Check is_valid on returned sprite to check it was found.
UserSprite SpriteArea::get_sprite | ( | OsSpritePtr | sprite_ptr | ) |
Get sprite for area given a pointer to it.
sprite_ptr | - pointer to sprite |
std::out_of_range |
bool SpriteArea::initialise | ( | int | size | ) |
Initialise a new user sprite area.
size | size of sprite area in bytes |
bool SpriteArea::load | ( | const std::string & | file_name | ) |
Load a sprite area from a file.
file_name | name of sprite area file |
bool SpriteArea::merge | ( | const std::string & | file_name | ) |
Merge a sprite area from a file into this sprite area.
Warning: Any UserSprites returned from the area will be invalid
file_name | name of tile to merge sprites from |
bool SpriteArea::rename | ( | UserSprite & | s, |
const std::string & | name | ||
) |
Rename a sprite in a sprite area.
s | UserSprite to rename |
name | new name for the sprite |
bool SpriteArea::resize | ( | int | newSize | ) |
Resize the sprite area.
newSize | new size for the area |
bool SpriteArea::save | ( | const std::string & | file_name | ) | const |
Save the sprite area to a file.
file_name | name of file to save to |
void SpriteArea::set | ( | OsSpriteAreaPtr | data, |
bool | ownsarea = false |
||
) |
Assign this sprite area to a sprite area pointer.
data | RISC OS sprite area pointer |
ownsarea | true if the SpriteArea now looks after the area |
int SpriteArea::size | ( | ) | const |
Get the size of the sprite area.