From bc206e1b3c50999d74e86a8e6533bf4962515f0d Mon Sep 17 00:00:00 2001 From: Daenarys Date: Sat, 29 Jun 2024 22:37:07 +0200 Subject: [PATCH] flyout fixes --- RazerNaga/actionButton.lua | 4 ++-- RazerNaga/spellFlyout.lua | 44 ++++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/RazerNaga/actionButton.lua b/RazerNaga/actionButton.lua index a3c79aa..a3348cf 100644 --- a/RazerNaga/actionButton.lua +++ b/RazerNaga/actionButton.lua @@ -122,7 +122,7 @@ function ActionButtonMixin:OnCreate(id) RazerNaga.BindableButton:AddQuickBindingSupport(self) -- apply custom flyout - --RazerNaga.SpellFlyout:Register(self) + RazerNaga.SpellFlyout:Register(self) -- use pre 10.x button size self:SetSize(36, 36) @@ -297,7 +297,7 @@ function ActionButton:AddCastOnKeyPressSupport(button) bind.SetOverrideBindings = bindButton_SetOverrideBindings - --RazerNaga.SpellFlyout:Register(bind) + RazerNaga.SpellFlyout:Register(bind) -- translate HOTKEY button "clicks" into LeftButton self:WrapScript(bind, "OnClick", [[ diff --git a/RazerNaga/spellFlyout.lua b/RazerNaga/spellFlyout.lua index a9c3e99..94320f9 100644 --- a/RazerNaga/spellFlyout.lua +++ b/RazerNaga/spellFlyout.lua @@ -93,35 +93,41 @@ function SpellFlyoutButtonMixin:UpdateCooldown() end function SpellFlyoutButtonMixin:UpdateState() - if C_Spell.IsCurrentSpell(self.spellID) then - self:SetChecked(true) - else - self:SetChecked(false) + if self.spellID then + if C_Spell.IsCurrentSpell(self.spellID) then + self:SetChecked(true) + else + self:SetChecked(false) + end end end function SpellFlyoutButtonMixin:UpdateUsable() - local isUsable, notEnoughMana = C_Spell.IsSpellUsable(self.spellID) - local icon = self.icon - if ( isUsable ) then - icon:SetVertexColor(1.0, 1.0, 1.0) - elseif ( notEnoughMana ) then - icon:SetVertexColor(0.5, 0.5, 1.0) - else - icon:SetVertexColor(0.4, 0.4, 0.4) + if self.spellID then + local isUsable, notEnoughMana = C_Spell.IsSpellUsable(self.spellID) + local icon = self.icon + if ( isUsable ) then + icon:SetVertexColor(1.0, 1.0, 1.0) + elseif ( notEnoughMana ) then + icon:SetVertexColor(0.5, 0.5, 1.0) + else + icon:SetVertexColor(0.4, 0.4, 0.4) + end end end function SpellFlyoutButtonMixin:UpdateCount() - if IsConsumableSpell(self.spellID) then - local count = C_Spell.GetSpellCastCount(self.spellID) - if count > (self.maxDisplayCount or 9999) then - self.Count:SetText("*") + if self.spellID then + if IsConsumableSpell(self.spellID) then + local count = C_Spell.GetSpellCastCount(self.spellID) + if count > (self.maxDisplayCount or 9999) then + self.Count:SetText("*") + else + self.Count:SetText(count) + end else - self.Count:SetText(count) + self.Count:SetText("") end - else - self.Count:SetText("") end end