Skip to content

Commit eb0fd43

Browse files
committed
Autopopulate macro from items and cancelaura, generate based on full binding
1 parent 0b290c2 commit eb0fd43

File tree

3 files changed

+43
-23
lines changed

3 files changed

+43
-23
lines changed

CHANGELOG.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel
1919
* Add option to prevent toggling an ability off [#248]
2020
* Make key options respect macro condtions where able [#251]
2121
* Add option to automatically fall back to action bar abilities when no other macro conditions are met [#257]
22+
* Automatically populate macro when converting from a spell, item, or cancelaura binding [#264] (by [Gateswong])
2223

2324
### Fixed
2425

@@ -1733,14 +1734,15 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel
17331734
[0.4.0]: https://github.com/Snakybo/Clicked/releases/tag/0.4.0
17341735
[0.3.0]: https://github.com/Snakybo/Clicked/releases/tag/0.3.0
17351736

1736-
[#267]: https://github.com/Snakybo/Clicked/pull/267
1737-
[#265]: https://github.com/Snakybo/Clicked/pull/265
1738-
[#263]: https://github.com/Snakybo/Clicked/pull/263
1739-
[#257]: https://github.com/Snakybo/Clicked/pull/257
1740-
[#251]: https://github.com/Snakybo/Clicked/pull/251
1741-
[#248]: https://github.com/Snakybo/Clicked/pull/248
1742-
[#247]: https://github.com/Snakybo/Clicked/pull/247
1743-
[#245]: https://github.com/Snakybo/Clicked/pull/245
1737+
[#267]: https://github.com/Snakybo/Clicked/issues/267
1738+
[#265]: https://github.com/Snakybo/Clicked/issues/265
1739+
[#264]: https://github.com/Snakybo/Clicked/pull/264
1740+
[#263]: https://github.com/Snakybo/Clicked/issues/263
1741+
[#257]: https://github.com/Snakybo/Clicked/issues/257
1742+
[#251]: https://github.com/Snakybo/Clicked/issues/251
1743+
[#248]: https://github.com/Snakybo/Clicked/issues/248
1744+
[#247]: https://github.com/Snakybo/Clicked/issues/247
1745+
[#245]: https://github.com/Snakybo/Clicked/issues/245
17441746
[#243]: https://github.com/Snakybo/Clicked/issues/243
17451747
[#242]: https://github.com/Snakybo/Clicked/pull/242
17461748
[#241]: https://github.com/Snakybo/Clicked/issues/241
@@ -1857,3 +1859,4 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel
18571859
[nihilistzsche]: https://github.com/nihilistzsche
18581860
[Aeceon]: https://github.com/Aeceon
18591861
[m33shoq]: https://github.com/m33shoq
1862+
[Gateswong]: https://github.com/Gateswong

Clicked/BindingConfig/BindingConfig.lua

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -991,21 +991,37 @@ function Addon.BindingConfig.Window:CreateTreeFrame()
991991
if binding.actionType ~= type then
992992
first = first or binding
993993

994-
-- When converting spell to macro, try pre-define name, icon and a "/cast" in macro.
995-
if binding.actionType == Clicked.ActionType.SPELL and type == Clicked.ActionType.MACRO then
996-
if binding.action.spellValue then
997-
local spellName = C_Spell.GetSpellName(binding.action.spellValue)
998-
local iconId, _ = C_Spell.GetSpellTexture(binding.action.spellValue)
999-
if spellName then
1000-
binding.action.macroName = "Cast " .. spellName .. " (Macro)"
1001-
binding.action.macroValue = "/cast " .. spellName
1002-
end
1003-
if iconId then
1004-
binding.action.macroIcon = iconId
1005-
end
994+
-- When converting to any macro, try to fill in the macro name, value and icon
995+
if type == Clicked.ActionType.MACRO and Addon:IsNilOrEmpty(binding.action.macroValue) then
996+
local name = nil
997+
local icon = nil
998+
local format = nil
999+
1000+
if binding.actionType == Clicked.ActionType.SPELL then
1001+
name = C_Spell.GetSpellName(binding.action.spellValue)
1002+
icon = C_Spell.GetSpellTexture(binding.action.spellValue)
1003+
format = Addon.L["Cast %s"]
1004+
elseif binding.actionType == Clicked.ActionType.ITEM then
1005+
name = C_Item.GetItemNameByID(binding.action.itemValue)
1006+
icon = C_Item.GetItemIconByID(binding.action.itemValue)
1007+
format = Addon.L["Use %s"]
1008+
elseif binding.actionType == Clicked.ActionType.CANCELAURA then
1009+
name = C_Spell.GetSpellName(binding.action.auraName)
1010+
icon = C_Spell.GetSpellTexture(binding.action.auraName)
1011+
format = Addon.L["Cancel %s"]
10061012
end
1013+
1014+
if name ~= nil and format ~= nil then
1015+
binding.action.macroName = string.format(format, name)
1016+
end
1017+
1018+
if icon ~= nil then
1019+
binding.action.macroIcon = icon
1020+
end
1021+
1022+
binding.action.macroValue = Addon:GetMacroForBindings({ binding }, Addon.InteractionType.REGULAR, true)
10071023
end
1008-
1024+
10091025
binding.actionType = type
10101026

10111027
Addon:ReloadBinding(binding, true)

Clicked/Core/BindingProcessor.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,9 +1201,10 @@ end
12011201
---
12021202
--- @param bindings Binding[]
12031203
--- @param interactionType number
1204+
--- @param ignoreActionBar? boolean
12041205
--- @return string macro
12051206
--- @return string segments
1206-
function Addon:GetMacroForBindings(bindings, interactionType)
1207+
function Addon:GetMacroForBindings(bindings, interactionType, ignoreActionBar)
12071208
assert(type(bindings) == "table", "bad argument #1, expected table but got " .. type(bindings))
12081209
assert(type(interactionType) == "number", "bad argument #1, expected number but got " .. type(interactionType))
12091210

@@ -1347,7 +1348,7 @@ function Addon:GetMacroForBindings(bindings, interactionType)
13471348
do
13481349
local actionBar = {}
13491350

1350-
if Addon.db.profile.options.autoBindActionBar and interactionType == Addon.InteractionType.REGULAR then
1351+
if not ignoreActionBar and Addon.db.profile.options.autoBindActionBar and interactionType == Addon.InteractionType.REGULAR then
13511352
actionBar = Addon.SpellLibrary:GetActionBarSpells()
13521353
end
13531354

0 commit comments

Comments
 (0)