@@ -24,13 +24,26 @@ local media = LibStub("LibSharedMedia-3.0")
24
24
local lsmlist = AceGUIWidgetLSMlists
25
25
26
26
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 )
27
30
28
31
---- ------------------------
29
32
-- Upvalues
30
33
local min , type , format , unpack , setmetatable = math.min , type , string.format , unpack , setmetatable
31
34
local CreateFrame , GetTime , UIParent = CreateFrame , GetTime , UIParent
32
35
local UnitName , UnitCastingInfo , UnitChannelInfo = UnitName , UnitCastingInfo , UnitChannelInfo
33
36
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
+
34
47
local CastBarTemplate = CreateFrame (" Frame" )
35
48
local CastBarTemplate_MT = {__index = CastBarTemplate }
36
49
@@ -516,17 +529,32 @@ function CastBarTemplate:RegisterEvents()
516
529
if self .unit == " player" then
517
530
self :RegisterEvent (" UNIT_SPELLCAST_SENT" )
518
531
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
530
558
end
531
559
532
560
media .RegisterCallback (self , " LibSharedMedia_SetGlobal" , function (mtype , override )
@@ -546,6 +574,9 @@ function CastBarTemplate:UnregisterEvents()
546
574
self :UnregisterAllEvents ()
547
575
media .UnregisterCallback (self , " LibSharedMedia_SetGlobal" )
548
576
media .UnregisterCallback (self , " LibSharedMedia_Registered" )
577
+ if LibClassicCasterino then
578
+ LibClassicCasterino .UnregisterAllCallbacks (self )
579
+ end
549
580
end
550
581
551
582
do
0 commit comments