| 196 | } |
| 197 | |
| 198 | std::vector<TexposHandle> Textures::loadTileset(const std::filesystem::path file, int tile_px_w, |
| 199 | int tile_px_h, bool reserved) { |
| 200 | if (g_tileset_to_handles.contains(file)) |
| 201 | return g_tileset_to_handles[file]; |
| 202 | if (!enabler) |
| 203 | return std::vector<TexposHandle>{}; |
| 204 | |
| 205 | SDL_Surface* surface = DFIMG_Load(file.string().c_str()); |
| 206 | if (!surface) { |
| 207 | ERR(textures).printerr("unable to load textures from '{}'\n", file); |
| 208 | return std::vector<TexposHandle>{}; |
| 209 | } |
| 210 | |
| 211 | surface = canonicalize_format(surface); |
| 212 | auto handles = slice_tileset(surface, tile_px_w, tile_px_h, reserved); |
| 213 | |
| 214 | DEBUG(textures).print("loaded {} textures from '{}'\n", handles.size(), file); |
| 215 | g_tileset_to_handles[file] = handles; |
| 216 | |
| 217 | return handles; |
| 218 | } |
| 219 | |
| 220 | long Textures::getTexposByHandle(TexposHandle handle) { |
| 221 | if (!handle || !enabler) |
nothing calls this directly
no test coverage detected