-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.lua
More file actions
3535 lines (3104 loc) · 133 KB
/
UI.lua
File metadata and controls
3535 lines (3104 loc) · 133 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
-- Wick's TBC BIS Tracker
-- UI.lua - Main panel, gear rows, dropdowns, phase selector
WTBT_UI = WTBT_UI or {}
-- ============================================================
-- CONSTANTS
-- ============================================================
local PANEL_W = 520
local PANEL_H_MAX = 650
local PANEL_MIN_W = 420
local PANEL_MIN_H = 300
local ROW_H = 38
local ALT_ROW_INDENT = 24
local ICON_SIZE = 28
local SLOT_LABEL_W = 58
local HEADER_H = 22
local SELECTOR_H = 36
local TAB_BAR_H = 28
local SUB_TAB_H = 22
local STATUS_H = 22
local GEAR_LIST_H = 480
-- Wick brand palette — see memory/reference_wick_brand_style.md
-- Fel #4FC778 · Void #0D0A14 · Shadow #171124 · Border #383058 · Text #D4C8A1
local C_BG = { 0.051, 0.039, 0.078, 0.97 }
local C_HEADER_BG = { 0.090, 0.067, 0.141, 1 }
local C_BORDER = { 0.220, 0.188, 0.345, 1 }
local C_GREEN = { 0.310, 0.780, 0.471, 1 }
local C_TEXT_DIM = { 0.42, 0.35, 0.54, 1 }
local C_TEXT_NORMAL = { 0.831, 0.784, 0.631, 1 }
local C_EPIC = { 0.64, 0.21, 0.93, 1 }
local C_RARE = { 0.00, 0.44, 0.87, 1 }
local C_LEGENDARY = { 1.00, 0.50, 0.00, 1 }
local C_ROW_HOVER = { 0.310, 0.780, 0.471, 0.06 }
-- Gem colors (texture via ColorTexture)
local GEM_COLORS = {
red = { 0.90, 0.15, 0.15 },
yellow = { 0.95, 0.85, 0.10 },
blue = { 0.15, 0.40, 0.95 },
meta = { 0.70, 0.50, 0.95 },
orange = { 0.95, 0.55, 0.10 },
purple = { 0.60, 0.10, 0.80 },
green = { 0.10, 0.80, 0.30 },
}
-- ============================================================
-- HELPER FUNCTIONS
-- ============================================================
local function SetRGBA(tex, c)
if c[4] then tex:SetColorTexture(c[1], c[2], c[3], c[4])
else tex:SetColorTexture(c[1], c[2], c[3], 1) end
end
local function NewTexture(parent, layer, c)
local t = parent:CreateTexture(nil, layer or "BACKGROUND")
if c then SetRGBA(t, c) end
return t
end
local function NewText(parent, size, r, g, b, a)
local f = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
f:SetFont("Fonts\\FRIZQT__.TTF", (size or 11) + 1, "")
f:SetTextColor(r or 1, g or 1, b or 1, a or 1)
return f
end
-- Thin 1px border helper
local function AddBorder(frame, r, g, b, a)
r, g, b, a = r or 0.22, g or 0.18, b or 0.36, a or 1
local e = {}
-- top
e[1] = NewTexture(frame, "BORDER"); e[1]:SetColorTexture(r,g,b,a)
e[1]:SetPoint("TOPLEFT"); e[1]:SetPoint("TOPRIGHT"); e[1]:SetHeight(1)
-- bottom
e[2] = NewTexture(frame, "BORDER"); e[2]:SetColorTexture(r,g,b,a)
e[2]:SetPoint("BOTTOMLEFT"); e[2]:SetPoint("BOTTOMRIGHT"); e[2]:SetHeight(1)
-- left
e[3] = NewTexture(frame, "BORDER"); e[3]:SetColorTexture(r,g,b,a)
e[3]:SetPoint("TOPLEFT"); e[3]:SetPoint("BOTTOMLEFT"); e[3]:SetWidth(1)
-- right
e[4] = NewTexture(frame, "BORDER"); e[4]:SetColorTexture(r,g,b,a)
e[4]:SetPoint("TOPRIGHT"); e[4]:SetPoint("BOTTOMRIGHT"); e[4]:SetWidth(1)
return e
end
-- (CreateSourceTag and CreateGemDots removed — now embedded in CreateGearRow for reuse)
-- ============================================================
-- GEAR ROW
-- ============================================================
local function CreateGearRow(parent, slotInfo, isAlt)
local row = CreateFrame("Button", nil, parent)
row:SetHeight(ROW_H)
local leftPad = isAlt and (10 + ALT_ROW_INDENT) or 10
-- Equipped row tint (hidden by default, shown for equipped items)
-- Uses BORDER layer so it renders above alt row backgrounds (which are BACKGROUND layer)
local equippedBG = NewTexture(row, "BORDER")
equippedBG:SetAllPoints()
equippedBG:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0.08)
equippedBG:Hide()
-- Hover highlight
local hoverBG = NewTexture(row, "BACKGROUND")
hoverBG:SetAllPoints()
hoverBG:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0)
row:SetScript("OnEnter", function(self)
hoverBG:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0.06)
end)
row:SetScript("OnLeave", function(self)
hoverBG:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0)
GameTooltip:Hide()
end)
-- Separator line at bottom
local sep = NewTexture(row, "BACKGROUND")
sep:SetColorTexture(0.220, 0.188, 0.345, 0.25)
sep:SetPoint("BOTTOMLEFT", 10, 0)
sep:SetPoint("BOTTOMRIGHT", -10, 0)
sep:SetHeight(1)
-- Slot label
local slotLabel = NewText(row, 9)
slotLabel:SetTextColor(C_TEXT_DIM[1], C_TEXT_DIM[2], C_TEXT_DIM[3], 1)
slotLabel:SetText(isAlt and "" or slotInfo.label:upper())
slotLabel:SetPoint("LEFT", row, "LEFT", leftPad, 0)
slotLabel:SetWidth(isAlt and (SLOT_LABEL_W - ALT_ROW_INDENT) or SLOT_LABEL_W)
slotLabel:SetJustifyH("LEFT")
-- Item icon frame
local iconWrap = CreateFrame("Frame", nil, row)
iconWrap:SetSize(ICON_SIZE, ICON_SIZE)
iconWrap:SetPoint("LEFT", slotLabel, "RIGHT", 4, 0)
local iconBG = NewTexture(iconWrap, "BACKGROUND")
iconBG:SetAllPoints()
iconBG:SetColorTexture(0.15, 0.10, 0.25, 1)
local iconBorder = NewTexture(iconWrap, "BORDER")
iconBorder:SetAllPoints()
iconBorder:SetColorTexture(C_EPIC[1], C_EPIC[2], C_EPIC[3], 1)
-- Actual item icon texture (set in PopulateRow)
local iconTex = iconWrap:CreateTexture(nil, "ARTWORK")
iconTex:SetPoint("TOPLEFT", 1, -1)
iconTex:SetPoint("BOTTOMRIGHT", -1, 1)
iconTex:SetTexCoord(0.08, 0.92, 0.08, 0.92)
-- Fallback color (shown when no icon available)
local iconFallback = NewTexture(iconWrap, "ARTWORK")
iconFallback:SetPoint("TOPLEFT", 1, -1)
iconFallback:SetPoint("BOTTOMRIGHT", -1, 1)
iconFallback:SetColorTexture(0.12, 0.08, 0.20, 1)
-- Green glow overlay for equipped items (hidden by default)
local iconGlow = CreateFrame("Frame", nil, iconWrap)
iconGlow:SetPoint("TOPLEFT", iconWrap, "TOPLEFT", -3, 3)
iconGlow:SetPoint("BOTTOMRIGHT", iconWrap, "BOTTOMRIGHT", 3, -3)
iconGlow:SetFrameLevel(iconWrap:GetFrameLevel() + 1)
-- Outer glow edges
local glowTop = iconGlow:CreateTexture(nil, "OVERLAY")
glowTop:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0.7)
glowTop:SetPoint("TOPLEFT"); glowTop:SetPoint("TOPRIGHT"); glowTop:SetHeight(2)
local glowBot = iconGlow:CreateTexture(nil, "OVERLAY")
glowBot:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0.7)
glowBot:SetPoint("BOTTOMLEFT"); glowBot:SetPoint("BOTTOMRIGHT"); glowBot:SetHeight(2)
local glowLeft = iconGlow:CreateTexture(nil, "OVERLAY")
glowLeft:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0.7)
glowLeft:SetPoint("TOPLEFT"); glowLeft:SetPoint("BOTTOMLEFT"); glowLeft:SetWidth(2)
local glowRight = iconGlow:CreateTexture(nil, "OVERLAY")
glowRight:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0.7)
glowRight:SetPoint("TOPRIGHT"); glowRight:SetPoint("BOTTOMRIGHT"); glowRight:SetWidth(2)
iconGlow:Hide()
-- Yellow diamond equipped indicator (centered between item name and source text)
-- Uses the raid target diamond icon (index 3), tinted yellow
local equippedDiamond = CreateFrame("Frame", nil, row)
equippedDiamond:SetSize(14, 14)
equippedDiamond:SetPoint("CENTER", row, "CENTER", 42, 0)
equippedDiamond:SetFrameLevel(row:GetFrameLevel() + 3)
local diamondIcon = equippedDiamond:CreateTexture(nil, "OVERLAY")
diamondIcon:SetAllPoints()
diamondIcon:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcon_3")
diamondIcon:SetVertexColor(1.00, 0.90, 0.2, 0.9)
equippedDiamond:Hide()
-- Item name (top-left of text area, stretches to source area)
local itemName = NewText(row, 11)
itemName:SetTextColor(C_EPIC[1], C_EPIC[2], C_EPIC[3], 1)
itemName:SetPoint("TOPLEFT", iconWrap, "TOPRIGHT", 8, -3)
itemName:SetPoint("RIGHT", row, "CENTER", 40, 0)
itemName:SetJustifyH("LEFT")
itemName:SetWordWrap(false)
-- Enchant / meta line (below name, left side)
local enchantText = NewText(row, 9)
enchantText:SetTextColor(0.00, 0.80, 0.40, 0.85)
enchantText:SetPoint("BOTTOMLEFT", iconWrap, "BOTTOMRIGHT", 8, 3)
enchantText:SetPoint("RIGHT", row, "CENTER", 40, 0)
enchantText:SetJustifyH("LEFT")
enchantText:SetWordWrap(false)
-- Source tag (far right, flush) — reusable, created once
local sourceTagHolder = CreateFrame("Frame", nil, row)
sourceTagHolder:SetPoint("RIGHT", row, "RIGHT", -8, 0)
sourceTagHolder:SetSize(38, 14)
local tagBG = NewTexture(sourceTagHolder, "BACKGROUND")
tagBG:SetAllPoints()
local tagBorder = AddBorder(sourceTagHolder)
local tagLabel = sourceTagHolder:CreateFontString(nil, "OVERLAY", "GameFontNormal")
tagLabel:SetFont("Fonts\\FRIZQT__.TTF", 9, "OUTLINE")
tagLabel:SetAllPoints()
tagLabel:SetJustifyH("CENTER")
-- Source detail text (between item name area and badge)
local sourceText = NewText(row, 9)
sourceText:SetTextColor(C_TEXT_DIM[1], C_TEXT_DIM[2], C_TEXT_DIM[3], 0.85)
sourceText:SetPoint("LEFT", row, "CENTER", 44, 0)
sourceText:SetPoint("RIGHT", sourceTagHolder, "LEFT", -6, 0)
sourceText:SetJustifyH("RIGHT")
sourceText:SetWordWrap(false)
-- Alt indicator dot (▾ bottom-right of icon)
local altDot = NewText(row, 7)
altDot:SetTextColor(C_GREEN[1], C_GREEN[2], C_GREEN[3], 1)
altDot:SetText("v")
altDot:SetPoint("BOTTOMRIGHT", iconWrap, "BOTTOMRIGHT", 1, 1)
-- Pre-created gem dot frames (max 4 gems, reused each populate)
local gemHolder = CreateFrame("Frame", nil, row)
gemHolder:SetSize(1, 8)
gemHolder:SetPoint("BOTTOMLEFT", iconWrap, "BOTTOMRIGHT", 8, 3)
local MAX_GEMS = 4
local DOT_SZ = 7
local DOT_GAP = 3
local gemDots = {}
for gi = 1, MAX_GEMS do
local dot = CreateFrame("Frame", nil, row)
dot:SetSize(DOT_SZ, DOT_SZ)
dot:SetPoint("BOTTOMLEFT", gemHolder, "BOTTOMLEFT", (gi - 1) * (DOT_SZ + DOT_GAP), 0)
local dotBG = NewTexture(dot, "BACKGROUND")
dotBG:SetAllPoints()
local dotShine = NewTexture(dot, "ARTWORK")
dotShine:SetPoint("TOPLEFT", 1, -1)
dotShine:SetPoint("BOTTOMRIGHT", -1, 1)
dot.bg = dotBG
dot.shine = dotShine
dot:Hide()
gemDots[gi] = dot
end
-- Alt row background (used for alt items, hidden by default)
local altBG = NewTexture(row, "BACKGROUND")
altBG:SetAllPoints()
altBG:SetColorTexture(0.12, 0.10, 0.20, 0.6)
altBG:Hide()
row.hoverBG = hoverBG
row.iconBorder = iconBorder
row.iconTex = iconTex
row.iconFallback = iconFallback
row.iconGlow = iconGlow
row.equippedBG = equippedBG
row.equippedDiamond = equippedDiamond
row.itemName = itemName
row.enchantText = enchantText
row.sourceText = sourceText
row.sourceHolder = sourceTagHolder
row.tagBG = tagBG
row.tagBorder = tagBorder
row.tagLabel = tagLabel
row.altDot = altDot
row.gemHolder = gemHolder
row.gemDots = gemDots
row.altBG = altBG
row.slotKey = slotInfo.key
row.slotLabel = slotLabel
return row
end
-- ============================================================
-- SECTION HEADER (must be defined before pool code)
-- ============================================================
local function CreateSectionHeader(parent, text)
local f = CreateFrame("Frame", nil, parent)
f:SetHeight(16)
local bg = NewTexture(f, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(0.310, 0.780, 0.471, 0.03)
local topLine = NewTexture(f, "BORDER")
topLine:SetColorTexture(0.220, 0.188, 0.345, 0.40)
topLine:SetPoint("TOPLEFT"); topLine:SetPoint("TOPRIGHT"); topLine:SetHeight(1)
local botLine = NewTexture(f, "BORDER")
botLine:SetColorTexture(0.220, 0.188, 0.345, 0.40)
botLine:SetPoint("BOTTOMLEFT"); botLine:SetPoint("BOTTOMRIGHT"); botLine:SetHeight(1)
local label = NewText(f, 9)
label:SetTextColor(C_TEXT_DIM[1], C_TEXT_DIM[2], C_TEXT_DIM[3], 1)
label:SetText(text:upper())
label:SetPoint("LEFT", f, "LEFT", 10, 0)
label:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
f.label = label
return f
end
-- Frame pools for recycling
local gearRowPool = {}
local sectionHeaderPool = {}
local activeGearRows = {}
-- Forward-declare pool release functions (defined after Refresh)
local ReleaseAllConsumableRows
local ReleaseAllGemRows
local ReleaseAllEnchantRows
local activeSectionHeaders = {}
-- Acquire a gear row from pool or create new
local function AcquireGearRow(parent, slotInfo, isAlt)
local row = table.remove(gearRowPool)
if not row then
row = CreateGearRow(parent, slotInfo, isAlt)
end
row:SetParent(parent)
row:Show()
activeGearRows[#activeGearRows + 1] = row
return row
end
-- Acquire a section header from pool or create new
local function AcquireSectionHeader(parent, text)
local hdr = table.remove(sectionHeaderPool)
if not hdr then
hdr = CreateSectionHeader(parent, text)
else
hdr.label:SetText(text:upper())
end
hdr:SetParent(parent)
hdr:Show()
activeSectionHeaders[#activeSectionHeaders + 1] = hdr
return hdr
end
-- Release all active frames back to pools
local function ReleaseAllFrames()
for _, row in ipairs(activeGearRows) do
row:Hide()
row:ClearAllPoints()
gearRowPool[#gearRowPool + 1] = row
end
wipe(activeGearRows)
for _, hdr in ipairs(activeSectionHeaders) do
hdr:Hide()
hdr:ClearAllPoints()
sectionHeaderPool[#sectionHeaderPool + 1] = hdr
end
wipe(activeSectionHeaders)
end
-- Configure a pooled gear row for its current slot/alt state
local function ConfigureGearRow(row, slotInfo, isAlt)
local leftPad = isAlt and (10 + ALT_ROW_INDENT) or 10
row.slotLabel:SetText(isAlt and "" or slotInfo.label:upper())
row.slotLabel:ClearAllPoints()
row.slotLabel:SetPoint("LEFT", row, "LEFT", leftPad, 0)
row.slotLabel:SetWidth(isAlt and (SLOT_LABEL_W - ALT_ROW_INDENT) or SLOT_LABEL_W)
row.slotKey = slotInfo.key
-- Show alt row dimming for alternates, hide for primaries
if row.altBG then
if isAlt then row.altBG:Show() else row.altBG:Hide() end
end
end
-- Track which slots are expanded to show alternatives
local expandedSlots = {}
-- ============================================================
-- POPULATE A ROW WITH ITEM DATA
-- ============================================================
local function PopulateRow(row, item, slotInfo, hasAlts, isAlt, altIndex)
if not item then
row.itemName:SetText("No data yet")
row.itemName:SetTextColor(C_TEXT_DIM[1], C_TEXT_DIM[2], C_TEXT_DIM[3], 1)
row.enchantText:SetText("")
row.sourceText:SetText("")
row.altDot:SetText("")
row.iconTex:Hide()
row.iconFallback:Show()
row.iconGlow:Hide()
row.equippedBG:Hide()
row.equippedDiamond:Hide()
row.sourceHolder:Hide()
for _, dot in ipairs(row.gemDots) do dot:Hide() end
if row.altBG then row.altBG:Hide() end
return
end
-- Item name + quality color (use actual item quality if available)
local nameColor = C_EPIC
local borderColor = C_EPIC
if item.itemId then
local _, _, itemRarity = GetItemInfo(item.itemId)
if itemRarity and GetItemQualityColor then
local r, g, b = GetItemQualityColor(itemRarity)
if r then
nameColor = { r, g, b, 1 }
borderColor = nameColor
end
end
end
if isAlt then
row.itemName:SetText("#" .. (altIndex + 1) .. " " .. item.name)
else
row.itemName:SetText(item.name)
end
row.itemName:SetTextColor(nameColor[1], nameColor[2], nameColor[3], 1)
row.iconBorder:SetColorTexture(borderColor[1], borderColor[2], borderColor[3], 1)
-- Item icon via itemId
local iconFound = false
if item.itemId then
if GetItemInfoInstant then
local _, _, _, _, icon = GetItemInfoInstant(item.itemId)
if icon then
row.iconTex:SetTexture(icon)
iconFound = true
end
end
if not iconFound then
local _, _, _, _, _, _, _, _, _, itemIcon = GetItemInfo(item.itemId)
if itemIcon then
row.iconTex:SetTexture(itemIcon)
iconFound = true
end
end
-- Queue item info for tooltip caching
GetItemInfo(item.itemId)
else
local _, _, _, _, _, _, _, _, _, itemIcon = GetItemInfo(item.name)
if itemIcon then
row.iconTex:SetTexture(itemIcon)
iconFound = true
end
end
if iconFound then
row.iconTex:Show()
row.iconFallback:Hide()
else
row.iconTex:Hide()
row.iconFallback:Show()
end
-- Green glow + row tint + diamond if this item is equipped and we're viewing our own class
if item.itemId and WTBT:IsViewingOwnClass() and WTBT:IsItemEquipped(item.itemId) then
row.iconGlow:Show()
row.equippedBG:Show()
row.equippedDiamond:Show()
-- Hide alt row dimming so the green tint matches normal rows
if row.altBG then row.altBG:Hide() end
else
row.iconGlow:Hide()
row.equippedBG:Hide()
row.equippedDiamond:Hide()
-- Restore alt row dimming
if row.altBG then row.altBG:Show() end
end
-- Enchant — use hand-entered value, then fall back to spec recommendation
local NO_ENCHANT_SLOTS = { Neck=true, Waist=true, Ring1=true, Ring2=true, Trinket1=true, Trinket2=true }
local enchantStr = item.enchant
if not enchantStr and not NO_ENCHANT_SLOTS[slotInfo.key] then
local encData = WTBT_Enchants and WTBT_Enchants[WTBT.state.class] and WTBT_Enchants[WTBT.state.class][WTBT.state.spec]
if encData then
for _, e in ipairs(encData) do
if e.slot == slotInfo.key then
enchantStr = e.name
break
end
end
end
end
if enchantStr then
row.enchantText:SetText(enchantStr)
row.enchantText:SetTextColor(0.00, 0.78, 0.40, 0.85)
elseif NO_ENCHANT_SLOTS[slotInfo.key] then
row.enchantText:SetText("")
else
row.enchantText:SetText("No enchant")
row.enchantText:SetTextColor(C_TEXT_DIM[1], C_TEXT_DIM[2], C_TEXT_DIM[3], 0.5)
end
-- Source detail text (visible in row)
if item.source then
row.sourceText:SetText(item.source)
else
row.sourceText:SetText("")
end
-- Alt dot (expand/collapse indicator)
if hasAlts and not isAlt then
local expanded = expandedSlots[slotInfo.key]
row.altDot:SetText(expanded and "^" or "v")
else
row.altDot:SetText("")
end
-- Gem dots — reuse pre-created dot frames
-- Use hand-entered gems if available, otherwise fall back to tooltip socket scan
local DOT_SZ = 7
local DOT_GAP = 3
local gemList = item.gems
local isFallback = false
if (not gemList or #gemList == 0) and item.itemId then
local scanned = WTBT:GetItemSockets(item.itemId)
if scanned and scanned ~= false then
gemList = scanned
isFallback = true
end
end
local gemCount = (gemList and #gemList) or 0
for gi, dot in ipairs(row.gemDots) do
if gi <= gemCount then
local gemColor = gemList[gi]
local gc = GEM_COLORS[gemColor] or { 0.5, 0.5, 0.5 }
local size = (gemColor == "meta") and 8 or DOT_SZ
dot:SetSize(size, size)
if isFallback then
-- Dimmed outline style for auto-detected sockets
dot.bg:SetColorTexture(gc[1] * 0.25, gc[2] * 0.25, gc[3] * 0.25, 0.6)
dot.shine:SetColorTexture(gc[1], gc[2], gc[3], 0.35)
else
-- Full bright style for curated gem recommendations
dot.bg:SetColorTexture(gc[1] * 0.5, gc[2] * 0.5, gc[3] * 0.5, 1)
dot.shine:SetColorTexture(gc[1], gc[2], gc[3], 0.85)
end
dot:Show()
else
dot:Hide()
end
end
row.enchantText:ClearAllPoints()
if gemCount > 0 then
local totalW = gemCount * DOT_SZ + (gemCount - 1) * DOT_GAP + 6
row.enchantText:SetPoint("BOTTOMLEFT", row.gemHolder, "BOTTOMLEFT", totalW, 0)
else
row.enchantText:SetPoint("BOTTOMLEFT", row.gemHolder, "BOTTOMLEFT", 0, 0)
end
row.enchantText:SetPoint("RIGHT", row, "CENTER", 40, 0)
-- Source tag — update existing tag in-place
local sourceType = item.sourceType
if sourceType then
local sc = WTBT.SOURCE_COLORS[sourceType] or { 0.6, 0.6, 0.6 }
local tagNames = { drop="Drop", craft="Craft", badge="Badge", rep="Rep", quest="Quest", pvp="PvP", token="Token", custom="Note" }
row.tagBG:SetColorTexture(sc[1], sc[2], sc[3], 0.15)
for _, e in ipairs(row.tagBorder) do e:SetColorTexture(sc[1], sc[2], sc[3], 0.30) end
row.tagLabel:SetTextColor(sc[1], sc[2], sc[3], 1)
row.tagLabel:SetText(tagNames[sourceType] or sourceType)
row.sourceHolder:Show()
else
row.sourceHolder:Hide()
end
-- Tooltip on hover — use native item tooltip if we have itemId
row:SetScript("OnEnter", function(self)
self.hoverBG:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0.06)
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:ClearLines()
if item.itemId then
GameTooltip:SetHyperlink("item:" .. item.itemId)
else
-- Fallback: try by name
local itemName, itemLink = GetItemInfo(item.name)
if itemLink then
GameTooltip:SetHyperlink(itemLink)
else
-- Manual tooltip as last resort
if isAlt then
GameTooltip:AddLine(item.name, C_RARE[1], C_RARE[2], C_RARE[3])
else
GameTooltip:AddLine(item.name, C_EPIC[1], C_EPIC[2], C_EPIC[3])
end
GameTooltip:AddLine(slotInfo.label, 1, 1, 1)
if item.source then
GameTooltip:AddLine(" ")
GameTooltip:AddDoubleLine("Source:", item.source, 0.7, 0.7, 0.7, 1, 1, 1)
end
end
end
GameTooltip:Show()
end)
row:SetScript("OnLeave", function(self)
self.hoverBG:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0)
GameTooltip:Hide()
end)
-- Click to expand/collapse alternatives
if hasAlts and not isAlt then
row:SetScript("OnClick", function(self)
expandedSlots[slotInfo.key] = not expandedSlots[slotInfo.key]
WTBT_UI:Refresh()
end)
else
row:SetScript("OnClick", nil)
end
end
-- Helper: get class color by name
local function GetClassColor(className)
for _, c in ipairs(WTBT.CLASSES) do
if c.name == className then return c.color end
end
return { 1, 1, 1 }
end
-- ============================================================
-- DROPDOWN (custom popup list, no UIDropDownMenuTemplate)
-- ============================================================
local activePopup = nil -- track open popup so we can close it
local function CloseActivePopup()
if activePopup then activePopup:Hide(); activePopup = nil end
end
-- colorFn: optional function(optionName) returning {r,g,b} for that option
local function CreateWTBTDropdown(parent, options, currentVal, onChange, colorFn)
local btn = CreateFrame("Button", nil, parent)
btn:SetSize(130, 24)
btn:RegisterForClicks("LeftButtonUp")
local bg = NewTexture(btn, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(0.09, 0.08, 0.18, 1)
local btnBorder = AddBorder(btn, C_BORDER[1], C_BORDER[2], C_BORDER[3], C_BORDER[4])
local label = NewText(btn, 11)
label:SetTextColor(C_TEXT_NORMAL[1], C_TEXT_NORMAL[2], C_TEXT_NORMAL[3], 1)
label:SetText(currentVal)
label:SetPoint("LEFT", btn, "LEFT", 8, 0)
label:SetPoint("RIGHT", btn, "RIGHT", -18, 0)
label:SetJustifyH("LEFT")
local arrow = NewText(btn, 10)
arrow:SetTextColor(C_GREEN[1], C_GREEN[2], C_GREEN[3], 1)
arrow:SetText("v")
arrow:SetPoint("RIGHT", btn, "RIGHT", -6, 0)
btn.label = label
btn.options = options
btn.colorFn = colorFn
-- Apply initial color
if colorFn then
local c = colorFn(currentVal)
if c then label:SetTextColor(c[1], c[2], c[3], 1) end
end
btn:SetScript("OnEnter", function(self)
for _, e in ipairs(btnBorder) do e:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 1) end
end)
btn:SetScript("OnLeave", function(self)
for _, e in ipairs(btnBorder) do e:SetColorTexture(C_BORDER[1], C_BORDER[2], C_BORDER[3], C_BORDER[4]) end
end)
-- Custom popup list
btn:SetScript("OnClick", function(self)
CloseActivePopup()
local popup = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
popup:SetFrameStrata("TOOLTIP")
popup:SetClampedToScreen(true)
local optList = self.options
local rowH = 20
local popW = self:GetWidth()
local popH = #optList * rowH + 4
popup:SetSize(popW, popH)
popup:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 0, -2)
local popBG = NewTexture(popup, "BACKGROUND")
popBG:SetAllPoints()
popBG:SetColorTexture(0.07, 0.06, 0.12, 0.97)
AddBorder(popup, C_BORDER[1], C_BORDER[2], C_BORDER[3], C_BORDER[4])
local cfn = self.colorFn
for i, opt in ipairs(optList) do
local optBtn = CreateFrame("Button", nil, popup)
optBtn:SetSize(popW - 2, rowH)
optBtn:SetPoint("TOPLEFT", popup, "TOPLEFT", 1, -(2 + (i - 1) * rowH))
optBtn:RegisterForClicks("LeftButtonUp", "LeftButtonDown")
local optLabel = NewText(optBtn, 11)
optLabel:SetText(opt)
optLabel:SetPoint("LEFT", optBtn, "LEFT", 8, 0)
optLabel:SetJustifyH("LEFT")
-- Color the option text
if cfn then
local c = cfn(opt)
if c then optLabel:SetTextColor(c[1], c[2], c[3], 1) end
else
optLabel:SetTextColor(C_TEXT_NORMAL[1], C_TEXT_NORMAL[2], C_TEXT_NORMAL[3], 1)
end
local optHover = NewTexture(optBtn, "HIGHLIGHT")
optHover:SetAllPoints()
optHover:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 0.15)
optBtn:SetScript("OnClick", function()
label:SetText(opt)
if cfn then
local c = cfn(opt)
if c then label:SetTextColor(c[1], c[2], c[3], 1) end
end
onChange(opt)
popup:Hide()
activePopup = nil
end)
end
activePopup = popup
-- Close popup when clicking elsewhere
local elapsed = 0
popup:SetScript("OnUpdate", function(self, dt)
elapsed = elapsed + dt
if elapsed > 0.05 then
if not MouseIsOver(self) and not MouseIsOver(btn) and IsMouseButtonDown("LeftButton") then
self:Hide()
activePopup = nil
end
end
end)
end)
return btn
end
-- ============================================================
-- PHASE BUTTONS
-- ============================================================
local function CreatePhaseSelector(parent)
local holder = CreateFrame("Frame", nil, parent)
holder:SetSize(5 * 26 + 4 * 2, 24)
local buttons = {}
for i = 1, 5 do
local btn = CreateFrame("Button", nil, holder)
btn:SetSize(26, 24)
btn:SetPoint("LEFT", holder, "LEFT", (i - 1) * 28, 0)
local bg = NewTexture(btn, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(0.07, 0.06, 0.12, 1)
local border = AddBorder(btn, 0.16, 0.12, 0.28, 1)
local label = NewText(btn, 9)
label:SetText("P" .. i)
label:SetTextColor(C_TEXT_DIM[1], C_TEXT_DIM[2], C_TEXT_DIM[3], 1)
label:SetAllPoints()
label:SetJustifyH("CENTER")
label:SetJustifyV("MIDDLE")
label:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE")
btn.bg = bg
btn.border = border
btn.label = label
btn.phase = i
btn:SetScript("OnClick", function(self)
WTBT.state.phase = self.phase
-- update all button visuals
for _, b in ipairs(buttons) do
local active = (b.phase == WTBT.state.phase)
if active then
b.bg:SetColorTexture(0.10, 0.22, 0.15, 1)
for _, e in ipairs(b.border) do e:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 1) end
b.label:SetTextColor(C_GREEN[1], C_GREEN[2], C_GREEN[3], 1)
else
b.bg:SetColorTexture(0.07, 0.06, 0.12, 1)
for _, e in ipairs(b.border) do e:SetColorTexture(0.16, 0.12, 0.28, 1) end
b.label:SetTextColor(C_TEXT_DIM[1], C_TEXT_DIM[2], C_TEXT_DIM[3], 1)
end
end
WTBT_UI:Refresh()
end)
buttons[i] = btn
end
holder.buttons = buttons
-- Activate current phase
local function SetActive(phase)
for _, b in ipairs(buttons) do
local active = (b.phase == phase)
if active then
b.bg:SetColorTexture(0.10, 0.22, 0.15, 1)
for _, e in ipairs(b.border) do e:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 1) end
b.label:SetTextColor(C_GREEN[1], C_GREEN[2], C_GREEN[3], 1)
else
b.bg:SetColorTexture(0.07, 0.06, 0.12, 1)
for _, e in ipairs(b.border) do e:SetColorTexture(0.16, 0.12, 0.28, 1) end
b.label:SetTextColor(C_TEXT_DIM[1], C_TEXT_DIM[2], C_TEXT_DIM[3], 1)
end
end
end
holder.SetActive = SetActive
SetActive(WTBT.state.phase)
return holder
end
-- ============================================================
-- CORNER ACCENTS (fel green brackets)
-- ============================================================
local function AddCornerAccents(frame)
local sz = 10
local corners = {
{ point = "TOPLEFT", x = 0, y = 0, wx = sz, wy = 1, hx = 1, hy = -sz },
{ point = "TOPRIGHT", x = 0, y = 0, wx = -sz, wy = 1, hx = -1, hy = -sz },
{ point = "BOTTOMLEFT", x = 0, y = 0, wx = sz, wy = -1, hx = 1, hy = sz },
{ point = "BOTTOMRIGHT", x = 0, y = 0, wx = -sz, wy = -1, hx = -1, hy = sz },
}
for _, c in ipairs(corners) do
-- horizontal bar
local h = NewTexture(frame, "OVERLAY")
h:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 1)
h:SetPoint(c.point, frame, c.point, 0, 0)
h:SetSize(sz, 2)
-- vertical bar
local v = NewTexture(frame, "OVERLAY")
v:SetColorTexture(C_GREEN[1], C_GREEN[2], C_GREEN[3], 1)
v:SetPoint(c.point, frame, c.point, 0, 0)
v:SetSize(2, sz)
end
end
-- ============================================================
-- BUILD — called once on ADDON_LOADED
-- ============================================================
function WTBT_UI:Build()
-- Main panel
local panel = CreateFrame("Frame", "WTBTPanel", UIParent, "BackdropTemplate")
tinsert(UISpecialFrames, "WTBTPanel")
panel:Hide() -- Start hidden, shown only by user action
panel:SetScript("OnShow", function()
WTBT_UI:Refresh() -- Re-render when shown (items may have cached since init)
end)
panel:SetSize(PANEL_W, PANEL_H_MAX)
panel:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
panel:SetFrameStrata("HIGH")
panel:SetMovable(true)
panel:SetResizable(true)
if panel.SetResizeBounds then
panel:SetResizeBounds(PANEL_MIN_W, PANEL_MIN_H, 800, 1000)
else
panel:SetMinResize(PANEL_MIN_W, PANEL_MIN_H)
panel:SetMaxResize(800, 1000)
end
panel:EnableMouse(true)
panel:RegisterForDrag("LeftButton")
panel:SetScript("OnDragStart", function(self) self:StartMoving() end)
panel:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
panel:SetClampedToScreen(true)
-- Background
local bg = NewTexture(panel, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(C_BG[1], C_BG[2], C_BG[3], C_BG[4])
-- Outer border
AddBorder(panel, C_BORDER[1], C_BORDER[2], C_BORDER[3], C_BORDER[4])
AddCornerAccents(panel)
self.panel = panel
-- ---- HEADER (slim, plain texture on main frame) ----
local headerBG = NewTexture(panel, "BACKGROUND")
headerBG:SetPoint("TOPLEFT", panel, "TOPLEFT", 1, -1)
headerBG:SetPoint("TOPRIGHT", panel, "TOPRIGHT", -1, -1)
headerBG:SetHeight(HEADER_H)
headerBG:SetColorTexture(C_HEADER_BG[1], C_HEADER_BG[2], C_HEADER_BG[3], C_HEADER_BG[4])
-- 1px separator below the header
local headerSep = NewTexture(panel, "BORDER")
headerSep:SetColorTexture(C_BORDER[1], C_BORDER[2], C_BORDER[3], 1)
headerSep:SetPoint("TOPLEFT", panel, "TOPLEFT", 1, -HEADER_H - 1)
headerSep:SetPoint("TOPRIGHT", panel, "TOPRIGHT", -1, -HEADER_H - 1)
headerSep:SetHeight(1)
-- Title — slim font, two-tone color preserved
local title = panel:CreateFontString(nil, "OVERLAY")
title:SetFont("Fonts\\FRIZQT__.TTF", 12, "")
title:SetText("|cff4FC778Wick's|r |cffD4C8A1TBC BIS Tracker|r")
title:SetPoint("LEFT", panel, "TOPLEFT", 10, -HEADER_H / 2)
-- Close (×) button — plain text, no border
local closeBtn = CreateFrame("Button", nil, panel)
closeBtn:SetSize(HEADER_H - 4, HEADER_H - 4)
closeBtn:SetPoint("RIGHT", panel, "TOPRIGHT", -4, -HEADER_H / 2)
local closeX = closeBtn:CreateFontString(nil, "OVERLAY")
closeX:SetFont("Fonts\\FRIZQT__.TTF", 14, "")
closeX:SetText("×")
closeX:SetTextColor(C_TEXT_NORMAL[1], C_TEXT_NORMAL[2], C_TEXT_NORMAL[3], 1)
closeX:SetAllPoints()
closeX:SetJustifyH("CENTER")
closeX:SetJustifyV("MIDDLE")
closeBtn:SetScript("OnEnter", function()
closeX:SetTextColor(C_GREEN[1], C_GREEN[2], C_GREEN[3], 1)
end)
closeBtn:SetScript("OnLeave", function()
closeX:SetTextColor(C_TEXT_NORMAL[1], C_TEXT_NORMAL[2], C_TEXT_NORMAL[3], 1)
end)
closeBtn:SetScript("OnClick", function() panel:Hide() end)
-- ---- SELECTOR BAR ----
local selectorBar = CreateFrame("Frame", nil, panel)
selectorBar:SetPoint("TOPLEFT", panel, "TOPLEFT", 1, -(HEADER_H + 1))
selectorBar:SetPoint("TOPRIGHT", panel, "TOPRIGHT", -1, -(HEADER_H + 1))
selectorBar:SetHeight(SELECTOR_H)
local selectorBG = NewTexture(selectorBar, "BACKGROUND")
selectorBG:SetAllPoints()
selectorBG:SetColorTexture(0, 0, 0, 0.20)
local selectorBot = NewTexture(selectorBar, "BORDER")
selectorBot:SetColorTexture(C_BORDER[1], C_BORDER[2], C_BORDER[3], 0.5)
selectorBot:SetPoint("BOTTOMLEFT"); selectorBot:SetPoint("BOTTOMRIGHT"); selectorBot:SetHeight(1)
-- Class dropdown
local classNames = {}
for _, c in ipairs(WTBT.CLASSES) do classNames[#classNames + 1] = c.name end
local classDD = CreateWTBTDropdown(selectorBar, classNames, WTBT.state.class, function(val)
WTBT.state.class = val
WTBT.state.subtab = "gear"
-- Reset spec to first valid and update spec dropdown options
for _, c in ipairs(WTBT.CLASSES) do
if c.name == val then
WTBT.state.spec = c.specs[1]
WTBT_UI.specDD.label:SetText(c.specs[1])
WTBT_UI.specDD.options = c.specs
break
end
end
-- Reset custom list selection for new class/spec
WTBT.state.customList = nil
local csNames = WTBT:GetCustomListNames()
if #csNames > 0 then WTBT.state.customList = csNames[1] end
WTBT_UI:Refresh()
end, GetClassColor)
classDD:SetPoint("LEFT", selectorBar, "LEFT", 8, 0)
classDD:SetSize(110, 24)
-- Spec dropdown
local specNames = {}
for _, c in ipairs(WTBT.CLASSES) do
if c.name == WTBT.state.class then
specNames = c.specs
break
end
end
local specDD = CreateWTBTDropdown(selectorBar, specNames, WTBT.state.spec, function(val)
WTBT.state.spec = val
WTBT.state.subtab = "gear"
-- Reset custom list selection for new spec
WTBT.state.customList = nil
local csNames = WTBT:GetCustomListNames()
if #csNames > 0 then WTBT.state.customList = csNames[1] end
WTBT_UI:Refresh()
end)
specDD:SetPoint("LEFT", classDD, "RIGHT", 4, 0)
specDD:SetSize(110, 24)
self.classDD = classDD
self.specDD = specDD
-- Phase selector
local phaseBar = CreatePhaseSelector(selectorBar)