Remove unecessary garbage
Are you kidding me? Producing more trash than saving space
This commit is contained in:
@@ -6,7 +6,5 @@
|
|||||||
## SavedVariables: ActionBarSaverReloaded
|
## SavedVariables: ActionBarSaverReloaded
|
||||||
|
|
||||||
Constants.lua
|
Constants.lua
|
||||||
StringHelpers.lua
|
|
||||||
TableHelpers.lua
|
|
||||||
Main.lua
|
Main.lua
|
||||||
Actions.lua
|
Actions.lua
|
||||||
92
Actions.lua
92
Actions.lua
@@ -31,7 +31,7 @@ local function RestoreActionButton(self, index, actionButton)
|
|||||||
|
|
||||||
if not actionButton then return true, nil end
|
if not actionButton then return true, nil end
|
||||||
|
|
||||||
local aliases = self.db.class.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)
|
||||||
|
|
||||||
for _, id in ipairs(ids) do
|
for _, id in ipairs(ids) do
|
||||||
@@ -80,8 +80,8 @@ local function AddWarning(warnings, macroName, usages)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SaveSet(setName)
|
function SaveSet(setName)
|
||||||
if Str.nullOrEmpty(setName) then
|
if not setName or setName == "" then
|
||||||
self:Print("Set name cannot be empty")
|
print("Set name cannot be empty")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -106,25 +106,25 @@ function SaveSet(setName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.db.class.sets[setName] = set
|
ActionBarSaverReloaded.sets[setName] = set
|
||||||
self:Print(string.format("Saved set '%s'!", setName))
|
print(string.format("Saved set '%s'!", setName))
|
||||||
Array.iter(warnings, function(warning) self:Print(warning) end)
|
Array.iter(warnings, function(warning) print(warning) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function RestoreSet(setName)
|
function RestoreSet(setName)
|
||||||
if Str.nullOrEmpty(setName) then
|
if not setName or setName == "" then
|
||||||
self:Print("Set name cannot be empty")
|
print("Set name cannot be empty")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local set = self.db.class.sets[setName]
|
local set = ActionBarSaverReloaded.sets[setName]
|
||||||
|
|
||||||
if not set then
|
if not set then
|
||||||
self:Print(string.format("No set with the name '%s' exists", setName))
|
print(string.format("No set with the name '%s' exists", setName))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if InCombatLockdown() then
|
if InCombatLockdown() then
|
||||||
self:Print("Cannot restore sets while in combat")
|
print("Cannot restore sets while in combat")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -147,37 +147,37 @@ function RestoreSet(setName)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:Print(string.format("Restored set '%s'", setName))
|
print(string.format("Restored set '%s'", setName))
|
||||||
Array.iter(messages, function(warning) self:Print(warning) end)
|
Array.iter(messages, function(warning) print(warning) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DeleteSet(setName)
|
function DeleteSet(setName)
|
||||||
if Str.nullOrEmpty(setName) then
|
if not setName or setName == "" then
|
||||||
self:Print("Set name cannot be empty")
|
print("Set name cannot be empty")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self.db.class.sets[setName] then
|
if not ActionBarSaverReloaded.sets[setName] then
|
||||||
self:Print(string.format("No set with the name '%s' exists", setName))
|
print(string.format("No set with the name '%s' exists", setName))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
self.db.class.sets[setName] = nil
|
ActionBarSaverReloaded.sets[setName] = nil
|
||||||
|
|
||||||
self:Print(string.format("Deleted set '%s'", setName))
|
print(string.format("Deleted set '%s'", setName))
|
||||||
end
|
end
|
||||||
|
|
||||||
function ListSets()
|
function ListSets()
|
||||||
local sets = Dict.keysAsArray(self.db.class.sets)
|
local sets = Dict.keysAsArray(ActionBarSaverReloaded.sets)
|
||||||
table.sort(sets)
|
table.sort(sets)
|
||||||
local setsStr = table.concat(sets, ", ")
|
local setsStr = table.concat(sets, ", ")
|
||||||
|
|
||||||
self:Print(not Str.nullOrEmpty(setsStr) and setsStr or "No sets found")
|
print(not Str.nullOrEmpty(setsStr) and setsStr or "No sets found")
|
||||||
end
|
end
|
||||||
|
|
||||||
function AliasSpell(args)
|
function AliasSpell(args)
|
||||||
if Str.nullOrEmpty(args) then
|
if not args or args == "" then
|
||||||
self:Print("Must provide args in the format 'spellID aliasID'")
|
print("Must provide args in the format 'spellID aliasID'")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local spellID, aliasID = string.match(args, "(%d+)%s+(%d+)")
|
local spellID, aliasID = string.match(args, "(%d+)%s+(%d+)")
|
||||||
@@ -186,63 +186,63 @@ function AliasSpell(args)
|
|||||||
aliasID = tonumber(aliasID)
|
aliasID = tonumber(aliasID)
|
||||||
|
|
||||||
if not (spellID and aliasID) then
|
if not (spellID and aliasID) then
|
||||||
self:Print(string.format("Could not parse spellID and aliasID from '%s'", args))
|
print(string.format("Could not parse spellID and aliasID from '%s'", args))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local aliases = self.db.class.spellAliases[spellID] or {}
|
local aliases = ActionBarSaverReloaded.spellAliases[spellID] or {}
|
||||||
|
|
||||||
if Array.contains(aliases, aliasID) then
|
if Array.contains(aliases, aliasID) then
|
||||||
self:Print(string.format("Spell %d is already aliased by %d", spellID, aliasID))
|
print(string.format("Spell %d is already aliased by %d", spellID, aliasID))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(aliases, aliasID)
|
table.insert(aliases, aliasID)
|
||||||
self.db.class.spellAliases[spellID] = aliases
|
ActionBarSaverReloaded.spellAliases[spellID] = aliases
|
||||||
|
|
||||||
self:Print(string.format("Added %d as an alias for %d", aliasID, spellID))
|
print(string.format("Added %d as an alias for %d", aliasID, spellID))
|
||||||
end
|
end
|
||||||
|
|
||||||
function DeleteSpellAliases(spellID)
|
function DeleteSpellAliases(spellID)
|
||||||
if Str.nullOrEmpty(spellID) then
|
if not spellID or spellID == "" then
|
||||||
self:Print("Must provide a valid spellID")
|
print("Must provide a valid spellID")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
spellID = tonumber(spellID)
|
spellID = tonumber(spellID)
|
||||||
|
|
||||||
if not self.db.class.spellAliases[spellID] then
|
if not ActionBarSaverReloaded.spellAliases[spellID] then
|
||||||
self:Print(string.format("No aliases to remove for spell with ID %d", spellID))
|
print(string.format("No aliases to remove for spell with ID %d", spellID))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
self.db.class.spellAliases[spellID] = nil
|
ActionBarSaverReloaded.spellAliases[spellID] = nil
|
||||||
|
|
||||||
self:Print(string.format("Removed all aliases for spell with ID %d", spellID))
|
print(string.format("Removed all aliases for spell with ID %d", spellID))
|
||||||
end
|
end
|
||||||
|
|
||||||
function ListAliases()
|
function ListAliases()
|
||||||
local aliases = self.db.class.spellAliases
|
local aliases = ActionBarSaverReloaded.spellAliases
|
||||||
|
|
||||||
if Dict.isEmpty(aliases) then
|
if Dict.isEmpty(aliases) then
|
||||||
self:Print("No aliases found")
|
print("No aliases found")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
Dict.iter(self.db.class.spellAliases, function(spellID, aliases)
|
Dict.iter(ActionBarSaverReloaded.spellAliases, function(spellID, aliases)
|
||||||
self:Print(string.format("Spell %d is aliased by: %s", spellID, table.concat(aliases, ", ")))
|
print(string.format("Spell %d is aliased by: %s", spellID, table.concat(aliases, ", ")))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PrintUsage()
|
function PrintUsage()
|
||||||
self:Print("ABS Slash commands")
|
print("ABS Slash commands")
|
||||||
self:Print("/abs save <set> - Saves your current action bar setup under the given <set>")
|
print("/abs save <set> - Saves your current action bar setup under the given <set>")
|
||||||
self:Print("/abs restore <set> - Restores the saved <set>")
|
print("/abs restore <set> - Restores the saved <set>")
|
||||||
self:Print("/abs delete <set> - Deletes the saved <set>")
|
print("/abs delete <set> - Deletes the saved <set>")
|
||||||
self:Print("/abs list - Lists all saved sets")
|
print("/abs list - Lists all saved sets")
|
||||||
self:Print("/abs alias <spellID> <aliasID> - Adds an alias with <aliasID> to <spellID>")
|
print("/abs alias <spellID> <aliasID> - Adds an alias with <aliasID> to <spellID>")
|
||||||
self:Print("/abs unalias <spellID> - Removes all aliases associated with <spellID>")
|
print("/abs unalias <spellID> - Removes all aliases associated with <spellID>")
|
||||||
self:Print("/abs aliases - List all spell aliases")
|
print("/abs aliases - List all spell aliases")
|
||||||
end
|
end
|
||||||
|
|
||||||
SlashCmdList["ABS"] = function(argv)
|
SlashCmdList["ABS"] = function(argv)
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
Str = {}
|
|
||||||
|
|
||||||
function Str.toLower(s) return string.lower(s or "") end
|
|
||||||
function Str.nullOrEmpty(s) return not s or s == "" end
|
|
||||||
|
|
||||||
function Str.split(s, delimiter, max)
|
|
||||||
---@diagnostic disable-next-line: undefined-field
|
|
||||||
return string.split(delimiter, s, max)
|
|
||||||
end
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
Array = {}
|
|
||||||
Dict = {}
|
|
||||||
|
|
||||||
function Array.iter(arr, fn)
|
|
||||||
for _,v in ipairs(arr) do
|
|
||||||
fn(v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Array.map(arr, fn)
|
|
||||||
local t = {}
|
|
||||||
|
|
||||||
for _,v in ipairs(arr) do
|
|
||||||
table.insert(t, fn(v))
|
|
||||||
end
|
|
||||||
|
|
||||||
return t
|
|
||||||
end
|
|
||||||
|
|
||||||
function Array.mapRange(start, stop, fn)
|
|
||||||
local arr = {}
|
|
||||||
|
|
||||||
for i = start, stop do
|
|
||||||
arr[i] = fn(i)
|
|
||||||
end
|
|
||||||
|
|
||||||
return arr
|
|
||||||
end
|
|
||||||
|
|
||||||
function Array.iterRange(start, stop, fn)
|
|
||||||
for i = start, stop do
|
|
||||||
fn(i)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Array.contains(arr, value)
|
|
||||||
for _,v in ipairs(arr) do
|
|
||||||
if v == value then return true end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function Array.insert(arr, value, index)
|
|
||||||
local t = {}
|
|
||||||
|
|
||||||
for _, v in ipairs(arr) do
|
|
||||||
table.insert(t, v)
|
|
||||||
end
|
|
||||||
|
|
||||||
table.insert(t, index, value)
|
|
||||||
|
|
||||||
return t
|
|
||||||
end
|
|
||||||
|
|
||||||
function Dict.iter(t, fn)
|
|
||||||
for k,v in pairs(t) do
|
|
||||||
fn(k,v)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Dict.map(t, fn)
|
|
||||||
local nt = {}
|
|
||||||
|
|
||||||
for k,v in pairs(t) do
|
|
||||||
nt[k] = fn(k,v)
|
|
||||||
end
|
|
||||||
|
|
||||||
return nt
|
|
||||||
end
|
|
||||||
|
|
||||||
function Dict.keysAsArray(t)
|
|
||||||
local nt = {}
|
|
||||||
|
|
||||||
for k,_ in pairs(t) do
|
|
||||||
table.insert(nt, k)
|
|
||||||
end
|
|
||||||
|
|
||||||
return nt
|
|
||||||
end
|
|
||||||
|
|
||||||
function Dict.isEmpty(t)
|
|
||||||
return next(t) == nil
|
|
||||||
end
|
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
ADDON_NAME = "ActionBarSaverReloaded"
|
|
||||||
MAX_MACROS = 138
|
MAX_MACROS = 138
|
||||||
MAX_ACTION_BUTTONS = 132
|
MAX_ACTION_BUTTONS = 132
|
||||||
Reference in New Issue
Block a user