Skip to content

Commit

Permalink
Add rune equipped load condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Snakybo committed Sep 8, 2024
1 parent 80182e5 commit 6281d3a
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 17 deletions.
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ read_globals = {
"C_ChatInfo",
"C_ClassTalents",
"C_CreatureInfo",
"C_Engraving",
"C_Item",
"C_MountJournal",
"C_PetJournal",
Expand Down
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel
### Added

* Add Shadow Dance form for Subtlety Rogue [#224]
* Add Runes to the spell autofill and spellbook import for Classic Era
* Add Runes to the spell autocomplete and spellbook import for Classic Era
* Add Rune equipped load condition for Classic Era

## [1.16.3] - 2024-09-06

Expand Down Expand Up @@ -67,15 +68,15 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel
* Add multi-selection editing, select multiple items and edit them all at once
* Remember last selected sorting method when closing the binding window
* Remember last selected binding(s) when closing the binding window
* Add profession abilities to spell autofill
* Add profession abilities to spell autocomplete
* Add profession abilities to spellbook import
* Add Dominos action bars to quick start import
* Include shapeshift-specific action bars in quick start import
* Include all 7 action bars in quick start import, up from 4
* Include all 15 Bartender4 action bars in quick start import, up from 6
* Include all 15 ElvUI bars action bars in quick start import, up from 6
* Add more information to a bunch of tooltips in the binding configuration window
* Add spell ranks to spell autofill in Classic Era
* Add spell ranks to spell autocomplete in Classic Era
* Create bindings when dragging a macro into the binding configuration window
* Add quick start import from macros
* Add chat command to disable (or re-enable) the self-cast warning
Expand All @@ -88,7 +89,7 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel
* Fix dragging bindings onto an empty space not doing anything
* Fix duplicate binding check when importing from spellbook or action bar
* Fix cancelaura spell input not parsing correctly [#216] [#217]
* Fix spell autofill for flyout abilities [#212]
* Fix spell autocomplete for flyout abilities [#212]
* Fix a game freeze when clearing the search box
* Fix macro length calculation for non-English letters
* Fix Lua error in the keyboard visualizer
Expand Down Expand Up @@ -141,7 +142,7 @@ The format of this changelog is based on [Keep a Changelog](https://keepachangel

### Added

* Add pet abilities to spell autofill
* Add pet abilities to spell autocomplete
* Add drag support for pet abilities into the spell name input field

### Fixed
Expand Down
48 changes: 46 additions & 2 deletions Clicked/BindingConfig/Conditions/InputDrawer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Addon.BindingConfig = Addon.BindingConfig or {}

--- @class BindingInputConditionDrawer : BindingConditionDrawer
--- @field private checkbox ClickedCheckBox
--- @field private editbox? ClickedEditBox
--- @field private editbox? ClickedEditBox|ClickedAutoFillEditBox
--- @field private negated? ClickedCheckBox
local Drawer = {}

Expand All @@ -47,11 +47,23 @@ function Drawer:Draw()

-- editbox
do
local items = self.requestAvailableValues()

--- @param binding Binding
--- @return string
local function ValueSelector(binding)
--- @type SimpleLoadOption
local load = binding.load[self.fieldName] or self.condition.init()
local spellId = tonumber(load.value)

if items ~= nil and spellId ~= nil then
for _, item in ipairs(items) do
if spellId == item.spellId then
return item.text
end
end
end

return load.value
end

Expand Down Expand Up @@ -105,7 +117,39 @@ function Drawer:Draw()
self.requestRedraw()
end

self.editbox = AceGUI:Create("ClickedEditBox") --[[@as ClickedEditBox]]
local function OnSelect(_, _, value, match)
local spellId = (match ~= nil and match.spellId ~= nil) and tostring(match.spellId) or value

for _, binding in ipairs(self.bindings) do
--- @type SimpleLoadOption
local load = binding.load[self.fieldName] or self.condition.init()

if load.selected then
load.value = spellId
binding.load[self.fieldName] = load
Addon:ReloadBinding(binding, self.fieldName)
end
end
end

if items ~= nil then
local error = FindInTableIf(self.bindings, function(binding)
--- @type SimpleLoadOption
local load = binding.load[self.fieldName] or self.condition.init()

return load.selected and FindInTableIf(items, function(item)
return item.spellId == load.value
end) == nil
end) == nil

self.editbox = AceGUI:Create("ClickedAutoFillEditBox") --[[@as ClickedAutoFillEditBox]]
self.editbox:SetInputError(error)
self.editbox:SetValues(items)
self.editbox:SetCallback("OnSelect", OnSelect)
else
self.editbox = AceGUI:Create("ClickedEditBox") --[[@as ClickedEditBox]]
end

self.editbox:SetCallback("OnTextChanged", OnTextChanged)
self.editbox:SetCallback("OnEnterPressed", OnEnterPressed)
self.editbox:SetRelativeWidth(0.5)
Expand Down
41 changes: 41 additions & 0 deletions Clicked/Conditions/LoadConditions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,47 @@ local config = {
test = function(value)
return C_Item.IsEquippedItem(value)
end
},
{
id = "runeEquipped",
drawer = {
type = "input",
label = "Rune equipped",
availableValues = function()
--- @type ClickedAutoFillEditBox.Option[]
local result = {}

C_Engraving:ClearAllCategoryFilters();
C_Engraving.RefreshRunesList()

for _, category in ipairs(C_Engraving.GetRuneCategories(false, false)) do
for _, engraving in ipairs(C_Engraving.GetRunesForCategory(category, false)) do
table.insert(result, {
text = engraving.name,
icon = engraving.iconTexture,
spellId = engraving.skillLineAbilityID
})
end
end

return result
end
},
disabled = Addon.EXPANSION_LEVEL > Addon.Expansion.CLASSIC or C_Engraving == nil,
init = function()
return Utils.CreateLoadOption("")
end,
unpack = Utils.UnpackSimpleLoadOption,
testOnEvents = { "RUNE_UPDATED", "PLAYER_EQUIPMENT_CHANGED" },
--- @param value string
test = function(value)
local spellId = tonumber(value)
if spellId == nil then
return false
end

return C_Engraving.IsRuneEquipped(spellId)
end
}
}

Expand Down
14 changes: 4 additions & 10 deletions Clicked/Config/SpellLibrary.lua
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ local function GetSpells_v1()
--- @param type string
--- @param id integer
--- @param tabName? string
--- @param tabIcon? string
--- @param tabIcon? string|integer
--- @param specId? integer
local function ParseSpellBookItem(type, id, tabName, tabIcon, specId)
if not IsPassiveSpell(id) then
Expand Down Expand Up @@ -276,19 +276,13 @@ local function GetSpells_v1()
end

if C_Engraving ~= nil then
C_Engraving:ClearAllCategoryFilters();
C_Engraving.RefreshRunesList()

for _, category in ipairs(C_Engraving.GetRuneCategories(false, true)) do
for _, category in ipairs(C_Engraving.GetRuneCategories(false, false)) do
for _, engraving in ipairs(C_Engraving.GetRunesForCategory(category, false)) do
for _, spellId in ipairs(engraving.learnedAbilitySpellIDs) do
result[spellId] = {
type = "SPELL",
name = engraving.name,
spellId = spellId,
icon = engraving.iconTexture,
tabName = runesTabName,
tabIcon = runesTabIcon
}
ParseSpellBookItem("SPELL", spellId, runesTabName, runesTabIcon)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions Clicked/Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,4 @@ L["Clear blue cursor"] = true
L["Clears the \"blue casting cursor\"."] = true
L["It's recommended to always leave this option enabled unless you need the extra space in a macro."] = true
L["Without it you may be left with a dangling cast if the macro cannot determine the target automatically, in other words if your targets don't end in either 'player' or 'cursor' (or 'default' if self-cast is enabled)"] = true
L["Rune equipped"] = true

0 comments on commit 6281d3a

Please sign in to comment.