Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Commit 2653250

Browse files
committed
I finally fixed the got-damn flickering Extra Action Button. Thank. Effing. Christ.
1 parent 5131fb3 commit 2653250

File tree

4 files changed

+73
-67
lines changed

4 files changed

+73
-67
lines changed

Neuron-Startup.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ function Neuron:RegisterGUI()
155155
TOOLTIPS = true,
156156
BINDTEXT = true,
157157
COUNTTEXT = true,
158+
CDTEXT = true,
159+
CDALPHA = true,
158160
BORDERSTYLE = true,},
159161
false, 65)
160162

@@ -171,6 +173,8 @@ function Neuron:RegisterGUI()
171173
TOOLTIPS = true,
172174
BINDTEXT = true,
173175
COUNTTEXT = true,
176+
CDTEXT = true,
177+
CDALPHA = true,
174178
BORDERSTYLE = true,},
175179
false, 65)
176180

Objects/BUTTON.lua

Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,14 @@ end
144144
function BUTTON:CancelCooldownTimer(stopAnimation)
145145
--cleanup so on state changes the cooldowns don't persist
146146
if self:TimeLeft(self.iconframecooldown.cooldownTimer) ~= 0 then
147+
self:CancelTimer(self.iconframecooldown.cooldownTimer)
148+
end
149+
150+
if self:TimeLeft(self.iconframecooldown.cooldownUpdateTimer) ~= 0 then
147151
self:CancelTimer(self.iconframecooldown.cooldownUpdateTimer)
148152
end
149-
self.iconframecooldown.timer:SetText("")
150153

151-
self:SetObjectVisibility()
154+
self.iconframecooldown.timer:SetText("")
152155

153156
self.iconframecooldown.showCountdownTimer = false
154157
self.iconframecooldown.showCountdownAlpha = false
@@ -157,16 +160,17 @@ function BUTTON:CancelCooldownTimer(stopAnimation)
157160
if stopAnimation then
158161
CooldownFrame_Clear(self.iconframecooldown) --clear the cooldown frame
159162
end
163+
164+
self:SetObjectVisibility()
165+
160166
end
161167

162168

163169
function BUTTON:SetCooldownTimer(start, duration, enable, showCountdownTimer, modrate, color1, color2, showCountdownAlpha, charges, maxCharges)
164170

165171
if not self.isShown then --if the button isn't shown, don't do set any cooldowns
166172
--if there's currently a timer, cancel it
167-
if self:TimeLeft(self.iconframecooldown.cooldownTimer) ~= 0 then
168-
self:CancelCooldownTimer(true)
169-
end
173+
self:CancelCooldownTimer(true)
170174
return
171175
end
172176

@@ -626,14 +630,17 @@ end
626630

627631
---Updates the buttons "count", i.e. the spell charges
628632
function BUTTON:UpdateSpellCount(spell)
629-
local charges, maxCharges = GetSpellCharges(spell)
630-
631-
local count = GetSpellCount(spell)
632-
633-
if (maxCharges and maxCharges > 1) then
634-
self.count:SetText(charges)
635-
elseif count and count > 0 then
636-
self.count:SetText(count)
633+
if spell then
634+
local charges, maxCharges = GetSpellCharges(spell)
635+
local count = GetSpellCount(spell)
636+
637+
if (maxCharges and maxCharges > 1) then
638+
self.count:SetText(charges)
639+
elseif count and count > 0 then
640+
self.count:SetText(count)
641+
else
642+
self.count:SetText("")
643+
end
637644
else
638645
self.count:SetText("")
639646
end
@@ -681,47 +688,56 @@ end
681688

682689

683690
function BUTTON:SetSpellCooldown(spell)
691+
if spell then
692+
if type(spell) == "string" then
693+
spell = (spell):lower()
694+
end
684695

685-
if type(spell) == "string" then
686-
spell = (spell):lower()
687-
end
688-
689-
local start, duration, enable, modrate = GetSpellCooldown(spell)
690-
local charges, maxCharges, chStart, chDuration, chargemodrate = GetSpellCharges(spell)
696+
local start, duration, enable, modrate = GetSpellCooldown(spell)
697+
local charges, maxCharges, chStart, chDuration, chargemodrate = GetSpellCharges(spell)
691698

692-
if (charges and maxCharges and maxCharges > 0 and charges < maxCharges) then
693-
self:SetCooldownTimer(chStart, chDuration, enable, self.cdText, chargemodrate, self.cdcolor1, self.cdcolor2, self.cdAlpha, charges, maxCharges) --only evoke charge cooldown (outer border) if charges are present and less than maxCharges (this is the case with the GCD)
699+
if (charges and maxCharges and maxCharges > 0 and charges < maxCharges) then
700+
self:SetCooldownTimer(chStart, chDuration, enable, self.cdText, chargemodrate, self.cdcolor1, self.cdcolor2, self.cdAlpha, charges, maxCharges) --only evoke charge cooldown (outer border) if charges are present and less than maxCharges (this is the case with the GCD)
701+
else
702+
self:SetCooldownTimer(start, duration, enable, self.cdText, modrate, self.cdcolor1, self.cdcolor2, self.cdAlpha, charges, maxCharges) --call standard cooldown, handles both abilty cooldowns and GCD
703+
end
694704
else
695-
self:SetCooldownTimer(start, duration, enable, self.cdText, modrate, self.cdcolor1, self.cdcolor2, self.cdAlpha, charges, maxCharges) --call standard cooldown, handles both abilty cooldowns and GCD
705+
self:CancelCooldownTimer(true)
696706
end
697707
end
698708

