-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexternals.lua
116 lines (91 loc) · 3.91 KB
/
externals.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
local detailsFramework = _G ["DetailsFramework"]
if (not detailsFramework) then
return
end
local IS_WOW_PROJECT_MAINLINE = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
local IS_WOW_PROJECT_NOT_MAINLINE = WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE
local IS_WOW_PROJECT_CLASSIC_ERA = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
detailsFramework.CastInfo = detailsFramework.CastInfo or {}
--NOTE: This NEEDs a chance to run, as Plater is depending on this working and LibCC is not bundled neccessarily in other addons.
-- for classic era use LibClassicCasterino:
--in vanilla wow, other addons might load the framework before an addon with libCasterino loads
--check here if libCasterino is loaded, if is, check if the framework is already using libCasterino, if not, make it use
function detailsFramework:LoadLCC(LibCC)
local fCast = CreateFrame("frame")
local getCastBar = function(unitId)
local plateFrame = C_NamePlate.GetNamePlateForUnit (unitId)
if (not plateFrame) then
return
end
local castBar = plateFrame.unitFrame and plateFrame.unitFrame.castBar
if (not castBar) then
return
end
return castBar
end
local triggerCastEvent = function(castBar, event, unitId, ...)
if (castBar and castBar.OnEvent) then
return castBar.OnEvent (castBar, event, unitId)
end
end
local funcCast = function(event, unitId, ...)
local castBar = getCastBar (unitId)
if (castBar) then
return triggerCastEvent (castBar, event, unitId)
end
end
fCast.UNIT_SPELLCAST_START = function(self, event, unitId, ...)
return triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_STOP = function(self, event, unitId, ...)
return triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_DELAYED = function(self, event, unitId, ...)
return triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_FAILED = function(self, event, unitId, ...)
return triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_INTERRUPTED = function(self, event, unitId, ...)
return triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_CHANNEL_START = function(self, event, unitId, ...)
return triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_CHANNEL_UPDATE = function(self, event, unitId, ...)
return triggerCastEvent (getCastBar (unitId), event, unitId)
end
fCast.UNIT_SPELLCAST_CHANNEL_STOP = function(self, event, unitId, ...)
return triggerCastEvent (getCastBar (unitId), event, unitId)
end
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_START", funcCast)
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_DELAYED", funcCast) -- only for player
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_STOP", funcCast)
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_FAILED", funcCast)
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_INTERRUPTED", funcCast)
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_CHANNEL_START", funcCast)
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_CHANNEL_UPDATE", funcCast) -- only for player
LibCC.RegisterCallback(fCast,"UNIT_SPELLCAST_CHANNEL_STOP", funcCast)
detailsFramework.CastInfo.UnitCastingInfo = function(unit)
return LibCC:UnitCastingInfo (unit)
end
detailsFramework.CastInfo.UnitChannelInfo = function(unit)
return LibCC:UnitChannelInfo (unit)
end
end
if IS_WOW_PROJECT_CLASSIC_ERA and false then --disable this for now, as it appears to be working now through API changes...
local LibCC = LibStub("LibClassicCasterino", true)
if (LibCC and not _G.DetailsFrameworkLCCLoaded) then
detailsFramework:LoadLCC(LibCC)
_G.DetailsFrameworkLCCLoaded = true
elseif not LibCC then
detailsFramework.CastInfo.UnitCastingInfo = CastingInfo
detailsFramework.CastInfo.UnitChannelInfo = ChannelInfo
end
else -- end classic era
detailsFramework.CastInfo.UnitCastingInfo = UnitCastingInfo
detailsFramework.CastInfo.UnitChannelInfo = UnitChannelInfo
end
if (not DetailsFrameworkCanLoad) then
return
end