Clean up the code in general a bit

This commit is contained in:
2025-05-06 22:15:08 +02:00
parent 24e56078bd
commit 38b5dbccb1
6 changed files with 42 additions and 68 deletions

View File

@@ -499,13 +499,6 @@ function PrintUsage()
print("/abs aliases - List all spell aliases") print("/abs aliases - List all spell aliases")
print("/abs export <set> - Brings up a dialog to export the given <set>") print("/abs export <set> - Brings up a dialog to export the given <set>")
print("/abs import <set> - Brings up a dialog to import the given <set>") print("/abs import <set> - Brings up a dialog to import the given <set>")
print("KBS Slash commands")
print("/kbs save <set> - Saves your current keybind setup under the given <set>")
print("/kbs restore <set> - Restores the saved <set>")
print("/kbs delete <set> - Deletes the saved <set>")
print("/kbs list - Lists all saved sets")
print("/kbs export <set> - Brings up a dialog to export the given <set>")
print("/kbs import <set> - Brings up a dialog to import the given <set>")
end end
SlashCmdList["ABS"] = function(argv) SlashCmdList["ABS"] = function(argv)

View File

@@ -1,4 +1,4 @@
local ADDON_NAME, shared = ... local ADDON_NAME = ...
-- Initialize saved variables -- Initialize saved variables
local frame = CreateFrame("Frame") local frame = CreateFrame("Frame")
@@ -61,17 +61,20 @@ importExportFrameTextBox:SetScript("OnEscapePressed", function(self)
end end
end) end)
---@param setName string
---@return nil
local function SaveSet(setName) local function SaveSet(setName)
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
end end
---@type table<string, {key1: string, key2: string?}>
local set = {} local set = {}
local numBindings = GetNumBindings() local numBindings = GetNumBindings()
for i = 1, numBindings do for i = 1, numBindings do
local command, category, key1, key2 = GetBinding(i) local command, _, key1, key2 = GetBinding(i)
if key1 or key2 then set[command] = { if key1 or key2 then set[command] = {
key1 = key1, key1 = key1,
key2 = key2, key2 = key2,
@@ -82,6 +85,8 @@ local function SaveSet(setName)
print(string.format("Saved keybind set '%s'!", setName)) print(string.format("Saved keybind set '%s'!", setName))
end end
---@param setName string
---@return nil
local function RestoreSet(setName) local function RestoreSet(setName)
if not setName or setName == "" then if not setName or setName == "" then
print("Set name cannot be empty") print("Set name cannot be empty")
@@ -108,6 +113,8 @@ local function RestoreSet(setName)
print(string.format("Restored keybind set '%s'", setName)) print(string.format("Restored keybind set '%s'", setName))
end end
---@param setName string
---@return nil
local function DeleteSet(setName) local function DeleteSet(setName)
if not setName or setName == "" then if not setName or setName == "" then
print("Set name cannot be empty") print("Set name cannot be empty")
@@ -123,6 +130,7 @@ local function DeleteSet(setName)
print(string.format("Deleted keybind set '%s'", setName)) print(string.format("Deleted keybind set '%s'", setName))
end end
---@return nil
local function ListSets() local function ListSets()
local sets = {} local sets = {}
for setName in pairs(KeybindSaverDaved.sets) do for setName in pairs(KeybindSaverDaved.sets) do
@@ -138,6 +146,8 @@ local function ListSets()
end end
end end
---@param setName string
---@return nil
local function ExportSet(setName) local function ExportSet(setName)
local set = KeybindSaverDaved.sets[setName] local set = KeybindSaverDaved.sets[setName]
if not set then if not set then
@@ -157,6 +167,9 @@ local function ExportSet(setName)
importExportFrameTextBox:SetFocus() importExportFrameTextBox:SetFocus()
end end
---@param setName string
---@param importStr string
---@return nil
local function ImportSet(setName, importStr) local function ImportSet(setName, importStr)
if not setName or setName == "" then if not setName or setName == "" then
print("Set name cannot be empty") print("Set name cannot be empty")
@@ -182,6 +195,8 @@ local function ImportSet(setName, importStr)
print(string.format("Imported keybind set '%s'", setName)) print(string.format("Imported keybind set '%s'", setName))
end end
---@param setName string
---@return nil
local function ImportSetDialogue(setName) local function ImportSetDialogue(setName)
if not setName or setName == "" then if not setName or setName == "" then
print("Set name cannot be empty") print("Set name cannot be empty")
@@ -193,6 +208,7 @@ local function ImportSetDialogue(setName)
importExportFrameTextBox:SetFocus() importExportFrameTextBox:SetFocus()
end end
---@return nil
local function PrintUsage() local function PrintUsage()
print("Keybind Saver Slash Commands:") print("Keybind Saver Slash Commands:")
print("/kbs save <set> - Saves your current keybinds under the given <set>") print("/kbs save <set> - Saves your current keybinds under the given <set>")
@@ -203,7 +219,6 @@ local function PrintUsage()
print("/kbs import <set> - Opens a window to import a keybind set") print("/kbs import <set> - Opens a window to import a keybind set")
end end
-- Register slash commands
SLASH_KBS1 = "/kbs" SLASH_KBS1 = "/kbs"
SlashCmdList["KBS"] = function(argv) SlashCmdList["KBS"] = function(argv)
local args = { strsplit(" ", argv) } local args = { strsplit(" ", argv) }

View File

@@ -1,30 +1,18 @@
local ADDON_NAME, shared = ... local ADDON_NAME = ...
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
---@class ActionBarSaverDaved
---@field spellAliases table<number, number[]>
ActionBarSaverDaved = ActionBarSaverDaved or {} ActionBarSaverDaved = ActionBarSaverDaved or {}
ActionBarSaverDaved.spellAliases = ActionBarSaverDaved.spellAliases or {} ActionBarSaverDaved.spellAliases = ActionBarSaverDaved.spellAliases or {}
ActionBarSaverDaved.sets = ActionBarSaverDaved.sets or {} ActionBarSaverDaved.sets = ActionBarSaverDaved.sets or {}
end)
-- function ABS:OnInitialize() ---@class KeybindSaverDaved
-- self.commands = { ---@field sets table<string, table<string, {key1: string, key2: string?}>>
-- save = self.actions.SaveSet, KeybindSaverDaved = KeybindSaverDaved or {}
-- restore = self.actions.RestoreSet, KeybindSaverDaved.sets = KeybindSaverDaved.sets or {}
-- delete = self.actions.DeleteSet, end)
-- list = self.actions.ListSets,
-- alias = self.actions.AliasSpell,
-- unalias = self.actions.DeleteSpellAliases,
-- aliases = self.actions.ListAliases,
-- }
-- end
--
-- function ABS:HandleCommands(input)
-- local cmd, args = Str.split(input, " ", 2)
-- local fn = self.commands[Str.toLower(cmd)]
--
-- if fn then fn(self, args) else self.actions.PrintUsage(self) end
-- end

