diff --git a/src/tiler.cpp b/src/tiler.cpp index 8b92e9fc..f484a547 100644 --- a/src/tiler.cpp +++ b/src/tiler.cpp @@ -67,6 +67,32 @@ void Tiler::Deregister(int id) data->tilesets.RemoveSlot(id - 1); /* ID 0 is for the empty tileset */ } +int2 Tiler::GetSize(int id) +{ + TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id - 1); +#if !FINAL_RELEASE + if (!tileset) + { + fprintf(stderr, "ERROR: getting size for null tiler #%i\n", id); + return 0; + } +#endif + return tileset->GetSize(); +} + +int2 Tiler::GetCount(int id) +{ + TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id - 1); +#if !FINAL_RELEASE + if (!tileset) + { + fprintf(stderr, "ERROR: getting count for null tiler #%i\n", id); + return 0; + } +#endif + return tileset->GetCount(); +} + void Tiler::BlitTile(uint32_t code, int x, int y, int z, int o) { int id = (code >> 16) - 1; /* ID 0 is for the empty tileset */ diff --git a/src/tiler.h b/src/tiler.h index 35202ae8..0c8d3484 100644 --- a/src/tiler.h +++ b/src/tiler.h @@ -25,6 +25,8 @@ public: static int Register(char const *path, int2 size, int2 count, float dilate); static void Deregister(int id); + static int2 GetSize(int id); + static int2 GetCount(int id); static void BlitTile(uint32_t code, int x, int y, int z, int o); }; diff --git a/src/tileset.cpp b/src/tileset.cpp index 572f8a3b..b29a52d1 100644 --- a/src/tileset.cpp +++ b/src/tileset.cpp @@ -157,6 +157,16 @@ char const *TileSet::GetName() return data->name; } +int2 TileSet::GetSize() const +{ + return data->size; +} + +int2 TileSet::GetCount() const +{ + return data->count; +} + void TileSet::BlitTile(uint32_t id, int x, int y, int z, int o) { float tx = data->tx * ((id & 0xffff) % data->count.i); diff --git a/src/tileset.h b/src/tileset.h index 73adeacc..b7c45f76 100644 --- a/src/tileset.h +++ b/src/tileset.h @@ -38,6 +38,8 @@ protected: public: /* New methods */ + int2 GetSize() const; + int2 GetCount() const; void BlitTile(uint32_t id, int x, int y, int z, int o); private: