Code format
This commit is contained in:
46
Actions.lua
46
Actions.lua
@@ -19,7 +19,7 @@ local pickupActionButton = {
|
||||
spell = PickupSpell,
|
||||
macro = PickupMacro,
|
||||
companion = PickupSpell,
|
||||
equipmentset = PickupEquipmentSet,
|
||||
equipmentset = PickupEquipmentSet
|
||||
}
|
||||
|
||||
local function RestoreActionButton(self, index, actionButton)
|
||||
@@ -29,7 +29,9 @@ local function RestoreActionButton(self, index, actionButton)
|
||||
ClearCursor()
|
||||
end
|
||||
|
||||
if not actionButton then return true, nil end
|
||||
if not actionButton then
|
||||
return true, nil
|
||||
end
|
||||
|
||||
local aliases = ActionBarSaverReloaded.spellAliases[actionButton.id] or {}
|
||||
local ids = Array.insert(aliases, actionButton.id, 1)
|
||||
@@ -48,7 +50,9 @@ local function RestoreActionButton(self, index, actionButton)
|
||||
return false
|
||||
end
|
||||
|
||||
local function IsMacro(actionButton) return actionButton and actionButton.type == "macro" end
|
||||
local function IsMacro(actionButton)
|
||||
return actionButton and actionButton.type == "macro"
|
||||
end
|
||||
|
||||
local function GetMacroDuplicates()
|
||||
local t = {}
|
||||
@@ -71,15 +75,12 @@ local function GetMacroDuplicates()
|
||||
end
|
||||
|
||||
local function AddWarning(warnings, macroName, usages)
|
||||
table.insert(
|
||||
warnings,
|
||||
string.format(
|
||||
"Warning: Found %d macros named '%s'. Consider renaming them to avoid issues",
|
||||
usages,
|
||||
macroName))
|
||||
table.insert(warnings, string.format("Warning: Found %d macros named '%s'. Consider renaming them to avoid issues",
|
||||
usages, macroName))
|
||||
end
|
||||
|
||||
function SaveSet(setName)
|
||||
print("ABS SaveSet")
|
||||
if not setName or setName == "" then
|
||||
print("Set name cannot be empty")
|
||||
return
|
||||
@@ -95,7 +96,9 @@ function SaveSet(setName)
|
||||
if type == "macro" then
|
||||
-- use macro name as the ID
|
||||
id = GetMacroInfo(id)
|
||||
if duplicates[id] then AddWarning(warnings, id, duplicates[id]) end
|
||||
if duplicates[id] then
|
||||
AddWarning(warnings, id, duplicates[id])
|
||||
end
|
||||
end
|
||||
|
||||
if type and id then
|
||||
@@ -108,7 +111,9 @@ function SaveSet(setName)
|
||||
|
||||
ActionBarSaverReloaded.sets[setName] = set
|
||||
print(string.format("Saved set '%s'!", setName))
|
||||
Array.iter(warnings, function(warning) print(warning) end)
|
||||
Array.iter(warnings, function(warning)
|
||||
print(warning)
|
||||
end)
|
||||
end
|
||||
|
||||
function RestoreSet(setName)
|
||||
@@ -137,18 +142,25 @@ function RestoreSet(setName)
|
||||
for i = 1, MAX_ACTION_BUTTONS do
|
||||
local actionButton = set[i]
|
||||
|
||||
if IsMacro(actionButton) and duplicates[actionButton.id] then AddWarning(messages, actionButton.id, duplicates[actionButton.id]) end
|
||||
if IsMacro(actionButton) and duplicates[actionButton.id] then
|
||||
AddWarning(messages, actionButton.id, duplicates[actionButton.id])
|
||||
end
|
||||
|
||||
local succeeded, restoredID = RestoreActionButton(self, i, actionButton)
|
||||
if not succeeded then
|
||||
table.insert(messages, string.format("Error: Unable to restore %s with id [%s] to slot %d", actionButton.type, actionButton.id or "", i))
|
||||
table.insert(messages, string.format("Error: Unable to restore %s with id [%s] to slot %d",
|
||||
actionButton.type, actionButton.id or "", i))
|
||||
elseif actionButton and restoredID ~= actionButton.id then
|
||||
table.insert(messages, string.format("Info: Restored spell %d (%s) in place of spell %d", restoredID, GetSpellInfo(restoredID), actionButton.id))
|
||||
table.insert(messages,
|
||||
string.format("Info: Restored spell %d (%s) in place of spell %d", restoredID, GetSpellInfo(restoredID),
|
||||
actionButton.id))
|
||||
end
|
||||
end
|
||||
|
||||
print(string.format("Restored set '%s'", setName))
|
||||
Array.iter(messages, function(warning) print(warning) end)
|
||||
Array.iter(messages, function(warning)
|
||||
print(warning)
|
||||
end)
|
||||
end
|
||||
|
||||
function DeleteSet(setName)
|
||||
@@ -246,8 +258,10 @@ function PrintUsage()
|
||||
end
|
||||
|
||||
SlashCmdList["ABS"] = function(argv)
|
||||
print("ABS slash", tostring(argv))
|
||||
local args = strsplit(" ", argv)
|
||||
local cmd = args[1]
|
||||
print("ABS slash", tostring(cmd))
|
||||
|
||||
if cmd == "save" then
|
||||
SaveSet(args[2])
|
||||
@@ -270,7 +284,7 @@ SlashCmdList["ABS"] = function(argv)
|
||||
if cmd == "aliases" then
|
||||
ListAliases()
|
||||
end
|
||||
if cmd == "" then
|
||||
if cmd == "" or not cmd then
|
||||
PrintUsage()
|
||||
end
|
||||
end
|
||||
|
4
Main.lua
4
Main.lua
@@ -3,7 +3,9 @@ local ADDON_NAME, shared = ...
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("ADDON_LOADED")
|
||||
frame:SetScript("OnEvent", function(self, event, addon)
|
||||
if addon ~= ADDON_NAME then return end
|
||||
if addon ~= ADDON_NAME then
|
||||
return
|
||||
end
|
||||
|
||||
ActionBarSaverReloaded = ActionBarSaverReloaded or {}
|
||||
ActionBarSaverReloaded.spellAliases = ActionBarSaverReloaded.spellAliases or {}
|
||||
|
Reference in New Issue
Block a user