Skip to content

Commit

Permalink
Rename various enums
Browse files Browse the repository at this point in the history
  • Loading branch information
Snakybo committed Aug 30, 2024
1 parent e840d8a commit e90da9b
Show file tree
Hide file tree
Showing 27 changed files with 461 additions and 464 deletions.
56 changes: 28 additions & 28 deletions Clicked/BindingConfig/BindingConfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -602,35 +602,35 @@ function Addon.BindingConfig.Window:CreateFrame()
local function OnReceiveDrag()
local type, p2, _, p4 = GetCursorInfo()

--- @type BindingType
--- @type ActionType
local actionType

--- @type integer
local id

if type == "item" then
actionType = Addon.BindingTypes.ITEM
actionType = Clicked.ActionType.ITEM
id = p2 --[[@as integer]]
elseif type == "spell" then
actionType = Addon.BindingTypes.SPELL
actionType = Clicked.ActionType.SPELL
id = p4 --[[@as integer]]
elseif type == "petaction" then
actionType = Addon.BindingTypes.SPELL
actionType = Clicked.ActionType.SPELL
id = p2 --[[@as integer]]
elseif type == "macro" then
actionType = Addon.BindingTypes.MACRO
actionType = Clicked.ActionType.MACRO
id = p2 --[[@as integer]]
end

if actionType ~= nil then
local binding = Clicked:CreateBinding()
binding.actionType = actionType

if binding.actionType == Addon.BindingTypes.SPELL then
if binding.actionType == Clicked.ActionType.SPELL then
binding.action.spellValue = id
elseif binding.actionType == Addon.BindingTypes.ITEM then
elseif binding.actionType == Clicked.ActionType.ITEM then
binding.action.itemValue = id
elseif binding.actionType == Addon.BindingTypes.MACRO then
elseif binding.actionType == Clicked.ActionType.MACRO then
local name, icon, content = GetMacroInfo(id)
binding.action.macroName = name
binding.action.macroIcon = icon
Expand Down Expand Up @@ -679,7 +679,7 @@ function Addon.BindingConfig.Window:CreateOrUpdateTree()
table.insert(hierarchy[parent], binding)
end

for _, scope in pairs(Addon.BindingScope) do
for _, scope in pairs(Clicked.DataObjectScope) do
local uid = Addon:GetScopeUid(scope)

--- @type ClickedTreeGroupItem
Expand Down Expand Up @@ -904,7 +904,7 @@ function Addon.BindingConfig.Window:CreateTreeFrame()

local ref = objects[1]

if Addon.EXPANSION_LEVEL >= Addon.EXPANSION.TWW then
if Addon.EXPANSION_LEVEL >= Addon.Expansion.TWW then
MenuUtil.CreateContextMenu(UIParent, function(_, rootDescription)
if ref.type == Clicked.DataObjectType.BINDING then
--- @cast objects Binding[]
Expand Down Expand Up @@ -967,13 +967,13 @@ function Addon.BindingConfig.Window:CreateTreeFrame()
end)
end

CreateOption(Addon.BindingTypes.SPELL, Addon.L["Cast a spell"])
CreateOption(Addon.BindingTypes.ITEM, Addon.L["Use an item"])
CreateOption(Addon.BindingTypes.CANCELAURA, Addon.L["Cancel an aura"])
CreateOption(Addon.BindingTypes.UNIT_SELECT, Addon.L["Target the unit"])
CreateOption(Addon.BindingTypes.UNIT_MENU, Addon.L["Open the unit menu"])
CreateOption(Addon.BindingTypes.MACRO, Addon.L["Run a macro"])
CreateOption(Addon.BindingTypes.APPEND, Addon.L["Append a binding segment"])
CreateOption(Clicked.ActionType.SPELL, Addon.L["Cast a spell"])
CreateOption(Clicked.ActionType.ITEM, Addon.L["Use an item"])
CreateOption(Clicked.ActionType.CANCELAURA, Addon.L["Cancel an aura"])
CreateOption(Clicked.ActionType.UNIT_SELECT, Addon.L["Target the unit"])
CreateOption(Clicked.ActionType.UNIT_MENU, Addon.L["Open the unit menu"])
CreateOption(Clicked.ActionType.MACRO, Addon.L["Run a macro"])
CreateOption(Clicked.ActionType.APPEND, Addon.L["Append a binding segment"])
end
end

