-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOptions.lua
More file actions
8900 lines (8137 loc) · 354 KB
/
Copy pathOptions.lua
File metadata and controls
8900 lines (8137 loc) · 354 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
if _G.AutoDeleteFrame then return end
local ADDON_NAME = ...
-- ============================================================================
-- Style Constants
-- ============================================================================
local WHITE8x8 = "Interface\\Buttons\\WHITE8x8"
-- FRIZQT is always present in WoW 3.3.5a, no external dependency needed.
local FONT = "Fonts\\FRIZQT__.TTF"
local function RGB(r, g, b, a) return r / 255, g / 255, b / 255, a or 1 end
-- Core colors
local C_BG = { RGB(5, 5, 5, 1) } -- #050505 frame bg per CSS
local C_BORDER = { 0.16, 0.16, 0.16, 1 } -- #2a2a2a outer frame border per CSS
local C_TITLE = { 1.00, 0.50, 0.00, 1 } -- #ff8000 WoW legendary orange
local C_TEXT = { 0.85, 0.85, 0.85, 1 } -- #D9D9D9
local C_DIM = { 0.45, 0.45, 0.45, 1 } -- #737373
local C_MAGE_BLUE = { RGB(63, 199, 235, 1) } -- bright WoW mage blue #3FC7EB
local C_TOOLTIP_BODY = { 1, 1, 1, 1 }
local C_HOVER = { 0.122, 0.435, 0.659, 1 } -- muted hover blue #1F6FA8 (alias: C_BLUE)
-- =========================================================================
-- Semantic action palette (HARD RULE: only THREE colors for button hover)
-- =========================================================================
-- C_GREEN -> additive / approve / go / positive (Add, Copy, Import, Apply, Save, Confirm)
-- C_RED -> destructive / decline / remove (Delete, Remove, Clear, Cancel)
-- C_BLUE -> change / update / reward / transform (Open Panel, Edit, Refresh, Audit, Toggle filters)
-- C_ACCENT (legendary orange) is for window CHROME only (title bars, frame
-- titles, accent borders). Never use it for a button hover.
local C_RED = { 0.75, 0.22, 0.22, 1 } -- destructive
local C_GREEN = { 0.20, 0.75, 0.20, 1 } -- additive
local C_BLUE = C_HOVER -- transformational; alias to keep one source
local C_ACCENT = { 1.00, 0.50, 0.00, 1 } -- #ff8000 WoW legendary orange (CHROME ONLY)
local C_DK_RED = { 0.77, 0.12, 0.23, 1 } -- #C41E3A WoW Death Knight class color
-- Exact WoW item quality colors (used for rarity toggles)
local C_Q_POOR = { 0.62, 0.62, 0.62, 1 } -- #9d9d9d (Junk)
local C_Q_COMMON = { 1.00, 1.00, 1.00, 1 } -- #ffffff (Common / white)
local C_Q_UNCOMMON = { 0.12, 1.00, 0.00, 1 } -- #1eff00
local C_Q_RARE = { 0.00, 0.44, 0.87, 1 } -- #0070dd
local C_Q_EPIC = { 0.64, 0.21, 0.93, 1 } -- #a335ee
local C_ROW_ODD = { RGB(11, 11, 11, 1) } -- #0b0b0b per CSS
local C_ROW_EVEN = { RGB(14, 14, 14, 1) } -- #0e0e0e per CSS
local C_ROW_HOVER = { RGB(20, 45, 70, 1) } -- mage blue row hover #142D46
local C_DROP_BG = { RGB(14, 14, 14, 1) }
local C_DROP_BORDER = { 0.25, 0.25, 0.25, 1 }
local C_TITLEBAR = { RGB(16, 16, 16, 1) }
-- v3.21 SetBackdrop consolidation (wiki §6.3): inner-card pattern shared by
-- five section cards (Affix Display, Affix Protection, Auto Actions, Disenchant
-- card, Manage Ignored launcher card). Slightly darker than the outer frame
-- so cards visually recede from the surrounding panel.
local C_CARD_BG = { 0.04, 0.04, 0.04, 1 } -- #0a0a0a inner card bg
local C_CARD_BORDER = { 0.14, 0.14, 0.14, 1 } -- #242424 inner card border
-- Dark button base used by the custom dropdown trigger and the spinner-input
-- arrow buttons. Pure-black 1px border + near-black fill on hover-out.
local C_BTN_BASE_BG = { 0.09, 0.09, 0.09, 1 }
local C_BTN_BASE_BORDER = { 0, 0, 0, 1 }
-- ============================================================================
-- Helper Functions
-- ============================================================================
local function ApplyBackdrop(frame, bgColor, borderColor)
frame:SetBackdrop({ bgFile = WHITE8x8, edgeFile = WHITE8x8, edgeSize = 1 })
frame:SetBackdropColor(unpack(bgColor or C_BG))
frame:SetBackdropBorderColor(unpack(borderColor or C_BORDER))
end
local function BringPopupToFront(frame)
if frame and frame.Raise then frame:Raise() end
end
_G.AutoDelete_BringPopupToFront = BringPopupToFront
local RegisterSpecialFrame = _G.AutoDelete_RegisterSpecialFrame
local function ApplyPopupChrome(frame)
ApplyBackdrop(frame, C_BG, { 0.26, 0.26, 0.26, 1 })
if frame.SetToplevel then frame:SetToplevel(true) end
if not frame._autoDeleteEdgeShadow then
local right = frame:CreateTexture(nil, "ARTWORK")
right:SetTexture(WHITE8x8)
right:SetVertexColor(0, 0, 0, 0.55)
right:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -1, -2)
right:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -1, 2)
right:SetWidth(3)
local bottom = frame:CreateTexture(nil, "ARTWORK")
bottom:SetTexture(WHITE8x8)
bottom:SetVertexColor(0, 0, 0, 0.55)
bottom:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 2, 1)
bottom:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -2, 1)
bottom:SetHeight(3)
frame._autoDeleteEdgeShadow = true
end
end
_G.AutoDelete_ApplyPopupChrome = ApplyPopupChrome
local function MakeText(parent, size, color, flag, justify)
local fs = parent:CreateFontString(nil, "OVERLAY")
fs:SetFont(FONT, size, flag or "OUTLINE")
fs:SetTextColor(unpack(color or C_TEXT))
if justify then fs:SetJustifyH(justify) end
return fs
end
local function MakeSeparator(parent, yOff)
local sep = parent:CreateTexture(nil, "ARTWORK")
sep:SetTexture(WHITE8x8)
sep:SetHeight(1)
sep:SetPoint("TOPLEFT", 15, yOff)
sep:SetPoint("RIGHT", -15, 0)
sep:SetVertexColor(0.15, 0.15, 0.15, 1)
return sep
end
local function ShowSimpleTooltip(owner, title, body, warning)
if not body or body == "" then return end
GameTooltip:SetOwner(owner, "ANCHOR_TOP")
GameTooltip:SetText(title or "", C_MAGE_BLUE[1], C_MAGE_BLUE[2], C_MAGE_BLUE[3], 1)
GameTooltip:AddLine(body, C_TOOLTIP_BODY[1], C_TOOLTIP_BODY[2], C_TOOLTIP_BODY[3], true)
if warning and warning ~= "" then
GameTooltip:AddLine(" ")
GameTooltip:AddLine(warning, C_RED[1], C_RED[2], C_RED[3], true)
end
GameTooltip:Show()
end
local function AttachSimpleTooltip(frame, title, body, warning)
if not frame or not body or body == "" then return end
frame:EnableMouse(true)
frame:SetScript("OnEnter", function(self)
ShowSimpleTooltip(self, title, body, warning)
end)
frame:SetScript("OnLeave", function() GameTooltip:Hide() end)
end
-- PEADAR-style toggle: 14x14 box + 14x14 checkmark indicator
local function MakeToggle(parent, label, color, tooltip, tooltipTitle, indicatorColor)
local row = CreateFrame("Button", nil, parent)
row:SetSize(290, 20)
local box = CreateFrame("Frame", nil, row)
box:SetSize(14, 14)
box:SetPoint("LEFT", 0, 0)
ApplyBackdrop(box, C_ROW_ODD, C_BORDER)
-- Bundled TGA check (128x128 for smooth downsample). Tried Unicode ✓ glyph
-- but FRIZQT__.TTF on 3.3.5 renders it poorly. TGA is reliable.
local indicator = box:CreateTexture(nil, "OVERLAY")
indicator:SetTexture("Interface\\AddOns\\AutoDelete\\textures\\checkmark.tga")
indicator:SetPoint("CENTER", box, "CENTER", 0, 0)
indicator:SetSize(14, 14)
indicator:SetVertexColor(1, 1, 1, 1)
indicator:Hide()
local text = MakeText(row, 10, C_TEXT, "OUTLINE")
text:SetPoint("LEFT", box, "RIGHT", 8, 0)
text:SetPoint("RIGHT", row, "RIGHT", -2, 0)
text:SetJustifyH("LEFT")
text:SetWordWrap(true)
text:SetText(label)
row._checked = false
local activeColor = color or C_ACCENT
local activeIndicatorColor = indicatorColor or { 1, 1, 1, 1 }
local function UpdateVisual()
if row._checked then
-- Checked: solid accent fill with slightly-brighter border of same hue, white glyph.
local lighter = {
math.min(activeColor[1] + 0.10, 1),
math.min(activeColor[2] + 0.10, 1),
math.min(activeColor[3] + 0.10, 1),
1,
}
ApplyBackdrop(box, activeColor, lighter)
indicator:SetVertexColor(unpack(activeIndicatorColor))
indicator:Show()
else
-- Unchecked: dark box, medium-gray border, no glyph.
ApplyBackdrop(box, { 0.04, 0.04, 0.04, 1 }, { 0.33, 0.33, 0.33, 1 })
indicator:Hide()
end
end
function row:SetChecked(val)
row._checked = val and true or false
UpdateVisual()
end
function row:GetChecked() return row._checked end
row:SetScript("OnClick", function()
row._checked = not row._checked
UpdateVisual()
end)
local tipText = tooltip
if (not tipText or tipText == "") and label and label ~= "" then
tipText = "Turn " .. label .. " on or off."
end
if tipText then
local ttTitle = tooltipTitle or label
row:SetScript("OnEnter", function(self)
ShowSimpleTooltip(self, ttTitle, tipText)
end)
row:SetScript("OnLeave", function() GameTooltip:Hide() end)
end
return row
end
-- Small helper for sub-toggles: smaller box (12x12), 9pt text.
local function MakeSubToggle(parent, label, color, tooltip, tooltipTitle, indicatorColor)
local row = CreateFrame("Button", nil, parent)
row:SetSize(120, 16)
local box = CreateFrame("Frame", nil, row)
box:SetSize(12, 12)
box:SetPoint("LEFT", 0, 0)
ApplyBackdrop(box, { 0.04, 0.04, 0.04, 1 }, { 0.33, 0.33, 0.33, 1 })
local indicator = box:CreateTexture(nil, "OVERLAY")
indicator:SetTexture("Interface\\AddOns\\AutoDelete\\textures\\checkmark.tga")
indicator:SetPoint("CENTER", box, "CENTER", 0, 0)
indicator:SetSize(12, 12)
indicator:SetVertexColor(1, 1, 1, 1)
indicator:Hide()
local text = row:CreateFontString(nil, "OVERLAY")
text:SetFont(FONT, 9, "OUTLINE")
text:SetTextColor(unpack(C_DIM))
text:SetPoint("LEFT", box, "RIGHT", 6, 0)
text:SetPoint("RIGHT", row, "RIGHT", -2, 0)
text:SetJustifyH("LEFT")
text:SetWordWrap(true)
text:SetText(label)
row._checked = false
local activeColor = color or C_ACCENT
local activeIndicatorColor = indicatorColor or { 1, 1, 1, 1 }
local function UpdateVisual()
if row._checked then
local lighter = {
math.min(activeColor[1] + 0.10, 1),
math.min(activeColor[2] + 0.10, 1),
math.min(activeColor[3] + 0.10, 1),
1,
}
ApplyBackdrop(box, activeColor, lighter)
indicator:SetVertexColor(unpack(activeIndicatorColor))
indicator:Show()
text:SetTextColor(unpack(C_TEXT))
else
ApplyBackdrop(box, { 0.04, 0.04, 0.04, 1 }, { 0.33, 0.33, 0.33, 1 })
indicator:Hide()
text:SetTextColor(unpack(C_DIM))
end
end
function row:SetChecked(val)
row._checked = val and true or false
UpdateVisual()
end
function row:GetChecked() return row._checked end
row:SetScript("OnClick", function()
row._checked = not row._checked
UpdateVisual()
end)
local tipText = tooltip
if (not tipText or tipText == "") and label and label ~= "" then
tipText = "Turn " .. label .. " on or off."
end
if tipText then
row:SetScript("OnEnter", function(self)
ShowSimpleTooltip(self, tooltipTitle or label, tipText)
end)
row:SetScript("OnLeave", function() GameTooltip:Hide() end)
end
return row
end
-- Segmented control: N pills laid out side-by-side, one active at a time,
-- or none active (idle/off). Used for the Auto Actions card but generic.
--
-- States table format (each entry):
-- { value="delete", label="Del", tooltip="...",
-- bg={r,g,b,a}, border={r,g,b,a}, fg={r,g,b,a} }
-- bg/border/fg describe the ACTIVE appearance. Inactive segments share a
-- single neutral-gray paint -- "all gray until you click one" -- so the
-- active pill is the only thing competing for attention.
--
-- Click semantics:
-- - Click an inactive segment -> SetValue(segment.value) (light it up)
-- - Click the active segment -> SetValue(offValue) (dim it out)
-- (only if offValue was supplied; otherwise it's a no-op repaint.)
--
-- offValue may be ANY string -- including one that doesn't match any segment.
-- A value that doesn't match any segment renders as "no segment active",
-- which is exactly what we want for an implicit-off state.
--
-- API surface:
-- ctrl:GetValue() -> current value string
-- ctrl:SetValue(value) -> set value (any string allowed); fires onChange
-- iff value actually changed
-- onChange(newValue, oldValue) -> caller-supplied callback
--
-- segWidth is the PER-SEGMENT width. Total control width is
-- N * segWidth + (N - 1) GAP. This lets two different controls share the
-- same pill width but have different total widths -- e.g. a 2-segment row
-- and a 1-segment row whose right edges line up because of where they're
-- anchored, with the single pill lining up with the rightmost pill of the
-- 2-segment row.
local function MakeSegmentedControl(parent, segWidth, height, states, offValue, onChange)
local n = #states
local GAP = 1
local totalWidth = n * segWidth + math.max(0, n - 1) * GAP
local ctrl = CreateFrame("Frame", nil, parent)
ctrl:SetSize(totalWidth, height)
ctrl._states = states
ctrl._value = offValue -- start in the implicit-off state; caller SetValue overrides
ctrl._segments = {}
-- Neutral inactive paint: dark bg, subtle gray border, dimmed text.
-- Same for every state when inactive so the visual reads "all gray".
local INACTIVE_BG = { 0.07, 0.07, 0.07, 1 }
local INACTIVE_BORDER = { 0.22, 0.22, 0.22, 1 }
local INACTIVE_FG = C_DIM
local function PaintSegment(seg, isActive)
local s = seg._state
if isActive then
ApplyBackdrop(seg, s.bg, s.border)
seg._text:SetTextColor(unpack(s.fg))
else
ApplyBackdrop(seg, INACTIVE_BG, INACTIVE_BORDER)
seg._text:SetTextColor(unpack(INACTIVE_FG))
end
end
local function Repaint()
for _, seg in ipairs(ctrl._segments) do
PaintSegment(seg, seg._state.value == ctrl._value)
end
end
for i, s in ipairs(states) do
local seg = CreateFrame("Button", nil, ctrl)
seg:SetSize(segWidth, height)
seg:SetPoint("LEFT", ctrl, "LEFT", (i - 1) * (segWidth + GAP), 0)
seg._state = s
local text = seg:CreateFontString(nil, "OVERLAY")
text:SetFont(FONT, 10, "OUTLINE")
text:SetPoint("CENTER", 0, 0)
text:SetJustifyH("CENTER")
text:SetText(s.label)
seg._text = text
-- Click an inactive segment -> activate it.
-- Click the active segment -> deselect (set to offValue).
seg:SetScript("OnClick", function()
if ctrl._value == s.value then
ctrl:SetValue(offValue)
else
ctrl:SetValue(s.value)
end
end)
-- Hover: brighten the border on this segment and show its tooltip.
-- Active segments brighten from their state border; inactive segments
-- brighten from INACTIVE_BORDER so the hover hint is visible without
-- pre-disclosing the state color.
seg:SetScript("OnEnter", function(self)
local b = (ctrl._value == self._state.value) and self._state.border or INACTIVE_BORDER
self:SetBackdropBorderColor(
math.min(b[1] + 0.25, 1),
math.min(b[2] + 0.25, 1),
math.min(b[3] + 0.25, 1),
1)
if self._state.tooltip then
GameTooltip:SetOwner(self, "ANCHOR_TOP")
GameTooltip:SetText(self._state.label, C_MAGE_BLUE[1], C_MAGE_BLUE[2], C_MAGE_BLUE[3], 1)
GameTooltip:AddLine(self._state.tooltip, C_TOOLTIP_BODY[1], C_TOOLTIP_BODY[2], C_TOOLTIP_BODY[3], true)
GameTooltip:Show()
end
end)
seg:SetScript("OnLeave", function()
Repaint()
GameTooltip:Hide()
end)
ctrl._segments[i] = seg
end
function ctrl:GetValue() return self._value end
function ctrl:SetValue(value)
local oldValue = self._value
if oldValue == value then
Repaint() -- idempotent paint so stale visuals (e.g. post profile-switch) line up
return
end
self._value = value
Repaint()
if onChange then onChange(value, oldValue) end
end
Repaint()
return ctrl
end
-- PEADAR-style custom dropdown
local function MakeDropdown(parent, width, options, onChange, tooltip, tooltipTitle)
local dd = CreateFrame("Frame", nil, parent)
dd:SetSize(width, 22)
dd._tooltip = tooltip
dd._tooltipTitle = tooltipTitle
-- Button: flat near-black bg, thin black border, subtle 1px top gloss
-- highlight line, teal-tinted border on hover.
local btn = CreateFrame("Button", nil, dd)
btn:SetAllPoints()
-- v3.21 §6.3: canonical ApplyBackdrop helper. Was three raw SetBackdrop /
-- SetBackdropColor / SetBackdropBorderColor calls; same visual result.
ApplyBackdrop(btn, C_BTN_BASE_BG, C_BTN_BASE_BORDER)
btn:SetFrameStrata(parent:GetFrameStrata() or "DIALOG")
btn:SetFrameLevel((parent:GetFrameLevel() or 1) + 5)
-- Top gloss highlight line
local gloss = btn:CreateTexture(nil, "OVERLAY")
gloss:SetTexture(WHITE8x8)
gloss:SetVertexColor(1, 1, 1, 0.08)
gloss:SetHeight(1)
gloss:SetPoint("TOPLEFT", 1, -1)
gloss:SetPoint("TOPRIGHT", -1, -1)
local btnText = btn:CreateFontString(nil, "OVERLAY")
btnText:SetDrawLayer("OVERLAY", 7)
btnText:SetFont(FONT, 11)
btnText:SetTextColor(1, 1, 1, 1)
btnText:SetShadowColor(0, 0, 0, 0)
btnText:SetPoint("LEFT", 8, 0)
btnText:SetPoint("RIGHT", -20, 0)
btnText:SetJustifyH("LEFT")
-- Arrow - uses pre-rotated arrowdown.tga (no SetRotation needed).
-- Pre-rotated textures render at exactly the size specified, unlike
-- rotated textures which WoW 3.3.5 scales slightly inconsistently.
local arrow = btn:CreateTexture(nil, "OVERLAY", nil, 7)
arrow:SetTexture("Interface\\AddOns\\AutoDelete\\textures\\arrowdown.tga")
arrow:SetSize(10, 10)
arrow:SetPoint("RIGHT", -6, 0)
arrow:SetVertexColor(1, 1, 1, 1)
btn:SetScript("OnEnter", function(self)
self:SetBackdropColor(0.14, 0.14, 0.14, 1)
self:SetBackdropBorderColor(0.25, 0.55, 0.65, 1)
gloss:SetVertexColor(1, 1, 1, 0.14)
ShowSimpleTooltip(self, dd._tooltipTitle or "Choose", dd._tooltip)
end)
btn:SetScript("OnLeave", function(self)
self:SetBackdropColor(0.09, 0.09, 0.09, 1)
self:SetBackdropBorderColor(0, 0, 0, 1)
gloss:SetVertexColor(1, 1, 1, 0.08)
GameTooltip:Hide()
end)
-- Popup as its own top-level frame so nothing from the panel overlays it
local popup = CreateFrame("Frame", nil, UIParent)
popup:SetToplevel(true)
popup:EnableMouse(true)
popup:SetClampedToScreen(true)
popup:SetFrameStrata("FULLSCREEN_DIALOG")
popup:SetFrameLevel(1000)
popup:SetWidth(width)
ApplyBackdrop(popup, { 0, 0, 0, 1 }, { 0.7, 0.7, 0.7, 1 })
popup:Hide()
dd._popup = popup
local popupRows = {}
for i, opt in ipairs(options) do
local row = CreateFrame("Button", nil, popup)
row:SetHeight(20)
row:SetPoint("TOPLEFT", 1, -1 - (i - 1) * 20)
row:SetPoint("RIGHT", -1, 0)
row:SetFrameStrata("FULLSCREEN_DIALOG")
row:SetFrameLevel(1001)
local rowBG = row:CreateTexture(nil, "BACKGROUND")
rowBG:SetTexture(WHITE8x8)
rowBG:SetAllPoints()
rowBG:SetVertexColor(0.02, 0.02, 0.02, 1)
local rowText = row:CreateFontString(nil, "OVERLAY")
rowText:SetDrawLayer("OVERLAY", 7)
rowText:SetFont(FONT, 11)
rowText:SetTextColor(1, 1, 1, 1)
rowText:SetShadowColor(0, 0, 0, 0)
rowText:SetJustifyH("LEFT")
rowText:SetPoint("LEFT", 8, 0)
rowText:SetPoint("RIGHT", -8, 0)
rowText:SetText(opt.label)
row:SetScript("OnEnter", function()
rowBG:SetVertexColor(0.12, 0.35, 0.40, 1)
end)
row:SetScript("OnLeave", function()
rowBG:SetVertexColor(0.02, 0.02, 0.02, 1)
end)
row:SetScript("OnClick", function()
popup:Hide()
btnText:SetText(opt.label)
dd._value = opt.value
if onChange then onChange(opt.value) end
end)
popupRows[i] = row
end
popup:SetHeight(2 + #options * 20)
local clickCatcher = CreateFrame("Button", nil, UIParent)
clickCatcher:SetAllPoints(UIParent)
clickCatcher:SetFrameStrata("FULLSCREEN_DIALOG")
clickCatcher:SetFrameLevel(999)
clickCatcher:EnableMouse(true)
clickCatcher:RegisterForClicks("AnyDown")
clickCatcher:Hide()
clickCatcher:SetScript("OnClick", function()
popup:Hide()
end)
local function ShowPopup()
popup:ClearAllPoints()
popup:SetPoint("TOPLEFT", btn, "BOTTOMLEFT", 0, -1)
clickCatcher:Show()
popup:Show()
end
btn:SetScript("OnClick", function()
if popup:IsShown() then
popup:Hide()
else
ShowPopup()
end
end)
popup:SetScript("OnShow", function()
clickCatcher:Show()
end)
popup:SetScript("OnHide", function()
clickCatcher:Hide()
end)
parent:HookScript("OnHide", function()
if popup:IsShown() then popup:Hide() end
end)
function dd:SetValue(val)
dd._value = val
for _, opt in ipairs(options) do
if opt.value == val then
btnText:SetText(opt.label)
return
end
end
btnText:SetText(tostring(val))
end
function dd:GetValue() return dd._value end
function dd:SetTooltip(title, body)
dd._tooltipTitle = title
dd._tooltip = body
end
-- Dynamic options rebuild. Used by tabs whose dropdown contents change
-- at runtime (e.g. Profiles tab - character names may be added/deleted).
-- Rebuilds the popup row pool, resets selection, preserves size.
function dd:SetOptions(newOptions)
-- Hide + remove existing rows.
for _, row in ipairs(popupRows) do
row:Hide()
row:SetParent(nil)
end
-- Rebuild the options upvalue so SetValue still finds labels.
options = newOptions or {}
popupRows = {}
for i, opt in ipairs(options) do
local row = CreateFrame("Button", nil, popup)
row:SetHeight(20)
row:SetPoint("TOPLEFT", 1, -1 - (i - 1) * 20)
row:SetPoint("RIGHT", -1, 0)
row:SetFrameStrata("FULLSCREEN_DIALOG")
row:SetFrameLevel(1001)
local rowBG = row:CreateTexture(nil, "BACKGROUND")
rowBG:SetTexture(WHITE8x8)
rowBG:SetAllPoints()
rowBG:SetVertexColor(0.02, 0.02, 0.02, 1)
local rowText = row:CreateFontString(nil, "OVERLAY")
rowText:SetDrawLayer("OVERLAY", 7)
rowText:SetFont(FONT, 12)
rowText:SetTextColor(1, 1, 1, 1)
rowText:SetShadowColor(0, 0, 0, 0)
rowText:SetJustifyH("LEFT")
rowText:SetPoint("LEFT", 8, 0)
rowText:SetPoint("RIGHT", -8, 0)
rowText:SetText(opt.label)
row:SetScript("OnEnter", function()
rowBG:SetVertexColor(0.12, 0.35, 0.40, 1)
end)
row:SetScript("OnLeave", function()
rowBG:SetVertexColor(0.02, 0.02, 0.02, 1)
end)
row:SetScript("OnClick", function()
popup:Hide()
btnText:SetText(opt.label)
dd._value = opt.value
if onChange then onChange(opt.value) end
end)
popupRows[i] = row
end
popup:SetHeight(2 + #options * 20)
-- Don't change the displayed label - caller decides what to show via SetValue.
end
return dd
end
-- ============================================================================
-- Section Helpers
-- ============================================================================
-- AutoSizeSection: set a section's height based on its lowest child element.
-- Uses GetTop/GetBottom which return absolute screen coords - valid as long as
-- both the section and the element have been SetPoint'd and the frame is shown.
-- Falls back to leaving the section at its current height if coords are nil.
local function AutoSizeSection(section, lastElement, padding, fallback)
padding = padding or 8
fallback = fallback or 80
local top = section:GetTop()
local bottom = lastElement:GetBottom()
if top and bottom then
local h = top - bottom + padding
if h < 20 then h = 20 end
section:SetHeight(h)
else
-- Layout not resolved yet; use safe fallback
section:SetHeight(fallback)
end
return section:GetHeight()
end
-- MakeSection: titled bordered box.
-- title appears above the box in C_TITLE gold; box has subtle border + dark bg.
-- Returns the content box frame. Caller sets its height and anchors children inside.
-- MakeSpinnerInput: numeric input with up/down arrow spin buttons on the right.
-- Uses Blizzard's stock UIPanelSquareButton textures for reliable arrow rendering.
-- Returns the outer frame (for anchoring) and its .editBox (for value access).
local function MakeSpinnerInput(parent, width, height, minVal, maxVal, onChanged, tooltip, tooltipTitle)
minVal = minVal or 1
maxVal = maxVal or 9999
height = height or 22
local frame = CreateFrame("Frame", nil, parent)
frame:SetSize(width, height)
ApplyBackdrop(frame, C_DROP_BG, C_DROP_BORDER)
local function ShowSpinnerTip(owner)
ShowSimpleTooltip(owner, tooltipTitle or "Number", tooltip)
end
-- The numeric editbox takes most of the width, arrows take the right ~14px
local ARROW_W = 16
local editBox = CreateFrame("EditBox", nil, frame)
editBox:SetFont(FONT, 11)
editBox:SetTextColor(1, 1, 1)
editBox:SetAutoFocus(false)
editBox:SetNumeric(true)
editBox:SetMaxLetters(4)
editBox:SetJustifyH("CENTER")
editBox:SetPoint("TOPLEFT", 5, -2)
editBox:SetPoint("BOTTOMRIGHT", -ARROW_W - 4, 2)
editBox:SetScript("OnEscapePressed", function(s) s:ClearFocus() end)
editBox:SetScript("OnEnterPressed", function(s) s:ClearFocus() end)
if tooltip and tooltip ~= "" then
frame:EnableMouse(true)
frame:SetScript("OnEnter", ShowSpinnerTip)
frame:SetScript("OnLeave", function() GameTooltip:Hide() end)
editBox:SetScript("OnEnter", ShowSpinnerTip)
editBox:SetScript("OnLeave", function() GameTooltip:Hide() end)
end
-- Clamp + callback wrapper
local function CommitValue(val)
if val < minVal then val = minVal end
if val > maxVal then val = maxVal end
editBox:SetText(tostring(val))
if onChanged then onChanged(val) end
end
editBox:SetScript("OnEditFocusLost", function(s)
local v = tonumber(s:GetText()) or minVal
CommitValue(v)
end)
-- Up arrow: pre-rotated arrowup.tga
local upBtn = CreateFrame("Button", nil, frame)
upBtn:SetSize(ARROW_W, math.floor(height / 2))
upBtn:SetPoint("TOPRIGHT", -1, -1)
local upGlyph = upBtn:CreateTexture(nil, "OVERLAY")
upGlyph:SetTexture("Interface\\AddOns\\AutoDelete\\textures\\arrowup.tga")
upGlyph:SetSize(9, 9)
upGlyph:SetPoint("CENTER", 0, 0)
upGlyph:SetVertexColor(1, 1, 1, 1)
upBtn:SetScript("OnClick", function()
local cur = tonumber(editBox:GetText()) or minVal
CommitValue(cur + 1)
end)
upBtn:SetScript("OnEnter", function(btn)
upGlyph:SetVertexColor(C_HOVER[1], C_HOVER[2], C_HOVER[3], 1)
ShowSpinnerTip(btn)
end)
upBtn:SetScript("OnLeave", function()
upGlyph:SetVertexColor(1, 1, 1, 1)
GameTooltip:Hide()
end)
-- Down arrow: pre-rotated arrowdown.tga (no SetRotation needed)
local downBtn = CreateFrame("Button", nil, frame)
downBtn:SetSize(ARROW_W, math.floor(height / 2))
downBtn:SetPoint("BOTTOMRIGHT", -1, 1)
local downGlyph = downBtn:CreateTexture(nil, "OVERLAY")
downGlyph:SetTexture("Interface\\AddOns\\AutoDelete\\textures\\arrowdown.tga")
downGlyph:SetSize(9, 9)
downGlyph:SetPoint("CENTER", 0, 0)
downGlyph:SetVertexColor(1, 1, 1, 1)
downBtn:SetScript("OnClick", function()
local cur = tonumber(editBox:GetText()) or minVal
CommitValue(cur - 1)
end)
downBtn:SetScript("OnEnter", function(btn)
downGlyph:SetVertexColor(C_HOVER[1], C_HOVER[2], C_HOVER[3], 1)
ShowSpinnerTip(btn)
end)
downBtn:SetScript("OnLeave", function()
downGlyph:SetVertexColor(1, 1, 1, 1)
GameTooltip:Hide()
end)
-- Thin divider between the editbox and the arrow column
local divider = frame:CreateTexture(nil, "OVERLAY")
divider:SetTexture(WHITE8x8)
divider:SetVertexColor(0.22, 0.22, 0.22, 1)
divider:SetPoint("TOPRIGHT", -ARROW_W - 1, -1)
divider:SetPoint("BOTTOMRIGHT", -ARROW_W - 1, 1)
divider:SetWidth(1)
frame.editBox = editBox
frame.upBtn = upBtn
frame.downBtn = downBtn
return frame
end
local function MakeSection(parent, title, yOff, height, leftMargin, rightMargin)
leftMargin = leftMargin or 15
rightMargin = rightMargin or 15
local titleFS = parent:CreateFontString(nil, "OVERLAY")
titleFS:SetFont(FONT, 13, "OUTLINE")
titleFS:SetTextColor(unpack(C_TITLE))
titleFS:SetPoint("TOPLEFT", leftMargin, yOff)
titleFS:SetText(title)
local box = CreateFrame("Frame", nil, parent)
box:SetPoint("TOPLEFT", parent, "TOPLEFT", leftMargin, yOff - 16)
box:SetPoint("TOPRIGHT", parent, "TOPRIGHT", -rightMargin, yOff - 16)
box:SetHeight(height)
-- Per CSS: panel bg #0a0a0a, border #1f1f1f
box:SetBackdrop({ bgFile = WHITE8x8, edgeFile = WHITE8x8, edgeSize = 1 })
box:SetBackdropColor(0.04, 0.04, 0.04, 1)
box:SetBackdropBorderColor(0.12, 0.12, 0.12, 1)
return box, titleFS
end
-- ============================================================================
-- Canonical button helpers (HARD RULE: every button must go through one
-- of these two helpers; see style.md "Buttons: the two
-- canonical helpers"). Defined here BEFORE BuildUI so BuildUI's tab
-- builders can capture them as upvalues. Other top-level builders below
-- (BuildClearListWindow, etc.) also capture from this same scope.
-- ============================================================================
-- MakeDialogButton: neutral footer button. Apply / Cancel / OK / Close.
-- Default 90x24, blue hover (C_ROW_HOVER), white text on hover. Use this
-- when the action has no semantic weight, or when it is one of a small
-- group of equivalent footer choices.
local function MakeDialogButton(parent, label, onClick)
local btn = CreateFrame("Button", nil, parent)
btn:SetSize(90, 24)
ApplyBackdrop(btn, C_ROW_ODD, C_BORDER)
local txt = MakeText(btn, 11, C_TEXT, "OUTLINE")
txt:SetPoint("CENTER")
txt:SetText(label)
btn._text = txt
btn:SetScript("OnEnter", function(b)
ApplyBackdrop(b, C_ROW_HOVER, C_BORDER)
txt:SetTextColor(1, 1, 1)
end)
btn:SetScript("OnLeave", function(b)
ApplyBackdrop(b, C_ROW_ODD, C_BORDER)
txt:SetTextColor(unpack(C_TEXT))
end)
btn:SetScript("OnClick", onClick)
return btn
end
-- MakeActionButton: semantic action button. Variable width, 26 tall by
-- default. On hover the backdrop fills with the semantic color at 0.3
-- alpha and the border switches to the full semantic color. Text becomes
-- pure white on hover. The Clear List window is the canonical reference.
--
-- HARD RULE: only THREE semantic colors. Pick by the action class:
-- C_GREEN -> additive / approve / go / positive
-- (Add, Copy, Import, Apply, Save, Confirm)
-- C_RED -> destructive / decline / remove
-- (Delete, Remove, Clear, Cancel)
-- C_BLUE -> change / update / reward / transform
-- (Open Panel, Edit, Refresh, Audit, Toggle filters)
--
-- Do NOT use C_ACCENT (legendary orange) for button hovers. That color
-- is reserved for window CHROME (title bars, frame titles, accent borders).
-- The hover color itself is a clarity cue for non-technical users: green
-- means "this adds something," red means "this removes something," blue
-- means "this changes or opens something."
local function MakeActionButton(parent, label, semanticColor, onClick, width, height)
local btn = CreateFrame("Button", nil, parent)
btn:SetSize(width or 290, height or 26)
ApplyBackdrop(btn, C_ROW_ODD, C_BORDER)
local txt = MakeText(btn, 11, C_TEXT, "OUTLINE")
txt:SetPoint("CENTER")
txt:SetText(label)
btn._text = txt
local color = semanticColor or C_ACCENT
btn:SetScript("OnEnter", function(b)
b:SetBackdropColor(color[1], color[2], color[3], 0.3)
b:SetBackdropBorderColor(color[1], color[2], color[3], 1)
txt:SetTextColor(1, 1, 1)
end)
btn:SetScript("OnLeave", function(b)
ApplyBackdrop(b, C_ROW_ODD, C_BORDER)
txt:SetTextColor(unpack(C_TEXT))
end)
if onClick then btn:SetScript("OnClick", onClick) end
return btn
end
-- AddToggleDescription: attaches a dim multi-line description below a toggle.
-- Positioned indented under the toggle's text label (not the box).
local function AddToggleDescription(toggle, description, maxWidth)
local parent = toggle:GetParent()
local desc = parent:CreateFontString(nil, "OVERLAY")
desc:SetFont(FONT, 10, "OUTLINE")
desc:SetTextColor(unpack(C_DIM))
-- Indent: 26 = 18 box + 8 gap → aligns with toggle label's left edge exactly
desc:SetPoint("TOPLEFT", toggle, "BOTTOMLEFT", 26, -1)
desc:SetWidth(maxWidth or 140)
desc:SetJustifyH("LEFT")
desc:SetWordWrap(true)
desc:SetText(description)
toggle._desc = desc
return desc
end
-- ============================================================================
-- Database Functions
-- ============================================================================
-- Partial fallback schema used by Options.lua's own EnsureProfileFields call
-- path. The canonical full DEFAULT_PROFILE lives in AutoDelete.lua. This copy
-- only needs the fields the UI itself reads or writes; AutoDelete.lua runs its
-- own EnsureProfileFields too, which fills in everything else (Auto-Invite
-- options, Hide Spam, summon options, etc.). Whichever file's GetDB executes
-- first does the migration and the other becomes a no-op for already-set
-- fields.
local DEFAULT_PROFILE = {
enabled = false,
listText = "",
sellListText = "",
whitelistText = "",
keepOneText = "",
keepStackText = "",
-- 3-state gear quality filters: "off" | "delete" | "sell".
-- Junk is checkbox-driven in the options UI: checked deletes gray
-- items, unchecked auto-sells gray items at vendors.
qualityActionJunk = "off",
qualityActionCommon = "off",
qualityActionGreens = "off",
qualityActionRares = "off",
scanInterval = 0.5,
autoGray = false,
autoDeleteCommon = false,
autoSellGreens = false,
boeArmorEnabled = false,
boeArmorIlvlMin = 1,
boeArmorIlvlMax = 199,
boeArmorRare = false,
boeArmorEpic = false,
bopEnabled = false,
bopIlvlMin = 1,
bopIlvlMax = 199,
bopRare = false,
bopEpic = false,
boeWeaponsEnabled = false,
boeWeaponsIlvlMin = 1,
boeWeaponsIlvlMax = 199,
boeWeaponsRare = false,
boeWeaponsEpic = false,
knownRecipeSellEnabled = false,
knownRecipeSellCommon = true,
knownRecipeSellUncommon = true,
knownRecipeSellRare = false,
knownRecipeSellEpic = false,
knownRecipeSellBoE = true,
knownRecipeSellBoP = true,
autoCloseMerchantAfterSell = true,
protectAffixFromSell = false, -- legacy migration source
affixIlvlMin = 0, -- legacy; no longer used
protectAffixTier1 = false,
protectAffixTier2 = false,
protectAffixTier3 = false,
protectAffixTier4 = false,
protectAffixTier5 = false,
protectAffixTier6 = false,
affixCollectionMode = false,
keepSingleMissingAffix = false,
missingAffixColor = "red",
missingAffixColorR = 1.00,
missingAffixColorG = 0.231,
missingAffixColorB = 0.255,
summonScavenger = false,
summonDisableInGroup = false,
}
local function GetCharKey()
local name = UnitName("player")
local realm = GetRealmName and GetRealmName() or nil
if not name then return nil end
if realm and realm ~= "" then return name .. "-" .. realm end
return name
end
local function EnsureProfileFields(p)
-- Invert old dontSellBoEWeapons field into sellBoEWeapons.
if p.dontSellBoEWeapons ~= nil then
p.sellBoEWeapons = not p.dontSellBoEWeapons
p.dontSellBoEWeapons = nil
end
-- Old profiles stored the weapon iLvl threshold as sellBoEWeaponMinIlvl
-- acting as a floor. The range model renamed it to sellBoEWeaponMaxIlvl
-- as the ceiling. Only migrate when the new field is absent so current
-- range-min values are preserved.
if p.sellBoEWeaponMinIlvl ~= nil and p.sellBoEWeaponMaxIlvl == nil then
p.sellBoEWeaponMaxIlvl = p.sellBoEWeaponMinIlvl
p.sellBoEWeaponMinIlvl = nil
end
-- v3.02 schema migration. Mirrors the logic in AutoDelete.lua so it runs
-- correctly regardless of which file's GetDB executes first.
local hasOldFields = (p.sellJunk ~= nil) or (p.sellGreen ~= nil)
or (p.sellBlue ~= nil) or (p.sellEpic ~= nil)
or (p.sellBoE ~= nil) or (p.sellBoEWeapons ~= nil)
or (p.sellIlvlEnabled ~= nil)
if hasOldFields and not p._v302Migrated then
-- Junk is no longer a separate sell option. Delete Junk checked
-- deletes; unchecked auto-sells at vendors.
p.autoDeleteCommon = false
p.autoSellGreens = (p.sellGreen == true)
local hadIlvlRange = (p.sellIlvlEnabled == true)
p.boeArmorEnabled = (p.sellBoE == true)
p.boeArmorRare = (p.sellBoE == true) and (p.sellBlue == true)
p.boeArmorEpic = (p.sellBoE == true) and (p.sellEpic == true)
if hadIlvlRange and p.sellIlvlMin then p.boeArmorIlvlMin = p.sellIlvlMin end
if hadIlvlRange and p.sellIlvlMax then p.boeArmorIlvlMax = p.sellIlvlMax end
p.bopEnabled = false
p.bopRare = false
p.bopEpic = false
p.boeWeaponsEnabled = (p.sellBoEWeapons == true)
p.boeWeaponsRare = (p.sellBoEWeapons == true) and (p.sellBlue == true)
p.boeWeaponsEpic = (p.sellBoEWeapons == true) and (p.sellEpic == true)
if p.sellBoEWeaponMinIlvl then p.boeWeaponsIlvlMin = p.sellBoEWeaponMinIlvl end