Skip to content

Commit

Permalink
Version 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
RampantDespair committed Nov 14, 2023
1 parent 1fc70e2 commit cfbcf0e
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 22 deletions.
121 changes: 100 additions & 21 deletions Aseprite-Exporter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Export(activeSprite, rootLayer, fileName, fileNameTemplate, dlgData)
ExportSpineJsonStart(fileName, dlgData)
end

if dlgData.setRootPostion == true and dlgData.rootPostionMethod == "automatic" then
if dlgData.exportSpineSheet == true and dlgData.setRootPostion == true and dlgData.rootPostionMethod == "automatic" then
for _, layer in ipairs(rootLayer.layers) do
if layer.name == "root" then
RootPositon = layer.cels[1].position
Expand Down Expand Up @@ -121,8 +121,12 @@ function ExportSpineJsonStart(fileName, dlgData)

Json:write('{ ')
Json:write('"skeleton": { ')
Json:write(string.format([["images": "%s", ]], "./" .. dlgData.imagesPath .. "/"))
Json:write(string.format([["audio": "%s" ]], "./" .. dlgData.audioPath .. "/"))

if dlgData.setSpinePaths then
Json:write(string.format([["images": "%s", ]], "./" .. dlgData.spineImagesPath .. "/"))
Json:write(string.format([["audio": "%s" ]], "./" .. dlgData.spineAudioPath .. "/"))
end

