MCPcopy Create free account
hub / github.com/DFHack/dfhack / loadTileset

Method loadTileset

library/modules/Textures.cpp:198–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198std::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
220long Textures::getTexposByHandle(TexposHandle handle) {
221 if (!handle || !enabler)

Callers

nothing calls this directly

Calls 6

canonicalize_formatFunction · 0.85
slice_tilesetFunction · 0.85
containsMethod · 0.80
c_strMethod · 0.80
printMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected