[lua] Sprite:newTileset() uses sprite grid size by default (fix #4116)

This commit is contained in:
David Capello 2023-10-30 13:45:11 -03:00
parent bb60da8c60
commit 557b22a719
2 changed files with 12 additions and 1 deletions

View File

@ -625,7 +625,7 @@ int Sprite_newTileset(lua_State* L)
tileset = Tileset::MakeCopyCopyingImages(reference);
}
else {
Grid grid;
Grid grid(sprite->gridBounds().size()); // Use sprite grid bounds by default
int ntiles = 1;
if (!lua_isnone(L, 2)) {
if (auto g = may_get_obj<Grid>(L, 2)) {

View File

@ -310,3 +310,14 @@ do
0, 0 })
end
-- Test that we use the sprite grid size by default to create new tilesets
do
local spr = Sprite(32, 32, ColorMode.INDEXED)
local ts = spr:newTileset()
assert(ts.grid.tileSize == Size(16, 16))
spr.gridBounds = Rectangle(1, 2, 3, 4)
ts = spr:newTileset()
assert(ts.grid.tileSize == Size(3, 4))
end