Skip to content

Commit

Permalink
Fixed config ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
RampantDespair committed Jan 16, 2024
1 parent 21cc432 commit 18aeb01
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions Aseprite-Exporter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -347,20 +347,20 @@ function PopulateConfig(configFile)
end

function InitializeConfigKeys()
for key, _ in pairs(Config) do
table.insert(ConfigKeys, key)
for key, value in pairs(Config) do
table.insert(ConfigKeys, { key = key, order = value.order })
end

table.sort(ConfigKeys)
table.sort(ConfigKeys, function (a, b) return a.order < b.order end)
end

function UpdateConfigFile(activeSprite, newValue)
WriteConfig()
UpdateConfigValue("configSelect", newValue)
InitializeConfig()

for key, value in pairs(Config) do
UpdateDialog(key, value.value)
for _, value in ipairs(ConfigKeys) do
UpdateDialog(value.key, Config[value.key].value)
end
Dlg:modify{
id = "outputFile",
Expand Down Expand Up @@ -402,10 +402,10 @@ function WriteConfig()

if configFile ~= nil then
for _, value in ipairs(ConfigKeys) do
if type(Config[value].value) ~= "string" then
configFile:write(value .. "=" .. tostring(Config[value].value) .. "\n")
if type(Config[value.key].value) ~= "string" then
configFile:write(value.key .. "=" .. tostring(Config[value.key].value) .. "\n")
else
configFile:write(value .. "=" .. Config[value].value .. "\n")
configFile:write(value.key .. "=" .. Config[value.key].value .. "\n")
end
end
end
Expand Down Expand Up @@ -441,8 +441,8 @@ function UpdateDialog(configKey, newValue)
end

function ResetConfig(activeSprite)
for key, value in pairs(Config) do
UpdateDialog(key, value.default)
for _, value in ipairs(ConfigKeys) do
UpdateDialog(value.key, Config[value.key].default)
end
Dlg:modify{
id = "outputFile",
Expand Down Expand Up @@ -475,27 +475,31 @@ ConfigPathGlobal = app.fs.joinPath(scriptDirectory, "Aseprite-Exporter.conf")

Config = {
configSelect = {
order = 100,
type = "combobox",
default = "global",
value = nil,
parent = nil,
children = {},
},
outputSubdirectory = {
order = 200,
type = "entry",
default = "images",
value = nil,
parent = nil,
children = {},
},
outputGroupsAsDirectories = {
order = 201,
type = "check",
default = true,
value = nil,
parent = nil,
children = {},
},
spriteSheetExport = {
order = 300,
type = "check",
default = true,
value = nil,
Expand All @@ -508,34 +512,39 @@ Config = {
},
},
spriteSheetNameTrim = {
order = 301,
type = "check",
default = true,
value = nil,
parent = nil,
children = {},
},
spriteSheetFileNameFormat = {
order = 302,
type = "entry",
default = "{spritename}-{layergroup}-{layername}",
value = nil,
parent = nil,
children = {},
},
spriteSheetFileFormat = {
order = 303,
type = "combobox",
default = "png",
value = nil,
parent = nil,
children = {},
},
spriteSheetTrim = {
order = 304,
type = "check",
default = true,
value = nil,
parent = nil,
children = {},
},
spineExport = {
order = 400,
type = "check",
default = true,
value = nil,
Expand All @@ -548,6 +557,7 @@ Config = {
},
},
spineSetStaticSlot = {
order = 401,
type = "check",
default = true,
value = nil,
Expand All @@ -557,13 +567,15 @@ Config = {
},
},
spineStaticSlotName = {
order = 402,
type = "entry",
default = "slot",
value = nil,
parent = nil,
children = {},
},
spineSetRootPostion = {
order = 403,
type = "check",
default = true,
value = nil,
Expand All @@ -575,6 +587,7 @@ Config = {
},
},
spineRootPostionMethod = {
order = 404,
type = "combobox",
default = "center",
value = nil,
Expand All @@ -585,20 +598,23 @@ Config = {
},
},
spineRootPostionX = {
order = 405,
type = "number",
default = 0,
value = nil,
parent = "manual",
children = {},
},
spineRootPostionY = {
order = 406,
type = "number",
default = 0,
value = nil,
parent = "manual",
children = {},
},
spineSetImagesPath = {
order = 407,
type = "check",
default = true,
value = nil,
Expand All @@ -608,13 +624,15 @@ Config = {
},
},
spineImagesPath = {
order = 408,
type = "entry",
default = "images",
value = nil,
parent = nil,
children = {},
},
spineGroupsAsSkins = {
order = 409,
type = "check",
default = true,
value = nil,
Expand All @@ -625,13 +643,15 @@ Config = {
},
},
spineSkinNameFormat = {
order = 410,
type = "entry",
default = "weapon-{layergroup}",
value = nil,
parent = nil,
children = {},
},
spineSeparateSlotSkin = {
order = 411,
type = "check",
default = true,
value = nil,
Expand All @@ -643,20 +663,23 @@ Config = {
},
},
spineSlotNameFormat = {
order = 412,
type = "entry",
default = "{layernameprefix}",
value = nil,
parent = nil,
children = {},
},
spineSkinAttachmentFormat = {
order = 413,
type = "entry",
default = "{layernameprefix}-{layernamesuffix}",
value = nil,
parent = nil,
children = {},
},
spineLayerNameSeparator = {
order = 414,
type = "entry",
default = "-",
value = nil,
Expand Down

0 comments on commit 18aeb01

Please sign in to comment.