do not trigger cooldown again if active and timeleft > threshold

This commit is contained in:
Sumsebrum 2022-08-07 06:00:53 +02:00
parent 51143988be
commit 6161fcc7e3

View File

@ -456,6 +456,9 @@ function Cooldowns:CooldownStart(button, spellId, duration, start)
end end
for _,icon in pairs(button.spellCooldownFrame.icons) do for _,icon in pairs(button.spellCooldownFrame.icons) do
if (icon.spellId == spellId) then if (icon.spellId == spellId) then
if not start and icon.active and icon.timeLeft > Gladdy:GetCooldownList()[button.class][spellId].cd/2 then
return -- do not trigger cooldown again
end
icon.active = true icon.active = true
icon.timeLeft = start and start - GetTime() + duration or duration icon.timeLeft = start and start - GetTime() + duration or duration
if (not Gladdy.db.cooldownDisableCircle) then icon.cooldown:SetCooldown(start or GetTime(), duration) end if (not Gladdy.db.cooldownDisableCircle) then icon.cooldown:SetCooldown(start or GetTime(), duration) end
@ -465,7 +468,6 @@ function Cooldowns:CooldownStart(button, spellId, duration, start)
if Gladdy.db.cooldownIconAlphaOnCooldown < 1 then if Gladdy.db.cooldownIconAlphaOnCooldown < 1 then
icon.texture:SetAlpha(Gladdy.db.cooldownIconAlphaOnCooldown) icon.texture:SetAlpha(Gladdy.db.cooldownIconAlphaOnCooldown)
end end
--if math.random(1, 30 ) > 10 then LCG.ButtonGlow_Start(icon, nil, 0.15) end
icon:SetScript("OnUpdate", function(self, elapsed) icon:SetScript("OnUpdate", function(self, elapsed)
self.timeLeft = self.timeLeft - elapsed self.timeLeft = self.timeLeft - elapsed
local timeLeft = ceil(self.timeLeft) local timeLeft = ceil(self.timeLeft)
@ -484,6 +486,7 @@ function Cooldowns:CooldownStart(button, spellId, duration, start)
Cooldowns:CooldownReady(button, spellId, icon) Cooldowns:CooldownReady(button, spellId, icon)
end end
end) end)
break
--C_VoiceChat.SpeakText(2, GetSpellInfo(spellId), 3, 4, 100) --C_VoiceChat.SpeakText(2, GetSpellInfo(spellId), 3, 4, 100)
end end
end end
@ -617,7 +620,6 @@ function Cooldowns:AddCooldown(spellID, value, button)
icon.texture:SetTexture(self.spellTextures[spellID]) icon.texture:SetTexture(self.spellTextures[spellID])
tinsert(button.spellCooldownFrame.icons, icon) tinsert(button.spellCooldownFrame.icons, icon)
self:IconsSetPoint(button) self:IconsSetPoint(button)
Gladdy:Debug("INFO", "Cooldowns:AddCooldown", button.unit, GetSpellInfo(spellID))
end end
end end