View File

@@ -2,15 +2,11 @@
## Overview ## Overview
ActionBarSaver:Daved is an addon for saving and restoring action bar profiles. It is based on the original ActionBarSaver addon but is a full re-write. ActionBarSaver:Daved is an addon for saving and restoring action bar profiles and keybindings. It is based on the original ActionBarSaver addon but is a full re-write.
All sets are saved by class rather than by character. Additionally, when you list profiles, you will only see profiles that pertain to your class. All sets are saved by class rather than by character. Additionally, when you list profiles, you will only see profiles that pertain to your class.
Features such as rename have been deleted for simplicity. To perform a rename, simply save the set with a new name and delete the old set. Additionally, restoring a set will no longer try to re-create macros that do not exist. It will simply notify you of the missing macro and restore nothing for that slot. ABS:R will not work properly if you have multiple macros with the same name, and will warn you of potential issues if you restore a set that has a macro with a shared name. ## Action Bar Saver Usage
A new feature has been added for setting up aliases for spells. A common use case for this would be restoring a single set for two characters that share a class but have a different race. For example, you could create a set on a troll shaman that contains `Berserking` and then add an alias for `War Stomp` using `/abs alias 20554 20549`. If you do this, when you restore a set it will first try to restore the proper spell but will also try each alias that you set up. A spell can have as many aliases as you want.
## Usage
`/abs save <set>` - Saves your current action bar setup under the given <set>\ `/abs save <set>` - Saves your current action bar setup under the given <set>\
`/abs restore <set>` - Restores the saved <set>\ `/abs restore <set>` - Restores the saved <set>\
@@ -18,7 +14,20 @@ A new feature has been added for setting up aliases for spells. A common use cas
`/abs list` - Lists all saved sets\ `/abs list` - Lists all saved sets\
`/abs alias <spellID> <aliasID>` - Adds an alias with <aliasID> to <spellID>\ `/abs alias <spellID> <aliasID>` - Adds an alias with <aliasID> to <spellID>\
`/abs unalias <spellID>` - Removes all aliases associated with <spellID>\ `/abs unalias <spellID>` - Removes all aliases associated with <spellID>\
`/abs aliases` - List all spell aliases `/abs aliases` - List all spell aliases\
`/abs export <set>` - Opens a window to export the given <set>\
`/abs import <set>` - Opens a window to import an action bar set
## Keybind Saver Usage
The addon also includes a keybind saver that allows you to save and restore your keybindings. This is useful for maintaining different keybind setups for different specs or situations.
`/kbs save <set>` - Saves your current keybinds under the given <set>\
`/kbs restore <set>` - Restores the saved <set>\
`/kbs delete <set>` - Deletes the saved <set>\
`/kbs list` - Lists all saved sets\
`/kbs export <set>` - Opens a window to export the given <set>\
`/kbs import <set>` - Opens a window to import a keybind set
## Known Issues ## Known Issues

View File

@@ -1,31 +0,0 @@
## 1.0.7 (2024-06-30)
- Updated for Cata classic
## 1.0.6 (2023-08-29)
- TOC bump for ICC patch
## 1.0.5 (2023-06-20)
- TOC bump for ToGC patch
## 1.0.4 (2023-01-18)
- TOC bump for WOTLK patch
## 1.0.3 (2022-11-09)
- Fixed bug with equipment sets not being restored properly
## 1.0.2 (2022-10-27)
- Fixed bug where totem sets were not being saved or restored
## 1.0.1 (2022-09-26)
- Fixed bug related to restoring sets containing companions and mounts
## 1.0.0 (2022-07-15)
- Initial re-write of the addon