Skip to content

Commit 016fc2b

Browse files
committed
Re-add support for LibClassicCasterino
1 parent 83434fe commit 016fc2b

File tree

4 files changed

+57
-20
lines changed

4 files changed

+57
-20
lines changed

.pkgmeta

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ externals:
1818
libs/LibSharedMedia-3.0: https://repos.wowace.com/wow/libsharedmedia-3-0/trunk/LibSharedMedia-3.0
1919
libs/LibDualSpec-1.0: https://repos.wowace.com/wow/libdualspec-1-0
2020
libs/LibWindow-1.1: https://repos.wowace.com/wow/libwindow-1-1/trunk/LibWindow-1.1
21+
libs/LibClassicCasterino: https://github.com/rgd87/LibClassicCasterino.git
2122

2223
tools-used:
2324
- localescrapper

CastBarTemplate.lua

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,26 @@ local media = LibStub("LibSharedMedia-3.0")
2424
local lsmlist = AceGUIWidgetLSMlists
2525

2626
local WoWRetail = (WOW_PROJECT_ID == WOW_PROJECT_MAINLINE)
27+
local WoWClassic = (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC)
28+
29+
local LibClassicCasterino = WoWClassic and LibStub("LibClassicCasterino", true)
2730

2831
----------------------------
2932
-- Upvalues
3033
local min, type, format, unpack, setmetatable = math.min, type, string.format, unpack, setmetatable
3134
local CreateFrame, GetTime, UIParent = CreateFrame, GetTime, UIParent
3235
local UnitName, UnitCastingInfo, UnitChannelInfo = UnitName, UnitCastingInfo, UnitChannelInfo
3336

37+
if LibClassicCasterino then
38+
UnitCastingInfo = function(unit)
39+
return LibClassicCasterino:UnitCastingInfo(unit)
40+
end
41+
42+
UnitChannelInfo = function(unit)
43+
return LibClassicCasterino:UnitChannelInfo(unit)
44+
end
45+
end
46+
3447
local CastBarTemplate = CreateFrame("Frame")
3548
local CastBarTemplate_MT = {__index = CastBarTemplate}
3649

