diff options
| author | ilotterytea <iltsu@alright.party> | 2025-02-01 21:34:22 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-02-01 21:34:22 +0500 |
| commit | 30e261ce0220110db201e522e751b1c82c0b5683 (patch) | |
| tree | 5d0c32423c8e97da986d68400aaa18b7a425abd4 /src/tileset.cpp | |
| parent | fcb69fd43a029db9f230f701a51338a9fe2ea60b (diff) | |
feat: tileset
Diffstat (limited to 'src/tileset.cpp')
| -rw-r--r-- | src/tileset.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tileset.cpp b/src/tileset.cpp new file mode 100644 index 0000000..8651a8f --- /dev/null +++ b/src/tileset.cpp @@ -0,0 +1,28 @@ +#include "tileset.hpp" + +namespace silly::editor { + void Tileset::add_tile(const std::string &path, TilesetTileType type) { + TilesetTile tile; + tile.type = type; + tile.id = this->tiles.size(); + + if (!tile.texture.loadFromFile(path)) { + // TODO: add logging here + return; + } + + this->tiles.push_back(tile); + } + + void Tileset::remove_tile(const TilesetTile &tile) { + this->tiles.resize(std::distance( + this->tiles.begin(), + std::remove_if( + this->tiles.begin(), this->tiles.end(), + [&tile](const TilesetTile &t) { return t.id == tile.id; }))); + } + + const std::vector<TilesetTile> &Tileset::get_tiles() const { + return this->tiles; + } +}
\ No newline at end of file |
