-
Notifications
You must be signed in to change notification settings - Fork 91
/
ShadowedUnitFrames.lua
570 lines (494 loc) · 22.3 KB
/
ShadowedUnitFrames.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
--[[
Shadowed Unit Frames, Shadow of Mal'Ganis (US) PvP
]]
ShadowUF = select(2, ...)
local L = ShadowUF.L
ShadowUF.dbRevision = 1
ShadowUF.playerUnit = "player"
ShadowUF.enabledUnits = {}
ShadowUF.modules = {}
ShadowUF.moduleOrder = {}
ShadowUF.unitList = {"player", "pet", "pettarget", "target", "targettarget", "targettargettarget", "focus", "focustarget", "party", "partypet", "partytarget", "raid", "raidpet", "boss", "bosstarget", "maintank", "maintanktarget", "mainassist", "mainassisttarget", "arena", "arenatarget", "arenapet"}
ShadowUF.fakeUnits = {["targettarget"] = true, ["targettargettarget"] = true, ["pettarget"] = true, ["arenatarget"] = true, ["focustarget"] = true, ["focustargettarget"] = true, ["partytarget"] = true, ["raidtarget"] = true, ["bosstarget"] = true, ["maintanktarget"] = true, ["mainassisttarget"] = true}
L.units = {["raidpet"] = L["Raid pet"], ["PET"] = L["Pet"], ["VEHICLE"] = L["Vehicle"], ["arena"] = L["Arena"], ["arenapet"] = L["Arena Pet"], ["arenatarget"] = L["Arena Target"], ["boss"] = L["Boss"], ["bosstarget"] = L["Boss Target"], ["focus"] = L["Focus"], ["focustarget"] = L["Focus Target"], ["mainassist"] = L["Main Assist"], ["mainassisttarget"] = L["Main Assist Target"], ["maintank"] = L["Main Tank"], ["maintanktarget"] = L["Main Tank Target"], ["party"] = L["Party"], ["partypet"] = L["Party Pet"], ["partytarget"] = L["Party Target"], ["pet"] = L["Pet"], ["pettarget"] = L["Pet Target"], ["player"] = L["Player"],["raid"] = L["Raid"], ["target"] = L["Target"], ["targettarget"] = L["Target of Target"], ["targettargettarget"] = L["Target of Target of Target"]}
-- Cache the units so we don't have to concat every time it updates
ShadowUF.unitTarget = setmetatable({}, {__index = function(tbl, unit) rawset(tbl, unit, unit .. "target"); return unit .. "target" end})
ShadowUF.partyUnits, ShadowUF.raidUnits, ShadowUF.raidPetUnits, ShadowUF.bossUnits, ShadowUF.arenaUnits = {}, {}, {}, {}, {}
ShadowUF.maintankUnits, ShadowUF.mainassistUnits, ShadowUF.raidpetUnits = ShadowUF.raidUnits, ShadowUF.raidUnits, ShadowUF.raidPetUnits
for i=1, MAX_PARTY_MEMBERS do ShadowUF.partyUnits[i] = "party" .. i end
for i=1, MAX_RAID_MEMBERS do ShadowUF.raidUnits[i] = "raid" .. i end
for i=1, MAX_RAID_MEMBERS do ShadowUF.raidPetUnits[i] = "raidpet" .. i end
for i=1, MAX_BOSS_FRAMES do ShadowUF.bossUnits[i] = "boss" .. i end
for i=1, 5 do ShadowUF.arenaUnits[i] = "arena" .. i end
function ShadowUF:OnInitialize()
self.defaults = {
profile = {
locked = false,
advanced = false,
tooltipCombat = false,
omnicc = false,
tags = {},
units = {},
positions = {},
range = {},
filters = {zonewhite = {}, zoneblack = {}, whitelists = {}, blacklists = {}},
visibility = {arena = {}, pvp = {}, party = {}, raid = {}},
hidden = {cast = false, runes = true, buffs = true, party = true, player = true, pet = true, target = true, focus = true, boss = true, arena = true},
},
}
self:LoadUnitDefaults()
-- Initialize DB
self.db = LibStub:GetLibrary("AceDB-3.0"):New("ShadowedUFDB", self.defaults, true)
self.db.RegisterCallback(self, "OnProfileChanged", "ProfilesChanged")
self.db.RegisterCallback(self, "OnProfileCopied", "ProfilesChanged")
self.db.RegisterCallback(self, "OnProfileReset", "ProfileReset")
-- Setup tag cache
self.tagFunc = setmetatable({}, {
__index = function(tbl, index)
if( not ShadowUF.Tags.defaultTags[index] and not ShadowUF.db.profile.tags[index] ) then
tbl[index] = false
return false
end
local func, msg = loadstring("return " .. (ShadowUF.Tags.defaultTags[index] or ShadowUF.db.profile.tags[index].func or ""))
if( func ) then
func = func()
elseif( msg ) then
error(msg, 3)
end
tbl[index] = func
return tbl[index]
end})
if( not self.db.profile.loadedLayout ) then
self:LoadDefaultLayout()
else
self:CheckUpgrade()
end
self.db.profile.revision = self.dbRevision
self:FireModuleEvent("OnInitialize")
self:HideBlizzardFrames()
self.Layout:LoadSML()
self:LoadUnits()
self.modules.movers:Update()
end
function ShadowUF:CheckUpgrade()
-- June 19th
if( not ShadowUF.db.profile.font.color ) then
ShadowUF.db.profile.font.color = {r = 1, g = 1, b = 1, a = 1}
for unit, config in pairs(self.db.profile.units) do
local indicators = ShadowUF.db.profile.units[unit].indicators
if( indicators and indicators.class ) then
indicators.class.anchorTo = "$parent"
indicators.class.anchorPoint = "BL"
indicators.class.x = 0
indicators.class.y = 0
end
end
end
-- April 29th
if( self.db.profile.filters.zones ) then
for unit, filter in pairs(self.db.profile.filters.zones) do
if( self.db.profile.filters.whitelists[filter] ) then
self.db.profile.filters.zonewhite[unit] = filter
else
self.db.profile.filters.zoneblack[unit] = filter
end
end
end
-- February 16th
if( not self.db.profile.units.raidpet.enabled and self.db.profile.units.raidpet.height == 0 and self.db.profile.units.raidpet.width == 0 and self.db.profile.positions.raidpet.anchorPoint == "" and self.db.profile.positions.raidpet.point == "" ) then
self:LoadDefaultLayout(true)
end
self.db.profile.units.party.unitsPerColumn = self.db.profile.units.party.unitsPerColumn or 5
self.db.profile.units.raid.groupsPerRow = self.db.profile.units.raid.groupsPerRow or 8
local castName = {enabled = true, size = 0, anchorTo = "$parent", rank = true, anchorPoint = "CLI", x = 1, y = 0}
local castTime = {enabled = true, size = 0, anchorTo = "$parent", anchorPoint = "CRI", x = -1, y = 0}
for unit, config in pairs(self.db.profile.units) do
config.portrait = config.portrait or {}
config.portrait.type = config.portrait.type or "3D"
config.portrait.fullBefore = config.portrait.fullBefore or 0
config.portrait.fullAfter = config.portrait.fullAfter or 100
config.portrait.order = config.portrait.order or 40
config.portrait.height = config.portrait.height or 0.50
config.highlight.size = config.highlight.size or 10
config.castBar = config.castBar or {}
config.castBar.icon = config.castBar.icon or "HIDE"
config.castBar.height = config.castBar.height or 0.60
config.castBar.order = config.castBar.order or 40
config.castBar.name = config.castBar.name or {}
config.castBar.time = config.castBar.time or {}
for key, value in pairs(castName) do
if( config.castBar.name[key] == nil ) then
config.castBar.name[key] = value
end
end
for key, value in pairs(castTime) do
if( config.castBar.time[key] == nil ) then
config.castBar.time[key] = value
end
end
end
end
function ShadowUF:LoadUnits()
-- CanHearthAndResurrectFromArea() returns true for world pvp areas, according to BattlefieldFrame.lua
local instanceType = CanHearthAndResurrectFromArea() and "pvp" or select(2, IsInInstance())
for _, type in pairs(self.unitList) do
local enabled = self.db.profile.units[type].enabled
if( ShadowUF.Units.zoneUnits[type] and enabled ) then
enabled = ShadowUF.Units.zoneUnits[type] == instanceType
elseif( instanceType ~= "none" ) then
if( self.db.profile.visibility[instanceType][type] == false ) then
enabled = false
elseif( self.db.profile.visibility[instanceType][type] == true ) then
enabled = true
end
end
self.enabledUnits[type] = enabled
if( enabled ) then
self.Units:InitializeFrame(type)
else
self.Units:UninitializeFrame(type)
end
end
end
function ShadowUF:LoadUnitDefaults()
for _, unit in pairs(self.unitList) do
self.defaults.profile.positions[unit] = {point = "", relativePoint = "", anchorPoint = "", anchorTo = "UIParent", x = 0, y = 0}
-- The reason why the defaults are so sparse, is because the layout needs to specify most of this. The reason I set tables here is basically
-- as an indication that hey, the unit wants this, if it doesn't that it won't want it.
self.defaults.profile.units[unit] = {
enabled = false, height = 0, width = 0, scale = 1.0,
healthBar = {enabled = true},
powerBar = {enabled = true},
emptyBar = {enabled = false},
portrait = {enabled = false},
castBar = {enabled = false, name = {}, time = {}},
text = {
{enabled = true, name = L["Left text"], text = "[name]", anchorPoint = "C", anchorTo = "$healthBar", size = 0},
{enabled = true, name = L["Right text"], text = "[curmaxhp]", anchorPoint = "C", anchorTo = "$healthBar", size = 0},
{enabled = true, name = L["Left text"], text = "[level] [race]", anchorPoint = "C", anchorTo = "$powerBar", size = 0},
{enabled = true, name = L["Right text"], text = "[curmaxpp]", anchorPoint = "C", anchorTo = "$powerBar", size = 0},
{enabled = true, name = L["Text"], text = "", anchorTo = "$emptyBar", anchorPoint = "C", size = 0, x = 0, y = 0},
},
indicators = {raidTarget = {enabled = true, size = 0}},
highlight = {},
auras = {
buffs = {enabled = false, perRow = 10, maxRows = 4, selfScale = 1.30, prioritize = true, enlargeSelf = false},
debuffs = {enabled = false, perRow = 10, maxRows = 4, selfScale = 1.30, enlargeSelf = true},
},
}
if( not self.fakeUnits[unit] ) then
self.defaults.profile.units[unit].combatText = {enabled = true, anchorTo = "$parent", anchorPoint = "C", x = 0, y = 0}
if( unit ~= "arena" and unit ~= "arenapet" ) then
self.defaults.profile.units[unit].incHeal = {enabled = false, cap = 1.30}
end
end
if( unit ~= "player" ) then
self.defaults.profile.units[unit].range = {enabled = false, oorAlpha = 0.80, inAlpha = 1.0}
if( not string.match(unit, "pet") ) then
self.defaults.profile.units[unit].indicators.class = {enabled = false, size = 19}
end
end
-- Want pvp/leader/ML enabled for these units
if( unit == "player" or unit == "party" or unit == "target" or unit == "raid" or unit == "focus" ) then
self.defaults.profile.units[unit].indicators.leader = {enabled = true, size = 0}
self.defaults.profile.units[unit].indicators.masterLoot = {enabled = true, size = 0}
self.defaults.profile.units[unit].indicators.pvp = {enabled = true, size = 0}
self.defaults.profile.units[unit].indicators.role = {enabled = true, size = 0}
self.defaults.profile.units[unit].indicators.status = {enabled = false, size = 19}
if( unit ~= "focus" and unit ~= "target" ) then
self.defaults.profile.units[unit].indicators.ready = {enabled = true, size = 0}
end
end
end
-- PLAYER
self.defaults.profile.units.player.enabled = true
self.defaults.profile.units.player.healthBar.predicted = true
self.defaults.profile.units.player.powerBar.predicted = true
self.defaults.profile.units.player.indicators.status.enabled = true
self.defaults.profile.units.player.runeBar = {enabled = false}
self.defaults.profile.units.player.totemBar = {enabled = false}
self.defaults.profile.units.player.druidBar = {enabled = false}
self.defaults.profile.units.player.xpBar = {enabled = false}
self.defaults.profile.units.player.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
self.defaults.profile.units.player.indicators.lfdRole = {enabled = true, size = 0, x = 0, y = 0}
-- PET
self.defaults.profile.units.pet.enabled = true
self.defaults.profile.units.pet.indicators.happiness = {enabled = true, size = 16, anchorPoint = "BR", anchorTo = "$parent", x = 2, y = -2}
self.defaults.profile.units.pet.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
self.defaults.profile.units.pet.xpBar = {enabled = false}
-- FOCUS
self.defaults.profile.units.focus.enabled = true
self.defaults.profile.units.focus.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
self.defaults.profile.units.focus.indicators.lfdRole = {enabled = false, size = 0, x = 0, y = 0}
-- FOCUSTARGET
self.defaults.profile.units.focustarget.enabled = true
self.defaults.profile.units.focustarget.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
-- TARGET
self.defaults.profile.units.target.enabled = true
self.defaults.profile.units.target.comboPoints = {enabled = true, isBar = false, height = 0.40, order = 30, anchorTo = "$parent", anchorPoint = "BR", x = 0, y = 0}
self.defaults.profile.units.target.indicators.lfdRole = {enabled = false, size = 0, x = 0, y = 0}
-- TARGETTARGET/TARGETTARGETTARGET
self.defaults.profile.units.targettarget.enabled = true
self.defaults.profile.units.targettargettarget.enabled = true
-- PARTY
self.defaults.profile.units.party.enabled = true
self.defaults.profile.units.party.auras.debuffs.maxRows = 1
self.defaults.profile.units.party.auras.buffs.maxRows = 1
self.defaults.profile.units.party.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
self.defaults.profile.units.party.combatText.enabled = false
self.defaults.profile.units.party.indicators.lfdRole = {enabled = true, size = 0, x = 0, y = 0}
-- ARENA
self.defaults.profile.units.arena.enabled = false
self.defaults.profile.units.arena.attribPoint = "TOP"
self.defaults.profile.units.arena.attribAnchorPoint = "LEFT"
self.defaults.profile.units.arena.auras.debuffs.maxRows = 1
self.defaults.profile.units.arena.auras.buffs.maxRows = 1
self.defaults.profile.units.arena.offset = 0
-- BOSS
self.defaults.profile.units.boss.enabled = false
self.defaults.profile.units.boss.attribPoint = "TOP"
self.defaults.profile.units.boss.attribAnchorPoint = "LEFT"
self.defaults.profile.units.boss.auras.debuffs.maxRows = 1
self.defaults.profile.units.boss.auras.buffs.maxRows = 1
self.defaults.profile.units.boss.offset = 0
-- RAID
self.defaults.profile.units.raid.groupBy = "GROUP"
self.defaults.profile.units.raid.sortOrder = "ASC"
self.defaults.profile.units.raid.sortMethod = "INDEX"
self.defaults.profile.units.raid.attribPoint = "TOP"
self.defaults.profile.units.raid.attribAnchorPoint = "RIGHT"
self.defaults.profile.units.raid.offset = 0
self.defaults.profile.units.raid.filters = {[1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true, [7] = true, [8] = true}
self.defaults.profile.units.raid.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
self.defaults.profile.units.raid.combatText.enabled = false
-- RAID PET
self.defaults.profile.units.raidpet.groupBy = "GROUP"
self.defaults.profile.units.raidpet.sortOrder = "ASC"
self.defaults.profile.units.raidpet.sortMethod = "INDEX"
self.defaults.profile.units.raidpet.attribPoint = "TOP"
self.defaults.profile.units.raidpet.attribAnchorPoint = "RIGHT"
self.defaults.profile.units.raidpet.offset = 0
self.defaults.profile.units.raidpet.filters = {[1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true, [7] = true, [8] = true}
self.defaults.profile.units.raidpet.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
self.defaults.profile.units.raidpet.combatText.enabled = false
-- MAINTANK
self.defaults.profile.units.maintank.groupFilter = "MAINTANK"
self.defaults.profile.units.maintank.groupBy = "GROUP"
self.defaults.profile.units.maintank.sortOrder = "ASC"
self.defaults.profile.units.maintank.sortMethod = "INDEX"
self.defaults.profile.units.maintank.attribPoint = "TOP"
self.defaults.profile.units.maintank.attribAnchorPoint = "RIGHT"
self.defaults.profile.units.maintank.offset = 0
self.defaults.profile.units.maintank.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
-- MAINASSIST
self.defaults.profile.units.mainassist.groupFilter = "MAINASSIST"
self.defaults.profile.units.mainassist.groupBy = "GROUP"
self.defaults.profile.units.mainassist.sortOrder = "ASC"
self.defaults.profile.units.mainassist.sortMethod = "INDEX"
self.defaults.profile.units.mainassist.attribPoint = "TOP"
self.defaults.profile.units.mainassist.attribAnchorPoint = "RIGHT"
self.defaults.profile.units.mainassist.offset = 0
self.defaults.profile.units.mainassist.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
-- PARTYPET
self.defaults.profile.positions.partypet.anchorTo = "$parent"
self.defaults.profile.positions.partypet.anchorPoint = "RB"
self.defaults.profile.units.partypet.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
-- PARTYTARGET
self.defaults.profile.positions.partytarget.anchorTo = "$parent"
self.defaults.profile.positions.partytarget.anchorPoint = "RT"
self.defaults.profile.units.partytarget.fader = {enabled = false, combatAlpha = 1.0, inactiveAlpha = 0.60}
end
-- Module APIs
function ShadowUF:RegisterModule(module, key, name, isBar, class)
-- December 16th
if( module.OnDefaultsSet ) then
DEFAULT_CHAT_FRAME:AddMessage(string.format("[WARNING!] You are running an outdated version of %s, you need to update it to the latest available for it to work with SUF.", name or key or "unknown"))
return
end
self.modules[key] = module
module.moduleKey = key
module.moduleHasBar = isBar
module.moduleName = name
module.moduleClass = class
table.insert(self.moduleOrder, module)
end
function ShadowUF:FireModuleEvent(event, frame, unit)
for _, module in pairs(self.moduleOrder) do
if( module[event] ) then
module[event](module, frame, unit)
end
end
end
-- Profiles changed
-- I really dislike this solution, but if we don't do it then there is setting issues
-- because when copying a profile, AceDB-3.0 fires OnProfileReset -> OnProfileCopied
-- SUF then sees that on the new reset profile has no profile, tries to load one in
-- ... followed by the profile copying happen and it doesn't copy everything correctly
-- due to variables being reset already.
local resetTimer
function ShadowUF:ProfileReset()
if( not resetTimer ) then
resetTimer = CreateFrame("Frame")
resetTimer:SetScript("OnUpdate", function(self)
ShadowUF:ProfilesChanged()
self:Hide()
end)
end
resetTimer:Show()
end
function ShadowUF:ProfilesChanged()
if( self.layoutImporting ) then return end
if( resetTimer ) then resetTimer:Hide() end
self.db:RegisterDefaults(self.defaults)
-- No active layout, register the default one
if( not self.db.profile.loadedLayout ) then
self:LoadDefaultLayout()
else
self:CheckUpgrade()
end
self:FireModuleEvent("OnProfileChange")
self:LoadUnits()
self:HideBlizzardFrames()
self.Layout:CheckMedia()
self.Units:ProfileChanged()
self.modules.movers:Update()
end
-- Stolen from haste
ShadowUF.noop = function() end
function ShadowUF:HideBlizzardFrames()
if( ShadowUF.db.profile.hidden.runes ) then
RuneFrame.Show = self.noop
RuneFrame:Hide()
end
if( ShadowUF.db.profile.hidden.cast ) then
CastingBarFrame:UnregisterAllEvents()
PetCastingBarFrame:UnregisterAllEvents()
end
if( ShadowUF.db.profile.hidden.party ) then
for i=1, MAX_PARTY_MEMBERS do
local name = "PartyMemberFrame" .. i
local frame = _G[name]
frame:UnregisterAllEvents()
frame.Show = self.noop
frame:Hide()
_G[name .. "HealthBar"]:UnregisterAllEvents()
_G[name .. "ManaBar"]:UnregisterAllEvents()
end
end
if( ShadowUF.db.profile.hidden.buffs ) then
BuffFrame:UnregisterAllEvents()
BuffFrame.Show = self.noop
BuffFrame:Hide()
ConsolidatedBuffs.Show = self.noop
ConsolidatedBuffs:Hide()
TemporaryEnchantFrame.Show = self.noop
TemporaryEnchantFrame:Hide()
end
if( ShadowUF.db.profile.hidden.player ) then
PlayerFrame:UnregisterAllEvents()
PlayerFrame.Show = self.noop
PlayerFrame:Hide()
PlayerFrame:RegisterEvent('UNIT_ENTERING_VEHICLE')
PlayerFrame:RegisterEvent('UNIT_ENTERED_VEHICLE')
PlayerFrame:RegisterEvent('UNIT_EXITING_VEHICLE')
PlayerFrame:RegisterEvent('UNIT_EXITED_VEHICLE')
PlayerFrameHealthBar:UnregisterAllEvents()
PlayerFrameManaBar:UnregisterAllEvents()
end
if( ShadowUF.db.profile.hidden.pet ) then
PetFrame:UnregisterAllEvents()
PetFrame.Show = self.noop
PetFrame:Hide()
PetFrameHealthBar:UnregisterAllEvents()
PetFrameManaBar:UnregisterAllEvents()
end
if( ShadowUF.db.profile.hidden.target ) then
TargetFrame:UnregisterAllEvents()
TargetFrame.Show = self.noop
TargetFrame:Hide()
TargetFrameHealthBar:UnregisterAllEvents()
TargetFrameManaBar:UnregisterAllEvents()
TargetFrameSpellBar:UnregisterAllEvents()
ComboFrame:UnregisterAllEvents()
ComboFrame.Show = self.noop
ComboFrame:Hide()
end
if( ShadowUF.db.profile.hidden.focus ) then
FocusFrame:UnregisterAllEvents()
FocusFrame.Show = self.noop
FocusFrame:Hide()
FocusFrameHealthBar:UnregisterAllEvents()
FocusFrameManaBar:UnregisterAllEvents()
FocusFrameSpellBar:UnregisterAllEvents()
end
if( ShadowUF.db.profile.hidden.boss ) then
for i=1, MAX_BOSS_FRAMES do
local name = "Boss" .. i .. "TargetFrame"
local frame = _G[name]
frame:UnregisterAllEvents()
frame.Show = self.noop
frame:Hide()
_G[name .. "HealthBar"]:UnregisterAllEvents()
_G[name .. "ManaBar"]:UnregisterAllEvents()
end
end
if( ShadowUF.db.profile.hidden.arena ) then
Arena_LoadUI = self.noop
end
-- Don't modify the raid menu because that will taint the MA/MT stuff and it'll break and that's bad
for key, list in pairs(UnitPopupMenus) do
if( key ~= "RAID" ) then
for i=#(list), 1, -1 do
if( list[i] == "SET_FOCUS" or list[i] == "CLEAR_FOCUS" or list[i] == "LOCK_FOCUS_FRAME" or list[i] == "UNLOCK_FOCUS_FRAME" ) then
table.remove(list, i)
end
end
end
end
end
function ShadowUF:Print(msg)
DEFAULT_CHAT_FRAME:AddMessage("|cff33ff99Shadow UF|r: " .. msg)
end
CONFIGMODE_CALLBACKS = CONFIGMODE_CALLBACKS or {}
CONFIGMODE_CALLBACKS["Shadowed Unit Frames"] = function(mode)
if( mode == "ON" ) then
ShadowUF.db.profile.locked = false
ShadowUF.modules.movers.isConfigModeSpec = true
elseif( mode == "OFF" ) then
ShadowUF.db.profile.locked = true
end
ShadowUF.modules.movers:Update()
end
SLASH_SHADOWEDUF1 = "/suf"
SLASH_SHADOWEDUF2 = "/shadowuf"
SLASH_SHADOWEDUF3 = "/shadoweduf"
SLASH_SHADOWEDUF4 = "/shadowedunitframes"
SlashCmdList["SHADOWEDUF"] = function(msg)
msg = msg and string.lower(msg)
if( msg and string.match(msg, "^profile (.+)") ) then
local profile = string.match(msg, "^profile (.+)")
for id, name in pairs(ShadowUF.db:GetProfiles()) do
if( string.lower(name) == profile ) then
ShadowUF.db:SetProfile(name)
ShadowUF:Print(string.format(L["Changed profile to %s."], name))
return
end
end
ShadowUF:Print(string.format(L["Cannot find any profiles named \"%s\"."], profile))
return
end
local loaded, reason = LoadAddOn("ShadowedUF_Options")
if( not ShadowUF.Config ) then
DEFAULT_CHAT_FRAME:AddMessage(string.format(L["Failed to load ShadowedUF_Options, cannot open configuration. Error returned: %s"], reason and _G["ADDON_" .. reason] or ""))
return
end
ShadowUF.Config:Open()
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_LOGIN")
frame:SetScript("OnEvent", function(self, event, addon)
if( event == "PLAYER_LOGIN" ) then
ShadowUF:OnInitialize()
self:UnregisterEvent("PLAYER_LOGIN")
end
end)