| 188 | } |
| 189 | |
| 190 | TMXMap::TMXMap(Json const& tmx) { |
| 191 | if (tmx.getUInt("tileheight") != 8 || tmx.getUInt("tilewidth") != 8) |
| 192 | throw StarException("Invalid tile size"); |
| 193 | |
| 194 | m_width = tmx.getUInt("width"); |
| 195 | m_height = tmx.getUInt("height"); |
| 196 | |
| 197 | m_tilesets = make_shared<TMXTilesets>(tmx.getArray("tilesets")); |
| 198 | |
| 199 | for (Json const& tmxLayer : tmx.get("layers").iterateArray()) { |
| 200 | String layerType = tmxLayer.getString("type"); |
| 201 | |
| 202 | if (layerType == "tilelayer") { |
| 203 | TMXTileLayerPtr layer = make_shared<TMXTileLayer>(tmxLayer); |
| 204 | m_tileLayers.append(layer); |
| 205 | |
| 206 | } else if (layerType == "objectgroup") { |
| 207 | TMXObjectGroupPtr group = make_shared<TMXObjectGroup>(tmxLayer, m_tilesets); |
| 208 | m_objectGroups.append(group); |
| 209 | |
| 210 | } else { |
| 211 | throw StarException(strf("Unknown layer type '{}'", layerType.utf8Ptr())); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | Tiled::Tile const& TMXTileLayer::getTile(TMXTilesetsPtr const& tilesets, Vec2I pos) const { |
| 217 | if (!m_rect.contains(pos)) |
nothing calls this directly
no test coverage detected