This repository has been archived by the owner on Apr 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
layout.lua
547 lines (471 loc) · 15.2 KB
/
layout.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
local _, ns = ...
local GenerateFontString = ns.GenerateFontString
local playerClass = ns.playerClass
-- layout rules for specific unit frames (auras, totems, runes, ...)
local UnitSpecific = {
player = function(self)
ns.AddReputationBar(self)
ns.AddExperienceBar(self)
ns.AddArtifactPowerBar(self)
ns.AddPowerPredictionBar(self)
ns.AddAlternativePower(self)
ns.AddTotems(self, 215, 5, 1)
ns.AddClassPower(self, 215, 5, 1)
if (playerClass == "DEATHKNIGHT") then
ns.AddRuneBar(self, 215, 5, 1)
end
ns.AddCombatIcon(self)
ns.AddRestingIcon(self)
self:RegisterEvent("PLAYER_TARGET_CHANGED", function()
if (UnitExists("target")) then
if (UnitIsEnemy("target", "player")) then
PlaySound(SOUNDKIT.IG_CREATURE_AGGRO_SELECT)
elseif (UnitIsFriend("target", "player")) then
PlaySound(SOUNDKIT.IG_CHARACTER_NPC_SELECT)
else
PlaySound(SOUNDKIT.IG_CREATURE_NEUTRAL_SELECT)
end
else
PlaySound(SOUNDKIT.INTERFACE_SOUND_LOST_TARGET_UNIT)
end
end)
self:Tag(self.Power.value, "[rain:power][ - >rain:altmana]")
end,
target = function(self)
local info = GenerateFontString(self.Health, ns.media.FONT2, 12, nil, "LEFT")
info:SetPoint("TOPLEFT", 3.5, -3.5)
info:SetPoint("RIGHT", self.Health.value, "LEFT", -5, 0)
self:Tag(info, "[rain:role< ][rain:name][difficulty][ >rain:level][ >shortclassification]|r")
self.Info = info
ns.AddQuestIcon(self)
ns.AddResurrectIcon(self)
ns.AddRangeCheck(self)
self:Tag(self.Power.value, "[rain:power]")
end,
pet = function(self)
ns.AddAlternativePower(self) -- this is needed when the player is in vehicle. because the pet frame then holds the player unit
ns.AddAuras(self, "pet")
ns.AddRangeCheck(self)
end,
focus = function(self)
ns.AddDebuffs(self, "focus")
ns.AddDispelHighlight(self, "focus")
end,
targettarget = function(self)
ns.AddDispelHighlight(self, "targettarget")
end,
}
-- shared rules between more than one unit
-- pet, focus, tot and focustarget would be basicaly the same
local Shared = function(self, unit)
self.colors = ns.colors
self:RegisterForClicks("AnyDown")
self:SetScript("OnEnter", UnitFrame_OnEnter)
self:SetScript("OnLeave", UnitFrame_OnLeave)
local unitIsPartyMember = self:GetParent():GetName():match("^oUF_Rain_Party$") -- could use unit == "party" here as long as showRaid is false on the party header
local unitIsPartyOrMTTarget = unit == "partytarget" or unit == "maintanktarget"
local unitIsPartyPet = unit == "partypet"
local unitIsMT = unit == "maintank"
local unitIsBoss = unit:match("^boss%d$")
local frameBackdrop = CreateFrame("Frame", nil, self)
frameBackdrop:SetFrameLevel(self:GetFrameLevel() - 1)
frameBackdrop:SetPoint("TOPLEFT", self, -5, 5)
frameBackdrop:SetPoint("BOTTOMRIGHT", self, 5, -5)
frameBackdrop:SetBackdrop(ns.media.BACKDROP2)
frameBackdrop:SetBackdropColor(0, 0, 0, 0)
frameBackdrop:SetBackdropBorderColor(0, 0, 0)
self.FrameBackdrop = frameBackdrop
local health = CreateFrame("StatusBar", self:GetName().."_Health", self)
health:SetStatusBarTexture(ns.media.TEXTURE)
health.colorTapping = true
health.colorDisconnected = true
health.colorSmooth = true
health.frequentUpdates = unit == "player" or unit == "target" or unitIsBoss -- TODO: remove unitIsBoss here when Blizzard fixes UNIT_HEALTH for boss units
health:SetBackdrop(ns.media.BACKDROP)
health:SetBackdropColor(0, 0, 0)
self.Health = health
local hbBG = health:CreateTexture(nil, "BORDER")
hbBG:SetAllPoints()
hbBG:SetTexture(ns.media.TEXTURE)
hbBG:SetVertexColor(0.15, 0.15, 0.15)
health.background = hbBG
health.UpdateColor = ns.UpdateHealthColor
local power
if (not unitIsPartyPet) then
power = CreateFrame("StatusBar", self:GetName().."_Power", self)
power:SetStatusBarTexture(ns.media.TEXTURE)
power:SetBackdrop(ns.media.BACKDROP)
power:SetBackdropColor(0, 0, 0)
power.altPowerColor = {0, 0.5, 1}
power.colorPower = unit == "player" or unit == "pet" or unitIsBoss
power.colorClass = true
power.colorReaction = true
power.frequentUpdates = unit == "player" or unit == "target"
power.useAtlas = unit == "player" or unit == "target"
if (unitIsBoss) then
power.displayAltPower = true
end
local pbBG = power:CreateTexture(nil, "BORDER")
pbBG:SetAllPoints()
pbBG:SetTexture(ns.media.TEXTURE)
pbBG.multiplier = 0.5
power.bg = pbBG
power.PostUpdate = unit == "player" and playerClass == "MONK" and ns.UpdateMonkStagger or ns.PostUpdatePower
self.Power = power
end
ns.AddRaidTargetIcon(self)
ns.AddPhaseIcon(self)
if (unit == "player" or unit == "target") then
self:SetSize(230, 50)
health:SetSize(230, 30)
health:SetPoint("TOPRIGHT")
health:SetPoint("TOPLEFT")
local healthValue = GenerateFontString(health, ns.media.FONT2, 12, nil, "RIGHT")
healthValue:SetPoint("TOPRIGHT", health, -3.5, -3.5)
self:Tag(healthValue, "[rain:health]")
health.value = healthValue
power:SetSize(230, 15)
power:SetPoint("BOTTOMRIGHT")
power:SetPoint("BOTTOMLEFT")
local powerValue = GenerateFontString(health, ns.media.FONT2, 12, nil, "LEFT")
powerValue:SetPoint("TOPLEFT", health, 3.5, -3.5)
power.value = powerValue
ns.AddPortrait(self)
ns.AddOverlay(self, unit)
ns.AddCastbar(self, unit)
ns.AddHealthPrediction(self, unit)
ns.AddThreatHighlight(self)
if (unit == "player" and ns.cfg.showPlayerBuffs or unit == "target") then
ns.AddBuffs(self, unit)
end
ns.AddDebuffs(self, unit)
ns.AddDispelHighlight(self, unit)
local pvpStatus = GenerateFontString(self.Portrait, ns.media.FONT2, 18, "OUTLINE", "RIGHT")
pvpStatus:SetPoint("RIGHT", -3.5, 2)
pvpStatus:SetTextColor(0.69, 0.31, 0.31, 0.6)
self:Tag(pvpStatus, "[rain:pvp]")
self:HookScript("OnEnter", function(self)
if (unit == "player" and UnitIsPVP(unit)) then
local pvpTimer = GetPVPTimer() / 1000 -- remaining seconds
if (pvpTimer < 300 and pvpTimer > 0) then
pvpStatus:SetText(format("%d:%02d", floor(pvpTimer / 60), pvpTimer % 60))
end
end
end)
self:HookScript("OnLeave", function(self)
pvpStatus:UpdateTag()
end)
ns.AddAssistantIcon(self)
ns.AddLeaderIcon(self)
ns.AddMasterLooterIcon(self)
ns.AddReadyCheckIcon(self)
end
if (unit == "pet" or unit == "focus"
or unit == "targettarget" or unit == "focustarget") then
self:SetSize(110, 22)
end
if (unit ~= "player" and unit ~= "target" and not unitIsPartyPet) then
health:SetSize(110, 15)
health:SetPoint("TOPRIGHT")
health:SetPoint("TOPLEFT")
local healthValue = GenerateFontString(health, ns.media.FONT2, 9, nil, "RIGHT")
healthValue:SetPoint("TOPRIGHT", -2, -2)
if (unitIsBoss) then
self:Tag(healthValue, "[rain:bossHealth]")
else
self:Tag(healthValue, "[rain:healthSmall]")
end
health.value = healthValue
power:SetSize(110, 5)
power:SetPoint("BOTTOMRIGHT")
power:SetPoint("BOTTOMLEFT")
local name = GenerateFontString(health, ns.media.FONT2, 9, nil, "LEFT")
name:SetPoint("TOPLEFT", 2, -2)
name:SetPoint("RIGHT", healthValue, "LEFT", -3, 0)
if (not unitIsPartyMember) then
self:Tag(name, "[rain:name]")
else
self:Tag(name, "[rain:role][rain:name]")
ns.AddAssistantIcon(self)
ns.AddLeaderIcon(self)
ns.AddMasterLooterIcon(self)
ns.AddReadyCheckIcon(self)
ns.AddResurrectIcon(self)
--ns.AddAuras(self, unit)
ns.AddDispelHighlight(self, unit)
ns.AddRangeCheck(self)
end
if (unitIsMT) then
ns.AddResurrectIcon(self)
ns.AddRangeCheck(self)
end
if (unitIsBoss) then
ns.AddBuffs(self, unit)
ns.AddCastbar(self, unit)
end
if (unit == "pet" or unit == "focus" or unitIsPartyMember) then
ns.AddCastbar(self, unit)
ns.AddHealthPrediction(self, unit)
ns.AddThreatHighlight(self)
end
end
if (unitIsPartyPet) then
health:SetSize(110, 10)
health:SetPoint("TOPRIGHT")
health:SetPoint("TOPLEFT")
local healthValue = GenerateFontString(health, ns.media.FONT2, 9, nil, "RIGHT")
healthValue:SetPoint("RIGHT", -2, 0)
self:Tag(healthValue, "[perhp<%]")
health.value = healthValue
local name = GenerateFontString(health, ns.media.FONT2, 9, nil, "LEFT")
name:SetPoint("LEFT", 2, 0)
name:SetPoint("RIGHT", healthValue, "LEFT", -3, 0)
self:Tag(name, "[rain:name]")
ns.AddRangeCheck(self)
end
if (UnitSpecific[unit]) then
return UnitSpecific[unit](self)
end
end
local raid = {}
oUF:RegisterStyle("Rain", Shared)
oUF:RegisterStyle("RainRaid", ns.RaidStyle)
oUF:Factory(function(self)
local cfg = ns.cfg
local spellName = GetSpellInfo(cfg.clickSpell[playerClass] or 6603) -- 6603 Auto Attack
self:SetActiveStyle("Rain")
self:Spawn("player", "oUF_Rain_Player"):SetPoint("CENTER", -210, -215)
self:Spawn("pet", "oUF_Rain_Pet"):SetPoint("BOTTOMLEFT", oUF_Rain_Player, "TOPLEFT", 0, 10)
self:Spawn("focus", "oUF_Rain_Focus"):SetPoint("BOTTOMRIGHT", oUF_Rain_Player, "TOPRIGHT", 0, 10)
self:Spawn("target", "oUF_Rain_Target"):SetPoint("CENTER", 210, -215)
self:Spawn("targettarget", "oUF_Rain_TargetTarget"):SetPoint("BOTTOMRIGHT", oUF_Rain_Target, "TOPRIGHT", 0, 10)
self:Spawn("focustarget", "oUF_Rain_FocusTarget"):SetPoint("BOTTOMLEFT", oUF_Rain_Target, "TOPLEFT", 0 , 10)
local party
if (cfg.showParty) then
if (cfg.horizParty) then
party = self:SpawnHeader(
"oUF_Rain_Party", nil, "party",
"showParty", true,
"showRaid", false,
"maxColumns", 4,
"unitsPerColumn", 1,
"columnAnchorPoint", "LEFT",
"columnSpacing", 9.5,
"oUF-initialConfigFunction", ([[
self:SetWidth(110)
self:SetHeight(22)
self:SetAttribute("type3", "spell")
self:SetAttribute("spell3", "%s")
]]):format(spellName)
)
party:SetPoint("LEFT", UIParent, "BOTTOM", -231.25, 130)
else
party = self:SpawnHeader(
"oUF_Rain_Party", nil, "party",
"showParty", true,
"showRaid", false,
"yOffset", -27.5,
"oUF-initialConfigFunction", ([[
self:SetWidth(110)
self:SetHeight(22)
self:SetAttribute("type3", "spell")
self:SetAttribute("spell3", "%s")
]]):format(spellName)
)
party:SetPoint("TOPLEFT", UIParent, 125, -25)
end
party:Show()
end
local partyTargets
if (cfg.showParty and cfg.showPartyTargets) then
if (cfg.horizParty) then
partyTargets = self:SpawnHeader(
"oUF_Rain_PartyTargets", nil, "party",
"showParty", true,
"showRaid", false,
"maxColumns", 4,
"unitsPerColumn", 1,
"columnAnchorPoint", "LEFT",
"columnSpacing", 9.5,
"oUF-initialConfigFunction", [[
self:SetWidth(110)
self:SetHeight(22)
self:SetAttribute("unitsuffix", "target")
]]
)
partyTargets:SetPoint("TOPLEFT", oUF_Rain_Party, "BOTTOMLEFT", 0, -27.5)
else
partyTargets = self:SpawnHeader(
"oUF_Rain_PartyTargets", nil, "party",
"showParty", true,
"showRaid", false,
"yOffset", -27.5,
"oUF-initialConfigFunction", [[
self:SetWidth(110)
self:SetHeight(22)
self:SetAttribute("unitsuffix", "target")
]]
)
partyTargets:SetPoint("TOPLEFT", oUF_Rain_Party, "TOPRIGHT", 7.5, 0)
end
partyTargets:Show()
end
local partyPets
if (cfg.showParty and cfg.showPartyPets) then
if (cfg.horizParty) then
partyPets = self:SpawnHeader(
"oUF_Rain_PartyPets", nil, "party",
"showParty", true,
"showRaid", false,
"maxColumns", 4,
"unitsPerColumn", 1,
"columnAnchorPoint", "LEFT",
"columnSpacing", 9.5,
"oUF-initialConfigFunction", ([[
self:SetWidth(110)
self:SetHeight(11)
self:SetAttribute("unitsuffix", "pet")
self:SetAttribute("type3", "spell")
self:SetAttribute("spell3", "%s")
]]):format(spellName)
)
else
partyPets = self:SpawnHeader(
"oUF_Rain_PartyPets", nil, "party",
"showParty", true,
"showRaid", false,
"yOffset", -27.5,
"oUF-initialConfigFunction", ([[
self:SetWidth(110)
self:SetHeight(11)
self:SetAttribute("unitsuffix", "pet")
self:SetAttribute("type3", "spell")
self:SetAttribute("spell3", "%s")
]]):format(spellName)
)
end
partyPets:SetPoint("TOPLEFT", oUF_Rain_Party, 0, -29.5)
partyPets:Show()
end
if (cfg.showMT) then
local mainTanks = self:SpawnHeader(
"oUF_Rain_MT", nil, "raid",
"showRaid", true,
"groupFilter", "MAINTANK",
"yOffset", -7.5,
"oUF-initialConfigFunction", ([[
self:SetWidth(110)
self:SetHeight(22)
self:SetAttribute("type3", "spell")
self:SetAttribute("spell3", "%s")
]]):format(spellName)
)
mainTanks:SetPoint("TOPLEFT", UIParent, "LEFT", 50, -50)
mainTanks:Show()
end
if (cfg.showMT and cfg.showMTT) then
local mainTankTargets = self:SpawnHeader(
"oUF_Rain_MTT", nil, "raid",
"showRaid", true,
"groupFilter", "MAINTANK",
"yOffset", -7.5,
"oUF-initialConfigFunction", [[
self:SetWidth(110)
self:SetHeight(22)
self:SetAttribute("unitsuffix", "target")
]]
)
mainTankTargets:SetPoint("TOPLEFT", oUF_Rain_MT, "TOPRIGHT", 7.5, 0)
mainTankTargets:Show()
end
local boss = {}
for i = 1, MAX_BOSS_FRAMES do
boss[i] = self:Spawn("boss"..i, "oUF_Rain_Boss"..i)
boss[i]:SetSize(110, 22)
if (i == 1) then
boss[i]:SetPoint("TOP", UIParent, "TOP", 0, -20)
else
boss[i]:SetPoint("TOP", boss[i-1], "BOTTOM", 0, -15)
end
end
self:SetActiveStyle("RainRaid")
-- TODO: add options for horizontal grow / filtering
if (cfg.showRaid) then
local hiddenParent = CreateFrame("Frame")
hiddenParent:Hide()
CompactRaidFrameContainer:UnregisterAllEvents()
CompactRaidFrameContainer:Hide()
CompactRaidFrameContainer:SetParent(hiddenParent)
local raid = {} -- need that for positioning the groups
for i = 1, NUM_RAID_GROUPS do
local raidGroup = self:SpawnHeader(
"oUF_Rain_RaidGroup" .. i, nil, "raid",
"showRaid", true,
"groupFilter", i,
"yOffset", -7.5,
"oUF-initialConfigFunction", ([[
self:SetWidth(64)
self:SetHeight(30)
self:SetAttribute("type3", "spell")
self:SetAttribute("spell3", "%s")
]]):format(spellName)
)
table.insert(raid, raidGroup)
if (i == 1) then
raidGroup:SetPoint("TOPLEFT", UIParent, 15, -15)
else
raidGroup:SetPoint("TOPLEFT", raid[i - 1], "TOPRIGHT", 7.5, 0)
end
end
end
end)
oUF:RegisterInitCallback(function(self)
if (self:IsElementEnabled("DebuffHighlight")) then
self:DisableElement("DebuffHighlight")
end
if (self:IsElementEnabled("Experience")) then
self:DisableElement("Experience")
end
return true
end)
SLASH_OUF_RAIN1 = "/raintest"
SlashCmdList.OUF_RAIN = function(group)
if group == "raid" then
local raid = {}
oUF:SetActiveStyle("RainRaid")
for i = 1, 8 do
local header = oUF:SpawnHeader(
"oUF_Rain_TestRaidGroup"..i, nil, "solo",
"showSolo", true,
"showRaid", true,
"yOffset", -7.5,
"oUF-initialConfigFunction", [[
self:SetWidth(64)
self:SetHeight(30)
]]
)
raid[i] = header
if (i == 1) then
header:SetPoint("LEFT", UIParent, 150, -15)
else
header:SetPoint("TOPLEFT", raid[i - 1], "TOPRIGHT", 7.5, 0)
end
end
elseif group == "party" then
oUF:SetActiveStyle("Rain")
local party = oUF:SpawnHeader(
"oUF_Rain_TestParty", nil, "solo",
"showSolo", true,
"showParty", true, -- need this or else oUF gets confused about the unit
"maxColumns", 4,
"unitsPerColumn", 1,
"columnAnchorPoint", "LEFT",
"columnSpacing", 9.5,
"oUF-initialConfigFunction", [[
self:SetWidth(110)
self:SetHeight(22)
]]
)
party:SetPoint("LEFT", UIParent, "BOTTOM", -231.25, 130)
end
end