| 225 | } |
| 226 | |
| 227 | String tilesetAssetPath(String const& relativePath) { |
| 228 | // Tiled stores tileset paths relative to the map file, which can go below |
| 229 | // the assets root if it's referencing a tileset in another asset package. |
| 230 | // The solution chosen here is to ignore everything in the path up until a |
| 231 | // known path segment, e.g.: |
| 232 | // "source" : "..\/..\/..\/..\/packed\/tilesets\/packed\/materials.json" |
| 233 | // We ignore everything up until the 'tilesets' path segment, and the asset |
| 234 | // we actually load is located at: |
| 235 | // /tilesets/packed/materials.json |
| 236 | |
| 237 | size_t i = relativePath.findLast("/tilesets/", String::CaseInsensitive); |
| 238 | if (i == NPos) |
| 239 | // Couldn't extract the right path, try the one we were given in the Json. |
| 240 | return relativePath; |
| 241 | return relativePath.slice(i); |
| 242 | } |
| 243 | |
| 244 | TMXTilesets::TMXTilesets(Json const& tmx) { |
| 245 | for (Json const& tilesetJson : tmx.iterateArray()) { |
no test coverage detected