diff --git a/init.lua b/init.lua index 5cd0baf..e9ce8ba 100644 --- a/init.lua +++ b/init.lua @@ -1210,6 +1210,38 @@ function M.atlas_id_at(idx, map_id) or m.atlases[idx + 1] and m.atlases[idx + 1].id end +-- 0.5.4: Public accessors for palette-like consumers (map-editor) that +-- need to render real tile thumbnails. All three return nil when the +-- atlas-idx is out of range, the slot has no tile in the atlas, or the +-- texture failed to load (headless test env). +function M.atlas_diffuse_handle(atlas_idx, map_id) + local id = map_id or current_map_id + if not id then error("maps.atlas_diffuse_handle: no current map") end + local m = map_registry[id] + local atlas = m.atlases and m.atlases[atlas_idx + 1] + return atlas and atlas.diffuse_texture_handle or nil +end + +function M.atlas_tile_size_px(atlas_idx, map_id) + local id = map_id or current_map_id + if not id then error("maps.atlas_tile_size_px: no current map") end + local m = map_registry[id] + local atlas = m.atlases and m.atlases[atlas_idx + 1] + return atlas and atlas.tile_size_px or nil +end + +function M.atlas_tile_uv(atlas_idx, slot, map_id) + local id = map_id or current_map_id + if not id then error("maps.atlas_tile_uv: no current map") end + local m = map_registry[id] + local atlas = m.atlases and m.atlases[atlas_idx + 1] + if not atlas or not atlas.tiles then return nil end + local slot_idx = atlas_slot_index(atlas) + local tile_id = slot_idx[slot] + local tile = tile_id and atlas.tiles[tile_id] + return tile and tile.uv or nil +end + function M.has_layer(layer_name, map_id) local id = map_id or current_map_id if not id then error("maps.has_layer: no current map") end diff --git a/manifest.lib b/manifest.lib index 6f71f74..bf04fce 100644 --- a/manifest.lib +++ b/manifest.lib @@ -1 +1 @@ -{"id":"lib-core.maps","version":"0.5.3","api_min":"0.1"} +{"id":"lib-core.maps","version":"0.5.4","api_min":"0.1"}