Json:write('}, ')
Json:write('"bones": [ { ')
Json:write('"name": "root" ')
Expand Down Expand Up @@ -291,30 +295,25 @@ dlg:file{
onchange = function()
dlg:modify{
id = "outputPath",
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.imagesPath)
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.outputSubdirectory)
}
end
}
dlg:entry{
id = "imagesPath",
label = "Images Path:",
text = "sprite",
id = "outputSubdirectory",
label = "Output Subdirectory:",
text = "images",
onchange = function()
dlg:modify{
id = "outputPath",
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.imagesPath)
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.outputSubdirectory)
}
end
}
dlg:entry{
id = "audioPath",
label = "Audio Path:",
text = "sound"
}
dlg:label{
id = "outputPath",
label = "Output Path:",
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.imagesPath)
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.outputSubdirectory)
}
dlg:separator{
id = "separator2",
Expand All @@ -325,6 +324,10 @@ dlg:check{
label = "Export SpriteSheet:",
selected = true,
onclick = function()
dlg:modify{
id = "exportSpriteNameTrim",
visible = dlg.data.exportSpriteSheet
}
dlg:modify{
id = "exportFileNameFormat",
visible = dlg.data.exportSpriteSheet
Expand All @@ -339,6 +342,11 @@ dlg:check{
}
end
}
dlg:check{
id = "exportSpriteNameTrim",
label = " Sprite Name Trim:",
selected = true
}
dlg:entry{
id = "exportFileNameFormat",
label = " File Name Format:",
Expand All @@ -362,11 +370,41 @@ dlg:separator{
dlg:check{
id = "exportSpineSheet",
label = "Export SpineSheet:",
selected = true
selected = true,
onclick = function()
dlg:modify{
id = "setRootPostion",
visible = dlg.data.exportSpineSheet
}
dlg:modify{
id = "rootPostionMethod",
visible = dlg.data.exportSpineSheet
}
dlg:modify{
id = "rootPositionX",
visible = dlg.data.exportSpineSheet and dlg.data.rootPostionMethod == "manual"
}
dlg:modify{
id = "rootPositionY",
visible = dlg.data.exportSpineSheet and dlg.data.rootPostionMethod == "manual"
}
dlg:modify{
id = "setSpinePaths",
visible = dlg.data.exportSpineSheet
}
dlg:modify{
id = "spineImagesPath",
visible = dlg.data.exportSpineSheet and dlg.data.setSpinePaths
}
dlg:modify{
id = "spineAudioPath",
visible = dlg.data.exportSpineSheet and dlg.data.setSpinePaths
}
end
}
dlg:check{
id = "setRootPostion",
label = "Set Root position:",
label = " Set Root Position:",
selected = true,
onclick = function()
dlg:modify{
Expand All @@ -375,17 +413,17 @@ dlg:check{
}
dlg:modify{
id = "rootPositionX",
visible = dlg.data.setRootPostion
visible = dlg.data.setRootPostion and dlg.data.rootPostionMethod == "manual"
}
dlg:modify{
id = "rootPositionY",
visible = dlg.data.setRootPostion
visible = dlg.data.setRootPostion and dlg.data.rootPostionMethod == "manual"
}
end
}
dlg:combobox{
id = "rootPostionMethod",
label = " Root position method:",
label = " Root position Method:",
option = "automatic",
options = {"manual", "automatic"},
onchange = function()
Expand All @@ -401,18 +439,43 @@ dlg:combobox{
}
dlg:number{
id = "rootPositionX",
label = " Root Postion X:",
label = " Root Postion X:",
text = "0",
decimals = 0,
visible = false
}
dlg:number{
id = "rootPositionY",
label = " Root Postion Y:",
label = " Root Postion Y:",
text = "0",
decimals = 0,
visible = false
}
dlg:check{
id = "setSpinePaths",
label = " Set Spine Paths:",
selected = true,
onclick = function()
dlg:modify{
id = "spineImagesPath",
visible = dlg.data.setSpinePaths
}
dlg:modify{
id = "spineAudioPath",
visible = dlg.data.setSpinePaths
}
end
}
dlg:entry{
id = "spineImagesPath",
label = " Images Path:",
text = "images"
}
dlg:entry{
id = "spineAudioPath",
label = " Audio Path:",
text = "audio"
}
dlg:separator{
id = "separator4",
text = "Group Settings"
Expand Down Expand Up @@ -486,6 +549,14 @@ dlg:entry{
dlg:separator{
id = "separator5"
}
dlg:entry{
id = "help",
label = "Need help? Visit my GitHub repository @",
text = "https://github.com/RampantDespair/Aseprite-Exporter"
}
dlg:separator{
id = "separator6"
}

dlg:button{id = "confirm", text = "Confirm"}
dlg:button{id = "cancel", text = "Cancel"}
Expand All @@ -502,6 +573,14 @@ if dlg.data.outputPath == nil then
end

local fileName = app.fs.fileTitle(activeSprite.filename)

if dlg.data.exportSpriteNameTrim then
local _index = string.find(fileName, "_")
if _index ~= nil then
fileName = string.sub(fileName, _index + 1, string.len(fileName))
end
end

local fileNameTemplate = dlg.data.exportFileNameFormat:gsub("{spritename}", fileName)

if fileNameTemplate == nil then
Expand Down
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Aseprite-Exporter

## Showcase
![showcase](media/showcase-v2.6.png)
![showcase](media/showcase-v3.0.png)

## Features
### Generic
Expand Down Expand Up @@ -39,6 +39,45 @@
## Important
- You cannot name your skins "default" as this is reserved by Spine itself

## Settings information
### Output Settings
| Option | Description | Default Value |
| --- | --- | --- |
| Output File | The parent directory of the selected file will be used for export. | the file itself |
| Output Subdirectory | The subdirectory used for export. | images |
| Output Path | The full path used for export. | Output File / Output Subdirectory |

### SpriteSheet Settings
| Option | Description | Default Value |
| --- | --- | --- |
| Export SpriteSheet | If the sprite sheet will be exported. | true |
| Sprite Name Trim | If the sprite name will be trimmed.<br> Trims the first instance "_" and everything preceding it. | true |
| File Name Format | The file name's format with modifiable placeholders. | {spritename}-{layergroup}-{layername} |
| File Format | The files' export format. | png |
| SpriteSheet Trim | If the exported files' will have there excess space trimmed. | true |

### Spine Settings
| Option | Description | Default Value |
| --- | --- | --- |
| Export SpineSheet | If the spine sheet will be exported. | true |
| Set Root Position | If the root position will be set in the export file. | true |
| Root Position Method | The method which will be used for setting the position.<br> Automatic: To use this method, create a layer called "root" and place a single pixel where you want the root to be.<br> Manual: Input the coordinates manually in the subsequent fields. | automatic |
| Root Position X | The X coordinate of the root. | 0 |
| Root Position Y | The Y coordinate of the root. | 0 |
| Set Spine Paths | If the paths whithin the exported spine file will be set. | true |
| Images Path | The images path. | images |
| Audio Path | The audio path. | audio |

### Group Settings
| Option | Description | Default Value |
| --- | --- | --- |
| Groups As Skins | If you want to convert aseprite groups to spine skins. | true |
| Skin Name Format | The skins' format with modifiable placeholders. | weapon-{layergroup} |
| Seperate Slot/Skin | If you want to seperate the slots and skins. | true |
| Slot Name Format | The slots' name format with modifiable placeholders. | {layernameprefix} |
| Skin Attachement Format | The skins' attachement format with modifiable placeholders. | {layernameprefix}-{layernamesuffix} |
| Layer Name Separator | The layers' name seperator. | - |

## Credits
Some portions of my code were inspired by the following repositories:
- [aseprite-to-spine](https://github.com/jordanbleu/aseprite-to-spine) made by [jordanbleu](https://github.com/jordanbleu)
Expand Down
Binary file added media/showcase-v3.0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cfbcf0e

Please sign in to comment.