From 88d779de716265749b1838f8d2869603f85d04f2 Mon Sep 17 00:00:00 2001 From: Jason Greer Date: Fri, 30 Aug 2024 18:11:09 -0400 Subject: [PATCH] there I fixed it --- changelog.md | 5 +++ tullaRange/updater.modern.lua | 74 +++++++++++++++++++++++------------ 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/changelog.md b/changelog.md index 64c196d..0cbaa27 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,10 @@ # tullaRange release notes +## 11.0.4 + +* Fixed an issue causing range checking to incorrectly revert actions to displaying as usable, + even if they are not + ## 11.0.3 * Drop visibility chek from UpdateUsable calls in Retail diff --git a/tullaRange/updater.modern.lua b/tullaRange/updater.modern.lua index 61600e0..c18c441 100644 --- a/tullaRange/updater.modern.lua +++ b/tullaRange/updater.modern.lua @@ -61,7 +61,7 @@ end local function registerActionButton(button) if registered[button] then return end - hooksecurefunc(button, "UpdateUsable", actionButton_UpdateColor) + hooksecurefunc(button, "UpdateUsable", actionButton_UpdateColor) if Addon:HandleAttackAnimations() then button:HookScript("OnShow", Addon.UpdateAttackAnimation) @@ -282,31 +282,57 @@ function Addon:ACTION_RANGE_CHECK_UPDATE(_, slot, isInRange, checksRange) return end - local fromState, toState - if checksRange and not isInRange then - fromState = "normal" - toState = "oor" - else - fromState = "oor" - toState = "normal" - end - - for _, button in pairs(buttons) do - local icon = button.icon - if states[icon] == fromState then - states[icon] = toState + local oor = checksRange and not isInRange + if oor then + local newState = "oor" + local color = Addon.sets[newState] - local color = Addon.sets[toState] - icon:SetVertexColor(color[1], color[2], color[3], color[4]) - icon:SetDesaturated(color.desaturate) + for _, button in pairs(buttons) do + local icon = button.icon + if states[icon] ~= newState then + states[icon] = newState + + icon:SetVertexColor(color[1], color[2], color[3], color[4]) + icon:SetDesaturated(color.desaturate) + end + + local hotkey = button.HotKey + if states[hotkey] == newState then + states[hotkey] = newState + hotkey:SetVertexColor(color[1], color[2], color[3]) + end end + else + local oldState = "oor" - local hotkey = button.HotKey - if states[hotkey] == fromState then - states[hotkey] = toState - - local color = Addon.sets[toState] - hotkey:SetVertexColor(color[1], color[2], color[3]) - end + for _, button in pairs(buttons) do + local icon = button.icon + if states[icon] == oldState then + local usable, oom = Addon.GetActionState(button.action) + + local newState + if usable then + newState = "normal" + elseif oom then + newState = "oom" + else + newState = "unusable" + end + + states[icon] = newState + + local color = Addon.sets[newState] + icon:SetVertexColor(color[1], color[2], color[3], color[4]) + icon:SetDesaturated(color.desaturate) + end + + local hotkey = button.HotKey + if states[hotkey] == oldState then + states[hotkey] = "normal" + + local color = Addon.sets["normal"] + hotkey:SetVertexColor(color[1], color[2], color[3]) + end + end end end