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