This repository has been archived by the owner on Nov 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.lua
587 lines (505 loc) · 20.6 KB
/
core.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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
local addon, ns = ...
local cfg = ns.cfg
local lib = ns.lib
-- Unit has an Aura
function hasUnitAura(unit, name)
local _, _, _, count, _, _, _, caster = UnitAura(unit, name)
if (caster and caster == "player") then
return count
end
end
-- Unit has a Debuff
function hasUnitDebuff(unit, name)
local _, _, _, count, _, _, _, _ = UnitDebuff(unit, name)
if (count) then return count
end
end
oUF.colors.smooth = {0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.22, }
local MyPvPUpdate = function(self, event, unit)
if (unit ~= self.unit) then return end
local pvp = self.MyPvP
if (pvp) then
local factionGroup = UnitFactionGroup(unit)
-- FFA!
if (UnitIsPVPFreeForAll(unit)) then
pvp:SetTexture([[Interface\TargetingFrame\UI-PVP-FFA]])
pvp:Show()
elseif (UnitIsPVP(unit) and factionGroup) then
if (factionGroup == 'Horde') then
pvp:SetTexture([[Interface\Addons\oUF_Fail\media\Horde]])
else
pvp:SetTexture([[Interface\Addons\oUF_Fail\media\Alliance]])
end
pvp:Show()
else
pvp:Hide()
end
end
end
-----------------------------
-- STYLE FUNCTIONS
-----------------------------
local UnitSpecific = {
player = function(self, ...)
self.mystyle = "player"
-- Size and Scale
self:SetScale(cfg.scale)
self:SetSize(192, 42)
-- Generate Bars
lib.gen_hpbar(self)
lib.gen_hpstrings(self)
lib.gen_highlight(self)
lib.gen_ppbar(self)
lib.gen_RaidMark(self)
lib.gen_combat_feedback(self)
lib.gen_InfoIcons(self)
lib.HealPred(self)
-- Buffs and Debuffs
if cfg.showPlayerAuras then
BuffFrame:Hide()
lib.createBuffs(self)
lib.createDebuffs(self)
lib.gen_WeaponEnchant(self)
end
self.Health.frequentUpdates = true
self.Health.colorSmooth = true
self.Health.Smooth = true
--self.Health.bg.multiplier = 0.2
self.Power.colorPower = true
--self.Power.arrow.colorPower = true
self.Power.Smooth = true
self.Power.frequentUpdates = true
self.Power.bg.multiplier = 0.2
lib.gen_castbar(self)
lib.debuffHighlight(self)
self.Power.PostUpdate = lib.setPowerArrowColor
-- PvP Icon
local pvp = self.Health:CreateTexture(nil, "OVERLAY")
pvp:SetHeight(32)
pvp:SetWidth(32)
pvp:SetPoint("BOTTOMLEFT", -8, -16)
self.PvPIndicator = pvp
-- This makes oUF update the information.
self:RegisterEvent("UNIT_FACTION", MyPvPUpdate)
-- This makes oUF update the information on forced updates.
table.insert(self.__elements, MyPvPUpdate)
-- Class Bars
if cfg.showRunebar then lib.genRunes(self) end
if cfg.showClassbar then lib.gen_Classbar(self) end
lib.RogueComboPoints(self)
lib.gen_AltPowerBar(self)
end,
target = function(self, ...)
self.mystyle = "target"
-- Size and Scale
self:SetScale(cfg.scale)
self:SetSize(256, 38)
-- Generate Bars
lib.gen_hpbar(self)
lib.gen_hpstrings(self)
lib.gen_highlight(self)
lib.gen_ppbar(self)
lib.gen_RaidMark(self)
lib.gen_combat_feedback(self)
lib.RogueComboPoints(self)
--style specific stuff
self.Health.frequentUpdates = true
self.Health.colorSmooth = true
self.Health.Smooth = true
-- self.Health.bg.multiplier = 0.3
self.Power.frequentUpdates = true
self.Power.Smooth = true
self.Power.colorTapping = true
self.Power.colorDisconnected = true
self.Power.colorHappiness = false
self.Power.colorHealth = true
self.Power.colorReaction = true
self.Power.colorClass = true
self.Power.bg.multiplier = 0.5
if cfg.ShowExtraUnitArrows then self.Power.PostUpdate = lib.setClassArrowColor end
lib.gen_castbar(self)
lib.gen_mirrorcb(self)
lib.debuffHighlight(self)
lib.HealPred(self)
-- PvP Icon
local pvp = self.Health:CreateTexture(nil, "OVERLAY")
--pvp:SetTexture(1, 0, 0)
pvp:SetHeight(36)
pvp:SetWidth(36)
pvp:SetPoint("BOTTOMRIGHT", 24, -12)
self.MyPvP = pvp
-- This makes oUF update the information.
self:RegisterEvent("UNIT_FACTION", MyPvPUpdate)
-- This makes oUF update the information on forced updates.
table.insert(self.__elements, MyPvPUpdate)
if cfg.showTargetBuffs then lib.createBuffs(self) end
if cfg.showTargetDebuffs then lib.createDebuffs(self) end
end,
focus = function(self, ...)
self.mystyle = "focus"
-- Size and Scale
self:SetScale(cfg.scale)
self:SetSize(140, 30)
-- Generate Bars
lib.gen_hpbar(self)
lib.gen_hpstrings(self)
lib.gen_highlight(self)
lib.gen_ppbar(self)
lib.gen_RaidMark(self)
--style specific stuff
self.Health.frequentUpdates = true
self.Health.Smooth = true
self.Health.colorSmooth = true
-- self.Health.bg.multiplier = 0.3
self.Power.Smooth = true
self.Power.colorTapping = true
self.Power.colorDisconnected = true
self.Power.colorHappiness = false
self.Power.colorClass = true
self.Power.colorReaction = true
self.Power.colorHealth = true
self.Power.bg.multiplier = 0.5
if cfg.ShowExtraUnitArrows then self.Power.PostUpdate = lib.setClassArrowColor end
lib.gen_castbar(self)
lib.HealPred(self)
lib.createDebuffs(self)
end,
targettarget = function(self, ...)
self.mystyle = "tot"
-- Size and Scale
self:SetScale(cfg.scale)
self:SetSize(150, 30)
-- Generate Bars
lib.gen_hpbar(self)
lib.gen_hpstrings(self)
lib.gen_highlight(self)
lib.gen_ppbar(self)
lib.gen_RaidMark(self)
--style specific stuff
self.Health.frequentUpdates = true
self.Health.colorSmooth = true
self.Health.Smooth = true
-- self.Health.bg.multiplier = 0.3
self.Power.Smooth = true
self.Power.colorTapping = true
self.Power.colorDisconnected = true
self.Power.colorHappiness = false
self.Power.colorClass = true
self.Power.colorReaction = true
self.Power.colorHealth = true
self.Power.bg.multiplier = 0.5
lib.HealPred(self)
lib.createBuffs(self)
lib.createDebuffs(self)
end,
focustarget = function(self, ...)
self.mystyle = "focustarget"
-- Size and Scale
self:SetScale(cfg.scale)
self:SetSize(140, 30)
-- Generate Bars
lib.gen_hpbar(self)
lib.gen_hpstrings(self)
lib.gen_highlight(self)
lib.gen_ppbar(self)
lib.gen_RaidMark(self)
--style specific stuff
self.Health.frequentUpdates = true
self.Health.colorSmooth = true
self.Health.colorClass = true
self.Health.Smooth = true
self.Power.Smooth = true
self.Power.colorTapping = true
self.Power.colorDisconnected = true
self.Power.colorPower = true
self.Power.colorReaction = true
self.Power.bg.multiplier = 0.5
if cfg.ShowExtraUnitArrows then self.Power.PostUpdate = lib.setPowerArrowColor end
lib.gen_castbar(self)
lib.HealPred(self)
end,
-- Pet style
pet = function(self, ...)
local _, playerClass = UnitClass("player")
self.mystyle = "pet"
self.Range = {
insideAlpha = 1,
outsideAlpha = .3,
}
-- Size and Scale
self:SetScale(cfg.scale)
self:SetSize(90, 30)
-- Generate Bars
lib.gen_hpbar(self)
lib.gen_hpstrings(self)
lib.gen_highlight(self)
lib.gen_ppbar(self)
lib.gen_RaidMark(self)
--style specific stuff
self.Health.frequentUpdates = true
self.Health.colorSmooth = true
self.Health.Smooth = true
-- self.Health.bg.multiplier = 0.3
self.Power.Smooth = true
self.Power.colorTapping = true
self.Power.colorDisconnected = true
self.Power.colorHappiness = false
self.Power.colorClass = true
self.Power.colorReaction = true
self.Power.colorHealth = true
self.Power.bg.multiplier = 0.5
lib.gen_castbar(self)
lib.HealPred(self)
end,
raid = function(self, ...)
self.mystyle = "raid"
self.Range = {
insideAlpha = 1,
outsideAlpha = .3,
}
-- Generate Bars
lib.gen_hpbar(self)
lib.gen_hpstrings(self)
lib.gen_highlight(self)
lib.gen_ppbar(self)
lib.gen_RaidMark(self)
lib.ReadyCheck(self)
--style specific stuff
self.Health.frequentUpdates = true
self.Health.colorSmooth = true
--self.Health.Smooth = true
--self.Power.Smooth = true
-- self.Health.bg.multiplier = 0.3
self.Power.colorClass = true
self.Power.bg.multiplier = 0.5
lib.gen_InfoIcons(self)
lib.CreateTargetBorder(self)
lib.CreateThreatBorder(self)
lib.HealPred(self)
lib.debuffHighlight(self)
lib.raidDebuffs(self)
self.Health.PostUpdate = lib.PostUpdateRaidFrame
self:RegisterEvent('PLAYER_TARGET_CHANGED', lib.ChangedTarget, true)
self:RegisterEvent('GROUP_ROSTER_UPDATE', lib.ChangedTarget, true)
self:RegisterEvent("UNIT_THREAT_LIST_UPDATE", lib.UpdateThreat)
self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", lib.UpdateThreat)
end,
party = function(self, ...)
self.mystyle = "party"
self.Range = {
insideAlpha = 1,
outsideAlpha = .3,
}
-- Generate Bars
lib.gen_hpbar(self)
lib.gen_hpstrings(self)
lib.gen_highlight(self)
lib.gen_ppbar(self)
lib.gen_RaidMark(self)
lib.ReadyCheck(self)
lib.gen_LFDRole(self)
--style specific stuff
self.Health.frequentUpdates = true
self.Health.colorSmooth = true
self.Health.Smooth = true
self.Power.Smooth = true
-- self.Health.bg.multiplier = 0.3
self.Power.colorClass = true
self.Power.bg.multiplier = 0.5
self.Power.arrow.colorPower = true
if cfg.ShowExtraUnitArrows then self.Power.PostUpdate = lib.setClassArrowColor end
lib.gen_InfoIcons(self)
lib.CreateTargetBorder(self)
lib.CreateThreatBorder(self)
lib.HealPred(self)
lib.debuffHighlight(self)
lib.raidDebuffs(self)
lib.addPhaseIcon(self)
self.Health.PostUpdate = lib.PostUpdateRaidFrame
self:RegisterEvent('PLAYER_TARGET_CHANGED', lib.ChangedTarget, true)
self:RegisterEvent('GROUP_ROSTER_UPDATE', lib.ChangedTarget)
self:RegisterEvent("UNIT_THREAT_LIST_UPDATE", lib.UpdateThreat)
self:RegisterEvent("UNIT_THREAT_SITUATION_UPDATE", lib.UpdateThreat)
end,
}
-- Boss frames layout
local function CreateUnitFrame(self, unit)
self.mystyle = "boss"
self.Range = {
insideAlpha = 1,
outsideAlpha = .3,
}
-- Size and Scale
self:SetSize(150, 29)
-- Generate Bars
lib.gen_hpbar(self)
lib.gen_hpstrings(self)
lib.gen_highlight(self)
lib.gen_ppbar(self)
lib.gen_RaidMark(self)
--style specific stuff
self.Health.frequentUpdates = true
self.Health.colorSmooth = true
--self.Health.Smooth = true
self.Power.frequentUpdates = true
self.Power.Smooth = true
self.Power.colorPower = true
self.Power.colorReaction = true
self.Power.colorTapping = true
self.Power.bg.multiplier = 0.5
lib.gen_castbar(self)
lib.gen_mirrorcb(self)
--[[if cfg.showBossBuffs then lib.createBuffs(self) end
if cfg.showBossDebuffs then lib.createDebuffs(self) end
]]
end
-- The Shared Style Function
local GlobalStyle = function(self, unit, isSingle)
self.menu = lib.spawnMenu
self:RegisterForClicks('AnyDown')
-- Call Unit Specific Styles
if (UnitSpecific[unit]) then
return UnitSpecific[unit](self)
end
end
-- The Shared Style Function for Party and Raid
local GroupGlobalStyle = function(self, unit)
self.menu = lib.spawnMenu
self:RegisterForClicks('AnyDown')
-- Call Unit Specific Styles
if (UnitSpecific[unit]) then
return UnitSpecific[unit](self)
end
end
-----------------------------
-- SPAWN UNITS
-----------------------------
oUF:RegisterStyle('fail', GlobalStyle)
oUF:RegisterStyle('failGroup', GroupGlobalStyle)
oUF:Factory(function(self)
-- Single Frames
self:SetActiveStyle('fail')
self:Spawn('player'):SetPoint("CENTER", UIParent, cfg.PlayerRelativePoint, cfg.PlayerX, cfg.PlayerY)
self:Spawn('target'):SetPoint("CENTER", UIParent, cfg.TargetRelativePoint, cfg.TargetX, cfg.TargetY)
if cfg.showtot then self:Spawn('targettarget'):SetPoint("BOTTOMLEFT", oUF_failTarget, cfg.TotRelativePoint, cfg.TotX, cfg.TotY) end
if cfg.showpet then self:Spawn('pet'):SetPoint("TOPRIGHT", oUF_failPlayer, "TOPLEFT", -10, 0) end
if cfg.showfocus then self:Spawn('focus'):SetPoint("BOTTOMRIGHT", oUF_failPlayer, cfg.FocusRelativePoint, cfg.FocusX, cfg.FocusY) end
if cfg.showfocustarget then self:Spawn('focustarget'):SetPoint("BOTTOMLEFT", oUF_failFocus, "TOPRIGHT", cfg.FocusTargetX, cfg.FocusTargetY) end
-- Party Frames
if cfg.ShowParty then
self:SetActiveStyle('failGroup')
if cfg.showPartyHorizontal then
local party = oUF:SpawnHeader('oUF_Party', nil, 'custom [group:party,nogroup:raid][@raid6,noexists,group:raid] show;hide',
--local party = oUF:SpawnHeader('oUF_Party', nil, "solo", "showSolo", true, -- debug
"showParty", cfg.ShowParty,
"showPlayer", cfg.ShowSelfParty,
"yoffset", -15,
"sortMethod", "INDEX",
"maxColumns", 5,
"unitsPerColumn", 1,
"columnSpacing", 9,
"point", "TOP",
"columnAnchorPoint", "LEFT",
"oUF-initialConfigFunction", ([[
self:SetWidth(%d)
self:SetHeight(%d)
]] ):format(128, 25))
party:SetScale(cfg.raidScale)
party:SetPoint('CENTER', UIParent, 'CENTER', cfg.PartyX, cfg.PartyY)
else
local party = oUF:SpawnHeader('oUF_Party', nil, 'custom [group:party,nogroup:raid][@raid6,noexists,group:raid] show;hide',
--local party = oUF:SpawnHeader('oUF_Party', nil, "solo", "showSolo", true, -- debug
"showParty", cfg.ShowParty,
"showPlayer", cfg.ShowSelfParty,
"yoffset", -15,
"oUF-initialConfigFunction", ([[
self:SetWidth(%d)
self:SetHeight(%d)
]]):format(128, 25))
party:SetScale(cfg.raidScale)
party:SetPoint('CENTER', UIParent, 'CENTER', cfg.PartyX, cfg.PartyY)
end
end
-- Raid Frames
if cfg.ShowRaid then
self:SetActiveStyle('failGroup')
local raid10 = oUF:SpawnHeader("oUF_Raid10", nil, "custom [@raid11,exists] hide; [@raid6,exists] show; hide", -- Raid frames for 6-10 players.
"showRaid", cfg.ShowRaid,
"showSolo", false,
"showPlayer", true,
"showParty", false,
"xoffset", 9,
"yOffset", -10,
"groupFilter", "1,2,3,4,5,6,7,8",
"groupBy", "GROUP",
"groupingOrder", "1,2,3,4,5,6,7,8",
"sortMethod", "INDEX",
"maxColumns", 2,
"unitsPerColumn", 5,
"columnSpacing", 9,
"point", "TOP",
"columnAnchorPoint", "LEFT",
"oUF-initialConfigFunction", ([[
self:SetWidth(%d)
self:SetHeight(%d)
]] ):format(96, 25))
raid10:SetScale(cfg.raidScale)
raid10:SetPoint('CENTER', UIParent, 'CENTER', cfg.RaidX + 200, cfg.RaidY + 100)
local raid25 = oUF:SpawnHeader("oUF_Raid25", nil, "custom [@raid26,exists] hide; [@raid11,exists] show; hide", -- Raid frames for 11-25 players.
"showRaid", cfg.ShowRaid,
"showPlayer", true,
"showParty", false,
"xoffset", 9,
"yOffset", -10,
"groupFilter", "1,2,3,4,5",
"groupBy", "GROUP",
"groupingOrder", "1,2,3,4,5",
"sortMethod", "INDEX",
"maxColumns", 5,
"unitsPerColumn", 5,
"columnSpacing", 9,
"point", "TOP",
"columnAnchorPoint", "LEFT",
"oUF-initialConfigFunction", ([[
self:SetWidth(%d)
self:SetHeight(%d)
]] ):format(80, 25))
raid25:SetScale(cfg.raidScale)
raid25:SetPoint('CENTER', UIParent, 'CENTER', cfg.RaidX + 80, cfg.RaidY)
local raid40 = oUF:SpawnHeader("oUF_Raid40", nil, "custom [@raid26,exists] show; hide", -- Raid frames for 26-40 players.
"showRaid", cfg.ShowRaid,
"showPlayer", true,
"showParty", false,
"xoffset", 9,
"yOffset", -10,
"groupFilter", "1,2,3,4,5,6,7,8",
"groupBy", "GROUP",
"groupingOrder", "1,2,3,4,5,6,7,8",
"sortMethod", "INDEX",
"maxColumns", 8,
"unitsPerColumn", 5,
"columnSpacing", 9,
"point", "TOP",
"columnAnchorPoint", "LEFT",
"oUF-initialConfigFunction", ([[
self:SetWidth(%d)
self:SetHeight(%d)
]] ):format(64, 25))
--raid40:SetScale(cfg.raidScale)
raid40:SetPoint('CENTER', UIParent, 'CENTER', cfg.RaidX, cfg.RaidY)
end
end)
--spawn the Boss Frames by Screamie
-----------------------------------
if cfg.showBossFrames then
oUF:RegisterStyle("oUF_failBoss", CreateUnitFrame)
oUF:SetActiveStyle("oUF_failBoss")
local boss1 = oUF:Spawn("boss1", "oUF_Boss1")
boss1:SetPoint("BOTTOMRIGHT", UIParent, "TOPRIGHT", cfg.BossX, cfg.BossY)
local boss2 = oUF:Spawn("boss2", "oUF_Boss2")
boss2:SetPoint("BOTTOMRIGHT", UIParent, "TOPRIGHT", cfg.BossX, cfg.BossY - 70)
local boss3 = oUF:Spawn("boss3", "oUF_Boss3")
boss3:SetPoint("BOTTOMRIGHT", UIParent, "TOPRIGHT", cfg.BossX, cfg.BossY - 140)
local boss4 = oUF:Spawn("boss4", "oUF_Boss4")
boss4:SetPoint("BOTTOMRIGHT", UIParent, "TOPRIGHT", cfg.BossX, cfg.BossY - 210)
end