699709

700710

701711
function BUTTON:SetItemCooldown(item)
712+
if item then
713+
local id = NeuronItemCache[item]
702714

703-
local id = NeuronItemCache[item]
704-
705-
if (id) then
715+
if (id) then
706716

707-
local start, duration, enable, modrate = GetItemCooldown(id)
717+
local start, duration, enable, modrate = GetItemCooldown(id)
708718

709-
self:SetCooldownTimer(start, duration, enable, self.cdText, modrate, self.cdcolor1, self.cdcolor2, self.cdAlpha)
719+
self:SetCooldownTimer(start, duration, enable, self.cdText, modrate, self.cdcolor1, self.cdcolor2, self.cdAlpha)
720+
end
721+
else
722+
self:CancelCooldownTimer(true)
710723
end
711724
end
712725

713726
function BUTTON:ACTION_SetCooldown(action)
727+
if action then
728+
local actionID = tonumber(action)
714729

715-
local actionID = tonumber(action)
730+
if (actionID) then
716731

717-
if (actionID) then
732+
if (HasAction(actionID)) then
718733

719-
if (HasAction(actionID)) then
734+
local start, duration, enable, modrate = GetActionCooldown(actionID)
720735

721-
local start, duration, enable, modrate = GetActionCooldown(actionID)
722-
723-
self:SetCooldownTimer(start, duration, enable, self.cdText, modrate, self.cdcolor1, self.cdcolor2, self.cdAlpha)
736+
self:SetCooldownTimer(start, duration, enable, self.cdText, modrate, self.cdcolor1, self.cdcolor2, self.cdAlpha)
737+
end
724738
end
739+
else
740+
self:CancelCooldownTimer(true)
725741
end
726742
end
727743

Objects/EXTRABTN.lua

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ function EXTRABTN:SetType()
6666
--action content gets set in UpdateButton
6767
self:UpdateButton()
6868

69-
self:SetScript("OnDragStart", function(self)
70-
if self.spellID then
71-
PickupSpell(self.spellID)
72-
end
73-
end)
74-
7569
self:SetScript("OnEnter", function(self, ...) self:OnEnter(...) end)
7670
self:SetScript("OnLeave", GameTooltip_Hide)
7771

@@ -106,32 +100,29 @@ function EXTRABTN:UpdateButton()
106100
self:SetAttribute("action1", self.actionID)
107101
end
108102

109-
self:SetObjectVisibility()
110-
103+
-----------------------
111104
_, self.spellID = GetActionInfo(self.actionID)
112105

113106
if self.spellID then
114-
115107
self.spellName, _, self.spellIcon = GetSpellInfo(self.spellID);
116-
117-
self:UpdateIcon()
118-
119-
self:UpdateCooldown()
120-
121-
--extra button charges (some quests have ability charges)
122-
self:UpdateSpellCount(self.spellID)
108+
else
109+
self.spellName = ""
110+
self.spellIcon = ""
123111
end
124112

113+
self:SetObjectVisibility()
114+
self:UpdateIcon()
115+
self:UpdateCooldown()
116+
--extra button charges (some quests have ability charges)
117+
self:UpdateSpellCount(self.spellID)
125118
--make sure our button gets the correct Normal texture if we're not using a Masque skin
126119
self:UpdateNormalTexture()
127120

128121
end
129122

130123
---overwrite function in parent class BUTTON
131124
function EXTRABTN:UpdateCooldown()
132-
if self.spellID then
133-
self:SetSpellCooldown(self.spellID) --for some reason this doesn't work if you give it self.spellName. The cooldown will be nil
134-
end
125+
self:SetSpellCooldown(self.spellID) --for some reason this doesn't work if you give it self.spellName. The cooldown will be nil
135126
end
136127

137128

Objects/ZONEABILITYBTN.lua

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -90,37 +90,32 @@ end
9090
---overwrite function in parent class BUTTON
9191
function ZONEABILITYBTN:UpdateButton()
9292

93-
self:SetObjectVisibility()
94-
9593
--update the ZoneAbility spell ID
9694
self.spellID = GetZoneAbilitySpellInfo();
9795

9896
if self.spellID then
99-
10097
self.spellName, _, self.spellIcon = GetSpellInfo(self.spellID);
101-
102-
self:UpdateIcon()
103-
104-
if (self.spellName and not InCombatLockdown()) then
98+
if self.spellName and not InCombatLockdown() then
10599
self:SetAttribute("macrotext1", "/cast " .. self.spellName .. "();")
106100
end
107-
108-
self:UpdateCooldown()
109-
110-
--zone ability button charges (I'm not sure if zone abilities have charges, but this is just in case)
111-
self:UpdateSpellCount(self.spellName)
101+
else
102+
self.spellName = ""
103+
self.spellIcon = ""
112104
end
113105

106+
self:SetObjectVisibility()
107+
self:UpdateIcon()
108+
self:UpdateCooldown()
109+
--zone ability button charges (I'm not sure if zone abilities have charges, but this is just in case)
110+
self:UpdateSpellCount(self.spellName)
114111
--make sure our button gets the correct Normal texture if we're not using a Masque skin
115112
self:UpdateNormalTexture()
116113

117114
end
118115

119116
--overwrite function in parent class BUTTON
120117
function ZONEABILITYBTN:UpdateCooldown()
121-
if self.spellName then
122-
self:SetSpellCooldown(self.spellName)
123-
end
118+
self:SetSpellCooldown(self.spellName)
124119
end
125120

126121
function ZONEABILITYBTN:SetObjectVisibility()

0 commit comments

Comments
 (0)