-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.lua
More file actions
executable file
·1372 lines (1198 loc) · 48.3 KB
/
settings.lua
File metadata and controls
executable file
·1372 lines (1198 loc) · 48.3 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
local _, ns = ...
---------------------------------------------------------------------------
-- Settings — Settings panel UI, notification sounds, quick replies,
-- font/opacity controls, export, and history management
--
-- Builds the scrollable settings panel with custom flat UI widgets:
-- - CreateSettingsSlider: track + thumb slider with live value display
-- - CreateSettingsCheckbox: flat toggle with blue check indicator
-- - CreateSettingsDropdown: scrollable popup with click-off dismiss
-- - CreateActionButton: flat button with hover highlight
--
-- All settings widgets support dynamic font resizing via the "Settings
-- Font Size" slider (tracked FontStrings are updated in-place without
-- rebuilding the panel). LibSharedMedia fonts/sounds are detected and
-- merged with built-in options when available.
---------------------------------------------------------------------------
local C = ns.C
-- LibSharedMedia integration (optional)
local LSM = LibStub and LibStub("LibSharedMedia-3.0", true)
local SOUND_PATH = "Interface\\AddOns\\iChat\\media\\sounds\\"
local BUILTIN_SOUNDS = {
{ name = "Glass", key = "glass", path = SOUND_PATH .. "glass.ogg" },
{ name = "Tritone", key = "tritone", path = SOUND_PATH .. "tritone.ogg" },
{ name = "Chime", key = "chime", path = SOUND_PATH .. "chime.ogg" },
}
local BUILTIN_SOUND_PATHS = {
glass = SOUND_PATH .. "glass.ogg",
tritone = SOUND_PATH .. "tritone.ogg",
chime = SOUND_PATH .. "chime.ogg",
}
local DEFAULT_FONTS = {
{ name = "Fritz Quadrata", path = "Fonts\\FRIZQT__.TTF" },
{ name = "Arial Narrow", path = "Fonts\\ARIALN.TTF" },
{ name = "Morpheus", path = "Fonts\\MORPHEUS.TTF" },
{ name = "Skurri", path = "Fonts\\SKURRI.TTF" },
{ name = "2002", path = "Fonts\\2002.TTF" },
{ name = "2002 Bold", path = "Fonts\\2002B.TTF" },
}
local function GetFontList()
if LSM then
local fonts = {}
for _, name in ipairs(LSM:List("font")) do
table.insert(fonts, { name = name, path = LSM:Fetch("font", name) })
end
if #fonts > 0 then return fonts end
end
return DEFAULT_FONTS
end
local function GetSoundList()
local sounds = {}
for _, s in ipairs(BUILTIN_SOUNDS) do
table.insert(sounds, s)
end
if LSM then
for _, name in ipairs(LSM:List("sound")) do
local path = LSM:Fetch("sound", name)
table.insert(sounds, { name = name, key = path, path = path })
end
end
table.insert(sounds, { name = "None", key = "none", path = nil })
return sounds
end
---------------------------------------------------------------------------
-- Helper: Flat Slider
---------------------------------------------------------------------------
local function GetSF()
return (ns.db and ns.db.settings and ns.db.settings.settingsFontSize) or 10
end
-- Tracking tables for smooth font resizing
local function TrackSF(fs)
if not ns._settingsFontStrings then ns._settingsFontStrings = {} end
table.insert(ns._settingsFontStrings, fs)
return fs
end
local function TrackSmallSF(fs)
if not ns._settingsSmallFontStrings then ns._settingsSmallFontStrings = {} end
table.insert(ns._settingsSmallFontStrings, fs)
return fs
end
-- EditBoxes also have SetFont but aren't FontStrings
local function TrackEditBoxSF(eb)
if not ns._settingsEditBoxes then ns._settingsEditBoxes = {} end
table.insert(ns._settingsEditBoxes, eb)
return eb
end
local function CreateSettingsSlider(parent, label, min, max, step, getValue, onChange, suffix)
suffix = suffix or ""
local sf = GetSF()
local container = CreateFrame("Frame", nil, parent)
container:SetHeight(38)
local labelText = TrackSF(container:CreateFontString(nil, "OVERLAY"))
labelText:SetFont("Fonts\\FRIZQT__.TTF", sf, "")
labelText:SetTextColor(0.65, 0.65, 0.65)
labelText:SetPoint("TOPLEFT")
labelText:SetText(label)
local valueText = TrackSF(container:CreateFontString(nil, "OVERLAY"))
valueText:SetFont("Fonts\\FRIZQT__.TTF", sf, "")
valueText:SetTextColor(1, 1, 1)
valueText:SetPoint("TOPRIGHT")
local slider = CreateFrame("Slider", nil, container)
slider:SetPoint("TOPLEFT", 0, -16)
slider:SetPoint("RIGHT", 0, 0)
slider:SetHeight(14)
slider:SetMinMaxValues(min, max)
slider:SetValueStep(step)
if slider.SetObeyStepOnDrag then
slider:SetObeyStepOnDrag(true)
end
slider:SetOrientation("HORIZONTAL")
slider:EnableMouse(true)
-- Track
local track = slider:CreateTexture(nil, "BACKGROUND")
track:SetHeight(2)
track:SetPoint("LEFT", 4, 0)
track:SetPoint("RIGHT", -4, 0)
track:SetColorTexture(0.25, 0.25, 0.25, 1)
-- Thumb (blue circle from pill texture)
slider:SetThumbTexture("Interface\\AddOns\\iChat\\media\\textures\\pill")
local thumb = slider:GetThumbTexture()
thumb:SetSize(14, 14)
thumb:SetVertexColor(0.0, 0.48, 1.0, 1)
local val = getValue()
slider:SetValue(val)
valueText:SetText(tostring(val) .. suffix)
slider:SetScript("OnValueChanged", function(self, v)
v = math.floor(v / step + 0.5) * step
valueText:SetText(tostring(v) .. suffix)
onChange(v)
end)
container.slider = slider
container.valueText = valueText
container.Refresh = function()
local v = getValue()
slider:SetValue(v)
valueText:SetText(tostring(v) .. suffix)
end
return container
end
---------------------------------------------------------------------------
-- Helper: Flat Checkbox
---------------------------------------------------------------------------
local function CreateSettingsCheckbox(parent, label, getValue, onChange)
local sf = GetSF()
local btn = CreateFrame("Button", nil, parent)
btn:SetHeight(22)
local box = btn:CreateTexture(nil, "ARTWORK")
box:SetSize(14, 14)
box:SetPoint("LEFT")
box:SetColorTexture(0.2, 0.2, 0.2, 1)
local check = btn:CreateTexture(nil, "OVERLAY")
check:SetSize(10, 10)
check:SetPoint("CENTER", box)
check:SetColorTexture(0.0, 0.48, 1.0, 1)
local text = TrackSF(btn:CreateFontString(nil, "OVERLAY"))
text:SetFont("Fonts\\FRIZQT__.TTF", sf, "")
text:SetTextColor(0.8, 0.8, 0.8)
text:SetPoint("LEFT", box, "RIGHT", 6, 0)
text:SetText(label)
local checked = getValue()
if checked then check:Show() else check:Hide() end
btn:SetScript("OnClick", function()
checked = not checked
if checked then check:Show() else check:Hide() end
onChange(checked)
end)
btn.Refresh = function()
checked = getValue()
if checked then check:Show() else check:Hide() end
end
return btn
end
---------------------------------------------------------------------------
-- Helper: Action Button
---------------------------------------------------------------------------
local function CreateActionButton(parent, label, color, onClick)
local sf = GetSF()
local btn = CreateFrame("Button", nil, parent)
btn:SetHeight(28)
local bg = btn:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(0.12, 0.12, 0.12, 1)
local text = TrackSF(btn:CreateFontString(nil, "OVERLAY"))
text:SetFont("Fonts\\FRIZQT__.TTF", sf, "")
text:SetPoint("CENTER")
text:SetText(label)
text:SetTextColor(unpack(color))
btn.label = text
btn:SetScript("OnClick", onClick)
btn:SetScript("OnEnter", function() bg:SetColorTexture(0.18, 0.18, 0.18, 1) end)
btn:SetScript("OnLeave", function() bg:SetColorTexture(0.12, 0.12, 0.12, 1) end)
return btn
end
---------------------------------------------------------------------------
-- Helper: Dropdown Selector
---------------------------------------------------------------------------
local function CreateSettingsDropdown(parent, label, getItems, getValue, onChange, opts)
opts = opts or {}
local sf = GetSF()
local container = CreateFrame("Frame", nil, parent)
container:SetHeight(46)
local labelFS = TrackSF(container:CreateFontString(nil, "OVERLAY"))
labelFS:SetFont("Fonts\\FRIZQT__.TTF", sf, "")
labelFS:SetTextColor(0.65, 0.65, 0.65)
labelFS:SetPoint("TOPLEFT")
labelFS:SetText(label)
-- Current selection button
local btn = CreateFrame("Button", nil, container)
btn:SetHeight(24)
btn:SetPoint("TOPLEFT", 0, -16)
btn:SetPoint("RIGHT")
local btnBg = btn:CreateTexture(nil, "BACKGROUND")
btnBg:SetAllPoints()
btnBg:SetColorTexture(0.12, 0.12, 0.12, 1)
local btnText = TrackSF(btn:CreateFontString(nil, "OVERLAY"))
btnText:SetFont("Fonts\\FRIZQT__.TTF", sf, "")
btnText:SetTextColor(1, 1, 1)
btnText:SetPoint("LEFT", 8, 0)
btnText:SetPoint("RIGHT", -20, 0)
btnText:SetJustifyH("LEFT")
btnText:SetWordWrap(false)
local arrow = TrackSmallSF(btn:CreateFontString(nil, "OVERLAY"))
arrow:SetFont("Fonts\\FRIZQT__.TTF", math.max(sf - 2, 7), "")
arrow:SetTextColor(0.5, 0.5, 0.5)
arrow:SetPoint("RIGHT", -6, 0)
arrow:SetText("v")
-- Dropdown popup
local MAX_VIS = 200
local ENTRY_H = 22
local dropFrame = CreateFrame("Frame", nil, ns.mainWindow or UIParent, "BackdropTemplate")
dropFrame:SetPoint("TOPLEFT", btn, "BOTTOMLEFT", 0, -2)
dropFrame:SetPoint("RIGHT", btn, "RIGHT")
dropFrame:SetFrameStrata("TOOLTIP")
dropFrame:SetFrameLevel(20)
dropFrame:SetBackdrop({
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
edgeFile = "Interface\\Buttons\\WHITE8x8",
edgeSize = 1,
})
dropFrame:SetBackdropColor(0.08, 0.08, 0.08, 0.98)
dropFrame:SetBackdropBorderColor(0.25, 0.25, 0.25, 1)
dropFrame:Hide()
local dropScroll = CreateFrame("ScrollFrame", nil, dropFrame)
dropScroll:SetPoint("TOPLEFT", 2, -2)
dropScroll:SetPoint("BOTTOMRIGHT", -2, 2)
dropScroll:EnableMouseWheel(true)
local dropChild = CreateFrame("Frame", nil, dropScroll)
dropChild:SetWidth(1)
dropChild:SetHeight(1)
dropScroll:SetScrollChild(dropChild)
dropScroll:SetScript("OnMouseWheel", function(self, delta)
local cur = self:GetVerticalScroll()
local maxS = math.max(0, dropChild:GetHeight() - self:GetHeight())
self:SetVerticalScroll(math.max(0, math.min(maxS, cur - delta * ENTRY_H * 3)))
end)
-- Click-off to close
local clickOff = CreateFrame("Button", nil, UIParent)
clickOff:SetAllPoints(UIParent)
clickOff:SetFrameStrata("TOOLTIP")
clickOff:SetFrameLevel(0)
clickOff:RegisterForClicks("AnyUp")
clickOff:SetScript("OnClick", function() dropFrame:Hide() end)
clickOff:Hide()
dropFrame:SetScript("OnShow", function()
clickOff:Show()
if ns.CancelFade then ns.CancelFade() end
end)
dropFrame:SetScript("OnHide", function() clickOff:Hide() end)
-- Track for cleanup when settings closes
if not ns._settingsDropdowns then ns._settingsDropdowns = {} end
table.insert(ns._settingsDropdowns, dropFrame)
local entryPool = {}
local function Populate()
for _, ef in ipairs(entryPool) do ef:Hide() end
local items = getItems()
local curVal = getValue()
dropChild:SetWidth(dropScroll:GetWidth())
local yOff = 0
for i, item in ipairs(items) do
local ef = entryPool[i]
if not ef then
ef = CreateFrame("Button", nil, dropChild)
ef:SetHeight(ENTRY_H)
local ebg = ef:CreateTexture(nil, "BACKGROUND")
ebg:SetAllPoints()
ebg:SetColorTexture(0, 0, 0, 0)
ef.bg = ebg
local etxt = ef:CreateFontString(nil, "OVERLAY")
etxt:SetPoint("LEFT", 8, 0)
etxt:SetPoint("RIGHT", -8, 0)
etxt:SetJustifyH("LEFT")
etxt:SetWordWrap(false)
ef.text = etxt
entryPool[i] = ef
end
ef:ClearAllPoints()
ef:SetPoint("TOPLEFT", 0, -yOff)
ef:SetPoint("RIGHT", dropChild, "RIGHT")
if opts.previewFont and item.path then
pcall(function() ef.text:SetFont(item.path, sf, "") end)
else
ef.text:SetFont("Fonts\\FRIZQT__.TTF", sf, "")
end
ef.text:SetText(item.name)
if item.value == curVal then
ef.bg:SetColorTexture(0.0, 0.48, 1.0, 0.2)
ef.text:SetTextColor(1, 1, 1)
else
ef.bg:SetColorTexture(0, 0, 0, 0)
ef.text:SetTextColor(0.7, 0.7, 0.7)
end
ef:SetScript("OnClick", function()
onChange(item.value, item)
dropFrame:Hide()
btnText:SetText(item.name)
if opts.previewFont and item.path then
pcall(function() btnText:SetFont(item.path, sf, "") end)
end
end)
ef:SetScript("OnEnter", function()
if item.value ~= curVal then
ef.bg:SetColorTexture(0.14, 0.14, 0.14, 1)
end
end)
ef:SetScript("OnLeave", function()
if item.value ~= curVal then
ef.bg:SetColorTexture(0, 0, 0, 0)
end
end)
ef:Show()
yOff = yOff + ENTRY_H
end
for j = #items + 1, #entryPool do
entryPool[j]:Hide()
end
dropChild:SetHeight(math.max(yOff, 1))
dropFrame:SetHeight(math.min(yOff + 4, MAX_VIS))
dropScroll:SetVerticalScroll(0)
end
btn:SetScript("OnClick", function()
if dropFrame:IsShown() then
dropFrame:Hide()
else
Populate()
dropFrame:Show()
end
end)
btn:SetScript("OnEnter", function() btnBg:SetColorTexture(0.16, 0.16, 0.16, 1) end)
btn:SetScript("OnLeave", function() btnBg:SetColorTexture(0.12, 0.12, 0.12, 1) end)
container.Refresh = function()
local curVal = getValue()
local items = getItems()
for _, item in ipairs(items) do
if item.value == curVal then
btnText:SetText(item.name)
if opts.previewFont and item.path then
pcall(function() btnText:SetFont(item.path, sf, "") end)
end
return
end
end
btnText:SetText("Unknown")
end
container.Refresh()
return container
end
---------------------------------------------------------------------------
-- Settings Panel
---------------------------------------------------------------------------
function ns.CreateSettingsPanel()
local SF = ns.db.settings.settingsFontSize or 10
-- Reset tracking tables
ns._settingsFontStrings = {}
ns._settingsSmallFontStrings = {}
ns._settingsEditBoxes = {}
local panel = CreateFrame("Frame", nil, ns.mainWindow)
panel:SetPoint("TOPLEFT", ns.rightPanel, "TOPLEFT")
panel:SetPoint("BOTTOMRIGHT", ns.rightPanel, "BOTTOMRIGHT")
panel:SetFrameLevel(ns.rightPanel:GetFrameLevel() + 5)
panel:Hide()
local bg = panel:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(0.05, 0.05, 0.05, 1)
-- Header
local header = CreateFrame("Frame", nil, panel)
header:SetHeight(36)
header:SetPoint("TOPLEFT")
header:SetPoint("TOPRIGHT")
local headerBorder = header:CreateTexture(nil, "OVERLAY")
headerBorder:SetHeight(1)
headerBorder:SetPoint("BOTTOMLEFT")
headerBorder:SetPoint("BOTTOMRIGHT")
headerBorder:SetColorTexture(0.15, 0.15, 0.15, 1)
local backBtn = CreateFrame("Button", nil, header)
backBtn:SetSize(40, 36)
backBtn:SetPoint("LEFT")
local backText = backBtn:CreateFontString(nil, "OVERLAY")
backText:SetFont("Fonts\\FRIZQT__.TTF", 11, "")
backText:SetPoint("CENTER")
backText:SetText("<")
backText:SetTextColor(0.0, 0.48, 1.0, 1)
backBtn:SetScript("OnClick", function() ns.ToggleSettings() end)
backBtn:SetScript("OnEnter", function() backText:SetTextColor(1, 1, 1) end)
backBtn:SetScript("OnLeave", function() backText:SetTextColor(0.0, 0.48, 1.0, 1) end)
local title = header:CreateFontString(nil, "OVERLAY")
title:SetFont("Fonts\\FRIZQT__.TTF", 12, "")
title:SetTextColor(1, 1, 1)
title:SetPoint("CENTER")
title:SetText("Settings")
-- Scroll area
local scroll = CreateFrame("ScrollFrame", nil, panel)
scroll:SetPoint("TOPLEFT", header, "BOTTOMLEFT", 12, -8)
scroll:SetPoint("BOTTOMRIGHT", -12, 8)
scroll:EnableMouseWheel(true)
local child = CreateFrame("Frame", nil, scroll)
child:SetWidth(1)
child:SetHeight(600)
scroll:SetScrollChild(child)
scroll:SetScript("OnSizeChanged", function(self, w)
child:SetWidth(w)
end)
scroll:SetScript("OnMouseWheel", function(self, delta)
local current = self:GetVerticalScroll()
local maxScroll = math.max(0, child:GetHeight() - self:GetHeight())
local newVal = math.max(0, math.min(maxScroll, current - (delta * 30)))
self:SetVerticalScroll(newVal)
end)
local yPos = 0
-- Track all settings UI font strings for dynamic resizing
local settingsFontStrings = {}
local function TrackFS(fs)
table.insert(settingsFontStrings, fs)
return fs
end
-----------------------------------------------------------------------
-- Settings Panel Font Size
-----------------------------------------------------------------------
local settingsFontSlider = CreateSettingsSlider(child, "Settings Font Size", 8, 14, 1,
function() return ns.db.settings.settingsFontSize or 10 end,
function(v)
ns.db.settings.settingsFontSize = v
ns.ApplySettingsFont()
end
)
settingsFontSlider:SetPoint("TOPLEFT", 0, -yPos)
settingsFontSlider:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 48
-----------------------------------------------------------------------
-- Font Selection (dropdown)
-----------------------------------------------------------------------
local fontDropdown = CreateSettingsDropdown(child, "Font",
function()
local items = {}
for _, f in ipairs(GetFontList()) do
table.insert(items, { name = f.name, value = f.path, path = f.path })
end
return items
end,
function() return ns.db.settings.font end,
function(v) ns.db.settings.font = v; ns.ApplyFont() end,
{ previewFont = true }
)
fontDropdown:SetPoint("TOPLEFT", 0, -yPos)
fontDropdown:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 52
-----------------------------------------------------------------------
-- Font Size Slider
-----------------------------------------------------------------------
local fontSizeSlider = CreateSettingsSlider(child, "Font Size", 8, 16, 1,
function() return ns.db.settings.fontSize end,
function(v) ns.db.settings.fontSize = v; ns.ApplyFont() end
)
fontSizeSlider:SetPoint("TOPLEFT", 0, -yPos)
fontSizeSlider:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 44
-----------------------------------------------------------------------
-- Background Opacity Slider
-----------------------------------------------------------------------
local opacitySlider = CreateSettingsSlider(child, "Background Opacity", 30, 100, 5,
function() return math.floor((ns.db.settings.bgAlpha or 0.95) * 100 + 0.5) end,
function(v)
ns.db.settings.bgAlpha = v / 100
ns.ApplyTransparency()
end,
"%"
)
opacitySlider:SetPoint("TOPLEFT", 0, -yPos)
opacitySlider:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 44
-----------------------------------------------------------------------
-- History Slider
-----------------------------------------------------------------------
local historySlider = CreateSettingsSlider(child, "Message History", 50, 500, 10,
function() return ns.db.settings.maxHistory end,
function(v) ns.db.settings.maxHistory = v end
)
historySlider:SetPoint("TOPLEFT", 0, -yPos)
historySlider:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 48
-----------------------------------------------------------------------
-- Toggles
-----------------------------------------------------------------------
local openWhisperCB = CreateSettingsCheckbox(child, "Open on incoming whisper",
function() return ns.db.settings.openOnWhisper end,
function(v) ns.db.settings.openOnWhisper = v end
)
openWhisperCB:SetPoint("TOPLEFT", 0, -yPos)
openWhisperCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 28
local suppressCB = CreateSettingsCheckbox(child, "Suppress default chat whispers",
function() return ns.db.settings.suppressDefault end,
function(v)
ns.db.settings.suppressDefault = v
if v then ns.RegisterChatFilters() else ns.UnregisterChatFilters() end
end
)
suppressCB:SetPoint("TOPLEFT", 0, -yPos)
suppressCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 36
-----------------------------------------------------------------------
-- Notification Sound (dropdown)
-----------------------------------------------------------------------
local soundDropdown = CreateSettingsDropdown(child, "Notification Sound",
function()
local items = {}
for _, s in ipairs(GetSoundList()) do
table.insert(items, { name = s.name, value = s.key })
end
return items
end,
function() return ns.db.settings.notifySound or "glass" end,
function(v)
ns.db.settings.notifySound = v
if v ~= "none" then
local path = BUILTIN_SOUND_PATHS[v] or v
PlaySoundFile(path, "Master")
end
end
)
soundDropdown:SetPoint("TOPLEFT", 0, -yPos)
soundDropdown:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 52
-----------------------------------------------------------------------
-- Display Section
-----------------------------------------------------------------------
local displayDiv = child:CreateTexture(nil, "OVERLAY")
displayDiv:SetHeight(1)
displayDiv:SetPoint("TOPLEFT", 0, -yPos)
displayDiv:SetPoint("RIGHT", child, "RIGHT")
displayDiv:SetColorTexture(0.15, 0.15, 0.15, 1)
yPos = yPos + 12
local displayLabel = TrackSF(child:CreateFontString(nil, "OVERLAY"))
displayLabel:SetFont("Fonts\\FRIZQT__.TTF", SF, "")
displayLabel:SetTextColor(0.65, 0.65, 0.65)
displayLabel:SetPoint("TOPLEFT", 0, -yPos)
displayLabel:SetText("Display")
yPos = yPos + 18
local dateSepCB = CreateSettingsCheckbox(child, "Show date separators",
function() return ns.db.settings.showDateSeparators end,
function(v)
ns.db.settings.showDateSeparators = v
if ns.activeConversation then ns.RebuildBubbles(ns.activeConversation) end
end
)
dateSepCB:SetPoint("TOPLEFT", 0, -yPos)
dateSepCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local hoverTimeCB = CreateSettingsCheckbox(child, "Show timestamps on hover",
function() return ns.db.settings.showTimestampOnHover end,
function(v)
ns.db.settings.showTimestampOnHover = v
if ns.activeConversation then ns.RebuildBubbles(ns.activeConversation) end
end
)
hoverTimeCB:SetPoint("TOPLEFT", 0, -yPos)
hoverTimeCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local itemLinksCB = CreateSettingsCheckbox(child, "Enable item links",
function() return ns.db.settings.enableItemLinks end,
function(v) ns.db.settings.enableItemLinks = v end
)
itemLinksCB:SetPoint("TOPLEFT", 0, -yPos)
itemLinksCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local classColorCB = CreateSettingsCheckbox(child, "Class-colored names",
function() return ns.db.settings.classColoredNames end,
function(v)
ns.db.settings.classColoredNames = v
ns.RefreshConversationList()
end
)
classColorCB:SetPoint("TOPLEFT", 0, -yPos)
classColorCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local onlineStatusCB = CreateSettingsCheckbox(child, "Show online status",
function() return ns.db.settings.showOnlineStatus end,
function(v)
ns.db.settings.showOnlineStatus = v
ns.RefreshConversationList()
end
)
onlineStatusCB:SetPoint("TOPLEFT", 0, -yPos)
onlineStatusCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
-- NOTE: Key is "showPortrait" for backward compatibility (formerly 3D portraits),
-- but now controls class-colored names in header.
local portraitCB = CreateSettingsCheckbox(child, "Show class-colored names in conversation header",
function() return ns.db.settings.showPortrait end,
function(v)
ns.db.settings.showPortrait = v
if ns.UpdatePortrait then ns.UpdatePortrait() end
end
)
portraitCB:SetPoint("TOPLEFT", 0, -yPos)
portraitCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 30
-----------------------------------------------------------------------
-- Behavior Section
-----------------------------------------------------------------------
local behaviorDiv = child:CreateTexture(nil, "OVERLAY")
behaviorDiv:SetHeight(1)
behaviorDiv:SetPoint("TOPLEFT", 0, -yPos)
behaviorDiv:SetPoint("RIGHT", child, "RIGHT")
behaviorDiv:SetColorTexture(0.15, 0.15, 0.15, 1)
yPos = yPos + 12
local behaviorLabel = TrackSF(child:CreateFontString(nil, "OVERLAY"))
behaviorLabel:SetFont("Fonts\\FRIZQT__.TTF", SF, "")
behaviorLabel:SetTextColor(0.65, 0.65, 0.65)
behaviorLabel:SetPoint("TOPLEFT", 0, -yPos)
behaviorLabel:SetText("Behavior")
yPos = yPos + 18
local sharedAcctCB = CreateSettingsCheckbox(child, "Share conversations across characters",
function() return ns.IsSharedAccount() end,
function(v) ns.SetSharedAccount(v) end
)
sharedAcctCB:SetPoint("TOPLEFT", 0, -yPos)
sharedAcctCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local kbShortcutsCB = CreateSettingsCheckbox(child, "Enable keyboard shortcuts",
function() return ns.db.settings.enableKeyboardShortcuts end,
function(v) ns.db.settings.enableKeyboardShortcuts = v end
)
kbShortcutsCB:SetPoint("TOPLEFT", 0, -yPos)
kbShortcutsCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local minimapBtnCB = CreateSettingsCheckbox(child, "Show minimap button",
function() return ns.db.settings.showMinimapButton end,
function(v)
ns.db.settings.showMinimapButton = v
if ns.SetMinimapButtonVisible then
ns.SetMinimapButtonVisible(v)
end
end
)
minimapBtnCB:SetPoint("TOPLEFT", 0, -yPos)
minimapBtnCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local typingCB = CreateSettingsCheckbox(child, "Show typing indicator",
function() return ns.db.settings.showTypingIndicator end,
function(v) ns.db.settings.showTypingIndicator = v end
)
typingCB:SetPoint("TOPLEFT", 0, -yPos)
typingCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local onlineNotifyCB = CreateSettingsCheckbox(child, "Online/offline notifications",
function() return ns.db.settings.showOnlineNotifications end,
function(v) ns.db.settings.showOnlineNotifications = v end
)
onlineNotifyCB:SetPoint("TOPLEFT", 0, -yPos)
onlineNotifyCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local elvuiCB = CreateSettingsCheckbox(child, "ElvUI theme integration",
function() return ns.db.settings.elvuiSkin end,
function(v)
ns.db.settings.elvuiSkin = v
if v and ns.ApplyElvUISkin then
ns.ApplyElvUISkin()
end
end
)
elvuiCB:SetPoint("TOPLEFT", 0, -yPos)
elvuiCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local hideCombatCB = CreateSettingsCheckbox(child, "Hide in combat",
function() return ns.db.settings.hideInCombat end,
function(v) ns.db.settings.hideInCombat = v end
)
hideCombatCB:SetPoint("TOPLEFT", 0, -yPos)
hideCombatCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local autoFadeCB = CreateSettingsCheckbox(child, "Auto-fade when mouse leaves",
function() return ns.db.settings.enableAutoFade end,
function(v)
ns.db.settings.enableAutoFade = v
if not v then
ns.CancelFade()
end
end
)
autoFadeCB:SetPoint("TOPLEFT", 0, -yPos)
autoFadeCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 30
local fadeMoveCB = CreateSettingsCheckbox(child, "Fade while moving",
function() return ns.db.settings.fadeWhileMoving end,
function(v) ns.db.settings.fadeWhileMoving = v end
)
fadeMoveCB:SetPoint("TOPLEFT", 0, -yPos)
fadeMoveCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
local buttonSizeSlider = CreateSettingsSlider(child, "Button Size", 24, 64, 2,
function() return ns.db.settings.buttonSize or 40 end,
function(v)
ns.db.settings.buttonSize = v
if ns.ResizeButton then ns.ResizeButton(v) end
end,
"px"
)
buttonSizeSlider:SetPoint("TOPLEFT", 0, -yPos)
buttonSizeSlider:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 44
local scaleSlider = CreateSettingsSlider(child, "Window Scale", 0.5, 2.0, 0.05,
function() return ns.db.settings.scale or 1.0 end,
function(v)
ns.db.settings.scale = v
if ns.mainWindow then
ns.mainWindow:SetScale(v)
end
end,
"x"
)
scaleSlider:SetPoint("TOPLEFT", 0, -yPos)
scaleSlider:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 44
-----------------------------------------------------------------------
-- Auto-Reply Section
-----------------------------------------------------------------------
local autoReplyDiv = child:CreateTexture(nil, "OVERLAY")
autoReplyDiv:SetHeight(1)
autoReplyDiv:SetPoint("TOPLEFT", 0, -yPos)
autoReplyDiv:SetPoint("RIGHT", child, "RIGHT")
autoReplyDiv:SetColorTexture(0.15, 0.15, 0.15, 1)
yPos = yPos + 12
local autoReplyLabel = TrackSF(child:CreateFontString(nil, "OVERLAY"))
autoReplyLabel:SetFont("Fonts\\FRIZQT__.TTF", SF, "")
autoReplyLabel:SetTextColor(0.65, 0.65, 0.65)
autoReplyLabel:SetPoint("TOPLEFT", 0, -yPos)
autoReplyLabel:SetText("Auto-Reply")
yPos = yPos + 18
local autoReplyCB = CreateSettingsCheckbox(child, "Enable auto-reply",
function() return ns.db.settings.autoReplyEnabled end,
function(v)
ns.db.settings.autoReplyEnabled = v
if v then
ns.autoRepliedTo = {}
end
end
)
autoReplyCB:SetPoint("TOPLEFT", 0, -yPos)
autoReplyCB:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 26
-- Auto-reply message EditBox
local arMsgLabel = TrackSmallSF(child:CreateFontString(nil, "OVERLAY"))
arMsgLabel:SetFont("Fonts\\FRIZQT__.TTF", math.max(SF-1, 7), "")
arMsgLabel:SetTextColor(0.5, 0.5, 0.5)
arMsgLabel:SetPoint("TOPLEFT", 0, -yPos)
arMsgLabel:SetText("Message:")
yPos = yPos + 14
local arMsgRow = CreateFrame("Frame", nil, child)
arMsgRow:SetHeight(24)
arMsgRow:SetPoint("TOPLEFT", 0, -yPos)
arMsgRow:SetPoint("RIGHT", child, "RIGHT")
local arMsgBox = CreateFrame("EditBox", nil, arMsgRow)
arMsgBox:SetPoint("LEFT", 0, 0)
arMsgBox:SetPoint("RIGHT")
arMsgBox:SetHeight(20)
TrackEditBoxSF(arMsgBox)
arMsgBox:SetFont("Fonts\\FRIZQT__.TTF", SF, "")
arMsgBox:SetTextColor(0.9, 0.9, 0.9)
arMsgBox:SetAutoFocus(false)
arMsgBox:SetMaxLetters(200)
local arMsgBg = arMsgBox:CreateTexture(nil, "BACKGROUND")
arMsgBg:SetAllPoints()
arMsgBg:SetColorTexture(0.1, 0.1, 0.1, 1)
arMsgBox:SetText(ns.db.settings.autoReplyMessage or "")
arMsgBox:SetScript("OnEnterPressed", function(self) self:ClearFocus() end)
arMsgBox:SetScript("OnEscapePressed", function(self) self:ClearFocus() end)
arMsgBox:SetScript("OnEditFocusLost", function(self)
ns.db.settings.autoReplyMessage = self:GetText()
end)
yPos = yPos + 30
-----------------------------------------------------------------------
-- Quick Replies Section
-----------------------------------------------------------------------
local qrDiv = child:CreateTexture(nil, "OVERLAY")
qrDiv:SetHeight(1)
qrDiv:SetPoint("TOPLEFT", 0, -yPos)
qrDiv:SetPoint("RIGHT", child, "RIGHT")
qrDiv:SetColorTexture(0.15, 0.15, 0.15, 1)
yPos = yPos + 12
local qrLabel = TrackSF(child:CreateFontString(nil, "OVERLAY"))
qrLabel:SetFont("Fonts\\FRIZQT__.TTF", SF, "")
qrLabel:SetTextColor(0.65, 0.65, 0.65)
qrLabel:SetPoint("TOPLEFT", 0, -yPos)
qrLabel:SetText("Quick Replies")
yPos = yPos + 18
local qrBoxes = {}
for i = 1, 5 do
local row = CreateFrame("Frame", nil, child)
row:SetHeight(24)
row:SetPoint("TOPLEFT", 0, -yPos)
row:SetPoint("RIGHT", child, "RIGHT")
local num = TrackSmallSF(row:CreateFontString(nil, "OVERLAY"))
num:SetFont("Fonts\\FRIZQT__.TTF", math.max(SF-1, 7), "")
num:SetTextColor(0.5, 0.5, 0.5)
num:SetPoint("LEFT", 0, 0)
num:SetText(i .. ".")
local box = CreateFrame("EditBox", nil, row)
box:SetPoint("LEFT", num, "RIGHT", 4, 0)
box:SetPoint("RIGHT")
box:SetHeight(20)
TrackEditBoxSF(box)
box:SetFont("Fonts\\FRIZQT__.TTF", SF, "")
box:SetTextColor(0.9, 0.9, 0.9)
box:SetAutoFocus(false)
box:SetMaxLetters(100)
local boxBg = box:CreateTexture(nil, "BACKGROUND")
boxBg:SetAllPoints()
boxBg:SetColorTexture(0.1, 0.1, 0.1, 1)
box:SetText(ns.db.settings.quickReplies and ns.db.settings.quickReplies[i] or "")
box:SetScript("OnEnterPressed", function(self)
self:ClearFocus()
end)
box:SetScript("OnEscapePressed", function(self)
self:ClearFocus()
end)
box:SetScript("OnEditFocusLost", function(self)
if not ns.db.settings.quickReplies then
ns.db.settings.quickReplies = {}
end
ns.db.settings.quickReplies[i] = self:GetText()
ns.RefreshQuickReplies()
end)
qrBoxes[i] = box
yPos = yPos + 26
end
yPos = yPos + 8
-----------------------------------------------------------------------
-- Divider
-----------------------------------------------------------------------
local div = child:CreateTexture(nil, "OVERLAY")
div:SetHeight(1)
div:SetPoint("TOPLEFT", 0, -yPos)
div:SetPoint("RIGHT", child, "RIGHT")
div:SetColorTexture(0.15, 0.15, 0.15, 1)
yPos = yPos + 12
-----------------------------------------------------------------------
-- Action Buttons
-----------------------------------------------------------------------
local exportBtn = CreateActionButton(child, "Export Conversation", {0.0, 0.48, 1.0, 1}, function()
ns.ExportConversation()
end)
exportBtn:SetPoint("TOPLEFT", 0, -yPos)
exportBtn:SetPoint("RIGHT", child, "RIGHT")
yPos = yPos + 34
local clearBtn = CreateActionButton(child, "Clear Current History", {0.8, 0.25, 0.2, 1}, function()
if not ns.activeConversation then return end
local convo = ns.db.conversations[ns.activeConversation]
if not convo then return end
wipe(convo.messages)
convo.unread = 0
ns.RebuildBubbles(ns.activeConversation)
ns.RefreshConversationList()
DEFAULT_CHAT_FRAME:AddMessage("|cff007AFFiChat:|r Cleared history for " .. ns.activeConversation)
end)
clearBtn:SetPoint("TOPLEFT", 0, -yPos)