Fix import and export
This commit is contained in:
26
Actions.lua
26
Actions.lua
@@ -66,6 +66,15 @@ local function RestoreActionButton(index, actionButton)
|
||||
return false
|
||||
end
|
||||
|
||||
---@param index number
|
||||
---@return boolean
|
||||
local function ClearActionButton(index)
|
||||
if not index then return false end
|
||||
PickupAction(index)
|
||||
ClearCursor()
|
||||
return true
|
||||
end
|
||||
|
||||
---@param actionButton {type: string, id: number|string}
|
||||
---@return boolean
|
||||
local function IsMacro(actionButton) return actionButton and actionButton.type == "macro" end
|
||||
@@ -165,7 +174,7 @@ function RestoreActionbarSet(setName)
|
||||
|
||||
for i = 1, MAX_ACTION_BUTTONS do
|
||||
local actionButton = set[i]
|
||||
|
||||
if actionButton then
|
||||
if IsMacro(actionButton) and duplicates[actionButton.id] then
|
||||
---@cast actionButton {type: string, id: string}
|
||||
AddWarning(messages, actionButton.id, duplicates[actionButton.id])
|
||||
@@ -193,6 +202,9 @@ function RestoreActionbarSet(setName)
|
||||
)
|
||||
)
|
||||
end
|
||||
else
|
||||
ClearActionButton(i)
|
||||
end
|
||||
end
|
||||
|
||||
print(string.format("Restored set '%s'", setName))
|
||||
@@ -380,6 +392,10 @@ function ExportActionbarSet(setName)
|
||||
importExportFrameTextBox:SetFocus()
|
||||
end
|
||||
|
||||
---@param action {slot: number, id: number|string, type: string}
|
||||
---@return string
|
||||
function FormatAction(action) return string.format("slot: %d, id: %s, type: %s", action.slot, action.id, action.type) end
|
||||
|
||||
---@param action string
|
||||
---@return {slot: number, id: number|string, type: string}
|
||||
function ParseAction(action)
|
||||
@@ -393,12 +409,12 @@ function ParseAction(action)
|
||||
action = strtrim(action)
|
||||
local slot, id, typeChar = string.match(action, "([^\\]+)\\([^\\]+)\\([^\\]+)")
|
||||
if not typeChar then
|
||||
print(string.format("Unknown action type '%s'", tostring(typeChar)))
|
||||
print(string.format("Unknown action type '%s' for action '%s'", tostring(typeChar), FormatAction(ret)))
|
||||
return ret
|
||||
end
|
||||
local type = inverseTypeMap[typeChar]
|
||||
if not type then
|
||||
print(string.format("Unknown action type '%s'", tostring(typeChar)))
|
||||
print(string.format("Unknown action type '%s' for action '%s'", tostring(typeChar), FormatAction(ret)))
|
||||
return ret
|
||||
end
|
||||
|
||||
@@ -406,12 +422,12 @@ function ParseAction(action)
|
||||
id = tonumber(id)
|
||||
|
||||
if not slot then
|
||||
print(string.format("Unknown slot '%s'", tostring(slot)))
|
||||
print(string.format("Unknown slot '%s' for action '%s'", tostring(slot), FormatAction(ret)))
|
||||
return ret
|
||||
end
|
||||
|
||||
if not id then
|
||||
print(string.format("Unknown id '%s'", tostring(id)))
|
||||
print(string.format("Unknown id '%s' for action '%s'", tostring(id), FormatAction(ret)))
|
||||
return ret
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user