From 8c7579ad26517e2c45959f77d22b28c59fab2bfe Mon Sep 17 00:00:00 2001 From: shagu Date: Tue, 8 Dec 2020 21:56:39 +0100 Subject: [PATCH] castbar: reset delays on new spell casts --- compat/tbc.lua | 3 +++ compat/vanilla.lua | 3 +++ modules/castbar.lua | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/compat/tbc.lua b/compat/tbc.lua index a90fb1b6..c28bb28b 100644 --- a/compat/tbc.lua +++ b/compat/tbc.lua @@ -5,6 +5,9 @@ if pfUI.expansion ~= "tbc" then return end -- [[ Constants ]]-- CASTBAR_EVENT_CAST_DELAY = "UNIT_SPELLCAST_DELAYED" CASTBAR_EVENT_CHANNEL_DELAY = "UNIT_SPELLCAST_CHANNEL_UPDATE" +CASTBAR_EVENT_CAST_START = "UNIT_SPELLCAST_START" +CASTBAR_EVENT_CHANNEL_START = "UNIT_SPELLCAST_CHANNEL_START" + EVENTS_MINIMAP_ZONE_UPDATE = {"PLAYER_ENTERING_WORLD", "ZONE_CHANGED_NEW_AREA", "ZONE_CHANGED"} MICRO_BUTTONS = { diff --git a/compat/vanilla.lua b/compat/vanilla.lua index be78e676..0cc4485f 100644 --- a/compat/vanilla.lua +++ b/compat/vanilla.lua @@ -5,6 +5,9 @@ if pfUI.expansion ~= "vanilla" then return end -- [[ Constants ]]-- CASTBAR_EVENT_CAST_DELAY = "SPELLCAST_DELAYED" CASTBAR_EVENT_CHANNEL_DELAY = "SPELLCAST_CHANNEL_UPDATE" +CASTBAR_EVENT_CAST_START = "SPELLCAST_START" +CASTBAR_EVENT_CHANNEL_START = "SPELLCAST_CHANNEL_START" + EVENTS_MINIMAP_ZONE_UPDATE = {"PLAYER_ENTERING_WORLD", "MINIMAP_ZONE_CHANGED"} MICRO_BUTTONS = { diff --git a/modules/castbar.lua b/modules/castbar.lua index 26246dc9..05be4f9d 100644 --- a/modules/castbar.lua +++ b/modules/castbar.lua @@ -159,6 +159,8 @@ pfUI:RegisterModule("castbar", "vanilla:tbc", function () local playerarg = nil cb:RegisterEvent(CASTBAR_EVENT_CAST_DELAY) cb:RegisterEvent(CASTBAR_EVENT_CHANNEL_DELAY) + cb:RegisterEvent(CASTBAR_EVENT_CAST_START) + cb:RegisterEvent(CASTBAR_EVENT_CHANNEL_START) cb:SetScript("OnEvent", function() if this.unitstr and not UnitIsUnit(this.unitstr, "player") then return end playerarg = pfUI.client <= 11200 or arg1 == "player" and true or nil @@ -172,6 +174,8 @@ pfUI:RegisterModule("castbar", "vanilla:tbc", function () local isChannel, _, _, _, startTime, endTime = UnitChannelInfo(this.unitstr or this.unitname) if not isChannel then return end this.delay = ( this.delay or 0 ) + this.bar:GetValue() - (endTime/1000 - GetTime()) + elseif playerarg then + this.delay = 0 end end)