-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.lua
484 lines (464 loc) · 13 KB
/
ui.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
local _, G = ...
local root = CreateFrame('Frame', 'FerronnizerRoot', UIParent)
root:SetAllPoints()
root:SetAlpha(0.75)
local function tooltipify(frame, anchor, ...)
local n = select('#', ...)
local fn = select(n, ...)
local args = {}
for i = 1, n - 1 do
table.insert(args, (select(i, ...)))
end
table.insert(args, function(mouseover, ...)
local tooltip = GameTooltip
if mouseover then
tooltip:SetOwner(frame, anchor)
fn(tooltip, ...)
tooltip:Show()
elseif tooltip:IsOwned(frame) then
tooltip:Hide()
end
end)
G.DataWatch(G.AddFrameWatch(frame), unpack(args))
end
local unitFrames = {
{
anchor = function()
return 'CENTER', -200, -140
end,
parentKey = 'Player',
unit = 'player',
widgets = true,
},
{
anchor = function()
return 'TOPRIGHT', root.Player, 'TOPLEFT', -20, 0
end,
parentKey = 'Pet',
scale = 0.5,
unit = 'pet',
},
{
anchor = function()
return 'BOTTOMLEFT', root.Player, 'TOPLEFT', 0, 20
end,
parentKey = 'Party1',
unit = 'party1',
widgets = true,
},
{
anchor = function()
return 'BOTTOMLEFT', root.Party1, 'TOPLEFT', 0, 20
end,
parentKey = 'Party2',
unit = 'party2',
widgets = true,
},
{
anchor = function()
return 'BOTTOMLEFT', root.Party2, 'TOPLEFT', 0, 20
end,
parentKey = 'Party3',
unit = 'party3',
widgets = true,
},
{
anchor = function()
return 'BOTTOMLEFT', root.Party3, 'TOPLEFT', 0, 20
end,
parentKey = 'Party4',
unit = 'party4',
widgets = true,
},
{
anchor = function()
return 'CENTER', 200, -140
end,
parentKey = 'Target',
unit = 'target',
},
{
anchor = function()
return 'CENTER', 0, -160
end,
parentKey = 'Focus',
unit = 'focus',
},
}
for _, uf in ipairs(unitFrames) do
local unit = uf.unit
local v = CreateFrame('Button', nil, root, 'SecureUnitButtonTemplate')
root[uf.parentKey] = v
v:SetPoint(uf.anchor())
v:SetSize(160, 60)
v:SetScale(uf.scale or 1)
v:SetAttribute('unit', unit)
v:SetAttribute('*type1', 'target')
v:SetAttribute('*type2', 'togglemenu')
RegisterUnitWatch(v)
v:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
if unit == 'player' then
tooltipify(
v,
'ANCHOR_NONE',
'player_level',
'max_player_level',
'player_xp',
'player_max_xp',
'rested_xp',
function(tooltip, level, levelMax, xp, xpMax, xpRested)
tooltip:SetPoint('RIGHT', v, 'LEFT')
tooltip:SetUnit(unit)
if level < levelMax then
tooltip:AddLine(('XP: %d/%d'):format(xp, xpMax))
tooltip:AddLine(('Rest: %d'):format(xpRested))
end
end
)
else
tooltipify(v, 'ANCHOR_NONE', function(tooltip)
tooltip:SetPoint('RIGHT', v, 'LEFT')
tooltip:SetUnit(unit)
end)
end
v.Health = (function()
local t = v:CreateTexture()
t:SetPoint('TOPLEFT')
t:SetHeight(40)
t:SetTexture('Interface\\Buttons\\WHITE8x8')
G.DataWatch(unit .. '_class', function(class)
local r, g, b = GetClassColor(class)
t:SetVertexColor(r, g, b)
end)
G.DataWatch(unit .. '_health', unit .. '_max_health', function(health, healthMax)
local r = healthMax and healthMax > 0 and health / healthMax or 1
t:SetWidth(160 * r)
end)
return t
end)()
v.IncomingHeals = (function()
local t = v:CreateTexture()
t:SetPoint('TOPLEFT', v.Health, 'TOPRIGHT')
t:SetPoint('BOTTOMLEFT', v.Health, 'BOTTOMRIGHT')
t:SetTexture('Interface\\Buttons\\WHITE8x8')
t:SetVertexColor(1, 1, 1)
G.DataWatch(unit .. '_incoming_heals', unit .. '_max_health', function(incomingHeals, healthMax)
if not incomingHeals or incomingHeals == 0 or not healthMax or healthMax == 0 then
t:Hide()
else
t:SetWidth(160 * incomingHeals / healthMax)
t:Show()
end
end)
return t
end)()
v.Name = (function()
local fs = v:CreateFontString()
fs:SetFontObject('GameFontDisable')
fs:SetPoint('TOPLEFT')
fs:SetPoint('TOPRIGHT')
fs:SetHeight(20)
fs:SetJustifyH('CENTER')
G.DataWatch(unit .. '_level', unit .. '_name', function(level, name)
fs:SetText(level .. ' - ' .. (name or ''))
end)
return fs
end)()
v.HealthText = (function()
local fs = v:CreateFontString()
fs:SetFontObject('GameFontDisable')
fs:SetPoint('TOPLEFT', v.Name, 'BOTTOMLEFT')
fs:SetPoint('TOPRIGHT', v.Name, 'BOTTOMRIGHT')
fs:SetHeight(20)
fs:SetJustifyH('CENTER')
G.DataWatch(
unit .. '_health',
unit .. '_max_health',
unit .. '_connected',
unit .. '_alive',
unit .. '_has_incoming_resurrection',
function(health, healthMax, isConnected, isAlive, hasIncomingRes)
local s
if not isConnected then
s = '< Offline >'
elseif hasIncomingRes then
s = '< Resurrecting >'
elseif not isAlive then
s = '< Dead >'
else
s = health .. ' / ' .. healthMax
end
fs:SetText(s)
end
)
return fs
end)()
if uf.widgets then
v.Following = (function()
local t = v:CreateTexture(nil, 'OVERLAY')
t:SetTexture('Interface\\TaxiFrame\\UI-Taxi-Icon-White')
t:SetPoint('TOPRIGHT', 0, -20)
t:SetSize(20, 20)
G.DataWatch(unit .. '_following', function(onHateList)
t:SetShown(onHateList)
end)
return t
end)()
v.OnHateList = (function()
local t = v:CreateTexture(nil, 'OVERLAY')
t:SetTexture('Interface\\CharacterFrame\\UI-StateIcon')
t:SetTexCoord(0.5, 1.0, 0, 0.484375)
t:SetPoint('TOPRIGHT')
t:SetSize(20, 20)
G.DataWatch(unit .. '_on_hate_list', function(onHateList)
t:SetShown(onHateList)
end)
return t
end)()
v.Resting = (function()
local t = v:CreateTexture(nil, 'OVERLAY')
t:SetTexture('Interface\\CharacterFrame\\UI-StateIcon')
t:SetTexCoord(0, 0.5, 0, 0.421875)
t:SetPoint('TOPLEFT')
t:SetSize(20, 20)
G.DataWatch(unit .. '_resting', function(resting)
t:SetShown(resting)
end)
return t
end)()
end
v.Power = (function()
local f = CreateFrame('StatusBar', nil, v)
f:SetPoint('TOPLEFT', 0, -40)
f:SetSize(160, 20)
f:SetStatusBarTexture('Interface\\Buttons\\WHITE8x8')
G.DataWatch(unit .. '_power_type', function(powerType)
C_Timer.After(0, function()
local color = PowerBarColor[powerType or 'MANA']
f:SetStatusBarColor(color.r, color.g, color.b)
end)
end)
local fs = f:CreateFontString()
fs:SetFontObject('GameFontDisable')
fs:SetAllPoints()
fs:SetJustifyH('CENTER')
G.DataWatch(unit .. '_power', unit .. '_max_power', function(power, powerMax)
f:SetMinMaxValues(0, powerMax)
f:SetValue(power)
fs:SetText(power .. ' / ' .. powerMax)
end)
f.Text = fs
return f
end)()
v.Auras = (function()
local f = CreateFrame('Frame', nil, v)
f:SetPoint('TOPLEFT', 0, -60)
f:SetSize(160, 100)
f.Kids = {}
for row = 0, 4 do
for col = 0, 7 do
local frame = CreateFrame('Frame', nil, f, nil, row * 8 + col + 1)
frame:SetPoint('TOPLEFT', col * 20, row * -20)
frame:SetSize(20, 20)
frame.Cooldown = CreateFrame('Cooldown', nil, frame, 'CooldownFrameTemplate')
frame.Cooldown:SetReverse(true)
frame.Icon = frame:CreateTexture(nil, 'ARTWORK')
frame.Icon:SetAllPoints()
frame.Icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
frame.Count = frame:CreateFontString()
frame.Count:SetFontObject('NumberFontNormalSmall')
frame.Count:SetPoint('BOTTOMRIGHT')
frame.Border = frame:CreateTexture(nil, 'OVERLAY')
frame.Border:SetAllPoints()
frame.Border:SetTexture('Interface\\Buttons\\UI-Debuff-Overlays')
frame.Border:SetTexCoord(0.296875, 0.5703125, 0, 0.515625)
tooltipify(frame, 'ANCHOR_BOTTOMRIGHT', 'server_time', function(tooltip)
tooltip:SetUnitAura(unit, frame.Index, frame.Filter)
end)
table.insert(f.Kids, frame)
end
end
G.DataWatch(unit .. '_buffs', unit .. '_debuffs', function(buffs, debuffs)
local index, auras = 1, buffs
for _, frame in ipairs(f.Kids) do
local aura = auras[index]
if not aura and auras == buffs then
index, auras = 1, debuffs
aura = auras[index]
end
if not aura then
frame.Index, frame.Filter = nil, nil
frame:Hide()
else
frame.Index, frame.Filter = index, auras == buffs and 'HELPFUL' or 'HARMFUL'
frame:Show()
frame.Icon:SetTexture(aura.icon)
frame.Count:SetText(aura.count and aura.count > 0 and aura.count or '')
if aura.dispelType then
local color = DebuffTypeColor[aura.dispelType]
frame.Border:SetVertexColor(color.r, color.g, color.b)
frame.Border:Show()
else
frame.Border:Hide()
end
frame.Cooldown:SetCooldown(aura.expiration - aura.duration, aura.duration)
end
index = index + 1
end
end)
return f
end)()
end
root.Pet.Happiness = (function()
-- Adapted from PetFrame.lua
local t = root.Pet:CreateTexture()
t:SetPoint('TOPRIGHT', root.Pet, 'TOPLEFT', -10, 0)
t:SetSize(24, 23)
t:SetTexture('Interface\\PetPaperDollFrame\\UI-PetHappiness')
G.DataWatch('pet_happiness', function(happiness)
t:SetTexCoord((function()
if happiness == 1 then
return 0.375, 0.5625, 0, 0.359375
elseif happiness == 2 then
return 0.1875, 0.375, 0, 0.359375
else
return 0, 0.1875, 0, 0.359375
end
end)())
end)
return t
end)()
root.Info = (function()
local t = {}
local last
local function f(...)
local fs = root:CreateFontString()
fs:SetFontObject('GameFontNormalSmall')
if last then
fs:SetPoint('TOPLEFT', last, 'BOTTOMLEFT')
else
fs:SetPoint('TOPLEFT')
end
fs:SetJustifyH('LEFT')
fs:SetJustifyV('TOP')
last = fs
table.insert(t, fs)
local args = { ... }
local fn = args[#args]
local timer
local r, g, b = fs:GetTextColor()
args[#args] = function(...)
if timer then
timer:Cancel()
end
fs:SetText(fn(...))
fs:SetTextColor(0, 1, 0)
timer = C_Timer.NewTimer(3, function()
fs:SetTextColor(r, g, b)
timer = nil
end)
end
G.DataWatch(unpack(args))
end
f('player_xp', 'player_max_xp', function(xp, max)
return 'XP: ' .. tostring(xp) .. ' / ' .. tostring(max)
end)
f('bank_open', function(value)
return 'Bank open: ' .. tostring(value)
end)
f('mailbox_open', function(value)
return 'Mailbox open: ' .. tostring(value)
end)
f('zone', function(value)
return 'Zone: ' .. tostring(value)
end)
f('subzone', function(value)
return 'Subzone: ' .. tostring(value)
end)
f('tracking_texture', function(value)
return 'Tracking texture: ' .. tostring(value)
end)
f('stealthed', function(value)
return 'Stealthed: ' .. tostring(value)
end)
f('mounted', function(value)
return 'Mounted: ' .. tostring(value)
end)
f('speed', function(value)
return string.format('Speed: %.2f', value)
end)
f('money', function(value)
return 'Money: ' .. GetCoinTextureString(value)
end)
f('rested_xp', function(value)
return 'Rested XP: ' .. value
end)
f('pos_x', 'pos_y', function(x, y)
return string.format('Position: %.2f, %.2f', x, y)
end)
f('player_following', function(unit)
return 'Following: ' .. tostring(unit)
end)
return t
end)()
root.Clock = (function()
local fs = root:CreateFontString()
fs:SetFontObject('GameFontNormalSmall')
fs:SetPoint('TOPRIGHT')
fs:SetJustifyH('RIGHT')
fs:SetJustifyV('TOP')
G.DataWatch('game_time', function(s)
fs:SetText(s)
end)
return fs
end)()
root.Hidden = (function()
local frames = {
BuffFrame,
_G.ComboFrame,
CompactRaidFrameManager,
FocusFrame,
PartyMemberFrame1,
PartyMemberFrame2,
PartyMemberFrame3,
PartyMemberFrame4,
PlayerFrame,
TargetFrame,
TemporaryEnchantFrame,
}
local f = CreateFrame('Frame', nil, root)
f:Hide()
for _, frame in pairs(frames) do
frame:SetParent(f)
end
return f
end)()
G.Eventer({
PLAYER_ENTERING_WORLD = function()
local Quartz3CastBarPlayer = _G.Quartz3CastBarPlayer
if Quartz3CastBarPlayer then
Quartz3CastBarPlayer:ClearAllPoints()
Quartz3CastBarPlayer:SetPoint('BOTTOM', Minimap, 'TOP')
else
CastingBarFrame.ignoreFramePositionManager = true
CastingBarFrame:ClearAllPoints()
CastingBarFrame:SetPoint('BOTTOM', 0, 275)
end
end,
})
LoadAddOn('Blizzard_CombatText')
local lastxp, lastxpmax
G.DataWatch('player_xp', 'player_max_xp', function(xp, xpmax)
local delta
if lastxpmax == nil then
delta = 0
elseif lastxpmax == xpmax then
delta = xp - lastxp
else
delta = lastxpmax - lastxp + xp
end
if delta > 0 then
CombatText_AddMessage('+ ' .. delta .. ' XP', COMBAT_TEXT_SCROLL_FUNCTION, 0, 0, 1)
end
lastxp, lastxpmax = xp, xpmax
end)