@@ -516,17 +529,32 @@ function CastBarTemplate:RegisterEvents()
516529
if self.unit == "player" then
517530
self:RegisterEvent("UNIT_SPELLCAST_SENT")
518531
end
519-
self:RegisterEvent("UNIT_SPELLCAST_START")
520-
self:RegisterEvent("UNIT_SPELLCAST_STOP")
521-
self:RegisterEvent("UNIT_SPELLCAST_FAILED")
522-
self:RegisterEvent("UNIT_SPELLCAST_DELAYED")
523-
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
524-
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
525-
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
526-
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
527-
if self.unit ~= "player" and WoWRetail then
528-
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE")
529-
self:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
532+
533+
if LibClassicCasterino then
534+
local CastbarEventHandler = function(event, ...)
535+
return self[event](self, event, ...)
536+
end
537+
LibClassicCasterino.RegisterCallback(self, "UNIT_SPELLCAST_START", CastbarEventHandler)
538+
LibClassicCasterino.RegisterCallback(self, "UNIT_SPELLCAST_STOP", CastbarEventHandler)
539+
LibClassicCasterino.RegisterCallback(self, "UNIT_SPELLCAST_FAILED", CastbarEventHandler)
540+
LibClassicCasterino.RegisterCallback(self, "UNIT_SPELLCAST_DELAYED", CastbarEventHandler)
541+
LibClassicCasterino.RegisterCallback(self, "UNIT_SPELLCAST_INTERRUPTED", CastbarEventHandler)
542+
LibClassicCasterino.RegisterCallback(self, "UNIT_SPELLCAST_CHANNEL_START", CastbarEventHandler)
543+
LibClassicCasterino.RegisterCallback(self, "UNIT_SPELLCAST_CHANNEL_UPDATE", CastbarEventHandler)
544+
LibClassicCasterino.RegisterCallback(self, "UNIT_SPELLCAST_CHANNEL_STOP", CastbarEventHandler)
545+
else
546+
self:RegisterEvent("UNIT_SPELLCAST_START")
547+
self:RegisterEvent("UNIT_SPELLCAST_STOP")
548+
self:RegisterEvent("UNIT_SPELLCAST_FAILED")
549+
self:RegisterEvent("UNIT_SPELLCAST_DELAYED")
550+
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED")
551+
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_START")
552+
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_UPDATE")
553+
self:RegisterEvent("UNIT_SPELLCAST_CHANNEL_STOP")
554+
if self.unit ~= "player" and WoWRetail then
555+
self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTIBLE")
556+
self:RegisterEvent("UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
557+
end
530558
end
531559

532560
media.RegisterCallback(self, "LibSharedMedia_SetGlobal", function(mtype, override)
@@ -546,6 +574,9 @@ function CastBarTemplate:UnregisterEvents()
546574
self:UnregisterAllEvents()
547575
media.UnregisterCallback(self, "LibSharedMedia_SetGlobal")
548576
media.UnregisterCallback(self, "LibSharedMedia_Registered")
577+
if LibClassicCasterino then
578+
LibClassicCasterino.UnregisterAllCallbacks(self)
579+
end
549580
end
550581

551582
do

Quartz.toc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ libs\AceGUI-3.0-SharedMediaWidgets\widget.xml
4040
libs\LibDualSpec-1.0\LibDualSpec-1.0.lua
4141
#@end-retail@
4242
libs\LibWindow-1.1\LibWindow-1.1.lua
43+
#@version-classic@
44+
libs\LibClassicCasterino\LibClassicCasterino.lua
45+
#@end-version-classic@
4346
#@end-no-lib-strip@
4447

4548
locale\locale.xml

modules/Target.lua

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
local Quartz3 = LibStub("AceAddon-3.0"):GetAddon("Quartz3")
2020
local L = LibStub("AceLocale-3.0"):GetLocale("Quartz3")
2121

22-
if WOW_PROJECT_ID == WOW_PROJECT_CLASSIC then return end
23-
2422
local MODNAME = "Target"
2523
local Target = Quartz3:NewModule(MODNAME, "AceEvent-3.0", "AceHook-3.0")
2624

@@ -94,7 +92,9 @@ end
9492
function Target:OnEnable()
9593
self.Bar:RegisterEvents()
9694
self.Bar:RegisterEvent("PLAYER_TARGET_CHANGED")
97-
self:HookScript(TargetFrameSpellBar, "OnEvent", "Target_Spellbar_OnEvent")
95+
if TargetFrameSpellBar then
96+
self:HookScript(TargetFrameSpellBar, "OnEvent", "Target_Spellbar_OnEvent")
97+
end
9898
self.Bar.PLAYER_TARGET_CHANGED = self.Bar.UpdateUnit
9999
self.lastNotInterruptible = false
100100
self:ApplySettings()
@@ -115,12 +115,14 @@ end
115115
function Target:ApplySettings()
116116
db = self.db.profile
117117

118-
if self:IsEnabled() and db.hideblizz then
119-
TargetFrameSpellBar.showCastbar = false
120-
TargetFrameSpellBar:Hide()
121-
else
122-
if GetCVar("showTargetCastbar") ~= "0" then
123-
TargetFrameSpellBar.showCastbar = true
118+
if TargetFrameSpellBar then
119+
if self:IsEnabled() and db.hideblizz then
120+
TargetFrameSpellBar.showCastbar = false
121+
TargetFrameSpellBar:Hide()
122+
else
123+
if GetCVar("showTargetCastbar") ~= "0" then
124+
TargetFrameSpellBar.showCastbar = true
125+
end
124126
end
125127
end
126128

0 commit comments

Comments
 (0)