Expand Down Expand Up @@ -1012,8 +1012,8 @@ function Addon.BindingConfig.Window:CreateTreeFrame()
end
end

CreateOption(Addon.BindingScope.GLOBAL, Addon.L["Global"])
CreateOption(Addon.BindingScope.PROFILE, Addon.L["Profile"])
CreateOption(Clicked.DataObjectScope.GLOBAL, Addon.L["Global"])
CreateOption(Clicked.DataObjectScope.PROFILE, Addon.L["Profile"])
end

rootDescription:CreateButton(Addon.L["Share"], function()
Expand Down Expand Up @@ -1131,13 +1131,13 @@ function Addon.BindingConfig.Window:CreateTreeFrame()

table.insert(menu, convertTo)

AddConvertToOption(Addon.BindingTypes.SPELL, Addon.L["Cast a spell"])
AddConvertToOption(Addon.BindingTypes.ITEM, Addon.L["Use an item"])
AddConvertToOption(Addon.BindingTypes.CANCELAURA, Addon.L["Cancel an aura"])
AddConvertToOption(Addon.BindingTypes.UNIT_SELECT, Addon.L["Target the unit"])
AddConvertToOption(Addon.BindingTypes.UNIT_MENU, Addon.L["Open the unit menu"])
AddConvertToOption(Addon.BindingTypes.MACRO, Addon.L["Run a macro"])
AddConvertToOption(Addon.BindingTypes.APPEND, Addon.L["Append a binding segment"])
AddConvertToOption(Clicked.ActionType.SPELL, Addon.L["Cast a spell"])
AddConvertToOption(Clicked.ActionType.ITEM, Addon.L["Use an item"])
AddConvertToOption(Clicked.ActionType.CANCELAURA, Addon.L["Cancel an aura"])
AddConvertToOption(Clicked.ActionType.UNIT_SELECT, Addon.L["Target the unit"])
AddConvertToOption(Clicked.ActionType.UNIT_MENU, Addon.L["Open the unit menu"])
AddConvertToOption(Clicked.ActionType.MACRO, Addon.L["Run a macro"])
AddConvertToOption(Clicked.ActionType.APPEND, Addon.L["Append a binding segment"])
end
end

Expand Down Expand Up @@ -1166,8 +1166,8 @@ function Addon.BindingConfig.Window:CreateTreeFrame()

table.insert(menu, changeScope)

AddOption(Addon.BindingScope.GLOBAL, Addon.L["Global"])
AddOption(Addon.BindingScope.PROFILE, Addon.L["Profile"])
AddOption(Clicked.DataObjectScope.GLOBAL, Addon.L["Global"])
AddOption(Clicked.DataObjectScope.PROFILE, Addon.L["Profile"])
end

table.insert(menu, {
Expand Down
14 changes: 7 additions & 7 deletions Clicked/BindingConfig/Pages/Binding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ local Addon = select(2, ...)

local Helpers = Addon.BindingConfig.Helpers

local BT_SPELL = Addon.BindingTypes.SPELL
local BT_ITEM = Addon.BindingTypes.ITEM
local BT_MACRO = Addon.BindingTypes.MACRO
local BT_UNIT_SELECT = Addon.BindingTypes.UNIT_SELECT
local BT_UNIT_MENU = Addon.BindingTypes.UNIT_MENU
local BT_APPEND = Addon.BindingTypes.APPEND
local BT_CANCELAURA = Addon.BindingTypes.CANCELAURA
local BT_SPELL = Clicked.ActionType.SPELL
local BT_ITEM = Clicked.ActionType.ITEM
local BT_MACRO = Clicked.ActionType.MACRO
local BT_UNIT_SELECT = Clicked.ActionType.UNIT_SELECT
local BT_UNIT_MENU = Clicked.ActionType.UNIT_MENU
local BT_APPEND = Clicked.ActionType.APPEND
local BT_CANCELAURA = Clicked.ActionType.CANCELAURA

--- @param bindings Binding[]
--- @param bindingTypes string[]
Expand Down
53 changes: 26 additions & 27 deletions Clicked/BindingConfig/Pages/New.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ local AceGUI = LibStub("AceGUI-3.0")
--- @class ClickedInternal
local Addon = select(2, ...)

--- @enum BindingConfigNewPageItemTemplate
local ItemTemplate = {
GROUP = 0,
BINDING_CAST_SPELL = 10,
Expand All @@ -43,29 +42,29 @@ local function CreateGroup()
return group
end

--- @param type BindingConfigNewPageItemTemplate
--- @param type integer
--- @return Binding
local function CreateBinding(type)
local binding = Clicked:CreateBinding()

if type == ItemTemplate.BINDING_CAST_SPELL then
binding.actionType = Addon.BindingTypes.SPELL
binding.actionType = Clicked.ActionType.SPELL
elseif type == ItemTemplate.BINDING_CAST_SPELL_CLICKCAST then
binding.actionType = Addon.BindingTypes.SPELL
binding.actionType = Clicked.ActionType.SPELL
binding.targets.hovercastEnabled = true
binding.targets.regularEnabled = false
elseif type == ItemTemplate.BINDING_USE_ITEM then
binding.actionType = Addon.BindingTypes.ITEM
binding.actionType = Clicked.ActionType.ITEM
elseif type == ItemTemplate.BINDING_RUN_MACRO then
binding.actionType = Addon.BindingTypes.MACRO
binding.actionType = Clicked.ActionType.MACRO
elseif type == ItemTemplate.BINDING_RUN_MACRO_APPEND then
binding.actionType = Addon.BindingTypes.APPEND
binding.actionType = Clicked.ActionType.APPEND
elseif type == ItemTemplate.BINDING_CANCELAURA then
binding.actionType = Addon.BindingTypes.CANCELAURA
binding.actionType = Clicked.ActionType.CANCELAURA
elseif type == ItemTemplate.BINDING_UNIT_TARGET then
binding.actionType = Addon.BindingTypes.UNIT_SELECT
binding.actionType = Clicked.ActionType.UNIT_SELECT
elseif type == ItemTemplate.BINDING_UNIT_MENU then
binding.actionType = Addon.BindingTypes.UNIT_MENU
binding.actionType = Clicked.ActionType.UNIT_MENU
end

Clicked:ReloadBinding(binding, true)
Expand All @@ -91,7 +90,7 @@ local function CreateMacroBindingCache()
local result = {}

for _, binding in Clicked:IterateConfiguredBindings() do
if binding.actionType == Addon.BindingTypes.MACRO then
if binding.actionType == Clicked.ActionType.MACRO then
table.insert(result, {
name = binding.action.macroName,
content = binding.action.macroValue
Expand All @@ -104,7 +103,7 @@ end

--- @param spell SpellLibrarySpellResult
local function DoesSpellBookBindingExist(spell)
for _, binding in ipairs(Clicked:GetByActionType(Addon.BindingTypes.SPELL)) do
for _, binding in ipairs(Clicked:GetByActionType(Clicked.ActionType.SPELL)) do
if binding.action.spellValue == spell.spellId then
return true
end
Expand All @@ -120,17 +119,17 @@ local function DoesActionBarBindingExist(cache, spell)
local collection = cache[key] or {}

for _, binding in ipairs(collection) do
if spell.type == Addon.SpellLibrary.ResultType.SPELL and binding.actionType == Addon.BindingTypes.SPELL then
if spell.type == "SPELL" and binding.actionType == Clicked.ActionType.SPELL then
--- @cast spell SpellLibrarySpellResult
if binding.action.spellValue == spell.spellId then
return true
end
elseif spell.type == Addon.SpellLibrary.ResultType.ITEM and binding.actionType == Addon.BindingTypes.ITEM then
elseif spell.type == "ITEM" and binding.actionType == Clicked.ActionType.ITEM then
--- @cast spell SpellLibraryItemResult
if binding.action.itemValue == spell.itemId then
return true
end
elseif spell.type == Addon.SpellLibrary.ResultType.MACRO and binding.actionType == Addon.BindingTypes.MACRO then
elseif spell.type == "MACRO" and binding.actionType == Clicked.ActionType.MACRO then
--- @cast spell SpellLibraryMacroResult
if binding.action.macroName == spell.name and binding.action.macroValue == spell.content then
return true
Expand Down Expand Up @@ -187,7 +186,7 @@ local function ImportSpellbook()
local binding = Clicked:CreateBinding()
first = first or binding

binding.actionType = Addon.BindingTypes.SPELL
binding.actionType = Clicked.ActionType.SPELL
binding.parent = FindGroupId(spell.tabName, spell.tabIcon)
binding.action.spellValue = spell.spellId

Expand Down Expand Up @@ -225,30 +224,30 @@ local function ImportActionbar()
binding.keybind = spell.key
end

if spell.type == Addon.SpellLibrary.ResultType.SPELL then
if spell.type == "SPELL" then
--- @cast spell SpellLibrarySpellResult
binding.parent = FindGroupId(spell.tabName, spell.tabIcon)

binding.load.class.selected = 1
binding.load.class.single = select(2, UnitClass("player"))

if Addon.EXPANSION_LEVEL >= Addon.EXPANSION.MOP then
if Addon.EXPANSION_LEVEL >= Addon.Expansion.MOP then
binding.load.specialization.selected = 1
binding.load.specialization.single = GetSpecialization()
elseif Addon.EXPANSION_LEVEL >= Addon.EXPANSION.CATA then
elseif Addon.EXPANSION_LEVEL >= Addon.Expansion.CATA then
binding.load.specialization.selected = 1
binding.load.specialization.single = GetPrimaryTalentTree()
end

binding.actionType = Addon.BindingTypes.SPELL
binding.actionType = Clicked.ActionType.SPELL
binding.action.spellValue = spell.spellId
elseif spell.type == Addon.SpellLibrary.ResultType.ITEM then
elseif spell.type == "ITEM" then
--- @cast spell SpellLibraryItemResult
binding.actionType = Addon.BindingTypes.ITEM
binding.actionType = Clicked.ActionType.ITEM
binding.action.itemValue = spell.itemId
elseif spell.type == Addon.SpellLibrary.ResultType.MACRO then
elseif spell.type == "MACRO" then
--- @cast spell SpellLibraryMacroResult
binding.actionType = Addon.BindingTypes.MACRO
binding.actionType = Clicked.ActionType.MACRO
binding.action.macroName = spell.name
binding.action.macroIcon = spell.icon
binding.action.macroValue = spell.content
Expand Down Expand Up @@ -278,7 +277,7 @@ local function ImportMacros()
local binding = Clicked:CreateBinding()
first = first or binding

binding.actionType = Addon.BindingTypes.MACRO
binding.actionType = Clicked.ActionType.MACRO
binding.action.macroName = spell.name
binding.action.macroIcon = spell.icon
binding.action.macroValue = spell.content
Expand Down Expand Up @@ -355,7 +354,7 @@ end

--- @private
--- @param container AceGUIContainer
--- @param type BindingConfigNewPageItemTemplate
--- @param type integer
--- @param label string
function Addon.BindingConfig.NewPage:CreateTemplateButton(container, type, label)
do
Expand All @@ -382,7 +381,7 @@ function Addon.BindingConfig.NewPage:CreateTemplateButton(container, type, label
end

--- @private
--- @param type BindingConfigNewPageItemTemplate
--- @param type integer
function Addon.BindingConfig.NewPage:CreateItem(type)
--- @type DataObject?
local target = nil
Expand Down
Loading

0 comments on commit e90da9b

Please sign in to comment.