From b40829abbbba21d27f432882015f15fb88bc1caa Mon Sep 17 00:00:00 2001 From: fulzamoth Date: Sat, 28 Sep 2019 23:58:39 -0400 Subject: [PATCH] add TargetCast support in Classic (#8) This change adds support for using LibCasterCasterino to get your target's casting info to enable the TargetCast module. It's not as clean as the newer retail native calls but works well enough for most interrupts. Note: because LibCasterCasterino is using combat log events to get casting info if a spell cast starts and is immediately cancelled or interrupted the log may not get updated and the cast bar will zombie complete. LibCasterCasterino can be found at: https://github.com/rgd87/LibClassicCasterino --- IceCastBar.lua | 76 ++++++++++++++++++++++++++++++++++-------- modules/TargetCast.lua | 10 ++++-- 2 files changed, 71 insertions(+), 15 deletions(-) diff --git a/IceCastBar.lua b/IceCastBar.lua index 2001d6f..8fe9015 100644 --- a/IceCastBar.lua +++ b/IceCastBar.lua @@ -23,6 +23,19 @@ if IceHUD.WowClassic then UnitChannelInfo = ChannelInfo end +-- Fulzamoth 2019-09-27 : Use LibClassicCasterino if it's there so we can use TargetCast +-- module in Classic WoW +if IceHUD.WowClassic then + LibClassicCasterino = LibStub("LibClassicCasterino", true) + UnitCastingInfo = function(unit) + return LibClassicCasterino:UnitCastingInfo(unit) + end + UnitChannelInfo = function(unit) + return LibClassicCasterino:UnitChannelInfo(unit) + end +end +-- end Fulzamoth change + local AuraIconWidth = 20 local AuraIconHeight = 20 @@ -46,21 +59,55 @@ end function IceCastBar.prototype:Enable(core) IceCastBar.super.prototype.Enable(self, core) - self:RegisterEvent("UNIT_SPELLCAST_SENT", "SpellCastSent") -- "player", spell, rank, target - self:RegisterEvent("CURRENT_SPELL_CAST_CHANGED", "SpellCastChanged") - self:RegisterEvent("UNIT_SPELLCAST_START", "SpellCastStart") -- unit, spell, rank - self:RegisterEvent("UNIT_SPELLCAST_STOP", "SpellCastStop") -- unit, spell, rank + -- Fulzamoth 2019-09-27 : LibClassicCasterino support + -- Setup callback to the library, and route events to + -- IceHUD's handler functions. + if LibClassicCasterino then + local CastbarEventHandler = function(event, ...) -- unitTarget, castGUID, spellID + if (event == "UNIT_SPELLCAST_START") then + return IceCastBar.prototype.SpellCastStart(self, event, ...) + elseif (event == "UNIT_SPELLCAST_DELAYED") then + return IceCastBar.prototype.SpellCastDelayed(self, event, ...) + elseif (event == "UNIT_SPELLCAST_STOP") then + return IceCastBar.prototype.SpellCastStop(self, event, ...) + elseif (event == "UNIT_SPELLCAST_FAILED") then + return IceCastBar.prototype.SpellCastFailed(self, event, ...) + elseif (event == "UNIT_SPELLCAST_INTERRUPTED") then + return IceCastBar.prototype.SpellCastInterrupted(self, event, ...) + elseif (event == "UNIT_SPELLCAST_CHANNEL_START") then + return IceCastBar.prototype.SpellCastChannelStart(self, event, ...) + elseif (event == "UNIT_SPELLCAST_CHANNEL_UPDATE") then + return IceCastBar.prototype.SpellCastChannelUpdate(self, event, ...) + elseif (event == "UNIT_SPELLCAST_CHANNEL_STOP") then + return IceCastBar.prototype.SpellCastChannelStop(self, event, ...) + end + end + LibClassicCasterino.RegisterCallback(self,"UNIT_SPELLCAST_START", CastbarEventHandler) + LibClassicCasterino.RegisterCallback(self,"UNIT_SPELLCAST_DELAYED", CastbarEventHandler) -- only for player + LibClassicCasterino.RegisterCallback(self,"UNIT_SPELLCAST_STOP", CastbarEventHandler) + LibClassicCasterino.RegisterCallback(self,"UNIT_SPELLCAST_FAILED", CastbarEventHandler) + LibClassicCasterino.RegisterCallback(self,"UNIT_SPELLCAST_INTERRUPTED", CastbarEventHandler) + LibClassicCasterino.RegisterCallback(self,"UNIT_SPELLCAST_CHANNEL_START", CastbarEventHandler) + LibClassicCasterino.RegisterCallback(self,"UNIT_SPELLCAST_CHANNEL_UPDATE", CastbarEventHandler) -- only for player + LibClassicCasterino.RegisterCallback(self,"UNIT_SPELLCAST_CHANNEL_STOP", CastbarEventHandler) + else -- No LibClassicCasterino, or we're not on Classic, so use IceHUD's normal event handlers. - self:RegisterEvent("UNIT_SPELLCAST_FAILED", "SpellCastFailed") -- unit, spell, rank - self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED", "SpellCastInterrupted") -- unit, spell, rank + self:RegisterEvent("UNIT_SPELLCAST_SENT", "SpellCastSent") -- "player", spell, rank, target + self:RegisterEvent("CURRENT_SPELL_CAST_CHANGED", "SpellCastChanged") + self:RegisterEvent("UNIT_SPELLCAST_START", "SpellCastStart") -- unit, spell, rank + self:RegisterEvent("UNIT_SPELLCAST_STOP", "SpellCastStop") -- unit, spell, rank - self:RegisterEvent("UNIT_SPELLCAST_DELAYED", "SpellCastDelayed") -- unit, spell, rank - self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED", "SpellCastSucceeded") -- "player", spell, rank + self:RegisterEvent("UNIT_SPELLCAST_FAILED", "SpellCastFailed") -- unit, spell, rank + self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED", "SpellCastInterrupted") -- unit, spell, rank - self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START", "SpellCastChannelStart") -- unit, spell, rank - self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", "SpellCastChannelUpdate") -- unit, spell, rank - self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", "SpellCastChannelStop") -- unit, spell, rank + self:RegisterEvent("UNIT_SPELLCAST_DELAYED", "SpellCastDelayed") -- unit, spell, rank + self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED", "SpellCastSucceeded") -- "player", spell, rank + self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START", "SpellCastChannelStart") -- unit, spell, rank + self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE", "SpellCastChannelUpdate") -- unit, spell, rank + self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP", "SpellCastChannelStop") -- unit, spell, rank + + end self:Show(false) end @@ -371,8 +418,11 @@ function IceCastBar.prototype:StartBar(action, message) end end - if not spell then - return + -- Fulzamoth 2019-09-27 : LibClassicCasterino won't return spell info on target's failed or interrupted cast + if LibClassicCasterino and not spell then + self:StopBar() + elseif not spell then + return end if icon ~= nil then diff --git a/modules/TargetCast.lua b/modules/TargetCast.lua index 4dd234a..d56f8b5 100644 --- a/modules/TargetCast.lua +++ b/modules/TargetCast.lua @@ -65,7 +65,12 @@ function TargetCast.prototype:GetDefaultSettings() settings["side"] = IceCore.Side.Right settings["offset"] = 3 settings["flashInstants"] = "Never" - settings["flashFailures"] = "Never" + -- Fulzamoth 2019-09-27 : let the flash handler work if in Classic and LibClassicCasterino exists + if LibClassicCasterino then + settings["flashFailures"] = "" + else + settings["flashFailures"] = "Never" + end settings["shouldAnimate"] = false settings["hideAnimationSettings"] = true settings["usesDogTagStrings"] = false @@ -197,7 +202,8 @@ end ------------------------------------------------------------------------------- +-- Fulzamoth 2019-09-27 : load in Classic if LibClassicCasterino exists -- Load us up -if not IceHUD.WowClassic then +if not IceHUD.WowClassic or LibClassicCasterino then IceHUD.TargetCast = TargetCast:new() end