![]() |
Peoplemon
0.1.0
Peoplemon 3 game source documentation
|
Stores the collection of images and animations used by Tiles in a Map. More...
#include <Tileset.hpp>
Public Types | |
using | TileStore = std::unordered_map< Tile::IdType, bl::resource::Ref< sf::Image > > |
using | AnimStore = std::unordered_map< Tile::IdType, bl::resource::Ref< bl::gfx::a2d::AnimationData > > |
Public Member Functions | |
Tileset () | |
Creates an empty Tileset. More... | |
Tile::IdType | addTexture (const std::string &uri) |
Adds a texture to the tileset and returns its id. More... | |
void | removeTexture (Tile::IdType id) |
Removes the given texture from the tileset. Undefined behavior if any tiles reference it. Care must be taken to blank those tiles before the next render. More... | |
Tile::IdType | addAnimation (const std::string &uri) |
Adds the given animation to the tileset and returns its id. More... | |
void | removeAnimation (Tile::IdType id) |
Removes the given animation from the tileset. Undefined behavior if any tiles reference it. Care must be taken to blank those tiles before the next render. More... | |
unsigned int | tileHeight (Tile::IdType id, bool isAnim) const |
Returns the height of the requested tile, in pixels. More... | |
bool | loadDev (std::istream &input) |
Loads the tileset from the development format data. More... | |
bool | loadProd (bl::serial::binary::InputStream &input) |
Loads the tileset from the production format data. More... | |
bool | save (const std::string &file) const |
Saves the tileset to the given file. No media is saved. More... | |
bool | saveBundle (bl::serial::binary::OutputStream &output, bl::resource::bundle::FileHandlerContext &ctx) const |
Saves the data from this object to the given bundle and registers dependency files. More... | |
void | activate (bl::engine::Engine &engine) |
Prepares renderer resources and starts playing all shared animations. More... | |
bl::resource::Ref< sf::Image > | getTile (Tile::IdType id) const |
Returns a tile from the set. Returns nullptr if not found. More... | |
std::vector< TileStore::const_iterator > | getTiles () const |
Returns all contained tiles. More... | |
bl::resource::Ref< bl::gfx::a2d::AnimationData > | getAnim (Tile::IdType id) const |
Returns an animation from the set. Returns nullptr if not found. More... | |
std::vector< AnimStore::const_iterator > | getAnims () const |
Returns all contained animations. More... | |
sf::FloatRect | getTileTextureBounds (Tile::IdType tid) const |
Returns the normalized texture coordinates for the given tile id. More... | |
Static Public Member Functions | |
static std::string | getFullPath (const std::string &path) |
Generates the full path to the given tileset file. More... | |
Friends | |
class | Map |
struct | bl::serial::SerializableObject< Tileset > |
Stores the collection of images and animations used by Tiles in a Map.
Definition at line 23 of file Tileset.hpp.
using core::map::Tileset::AnimStore = std::unordered_map<Tile::IdType, bl::resource::Ref<bl::gfx::a2d::AnimationData> > |
Definition at line 26 of file Tileset.hpp.
using core::map::Tileset::TileStore = std::unordered_map<Tile::IdType, bl::resource::Ref<sf::Image> > |
Definition at line 25 of file Tileset.hpp.
core::map::Tileset::Tileset | ( | ) |
Creates an empty Tileset.
Definition at line 9 of file Tileset.cpp.
void core::map::Tileset::activate | ( | bl::engine::Engine & | engine | ) |
Prepares renderer resources and starts playing all shared animations.
engine | The game engine instance |
Definition at line 56 of file Tileset.cpp.
Tile::IdType core::map::Tileset::addAnimation | ( | const std::string & | uri | ) |
Adds the given animation to the tileset and returns its id.
uri | The path to the animation |
Definition at line 35 of file Tileset.cpp.
Tile::IdType core::map::Tileset::addTexture | ( | const std::string & | uri | ) |
Adds a texture to the tileset and returns its id.
uri | The path of the texture to add |
Definition at line 14 of file Tileset.cpp.
bl::resource::Ref< bl::gfx::a2d::AnimationData > core::map::Tileset::getAnim | ( | Tile::IdType | id | ) | const |
Returns an animation from the set. Returns nullptr if not found.
id | The id of the animation to get |
Definition at line 175 of file Tileset.cpp.
std::vector< Tileset::AnimStore::const_iterator > core::map::Tileset::getAnims | ( | ) | const |
Returns all contained animations.
Definition at line 180 of file Tileset.cpp.
|
static |
Generates the full path to the given tileset file.
path | The relative tileset path |
Definition at line 190 of file Tileset.cpp.
bl::resource::Ref< sf::Image > core::map::Tileset::getTile | ( | Tile::IdType | id | ) | const |
Returns a tile from the set. Returns nullptr if not found.
id | The id of the tile to get |
Definition at line 160 of file Tileset.cpp.
std::vector< Tileset::TileStore::const_iterator > core::map::Tileset::getTiles | ( | ) | const |
Returns all contained tiles.
Definition at line 165 of file Tileset.cpp.
sf::FloatRect core::map::Tileset::getTileTextureBounds | ( | Tile::IdType | tid | ) | const |
Returns the normalized texture coordinates for the given tile id.
tid | The tile id to get the texture coordinates for |
Definition at line 194 of file Tileset.cpp.
bool core::map::Tileset::loadDev | ( | std::istream & | input | ) |
Loads the tileset from the development format data.
input | The input stream to load from |
Definition at line 97 of file Tileset.cpp.
bool core::map::Tileset::loadProd | ( | bl::serial::binary::InputStream & | input | ) |
Loads the tileset from the production format data.
input | The input stream to load from |
Definition at line 113 of file Tileset.cpp.
void core::map::Tileset::removeAnimation | ( | Tile::IdType | id | ) |
Removes the given animation from the tileset. Undefined behavior if any tiles reference it. Care must be taken to blank those tiles before the next render.
id | The id of the animation to remove |
Definition at line 50 of file Tileset.cpp.
void core::map::Tileset::removeTexture | ( | Tile::IdType | id | ) |
Removes the given texture from the tileset. Undefined behavior if any tiles reference it. Care must be taken to blank those tiles before the next render.
id | The id of the texture to remove |
Definition at line 30 of file Tileset.cpp.
bool core::map::Tileset::save | ( | const std::string & | file | ) | const |
Saves the tileset to the given file. No media is saved.
file | The file to save to |
Definition at line 138 of file Tileset.cpp.
bool core::map::Tileset::saveBundle | ( | bl::serial::binary::OutputStream & | output, |
bl::resource::bundle::FileHandlerContext & | ctx | ||
) | const |
Saves the data from this object to the given bundle and registers dependency files.
output | Stream to output to |
ctx | Context to register dependencies with |
Definition at line 145 of file Tileset.cpp.
unsigned int core::map::Tileset::tileHeight | ( | Tile::IdType | id, |
bool | isAnim | ||
) | const |
Returns the height of the requested tile, in pixels.
id | The id of the tile |
isAnim | True for animation, false for sprite |
Definition at line 83 of file Tileset.cpp.
|
friend |
Definition at line 175 of file Tileset.hpp.
|
friend |
Definition at line 175 of file Tileset.hpp.