Repository navigation
Expand file tree
/
Copy pathUI.lua
More file actions
5659 lines (5337 loc) · 259 KB
/
Copy pathUI.lua
File metadata and controls
5659 lines (5337 loc) · 259 KB
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
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[--------------------------------------------------------------------
WhoDidIt - window
----------------------------------------------------------------------]]
local W = WhoDidIt
local UI = {}
W.UI = UI
local floor = math.floor
local getn = table.getn
local FmtTime = W.FmtTime
local FmtNum = W.FmtNum
local WIDTH, HEIGHT = 940, 562
local LEFTW = 230
local ROWH, NROWS = 16, 21
local FROWH, FROWS = 30, 10
UI.tab = "summary"
UI.meter = "dmg"
UI.selIdx = 1
UI.detail = nil; UI.cause = nil
UI.liveRec = nil
local RESULT = {
KILL = "|cff33ff33KILL|r",
WIPE = "|cffff3333WIPE|r",
RESET = "|cffff9933RESET|r",
LIVE = "|cff33ccffLIVE|r",
}
local KIND_COLOR = {
death = "|cffff4444", aggro = "|cffff9933", avoid = "|cffffff55", kill = "|cff33ff33",
pull = "|cff33ccff", enrage = "|cffff55ff", mc = "|cffcc77ff", cast = "|cff999999",
tranq = "|cffaad372", interrupt = "|cffff7755", fail = "|cffff5555", boss = "|cffcccccc",
debuff = "|cffcc99ff", info = "|cff888888", wipe = "|cffff3333", taunt = "|cffffaa55",
save = "|cff33ff33",
}
------------------------------------------------------------------ the look
-- Flat dark panels and buttons with crisp 1-pixel borders. WHITE8X8 is a plain
-- white square in the client (Interface\Buttons\WHITE8X8.blp, checked in its files).
UI.FLAT = "Interface\\Buttons\\WHITE8X8"
UI.COL = {
frame = { 0.035, 0.035, 0.045, 0.96 }, frameEdge = { 0.42, 0.34, 0.16, 1 },
panel = { 0.07, 0.07, 0.085, 0.88 }, panelEdge = { 0.2, 0.2, 0.24, 1 },
btn = { 0.11, 0.11, 0.13, 0.96 }, btnEdge = { 0.3, 0.3, 0.35, 1 },
sel = { 0.85, 0.66, 0.15, 1 }, hover = { 1, 0.82, 0, 0.13 },
}
-- WhoDidIt's font: Fira Sans Condensed (SIL Open Font Licence, Fonts\OFL.txt), regular for
-- text, semibold for the gold titles and button labels, one size up from WoW's own
-- (it's narrower). Copies of the WoW font objects WhoDidIt uses; without CreateFont
-- on this client the WoW ones stay.
UI.FONT = "Interface\\AddOns\\WhoDidIt\\Fonts\\FiraSansCondensed-Regular.ttf"
UI.FONT_BOLD = "Interface\\AddOns\\WhoDidIt\\Fonts\\FiraSansCondensed-SemiBold.ttf"
UI.FONTS = {}
if CreateFont then
for _, name in ipairs({ "GameFontNormal", "GameFontNormalSmall", "GameFontNormalLarge",
"GameFontHighlight", "GameFontHighlightSmall", "GameFontDisable", "GameFontDisableSmall" }) do
local base = getglobal(name)
if base and base.GetFont then
local _, size, flags = base:GetFont()
local fo = CreateFont("WhoDidIt" .. name)
fo:SetFont(string.find(name, "Normal") and UI.FONT_BOLD or UI.FONT, (size or 12) + 1, flags or "")
if base.GetTextColor then
local r, g, b = base:GetTextColor()
fo:SetTextColor(r or 1, g or 1, b or 1)
end
UI.FONTS[name] = "WhoDidIt" .. name
end
end
end
-- smaller still, for a translated button label that doesn't fit (UI.Fit)
if CreateFont then
for _, name in ipairs({ "GameFontNormalSmall", "GameFontHighlightSmall", "GameFontDisableSmall" }) do
local base = getglobal(UI.FONTS[name] or name)
if base and base.GetFont then
local p, size, flags = base:GetFont()
local fo = CreateFont("WhoDidItTiny" .. name)
fo:SetFont(p, (size or 11) - 1.5, flags or "")
if base.GetTextColor then
local r, g, b = base:GetTextColor()
fo:SetTextColor(r or 1, g or 1, b or 1)
end
UI.FONTS["Tiny" .. name] = "WhoDidItTiny" .. name
end
end
end
-- Fira Sans (Locale.lua swaps UI.FONT for Chinese / Korean; the flags' names keep Fira)
UI.FIRA = UI.FONT
-- every button in the window (UI.Fit shrinks a translated label that's too wide)
UI.allBtns = {}
-- a font template name / font object: WhoDidIt's copy when there is one
function UI.F(name) return UI.FONTS[name] or name end
function UI.FO(name) return getglobal(UI.FONTS[name] or name) end
-- a font string that shows what it's given in the player's language (fixed texts
-- are translated, anything else stays as it is)
function UI.SinkText(fs)
local setText = fs.SetText
fs.SetText = function(self, t) return setText(self, W.L(t)) end
end
function UI.Flat(fr, bg, edge)
fr:SetBackdrop({ bgFile = UI.FLAT, edgeFile = UI.FLAT, tile = false, edgeSize = 1,
insets = { left = 1, right = 1, top = 1, bottom = 1 } })
fr:SetBackdropColor(bg[1], bg[2], bg[3], bg[4])
fr:SetBackdropBorderColor(edge[1], edge[2], edge[3], edge[4])
end
-- a WoW panel button made flat: its red art hidden, a dark fill, a thin border,
-- a soft gold glow on hover (and while it's the selected tab)
function UI.Skin(b)
if not b or b.wdiSkin then return b end
b.wdiSkin = true
b.wdiLevel = 1
tinsert(UI.allBtns, b)
-- labels are given in English; the button shows them in the player's language
local setText = b.SetText
b.SetText = function(self, t) return setText(self, W.L(t)) end
local hidden = 0
for _, get in ipairs({ "GetNormalTexture", "GetPushedTexture", "GetDisabledTexture" }) do
local t = b[get] and b[get](b)
if t then t:SetAlpha(0); hidden = hidden + 1 end
end
if hidden == 0 then
-- no Get...Texture on this client: take the art away instead
pcall(b.SetNormalTexture, b, "")
pcall(b.SetPushedTexture, b, "")
pcall(b.SetDisabledTexture, b, "")
end
-- the hover glow: the client's own quest-log highlight (a soft gold band)
b:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
local h = b.GetHighlightTexture and b:GetHighlightTexture()
if h then
h:ClearAllPoints()
h:SetPoint("TOPLEFT", b, "TOPLEFT", 1, -1)
h:SetPoint("BOTTOMRIGHT", b, "BOTTOMRIGHT", -1, 1)
h:SetAlpha(0.55)
end
UI.Flat(b, UI.COL.btn, UI.COL.btnEdge)
if b.SetTextFontObject then b:SetTextFontObject(UI.FO("GameFontNormal")) end
if b.SetHighlightFontObject then b:SetHighlightFontObject(UI.FO("GameFontHighlight")) end
if b.SetDisabledFontObject then b:SetDisabledFontObject(UI.FO("GameFontDisable")) end
return b
end
-- the selected tab: a gold border and the glow kept on
function UI.SkinSelect(b, on)
local e = on and UI.COL.sel or UI.COL.btnEdge
if b.wdiSkin then b:SetBackdropBorderColor(e[1], e[2], e[3], e[4]) end
if on then b:LockHighlight() else b:UnlockHighlight() end
end
------------------------------------------------------------------ list widget
local function CreateList(parent, nrows, rowh, width)
local L = CreateFrame("Frame", nil, parent)
L:SetWidth(width)
L:SetHeight(nrows * rowh)
L.nrows, L.rowh, L.offset, L.data, L.rows = nrows, rowh, 0, {}, {}
local rowW = width - 18
L.rowW = rowW
local function wheel()
L:Scroll(arg1 > 0 and -3 or 3)
end
L:EnableMouseWheel(true)
L:SetScript("OnMouseWheel", wheel)
for i = 1, nrows do
local b = CreateFrame("Button", nil, L)
b:SetWidth(rowW)
b:SetHeight(rowh)
b:SetPoint("TOPLEFT", L, "TOPLEFT", 0, -(i - 1) * rowh)
b:EnableMouseWheel(true)
b:SetScript("OnMouseWheel", wheel)
b:RegisterForClicks("LeftButtonUp", "RightButtonUp")
b.stripe = b:CreateTexture(nil, "BACKGROUND")
b.stripe:SetAllPoints(b)
-- a picture behind the row (d.art), e.g. a raid's loading screen on a run header
b.art = b:CreateTexture(nil, "BACKGROUND")
b.art:SetAllPoints(b)
b.art:Hide()
b.bar = b:CreateTexture(nil, "BORDER")
b.bar:SetTexture("Interface\\TargetingFrame\\UI-StatusBar")
b.bar:SetPoint("TOPLEFT", b, "TOPLEFT", 0, -1)
b.bar:SetPoint("BOTTOMLEFT", b, "BOTTOMLEFT", 0, 1)
b.bar:Hide()
local hl = b:CreateTexture(nil, "HIGHLIGHT")
hl:SetAllPoints(b)
hl:SetTexture(1, 1, 1, 0.08)
b.r = b:CreateFontString(nil, "OVERLAY", UI.F("GameFontHighlightSmall"))
b.r:SetPoint("RIGHT", b, "RIGHT", -4, 0)
b.r:SetJustifyH("RIGHT")
b.l = b:CreateFontString(nil, "OVERLAY", UI.F("GameFontHighlightSmall"))
b.l:SetPoint("LEFT", b, "LEFT", 4, 0)
b.l:SetJustifyH("LEFT")
b.l:SetHeight(rowh)
b:SetScript("OnEnter", function() UI.RowEnter(this) end)
b:SetScript("OnLeave", function() W.TT:Hide() end)
b:SetScript("OnClick", function()
local d = this.d
if not (d and d.click) then return end
-- x = where on the row it was clicked, so a row can tell its columns apart
local cx = GetCursorPosition()
local x = cx / this:GetEffectiveScale() - (this:GetLeft() or 0)
d.click(d, arg1, x)
end)
L.rows[i] = b
end
local s = CreateFrame("Slider", nil, L)
s:SetOrientation("VERTICAL")
s:SetWidth(14)
s:SetPoint("TOPRIGHT", L, "TOPRIGHT", 0, 0)
s:SetPoint("BOTTOMRIGHT", L, "BOTTOMRIGHT", 0, 0)
s:SetWidth(8)
UI.Flat(s, { 0, 0, 0, 0.35 }, { 0.18, 0.18, 0.22, 1 })
s:SetThumbTexture(UI.FLAT)
local thumb = s:GetThumbTexture()
if thumb then
thumb:SetVertexColor(0.55, 0.5, 0.38, 0.9)
thumb:SetWidth(6)
thumb:SetHeight(24)
end
s:SetMinMaxValues(0, 0)
s:SetValueStep(1)
s:SetValue(0)
s:SetScript("OnValueChanged", function()
if L.updating then return end
L.offset = floor(this:GetValue() + 0.5)
L:Refresh()
end)
L.slider = s
function L:MaxOffset()
return math.max(0, getn(self.data) - self.nrows)
end
function L:SetData(data, keepOffset)
self.data = data or {}
if not keepOffset then self.offset = 0 end
if self.offset > self:MaxOffset() then self.offset = self:MaxOffset() end
self:Refresh()
end
function L:Scroll(delta)
local o = self.offset + delta
if o < 0 then o = 0 end
if o > self:MaxOffset() then o = self:MaxOffset() end
self.offset = o
self:Refresh()
end
function L:Refresh()
local max = self:MaxOffset()
self.updating = true
self.slider:SetMinMaxValues(0, max)
self.slider:SetValue(self.offset)
self.updating = false
if max == 0 then self.slider:Hide() else self.slider:Show() end
for i = 1, self.nrows do
local b = self.rows[i]
local d = self.data[self.offset + i]
b.d = d
if d then
b.c = b.c or {}
local ncols = d.cols and getn(d.cols) or 0
if ncols > 0 then
-- table row: every cell on a fixed column
b.l:SetText("")
b.r:SetText("")
for j = 1, ncols do
local c = d.cols[j]
local fs = b.c[j]
if not fs then
fs = b:CreateFontString(nil, "OVERLAY", UI.F("GameFontHighlightSmall"))
fs:SetHeight(self.rowh)
b.c[j] = fs
end
fs:ClearAllPoints()
fs:SetPoint("LEFT", b, "LEFT", c[1], 0)
fs:SetWidth(c[2])
fs:SetJustifyH(c[4] or "LEFT")
fs:SetText(W.L(c[3] or ""))
fs:Show()
end
else
b.r:SetText(W.L(d.r or ""))
b.l:SetText(W.L(d.l or ""))
-- d.indent: start the text further in (fights under their raid run)
b.l:ClearAllPoints()
b.l:SetPoint("LEFT", b, "LEFT", 4 + (d.indent or 0), 0)
local rw = (d.r and d.r ~= "") and (b.r:GetStringWidth() + 12) or 0
b.l:SetWidth(self.rowW - rw - 8 - (d.indent or 0))
end
-- d.art = { path, alpha, left, right, top, bottom } (tex coords crop the picture)
if d.art and d.art[1] then
b.art:SetTexture(d.art[1])
b.art:SetTexCoord(d.art[3] or 0, d.art[4] or 1, d.art[5] or 0, d.art[6] or 1)
b.art:SetAlpha(d.art[2] or 0.35)
b.art:Show()
else
b.art:Hide()
end
for j = ncols + 1, getn(b.c) do b.c[j]:Hide() end
-- raid mark icons: d.icons = { { x, mark }, ... }
b.ic = b.ic or {}
local nic = d.icons and getn(d.icons) or 0
for j = 1, nic do
local tex = b.ic[j]
if not tex then
tex = b:CreateTexture(nil, "OVERLAY")
tex:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcons")
tex:SetWidth(14)
tex:SetHeight(14)
b.ic[j] = tex
end
local m = d.icons[j][2]
local cx, cy = math.mod(m - 1, 4), floor((m - 1) / 4)
tex:SetTexCoord(cx * 0.25, cx * 0.25 + 0.25, cy * 0.25, cy * 0.25 + 0.25)
tex:ClearAllPoints()
tex:SetPoint("LEFT", b, "LEFT", d.icons[j][1], 0)
tex:Show()
end
for j = nic + 1, getn(b.ic) do b.ic[j]:Hide() end
-- icon cells (the Consumes grid): d.grid = { { x, state, icon, title, tip, text }, ... }
b.g = b.g or {}
local ng = d.grid and getn(d.grid) or 0
for j = 1, ng do
if not b.g[j] then b.g[j] = UI.GridCell(b, self.rowh - 4, wheel) end
UI.SetGridCell(b.g[j], d.grid[j], b)
end
for j = ng + 1, getn(b.g) do b.g[j]:Hide() end
if d.bar then
b.bar:SetWidth(math.max(1, self.rowW * math.min(1, d.bar)))
b.bar:SetVertexColor(d.cr or 0.5, d.cg or 0.5, d.cb or 0.5, d.ba or 0.45)
b.bar:Show()
else
b.bar:Hide()
end
if d.sel then
b.stripe:SetTexture(0.9, 0.7, 0.1, 0.22)
elseif d.head then
b.stripe:SetTexture(0.25, 0.25, 0.32, 0.55)
elseif math.mod(self.offset + i, 2) == 0 then
b.stripe:SetTexture(1, 1, 1, 0.035)
else
b.stripe:SetTexture(0, 0, 0, 0)
end
b:Show()
else
b:Hide()
end
end
end
return L
end
-- one icon cell of a grid row: coloured edge, icon, hover tooltip; a click
-- counts as a click on its row
UI.GRID_LOOK = { -- edge r, g, b, a, then fill r, g, b
ok = { 0.25, 0.75, 0.3, 1, 0.06, 0.12, 0.06 },
miss = { 0.85, 0.15, 0.15, 1, 0.32, 0.04, 0.04 },
unk = { 0.5, 0.5, 0.55, 1, 0.12, 0.12, 0.14 },
na = { 0.2, 0.2, 0.24, 0.8, 0.07, 0.07, 0.09 },
ready = { 1, 0.82, 0, 1, 0.2, 0.16, 0.02 }, -- off cooldown when they died
}
function UI.GridCell(row, size, wheel)
local c = CreateFrame("Button", nil, row)
c:SetWidth(size)
c:SetHeight(size)
c.edge = c:CreateTexture(nil, "BACKGROUND")
c.edge:SetAllPoints(c)
c.fill = c:CreateTexture(nil, "BORDER")
c.fill:SetPoint("TOPLEFT", c, "TOPLEFT", 1, -1)
c.fill:SetPoint("BOTTOMRIGHT", c, "BOTTOMRIGHT", -1, 1)
-- same set-up as the raid-mark icons (fixed size, OVERLAY), which draw fine
c.icon = c:CreateTexture(nil, "OVERLAY")
c.icon:SetWidth(size - 4)
c.icon:SetHeight(size - 4)
c.icon:SetPoint("CENTER", c, "CENTER", 0, 0)
-- the X / ? / - mark sits on its own layer above the icon
c.top = CreateFrame("Frame", nil, c)
c.top:SetAllPoints(c)
c.txt = c.top:CreateFontString(nil, "OVERLAY", UI.F("GameFontNormal"))
c.txt:SetPoint("CENTER", c, "CENTER", 0, 0)
c.num = c.top:CreateFontString(nil, "OVERLAY", "NumberFontNormal")
c.num:SetPoint("BOTTOMRIGHT", c, "BOTTOMRIGHT", -1, 1)
local hl = c:CreateTexture(nil, "HIGHLIGHT")
hl:SetAllPoints(c)
hl:SetTexture(1, 1, 1, 0.18)
c:EnableMouseWheel(true)
c:SetScript("OnMouseWheel", wheel)
c:RegisterForClicks("LeftButtonUp", "RightButtonUp")
c:SetScript("OnClick", function()
local d = this:GetParent().d
if d and d.click then d.click(d, arg1, 0) end
end)
c:SetScript("OnEnter", function()
local g = this.g
if not g then return end
W.TT:SetOwner(this, "ANCHOR_RIGHT")
W.TT:SetText(W.L(g[4] or ""), 1, 0.82, 0)
for i = 1, getn(g[5] or {}) do W.TT:AddLine(W.LT(g[5][i]), 0.9, 0.9, 0.9, 1) end
W.TT:Show()
end)
c:SetScript("OnLeave", function() W.TT:Hide() end)
return c
end
function UI.SetGridCell(c, g, row)
c.g = g
local k = UI.GRID_LOOK[g[2]] or UI.GRID_LOOK.na
c.edge:SetTexture(k[1], k[2], k[3], k[4])
c.fill:SetTexture(k[5], k[6], k[7], 1)
if g[3] then
c.icon:SetTexture(g[3])
c.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92)
-- a missing one: the icon of what's needed, faded red under the X;
-- off cooldown at death: faded under a yellow !
if g[2] == "ready" then
c.icon:SetVertexColor(1, 1, 0.6)
c.icon:SetAlpha(0.45)
elseif g[2] == "miss" then
c.icon:SetVertexColor(1, 0.35, 0.35)
c.icon:SetAlpha(0.5)
else
c.icon:SetVertexColor(1, 1, 1)
c.icon:SetAlpha(1)
end
c.icon:Show()
else
c.icon:Hide()
end
c.txt:SetText(g[6] or "")
c.num:SetText(g[7] and tostring(g[7]) or "")
c:ClearAllPoints()
c:SetPoint("LEFT", row, "LEFT", g[1], 0)
c:Show()
end
function UI.RowEnter(b)
local d = b.d
if not d or not (d.tip or d.link) then return end
W.TT:SetOwner(b, "ANCHOR_RIGHT")
if d.link then
-- an item: its real tooltip, then our lines under it
W.TT:SetHyperlink(d.link)
for i = 1, getn(d.tip or {}) do
if type(d.tip[i]) == "string" and d.tip[i] ~= "" then W.TT:AddLine(W.LT(d.tip[i]), 0.9, 0.9, 0.9, 1) end
end
W.TT:Show()
return
end
W.TT:SetText(W.LT(d.tipTitle or d.l or ""), 1, 0.82, 0, 1)
for i = 1, getn(d.tip) do
local line = d.tip[i]
if type(line) == "table" then
W.TT:AddDoubleLine(W.LT(line[1]), W.L(line[2]), 0.9, 0.9, 0.9, 1, 1, 1)
elseif line and line ~= "" then
W.TT:AddLine(W.LT(line), 0.9, 0.9, 0.9, 1)
end
end
W.TT:Show()
end
------------------------------------------------------------------ frame
--
-- +-------------------------------------------------------------+
-- | WhoDidIt mods [x] | title bar
-- | +-----------+ +-------------------------------+-----------+ |
-- | | Encounters| | title / info / verdict | shout btns| | header
-- | | list | +-------------------------------+-----------+ |
-- | | | [tab][tab][tab][tab][tab][tab] | tabs
-- | | | +-------------------------------------------+ |
-- | | | | content list | | content
-- | | [btn][btn]| +-------------------------------------------+ |
-- | | [btn][btn]| [meter modes / hint] [Report] | bottom bar
-- | +-----------+ |
-- +-------------------------------------------------------------+
local PAD, GAP = 10, 8
local TOP = -58 -- under the title bar's two rows
local RX = PAD + LEFTW + GAP
local RW = WIDTH - RX - PAD
local HEADH = 78
local HEADW = RW - 24
local TABY = TOP - HEADH - 6
local TABH = 22
local CONTY = TABY - TABH - 4
local CONTH = HEIGHT + CONTY - 38
local BW = floor((LEFTW - 22) / 2)
local f = CreateFrame("Frame", "WhoDidItFrame", UIParent)
f:SetWidth(WIDTH)
f:SetHeight(HEIGHT)
f:SetPoint("CENTER", UIParent, "CENTER", 0, 40)
f:SetFrameStrata("HIGH")
f:SetToplevel(true)
f:SetMovable(true)
f:EnableMouse(true)
f:SetClampedToScreen(true)
f:RegisterForDrag("LeftButton")
f:SetScript("OnDragStart", function() this:StartMoving() end)
f:SetScript("OnDragStop", function() this:StopMovingOrSizing() end)
UI.Flat(f, UI.COL.frame, UI.COL.frameEdge)
f:Hide()
UI.frame = f
tinsert(UISpecialFrames, "WhoDidItFrame")
local titleBar = f:CreateTexture(nil, "ARTWORK")
titleBar:SetTexture(UI.FLAT)
if titleBar.SetGradientAlpha then
titleBar:SetGradientAlpha("VERTICAL", 0.1, 0.08, 0.04, 0.9, 0.22, 0.17, 0.07, 0.9)
else
titleBar:SetVertexColor(0.16, 0.13, 0.06, 0.9)
end
titleBar:SetPoint("TOPLEFT", f, "TOPLEFT", 5, -5)
titleBar:SetPoint("TOPRIGHT", f, "TOPRIGHT", -5, -5)
titleBar:SetHeight(24)
-- a thin gold line under the title bar
local titleLine = f:CreateTexture(nil, "ARTWORK")
titleLine:SetTexture(UI.FLAT)
titleLine:SetVertexColor(UI.COL.frameEdge[1], UI.COL.frameEdge[2], UI.COL.frameEdge[3], 0.8)
titleLine:SetPoint("TOPLEFT", titleBar, "BOTTOMLEFT", 0, 0)
titleLine:SetPoint("TOPRIGHT", titleBar, "BOTTOMRIGHT", 0, 0)
titleLine:SetHeight(1)
-- the second row: auto-loot and the add-on lights, on the right
local statusBar = f:CreateTexture(nil, "ARTWORK")
statusBar:SetTexture(1, 1, 1, 0.03)
statusBar:SetPoint("TOPLEFT", titleBar, "BOTTOMLEFT", 0, -2)
statusBar:SetPoint("TOPRIGHT", titleBar, "BOTTOMRIGHT", 0, -2)
statusBar:SetHeight(20)
local title = f:CreateFontString(nil, "OVERLAY", UI.F("GameFontNormalLarge"))
title:SetPoint("TOPLEFT", f, "TOPLEFT", PAD + 4, -10)
title:SetText("|cffff5555Who|cffffd100DidIt|r")
local version = f:CreateFontString(nil, "OVERLAY", UI.F("GameFontDisableSmall"))
version:SetPoint("BOTTOMLEFT", title, "BOTTOMRIGHT", 4, 1)
version:SetText("v" .. W.version)
local envText = f:CreateFontString(nil, "OVERLAY", UI.F("GameFontDisableSmall"))
-- the add-on lights: on the left, under the title
envText:SetPoint("TOPLEFT", f, "TOPLEFT", PAD + 4, -38)
envText:SetJustifyH("LEFT")
local close = CreateFrame("Button", nil, f, "UIPanelCloseButton")
close:SetPoint("TOPRIGHT", f, "TOPRIGHT", -2, -2)
-- auto master looting: on/off at a glance, click to pick who gets the loot
local amlBtn = UI.Skin(CreateFrame("Button", nil, f, "UIPanelButtonTemplate"))
amlBtn:SetWidth(118)
amlBtn:SetHeight(18)
-- (placed under Hall of Fame, the same width, once the tab buttons exist - see below)
if amlBtn.SetTextFontObject then amlBtn:SetTextFontObject(UI.FO("GameFontNormalSmall")) end
if amlBtn.SetHighlightFontObject then amlBtn:SetHighlightFontObject(UI.FO("GameFontHighlightSmall")) end
amlBtn.wdiLevel = 2
amlBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
amlBtn:SetScript("OnClick", function()
if not W.AutoML then W.Print(W.RESTART_MSG) return end
if arg1 == "RightButton" then W.AutoML:SetOn(not W.AutoML:On()) else W.AutoML:TogglePanel(this) end
end)
amlBtn:SetScript("OnEnter", function()
local A = W.AutoML
W.TT:SetOwner(this, "ANCHOR_BOTTOMLEFT")
W.TT:SetText(W.L("Auto master looting"), 1, 0.82, 0)
if not A then W.TT:AddLine(W.L("Restart WoW to load it."), 1, 0.5, 0.5) W.TT:Show() return end
W.TT:AddLine(W.L(A:On() and "|cff33ff33On|r - while you're the master looter, greys, whites and greens are handed out as soon as you open a corpse."
or "|cffff5555Off|r - loot is handed out by hand as normal."), 0.9, 0.9, 0.9, 1)
W.TT:AddLine(W.LF("Loot goes to: |cffffffff%s|r", A.Who(A:Target())), 0.9, 0.9, 0.9)
W.TT:AddLine(W.LF("If your bags are full: |cffffffff%s|r", A:Backup() or W.L("nobody")), 0.9, 0.9, 0.9)
W.TT:AddLine(W.L("Epics are never handed out - you get a warning and a sound."), 0.6, 0.6, 0.6, 1)
W.TT:AddLine(W.L("Click: choose who gets the loot Right-click: on / off"), 0.6, 0.6, 0.6)
W.TT:Show()
end)
amlBtn:SetScript("OnLeave", function() W.TT:Hide() end)
function UI:UpdateAML()
local A = W.AutoML
if not A then amlBtn:SetText(W.L("|cff888888Auto-loot: ?|r")) return end
local who = A:Target()
amlBtn:SetText(A:On() and (W.L("Auto-loot: |cff33ff33ON|r") .. (who and ("|cffffffff > " .. string.sub(who, 1, 8) .. "|r") or "")) or W.L("Auto-loot: |cff888888off|r"))
end
-- the language flags, left of Auto-loot. Hover: the language's name (in its own
-- font). A click asks once more, in that language; a second click switches it
-- (the UI reloads: only the chosen language's texts are kept, Locale.lua).
-- No Locale.lua (updated, then only /reload): no flags until WoW restarts.
if W.Locale then
local Loc = W.Locale
local n = getn(Loc.LANGS)
local FW, FH, GAP = 18, 12, 4
local bar = CreateFrame("Frame", nil, f)
bar:SetWidth(n * (FW + GAP) - GAP)
bar:SetHeight(FH + 4)
bar:SetPoint("RIGHT", amlBtn, "LEFT", -12, 0)
local label = bar:CreateFontString(nil, "OVERLAY")
label:SetPoint("RIGHT", bar, "LEFT", -8, 0)
label:SetJustifyH("RIGHT")
UI.flagBar, UI.flagBtns = bar, {}
local pending, pendingAt
local function say(L, text, r, g, b)
label:SetFont(L.font or UI.FIRA, 11, "")
label:SetTextColor(r, g, b)
label:SetText(text)
end
-- the chosen flag bright with a gold edge, the others dimmed; its name beside them
function UI.FlagIdle()
pending = nil
for i = 1, getn(UI.flagBtns) do
local b = UI.flagBtns[i]
local on = (b.lang.code == Loc.lang)
b.tex:SetAlpha(on and 1 or 0.45)
if on then b.edge:SetTexture(UI.COL.sel[1], UI.COL.sel[2], UI.COL.sel[3], 1) else b.edge:SetTexture(0, 0, 0, 0.9) end
end
say(Loc.BY[Loc.lang], Loc.BY[Loc.lang].name, 0.55, 0.55, 0.55)
end
for i = 1, n do
local b = CreateFrame("Button", nil, bar)
b:SetWidth(FW)
b:SetHeight(FH)
b:SetPoint("LEFT", bar, "LEFT", (i - 1) * (FW + GAP), 2)
b.edge = b:CreateTexture(nil, "BACKGROUND")
b.edge:SetPoint("TOPLEFT", b, "TOPLEFT", -1, 1)
b.edge:SetPoint("BOTTOMRIGHT", b, "BOTTOMRIGHT", 1, -1)
b.tex = b:CreateTexture(nil, "ARTWORK")
b.tex:SetAllPoints(b)
b.tex:SetTexture(Loc.Flag(Loc.LANGS[i].code))
b.lang = Loc.LANGS[i]
b:SetScript("OnEnter", function()
this.tex:SetAlpha(1)
if not pending then say(this.lang, this.lang.name, 1, 1, 1) end
end)
b:SetScript("OnLeave", function() if not pending then UI.FlagIdle() end end)
b:SetScript("OnClick", function()
local code = this.lang.code
if code == Loc.lang then UI.FlagIdle() return end
if pending == code and GetTime() - pendingAt < 8 then Loc.Set(code) return end
UI.FlagIdle()
pending, pendingAt = code, GetTime()
this.tex:SetAlpha(1)
say(this.lang, this.lang.confirm, 1, 0.82, 0)
end)
UI.flagBtns[i] = b
end
-- a click that wasn't followed by a second one: back to normal after a while
W:Every(1, function() if pending and GetTime() - pendingAt > 8 then UI.FlagIdle() end end)
UI.FlagIdle()
end
local function panel(x, y, w, h)
local p = CreateFrame("Frame", nil, f)
p:SetPoint("TOPLEFT", f, "TOPLEFT", x, y)
p:SetWidth(w)
p:SetHeight(h)
UI.Flat(p, UI.COL.panel, UI.COL.panelEdge)
return p
end
local function button(parent, text, w, h)
local b = UI.Skin(CreateFrame("Button", nil, parent, "UIPanelButtonTemplate"))
b:SetWidth(w)
b:SetHeight(h or 20)
b:SetText(text)
return b
end
-- tooltip on hover; lines may be a function returning lines
local function tooltip(b, titleText, lines, anchor)
b:SetScript("OnEnter", function()
W.TT:SetOwner(this, anchor or "ANCHOR_RIGHT")
W.TT:SetText(W.L(titleText), 1, 0.82, 0)
local l = (type(lines) == "function") and lines() or lines
for i = 1, getn(l) do W.TT:AddLine(W.LT(l[i]), 0.9, 0.9, 0.9, 1) end
W.TT:Show()
end)
b:SetScript("OnLeave", function() W.TT:Hide() end)
end
-- "Posts to: Raid" for the tooltips
function UI.PostsTo() return W.LF("|cff888888Posts to: %s|r", W.Shout:ChannelLabel()) end
-- " - 23 online" after the add-on lights (W.Board's count of WhoDidIt users on the realm)
function UI.OnlineText()
local B = W.Board
if not (B and B.OnlineCount) or not (WhoDidItDB and WhoDidItDB.opts.shareBoard) then return "" end
return " |cff666666-|r |cff888888" .. W.LF("%s online", B.OnlineCount()) .. "|r"
end
-- the add-on lights in the title bar: hover explains them, click = ClassicAPI guide
do
local hover = CreateFrame("Button", nil, f)
hover:SetPoint("TOPLEFT", envText, "TOPLEFT", -2, 3)
hover:SetPoint("BOTTOMRIGHT", envText, "BOTTOMRIGHT", 2, -3)
hover:SetScript("OnClick", function() W:ClassicApiInfo() end)
tooltip(hover, "Add-ons WhoDidIt uses", function()
local e = W.env
local function st(v, yes, no) return v and ("|cff33ff33" .. W.L(yes) .. "|r") or W.L(no) end
local B = W.Board
local l = {
(B and B.OnlineCount) and (W.LF("|cffffffff%s|r WhoDidIt users online on %s (%s)", B.OnlineCount(), B.Realm(), W.L(B.Faction()))
.. W.L("|cff888888 - heard on WhoDidIt's hidden channel in the last 25 min; players with sharing off aren't counted|r")) or " ",
" ",
"Nampower: " .. st(e.nampower, "found", "|cffff5555missing - only deaths are tracked|r"),
"SuperWoW: " .. st(e.superwow, "found", "|cffff5555missing - most tracking is off|r"),
W.L("Threat") .. ": " .. st(e.twthreat or WhoDidItDB.opts.queryThreat, "on", "|cffff5555off|r"),
"ClassicAPI: " .. st(e.classicapi, "found", "|cff999999not installed (optional)|r"),
" ",
}
if e.classicapi then
tinsert(l, "|cff33ff33ClassicAPI adds:|r")
else
tinsert(l, "|cffffd100Optional - WhoDidIt works fine without it. ClassicAPI would add:|r")
end
for i = 1, getn(W.CAPI_PERKS) do tinsert(l, "|cff33ff33+|r " .. W.L(W.CAPI_PERKS[i])) end
if not e.classicapi then
tinsert(l, " ")
tinsert(l, "|cffffd100To get it:|r exit WoW and double-click tools\\Install-ClassicAPI.cmd in the WhoDidIt folder.")
tinsert(l, "|cff888888Click for the details in chat.|r")
end
return l
end, "ANCHOR_BOTTOMLEFT")
end
local function cycle(list, cur)
for i = 1, getn(list) do
if list[i] == cur then return list[i + 1] or list[1] end
end
return list[1]
end
------------------------------------------------------------------ left: encounters
local left = panel(PAD, TOP, LEFTW, HEIGHT + TOP - PAD)
local leftHead = left:CreateFontString(nil, "OVERLAY", UI.F("GameFontNormal"))
leftHead:SetPoint("TOPLEFT", left, "TOPLEFT", 10, -9)
leftHead:SetText("Encounters")
local leftCount = left:CreateFontString(nil, "OVERLAY", UI.F("GameFontDisableSmall"))
leftCount:SetPoint("TOPRIGHT", left, "TOPRIGHT", -10, -11)
leftCount:SetJustifyH("RIGHT")
local fightList = CreateList(left, FROWS, FROWH, LEFTW - 12)
fightList:SetPoint("TOPLEFT", left, "TOPLEFT", 6, -28)
-- Rankings: Raids or 5-mans, in place of the list's title
do
local w = floor((LEFTW - 20) / 2)
UI.kindBtns = {}
local defs = {
{ false, "Raids", { "Raid rankings: boss kill times and full clears of every guild,\nfrom Chronicle, through the maintainer's master feed." } },
{ true, "5-mans", { "5-man rankings: the fastest groups through each level-60 dungeon,\nfirst pull to the last boss. Click a group for its run:\nmembers, boss splits and deaths. Name your group when it finishes." } },
}
for i = 1, getn(defs) do
local d = defs[i]
local b = button(left, d[2], w, 20)
b:SetPoint("TOPLEFT", left, "TOPLEFT", 8 + (i - 1) * (w + 4), -5)
b.five = d[1]
b:SetScript("OnClick", function()
UI.rk.five = this.five or nil
UI.rk.boss = nil; UI.rk.log = nil; UI.rk.run = nil; UI.rk.web = nil
UI:Refresh()
end)
tooltip(b, d[2], d[3])
b:Hide()
UI.kindBtns[i] = b
end
end
--[[ the panel under the list - the same on every tab:
[ Post to: Raid ] <- where WhoDidIt posts (every tab)
[ row 4 ] [ row 4 ] <- this tab's buttons (2 x 4 grid)
...
[ row 1 ] [ row 1 ] ]]
local sep = left:CreateTexture(nil, "ARTWORK")
sep:SetTexture(1, 1, 1, 0.12)
sep:SetHeight(1)
sep:SetPoint("BOTTOMLEFT", left, "BOTTOMLEFT", 8, 132)
sep:SetPoint("BOTTOMRIGHT", left, "BOTTOMRIGHT", -8, 132)
-- smaller text, so labels like "Auto shout-outs: smart" fit
local function smallText(b)
if b.SetTextFontObject then b:SetTextFontObject(UI.FO("GameFontNormalSmall")) end
if b.SetHighlightFontObject then b:SetHighlightFontObject(UI.FO("GameFontHighlightSmall")) end
if b.SetDisabledFontObject then b:SetDisabledFontObject(UI.FO("GameFontDisableSmall")) end
b.wdiLevel = 2
return b
end
-- 2 x 4 button grid, row 1 at the bottom
local function gridButton(text, row, col)
local b = smallText(button(left, text, BW, 20))
b:SetPoint("BOTTOMLEFT", left, "BOTTOMLEFT", 8 + (col - 1) * (BW + 6), 8 + (row - 1) * 24)
return b
end
-- where WhoDidIt posts: one selector, same place on every tab
local chanBtn = smallText(button(left, "Post to: Raid", BW * 2 + 6, 20))
chanBtn:SetPoint("BOTTOMLEFT", left, "BOTTOMLEFT", 8, 8 + 4 * 24)
chanBtn:RegisterForClicks("LeftButtonUp", "RightButtonUp")
chanBtn:SetScript("OnClick", function()
W.Shout:CycleChannel(arg1 == "RightButton")
UI:Refresh()
end)
tooltip(chanBtn, "Post to", function()
return {
"Where everything WhoDidIt posts goes: fight summaries, Report, Name & Shame,\nBig Them Up, shout-outs, kill and clear banter, and the rival watch.",
W.LF("Now: |cffffffff%s|r", W.Shout:ChannelLabel()),
"Click: next channel Right-click: previous",
"Raid, Raid Warning, Party, Guild, Officer, Say, Yell, Only me (a preview just for you).",
"|cff888888A custom channel: /wdi channel <name>. If you're not in the group or guild it names, posts show only to you.|r",
}
end)
-- Fights tab
local shameBtn = gridButton("|cffff5555Name & Shame|r", 4, 1)
local praiseBtn = gridButton("|cff33ff33Big Them Up|r", 4, 2)
local annBtn = gridButton("Auto summary: me", 3, 1)
local autoBtn = gridButton("Shout-outs: off", 3, 2)
local trashBtn = gridButton("Track trash: off", 2, 1)
local demoBtn = gridButton("|cff33ccffDemo fight|r", 2, 2)
local delBtn = gridButton("Delete fight", 1, 1)
local clearBtn = gridButton("Clear all fights", 1, 2)
StaticPopupDialogs["WHODIDIT_CLEAR"] = {
text = "Delete ALL saved WhoDidIt fights?",
button1 = YES, button2 = NO,
OnAccept = function()
WhoDidItDB.fights = {}
UI.selIdx = 1
UI:Refresh()
end,
timeout = 0, whileDead = 1, hideOnEscape = 1,
}
StaticPopupDialogs["WHODIDIT_DELETE"] = {
text = "Delete this fight?\n\n%s",
button1 = YES, button2 = NO,
OnAccept = function()
if UI.selIdx and UI.selIdx > 0 and WhoDidItDB.fights[UI.selIdx] then
tremove(WhoDidItDB.fights, UI.selIdx)
if UI.selIdx > getn(WhoDidItDB.fights) then UI.selIdx = getn(WhoDidItDB.fights) end
if UI.selIdx < 1 then UI.selIdx = 1 end
UI.detail = nil; UI.cause = nil
UI:Refresh()
end
end,
timeout = 0, whileDead = 1, hideOnEscape = 1,
}
delBtn:SetScript("OnClick", function()
local rec = UI.selIdx and UI.selIdx > 0 and WhoDidItDB.fights[UI.selIdx]
if rec then W.ShowPopup("WHODIDIT_DELETE", (rec.enc or "?") .. " " .. W.L(rec.result or "") .. " " .. (rec.date or "")) end
end)
tooltip(delBtn, "Delete fight", { "Delete the fight selected in the list above. Asks first." })
clearBtn:SetScript("OnClick", function() W.ShowPopup("WHODIDIT_CLEAR") end)
tooltip(clearBtn, "Clear all fights", { "Delete every saved fight. Asks first." })
trashBtn:SetScript("OnClick", function()
WhoDidItDB.opts.trackTrash = not WhoDidItDB.opts.trackTrash
UI:Refresh()
end)
tooltip(trashBtn, "Track trash", { "On: elite trash pulls are recorded and analysed too.", "Off: raid bosses only (recommended)." })
annBtn:SetScript("OnClick", function()
WhoDidItDB.opts.announce = cycle({ "self", "channel", "off" }, WhoDidItDB.opts.announce)
UI:Refresh()
end)
tooltip(annBtn, "Auto summary after each fight", function()
return {
"A summary after every boss fight: kill or wipe, time, deaths, why, who's to blame.",
W.LF("on - a short two-line post to %s (one post, even with shout-outs on)", W.Shout:ChannelLabel()),
"me - the full summary in your own chat, nobody else sees it",
"off - nothing",
"|cff888888Click to change. Report (bottom right) posts the full report any time.|r",
}
end)
autoBtn:SetScript("OnClick", function()
WhoDidItDB.opts.autoShout = cycle({ "off", "smart", "shame", "praise", "both" }, WhoDidItDB.opts.autoShout)
UI:Refresh()
end)
tooltip(autoBtn, "Auto shout-outs after each fight", function()
return {
"A short post by itself after each fight - two lines:\nafter a wipe: why, and the top 3 to blame; after a kill: MVP, top damage and heals.",
"off - never smart / both - every fight shame - wipes only praise - kills only",
"With Auto summary on as well, it's still one post, not two.",
"|cff888888Name & Shame / Big Them Up (above) post the longer versions.|r",
W.LF("|cff888888Posts to: %s. Demo fights only post to your own chat.|r", W.Shout:ChannelLabel()),
}
end)
demoBtn:SetScript("OnClick", function()
if IsShiftKeyDown() then W.Demo:Live() else W.Demo:Instant() end
end)
tooltip(demoBtn, "Demo / test mode", {
"Click: add two scripted sample fights (a messy wipe and a kill) that use every feature - deaths, aggro, mechanics, threat, meters, shout-outs.",
"Shift-click: watch the wipe play out live at 4x speed.",
"|cff888888Automatic posts after demo fights stay in your chat. Clicking Report / Name & Shame / Big Them Up posts for real, tagged DEMO. /wdi demo clear removes them.|r",
})
------------------------------------------------------------------ right: header
local header = panel(RX, TOP, RW, HEADH)
local rTitle = header:CreateFontString(nil, "OVERLAY", UI.F("GameFontNormalLarge"))
rTitle:SetPoint("TOPLEFT", header, "TOPLEFT", 10, -9)
rTitle:SetWidth(HEADW)
rTitle:SetHeight(18)
rTitle:SetJustifyH("LEFT")
local rInfo = header:CreateFontString(nil, "OVERLAY", UI.F("GameFontHighlightSmall"))
rInfo:SetPoint("TOPLEFT", rTitle, "BOTTOMLEFT", 0, -3)
rInfo:SetWidth(HEADW)
rInfo:SetHeight(12)
rInfo:SetJustifyH("LEFT")
local rVerdict = header:CreateFontString(nil, "OVERLAY", UI.F("GameFontHighlightSmall"))
rVerdict:SetPoint("TOPLEFT", rInfo, "BOTTOMLEFT", 0, -5)
rVerdict:SetWidth(HEADW)
rVerdict:SetHeight(28)
rVerdict:SetJustifyH("LEFT")
rVerdict:SetJustifyV("TOP")
UI.headArt = header:CreateTexture(nil, "BACKGROUND")
UI.headArt:SetPoint("TOPLEFT", header, "TOPLEFT", 4, -4)
UI.headArt:SetPoint("BOTTOMRIGHT", header, "BOTTOMRIGHT", -4, 4)
UI.headArt:Hide()
UI.headShade = header:CreateTexture(nil, "BORDER")
UI.headShade:SetPoint("TOPLEFT", header, "TOPLEFT", 4, -4)
UI.headShade:SetPoint("BOTTOMRIGHT", header, "BOTTOMRIGHT", -4, 4)
UI.headShade:SetTexture("Interface\\ChatFrame\\ChatFrameBackground")
if UI.headShade.SetGradientAlpha then
UI.headShade:SetGradientAlpha("HORIZONTAL", 0, 0, 0, 0.9, 0, 0, 0, 0.2)
else
UI.headShade:SetVertexColor(0, 0, 0, 0.6)
end
UI.headShade:Hide()
-- the header shows the raid it's about (nil: plain)
function UI.SetHeaderArt(zone)
local a = zone and UI.ZoneArt(zone)
if a then
UI.headArt:SetTexture(a[1])
UI.headArt:SetTexCoord(0, 1, 0.40, 0.58)
UI.headArt:SetAlpha(0.6)
UI.headArt:Show()
UI.headShade:Show()
else
UI.headArt:Hide()
UI.headShade:Hide()
end
end
-- RollForML: where soft-res sheets are made, with a copy box for the link
local SR_SITE = "https://raidres.fly.dev"
local srCopy = button(header, "Copy link", 84, 20)
srCopy:SetPoint("TOPRIGHT", header, "TOPRIGHT", -10, -10)
srCopy:SetScript("OnClick", function()
W:CopyLink("Soft-res sheets", SR_SITE)
end)
tooltip(srCopy, "raidres.fly.dev", { "The website where you make the soft-res sheet: raiders pick their items there,\nthen you use its RollFor export to import the sheet here.",
"Click: copies the link (with ClassicAPI straight to your clipboard,\notherwise a box opens with it selected - press Ctrl+C)." }, "ANCHOR_LEFT")
local srSite = header:CreateFontString(nil, "OVERLAY", UI.F("GameFontNormal"))
srSite:SetPoint("RIGHT", srCopy, "LEFT", -8, 0)
srSite:SetText("|cffaaaaaaSoft-res sheets:|r |cffffd100raidres.fly.dev|r")
srCopy:Hide()
srSite:Hide()
local function finishedRec()
local rec = UI:Current()
if not rec or rec.result == "LIVE" then W.Print("Pick a finished fight first.") return nil end
return rec
end
-- Name & Shame / Big Them Up live in the panel under the fight list
shameBtn:SetScript("OnClick", function()
local rec = finishedRec()
if rec then W.Shout:Shame(rec) end
end)
tooltip(shameBtn, "Name & Shame", function()
return {
"Post this fight's hall of shame: Most to blame, Threat Junkie, Floor Inspector,\nFire Enthusiast, Bomb Squad, AFK Award, Participation Trophy, plus two bonus awards\n(Glass Cannon, Potion Hoarder, Splattered...). Award names change every post.",
"Shame one player: Shift-click their name anywhere in the window.",
UI.PostsTo(),
}
end)