Skip to content

Commit cfbcf0e

Browse files
Version 3.0
1 parent 1fc70e2 commit cfbcf0e

File tree

3 files changed

+140
-22
lines changed

3 files changed

+140
-22
lines changed

Aseprite-Exporter.lua

Lines changed: 100 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function Export(activeSprite, rootLayer, fileName, fileNameTemplate, dlgData)
3737
ExportSpineJsonStart(fileName, dlgData)
3838
end
3939

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

122122
Json:write('{ ')
123123
Json:write('"skeleton": { ')
124-
Json:write(string.format([["images": "%s", ]], "./" .. dlgData.imagesPath .. "/"))
125-
Json:write(string.format([["audio": "%s" ]], "./" .. dlgData.audioPath .. "/"))
124+
125+
if dlgData.setSpinePaths then
126+
Json:write(string.format([["images": "%s", ]], "./" .. dlgData.spineImagesPath .. "/"))
127+
Json:write(string.format([["audio": "%s" ]], "./" .. dlgData.spineAudioPath .. "/"))
128+
end
129+
126130
Json:write('}, ')
127131
Json:write('"bones": [ { ')
128132
Json:write('"name": "root" ')
@@ -291,30 +295,25 @@ dlg:file{
291295
onchange = function()
292296
dlg:modify{
293297
id = "outputPath",
294-
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.imagesPath)
298+
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.outputSubdirectory)
295299
}
296300
end
297301
}
298302
dlg:entry{
299-
id = "imagesPath",
300-
label = "Images Path:",
301-
text = "sprite",
303+
id = "outputSubdirectory",
304+
label = "Output Subdirectory:",
305+
text = "images",
302306
onchange = function()
303307
dlg:modify{
304308
id = "outputPath",
305-
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.imagesPath)
309+
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.outputSubdirectory)
306310
}
307311
end
308312
}
309-
dlg:entry{
310-
id = "audioPath",
311-
label = "Audio Path:",
312-
text = "sound"
313-
}
314313
dlg:label{
315314
id = "outputPath",
316315
label = "Output Path:",
317-
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.imagesPath)
316+
text = app.fs.joinPath(app.fs.filePath(dlg.data.outputFile), dlg.data.outputSubdirectory)
318317
}
319318
dlg:separator{
320319
id = "separator2",
@@ -325,6 +324,10 @@ dlg:check{
325324
label = "Export SpriteSheet:",
326325
selected = true,
327326
onclick = function()
327+
dlg:modify{
328+
id = "exportSpriteNameTrim",
329+
visible = dlg.data.exportSpriteSheet
330+
}
328331
dlg:modify{
329332
id = "exportFileNameFormat",
330333
visible = dlg.data.exportSpriteSheet
@@ -339,6 +342,11 @@ dlg:check{
339342
}
340343
end
341344
}
345+
dlg:check{
346+
id = "exportSpriteNameTrim",
347+
label = " Sprite Name Trim:",
348+
selected = true
349+
}
342350
dlg:entry{
343351
id = "exportFileNameFormat",
344352
label = " File Name Format:",
@@ -362,11 +370,41 @@ dlg:separator{
362370
dlg:check{
363371
id = "exportSpineSheet",
364372
label = "Export SpineSheet:",
365-
selected = true
373+
selected = true,
374+
onclick = function()
375+
dlg:modify{
376+
id = "setRootPostion",
377+
visible = dlg.data.exportSpineSheet
378+
}
379+
dlg:modify{
380+
id = "rootPostionMethod",
381+
visible = dlg.data.exportSpineSheet
382+
}
383+
dlg:modify{
384+
id = "rootPositionX",
385+
visible = dlg.data.exportSpineSheet and dlg.data.rootPostionMethod == "manual"
386+
}
387+
dlg:modify{
388+
id = "rootPositionY",
389+
visible = dlg.data.exportSpineSheet and dlg.data.rootPostionMethod == "manual"
390+
}
391+
dlg:modify{
392+
id = "setSpinePaths",
393+
visible = dlg.data.exportSpineSheet
394+
}
395+
dlg:modify{
396+
id = "spineImagesPath",
397+
visible = dlg.data.exportSpineSheet and dlg.data.setSpinePaths
398+
}
399+
dlg:modify{
400+
id = "spineAudioPath",
401+
visible = dlg.data.exportSpineSheet and dlg.data.setSpinePaths
402+
}
403+
end
366404
}
367405
dlg:check{
368406
id = "setRootPostion",
369-
label = "Set Root position:",
407+
label = " Set Root Position:",
370408
selected = true,
371409
onclick = function()
372410
dlg:modify{
@@ -375,17 +413,17 @@ dlg:check{
375413
}
376414
dlg:modify{
377415
id = "rootPositionX",
378-
visible = dlg.data.setRootPostion
416+
visible = dlg.data.setRootPostion and dlg.data.rootPostionMethod == "manual"
379417
}
380418
dlg:modify{
381419
id = "rootPositionY",
382-
visible = dlg.data.setRootPostion
420+
visible = dlg.data.setRootPostion and dlg.data.rootPostionMethod == "manual"
383421
}
384422
end
385423
}
386424
dlg:combobox{
387425
id = "rootPostionMethod",
388-
label = " Root position method:",
426+
label = " Root position Method:",
389427
option = "automatic",
390428
options = {"manual", "automatic"},
391429
onchange = function()
@@ -401,18 +439,43 @@ dlg:combobox{
401439
}
402440
dlg:number{
403441
id = "rootPositionX",
404-
label = " Root Postion X:",
442+
label = " Root Postion X:",
405443
text = "0",
406444
decimals = 0,
407445
visible = false
408446
}
409447
dlg:number{
410448
id = "rootPositionY",
411-
label = " Root Postion Y:",
449+
label = " Root Postion Y:",
412450
text = "0",
413451
decimals = 0,
414452
visible = false
415453
}
454+
dlg:check{
455+
id = "setSpinePaths",
456+
label = " Set Spine Paths:",
457+
selected = true,
458+
onclick = function()
459+
dlg:modify{
460+
id = "spineImagesPath",
461+
visible = dlg.data.setSpinePaths
462+
}
463+
dlg:modify{
464+
id = "spineAudioPath",
465+
visible = dlg.data.setSpinePaths
466+
}
467+
end
468+
}
469+
dlg:entry{
470+
id = "spineImagesPath",
471+
label = " Images Path:",
472+
text = "images"
473+
}
474+
dlg:entry{
475+
id = "spineAudioPath",
476+
label = " Audio Path:",
477+
text = "audio"
478+
}
416479
dlg:separator{
417480
id = "separator4",
418481
text = "Group Settings"
@@ -486,6 +549,14 @@ dlg:entry{
486549
dlg:separator{
487550
id = "separator5"
488551
}
552+
dlg:entry{
553+
id = "help",
554+
label = "Need help? Visit my GitHub repository @",
555+
text = "https://github.com/RampantDespair/Aseprite-Exporter"
556+
}
557+
dlg:separator{
558+
id = "separator6"
559+
}
489560

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

504575
local fileName = app.fs.fileTitle(activeSprite.filename)
576+
577+
if dlg.data.exportSpriteNameTrim then
578+
local _index = string.find(fileName, "_")
579+
if _index ~= nil then
580+
fileName = string.sub(fileName, _index + 1, string.len(fileName))
581+
end
582+
end
583+
505584
local fileNameTemplate = dlg.data.exportFileNameFormat:gsub("{spritename}", fileName)
506585

507586
if fileNameTemplate == nil then

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Aseprite-Exporter
22

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

66
## Features
77
### Generic
@@ -39,6 +39,45 @@
3939
## Important
4040
- You cannot name your skins "default" as this is reserved by Spine itself
4141

42+
## Settings information
43+
### Output Settings
44+
| Option | Description | Default Value |
45+
| --- | --- | --- |
46+
| Output File | The parent directory of the selected file will be used for export. | the file itself |
47+
| Output Subdirectory | The subdirectory used for export. | images |
48+
| Output Path | The full path used for export. | Output File / Output Subdirectory |
49+
50+
### SpriteSheet Settings
51+
| Option | Description | Default Value |
52+
| --- | --- | --- |
53+
| Export SpriteSheet | If the sprite sheet will be exported. | true |
54+
| Sprite Name Trim | If the sprite name will be trimmed.<br> Trims the first instance "_" and everything preceding it. | true |
55+
| File Name Format | The file name's format with modifiable placeholders. | {spritename}-{layergroup}-{layername} |
56+
| File Format | The files' export format. | png |
57+
| SpriteSheet Trim | If the exported files' will have there excess space trimmed. | true |
58+
59+
### Spine Settings
60+
| Option | Description | Default Value |
61+
| --- | --- | --- |
62+
| Export SpineSheet | If the spine sheet will be exported. | true |
63+
| Set Root Position | If the root position will be set in the export file. | true |
64+
| 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 |
65+
| Root Position X | The X coordinate of the root. | 0 |
66+
| Root Position Y | The Y coordinate of the root. | 0 |
67+
| Set Spine Paths | If the paths whithin the exported spine file will be set. | true |
68+
| Images Path | The images path. | images |
69+
| Audio Path | The audio path. | audio |
70+
71+
### Group Settings
72+
| Option | Description | Default Value |
73+
| --- | --- | --- |
74+
| Groups As Skins | If you want to convert aseprite groups to spine skins. | true |
75+
| Skin Name Format | The skins' format with modifiable placeholders. | weapon-{layergroup} |
76+
| Seperate Slot/Skin | If you want to seperate the slots and skins. | true |
77+
| Slot Name Format | The slots' name format with modifiable placeholders. | {layernameprefix} |
78+
| Skin Attachement Format | The skins' attachement format with modifiable placeholders. | {layernameprefix}-{layernamesuffix} |
79+
| Layer Name Separator | The layers' name seperator. | - |
80+
4281
## Credits
4382
Some portions of my code were inspired by the following repositories:
4483
- [aseprite-to-spine](https://github.com/jordanbleu/aseprite-to-spine) made by [jordanbleu](https://github.com/jordanbleu)

media/showcase-v3.0.png

29 KB
Loading

0 commit comments

Comments
 (0)