-
Notifications
You must be signed in to change notification settings - Fork 58
/
blizzard.lua
172 lines (138 loc) · 4.06 KB
/
blizzard.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
local _, ns = ...
local oUF = ns.oUF
-- sourced from Blizzard_UnitFrame/TargetFrame.lua
local MAX_BOSS_FRAMES = 8 -- blizzard can spawn more than the default 5 apparently
-- sourced from Blizzard_FrameXMLBase/Shared/Constants.lua
local MEMBERS_PER_RAID_GROUP = _G.MEMBERS_PER_RAID_GROUP or 5
local hookedFrames = {}
local hookedNameplates = {}
local isArenaHooked = false
local isBossHooked = false
local isPartyHooked = false
local hiddenParent = CreateFrame('Frame', nil, UIParent)
hiddenParent:SetAllPoints()
hiddenParent:Hide()
local function insecureHide(self)
self:Hide()
end
local function resetParent(self, parent)
if(parent ~= hiddenParent) then
self:SetParent(hiddenParent)
end
end
local function handleFrame(baseName, doNotReparent)
local frame
if(type(baseName) == 'string') then
frame = _G[baseName]
else
frame = baseName
end
if(frame) then
frame:UnregisterAllEvents()
frame:Hide()
if(not doNotReparent) then
frame:SetParent(hiddenParent)
if(not hookedFrames[frame]) then
hooksecurefunc(frame, 'SetParent', resetParent)
hookedFrames[frame] = true
end
end
local health = frame.healthBar or frame.healthbar or frame.HealthBar
if(health) then
health:UnregisterAllEvents()
end
local power = frame.manabar or frame.ManaBar
if(power) then
power:UnregisterAllEvents()
end
local spell = frame.castBar or frame.spellbar or frame.CastingBarFrame
if(spell) then
spell:UnregisterAllEvents()
end
local altpowerbar = frame.powerBarAlt or frame.PowerBarAlt
if(altpowerbar) then
altpowerbar:UnregisterAllEvents()
end
local buffFrame = frame.BuffFrame
if(buffFrame) then
buffFrame:UnregisterAllEvents()
end
local petFrame = frame.petFrame or frame.PetFrame
if(petFrame) then
petFrame:UnregisterAllEvents()
end
local totFrame = frame.totFrame
if(totFrame) then
totFrame:UnregisterAllEvents()
end
local classPowerBar = frame.classPowerBar
if(classPowerBar) then
classPowerBar:UnregisterAllEvents()
end
local ccRemoverFrame = frame.CcRemoverFrame
if(ccRemoverFrame) then
ccRemoverFrame:UnregisterAllEvents()
end
local debuffFrame = frame.DebuffFrame
if(debuffFrame) then
debuffFrame:UnregisterAllEvents()
end
end
end
function oUF:DisableBlizzard(unit)
if(not unit) then return end
if(unit == 'player') then
handleFrame(PlayerFrame)
elseif(unit == 'pet') then
handleFrame(PetFrame)
elseif(unit == 'target') then
handleFrame(TargetFrame)
elseif(unit == 'focus') then
handleFrame(FocusFrame)
elseif(unit:match('boss%d?$')) then
if(not isBossHooked) then
isBossHooked = true
-- it's needed because the layout manager can bring frames that are
-- controlled by containers back from the dead when a user chooses
-- to revert all changes
-- for now I'll just reparent it, but more might be needed in the
-- future, watch it
handleFrame(BossTargetFrameContainer)
-- do not reparent frames controlled by containers, the vert/horiz
-- layout code will go insane because it won't be able to calculate
-- the size properly, 0 or negative sizes in turn will break the
-- layout manager, fun...
for i = 1, MAX_BOSS_FRAMES do
handleFrame('Boss' .. i .. 'TargetFrame', true)
end
end
elseif(unit:match('party%d?$')) then
if(not isPartyHooked) then
isPartyHooked = true
handleFrame(PartyFrame)
for frame in PartyFrame.PartyMemberFramePool:EnumerateActive() do
handleFrame(frame, true)
end
for i = 1, MEMBERS_PER_RAID_GROUP do
handleFrame('CompactPartyFrameMember' .. i)
end
end
elseif(unit:match('arena%d?$')) then
if(not isArenaHooked) then
isArenaHooked = true
handleFrame(CompactArenaFrame)
for _, frame in next, CompactArenaFrame.memberUnitFrames do
handleFrame(frame, true)
end
end
end
end
function oUF:DisableNamePlate(frame)
if(not(frame and frame.UnitFrame)) then return end
if(frame.UnitFrame:IsForbidden()) then return end
if(not hookedNameplates[frame]) then
frame.UnitFrame:HookScript('OnShow', insecureHide)
hookedNameplates[frame] = true
end
handleFrame(frame.UnitFrame, true)
end