advanced-spritesheet-export/abase-commands.lua

62 lines
1.6 KiB
Lua
Raw Normal View History

2024-07-30 01:25:14 +00:00
-- New commands to be executed via Aseprite menus / keyboard shortcuts
2024-07-31 02:58:23 +00:00
local l = require "abase-layer"
local c = require "abase-color"
local p = require "abase-properties"
2024-07-30 01:25:14 +00:00
local function ExportSpritesheetAdvanced()
if not app.sprite then
return app.alert "Must have a sprite open to export."
end
local spr = Sprite(app.sprite)
l.RevealLayers(spr.layers)
2024-07-31 02:58:23 +00:00
l.DeleteLayers(spr, spr.layers)
l.FlattenLayers(spr.layers)
2024-07-30 01:25:14 +00:00
app.command.ExportSpriteSheet {
splitLayers = true
}
spr:close()
end
-- Toggle ignore for all selected layers
local function ToggleIgnore()
2024-07-31 02:58:23 +00:00
-- Determine whether we are setting or clearing the flag
local ignore = false
for _, layer in ipairs(app.range.layers) do
2024-07-31 02:58:23 +00:00
if not p.IsIgnored(layer) then
ignore = true
end
end
2024-07-31 02:58:23 +00:00
for _, layer in ipairs(app.range.layers) do
p.SetIgnored(layer, ignore)
c.SetColorFromRoot(layer)
2024-07-30 01:25:14 +00:00
end
end
-- Toggle Merge on Export for all selected group layers
local function ToggleExportAsSprite()
2024-07-31 02:58:23 +00:00
-- Determine whether we are setting or clearing the flag
local merge = false
for _, layer in ipairs(app.range.layers) do
if layer.isGroup and not p.IsMerged(layer) then
merge = true
end
end
for _, layer in ipairs(app.range.layers) do
2024-07-31 02:58:23 +00:00
p.SetMerged(layer, merge)
c.SetColorFromRoot(layer)
end
end
2024-07-30 01:25:14 +00:00
local export = {
ExportSpritesheetAdvanced = ExportSpritesheetAdvanced,
ToggleIgnore = ToggleIgnore,
ToggleExportAsSprite = ToggleExportAsSprite
}
return export