-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathConfig.lua
More file actions
3164 lines (2930 loc) · 107 KB
/
Config.lua
File metadata and controls
3164 lines (2930 loc) · 107 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 addonName, DF = ...
-- Expose as global for other files and external access
DandersFrames = DF
-- ============================================================
-- SHARED MEDIA SUPPORT
-- ============================================================
-- Helper function to get LibSharedMedia (fetched fresh each time to handle late-loading)
-- Cache the SharedMedia reference like MPlusTimer does
local LSM_Cached = nil
local function GetLSM()
if not LSM_Cached then
LSM_Cached = LibStub and LibStub("LibSharedMedia-3.0", true)
end
return LSM_Cached
end
-- Register our custom fonts and textures with SharedMedia
local function RegisterCustomMedia()
local LSM = GetLSM()
if not LSM then return end
-- Register custom fonts (langmask covers all locales so fonts work on all clients)
local ALL_LOCALES = LSM.LOCALE_BIT_western + LSM.LOCALE_BIT_koKR + LSM.LOCALE_BIT_ruRU + LSM.LOCALE_BIT_zhCN + LSM.LOCALE_BIT_zhTW
LSM:Register(LSM.MediaType.FONT, "DF Expressway", "Interface\\AddOns\\DandersFrames\\Fonts\\Expressway.ttf", ALL_LOCALES)
LSM:Register(LSM.MediaType.FONT, "DF Roboto SemiBold", "Interface\\AddOns\\DandersFrames\\Fonts\\Roboto-SemiBold.ttf", ALL_LOCALES)
LSM:Register(LSM.MediaType.FONT, "DF Roboto Bold", "Interface\\AddOns\\DandersFrames\\Fonts\\Roboto-Bold.ttf", ALL_LOCALES)
-- Register custom statusbar textures
LSM:Register(LSM.MediaType.STATUSBAR, "DF Flat", "Interface\\Buttons\\WHITE8x8")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Gradient H", "Interface\\AddOns\\DandersFrames\\Media\\DF_Gradient_H")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Gradient V", "Interface\\AddOns\\DandersFrames\\Media\\DF_Gradient_V")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Gradient H Rev", "Interface\\AddOns\\DandersFrames\\Media\\DF_Gradient_H_Rev")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Gradient V Rev", "Interface\\AddOns\\DandersFrames\\Media\\DF_Gradient_V_Rev")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Stripes", "Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Stripes Soft", "Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Soft")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Stripes Soft Wide", "Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Soft_Wide")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Stripes Sparse", "Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Sparse")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Stripes Medium", "Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Medium")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Stripes Dense", "Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Dense")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Stripes Very Dense", "Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Very_Dense")
-- Health bar textures
LSM:Register(LSM.MediaType.STATUSBAR, "DF Smooth", "Interface\\AddOns\\DandersFrames\\Media\\DF_Smooth")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Glossy", "Interface\\AddOns\\DandersFrames\\Media\\DF_Glossy")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Matte", "Interface\\AddOns\\DandersFrames\\Media\\DF_Matte")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Glass", "Interface\\AddOns\\DandersFrames\\Media\\DF_Glass")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Soft", "Interface\\AddOns\\DandersFrames\\Media\\DF_Soft")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Beveled", "Interface\\AddOns\\DandersFrames\\Media\\DF_Beveled")
LSM:Register(LSM.MediaType.STATUSBAR, "DF Minimalist", "Interface\\AddOns\\DandersFrames\\Media\\DF_Minimalist")
-- Register callback to clear font cache when new fonts are added
LSM:RegisterCallback("LibSharedMedia_Registered", function(_, mediaType)
if mediaType == LSM.MediaType.FONT then
if DF.ClearFontCache then
DF:ClearFontCache()
end
end
end)
end
-- Try to register now, and also schedule for later in case LSM loads after us
RegisterCustomMedia()
-- Also try after ADDON_LOADED in case SharedMedia addons load later
local registrationFrame = CreateFrame("Frame")
registrationFrame:RegisterEvent("ADDON_LOADED")
registrationFrame:SetScript("OnEvent", function(self, event, loadedAddon)
-- Try to register our media whenever any addon loads (in case it's SharedMedia)
RegisterCustomMedia()
-- Once LSM is available, we're done - stop listening
local LSM = GetLSM()
if LSM then
self:UnregisterAllEvents()
end
end)
-- Store reference for other modules (use getter function)
DF.GetLSM = GetLSM
-- ============================================================
-- FONTS & TEXTURES (SharedMedia integration)
-- ============================================================
-- Fallback fonts if SharedMedia not available
DF.SharedFonts = {
["Fonts\\FRIZQT__.TTF"] = "Friz Quadrata TT",
["Fonts\\ARIALN.TTF"] = "Arial Narrow",
["Fonts\\skurri.ttf"] = "Skurri",
["Fonts\\MORPHEUS.TTF"] = "Morpheus",
["Interface\\AddOns\\DandersFrames\\Fonts\\Expressway.ttf"] = "DF Expressway",
["Interface\\AddOns\\DandersFrames\\Fonts\\Roboto-SemiBold.ttf"] = "DF Roboto SemiBold",
["Interface\\AddOns\\DandersFrames\\Fonts\\Roboto-Bold.ttf"] = "DF Roboto Bold",
}
-- Fallback textures if SharedMedia not available
DF.SharedTextures = {
["Solid"] = "Solid (No Texture)", -- Special option for solid color backgrounds
["Interface\\TargetingFrame\\UI-StatusBar"] = "Blizzard",
["Interface\\Buttons\\WHITE8x8"] = "Flat",
["Interface\\RaidFrame\\Raid-Bar-Hp-Fill"] = "Raid",
["Interface\\AddOns\\DandersFrames\\Media\\DF_Gradient_H"] = "DF Gradient H",
["Interface\\AddOns\\DandersFrames\\Media\\DF_Gradient_V"] = "DF Gradient V",
["Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes"] = "DF Stripes",
["Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Soft"] = "DF Stripes Soft",
["Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Soft_Wide"] = "DF Stripes Soft Wide",
["Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Sparse"] = "DF Stripes Sparse",
["Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Medium"] = "DF Stripes Medium",
["Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Dense"] = "DF Stripes Dense",
["Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Very_Dense"] = "DF Stripes Very Dense",
}
-- Fonts to exclude (known problematic fonts)
-- Font validation removed - show all SharedMedia fonts like MPlusTimer does
function DF:GetFontList()
-- Returns a table of fontName -> fontName for dropdown compatibility
-- We now store font NAMES in the database, not paths
-- Show all fonts like MPlusTimer does - no filtering
local list = {}
local LSM = GetLSM()
if LSM then
-- Use SharedMedia fonts - use lowercase "font" like MPlusTimer
local fonts = LSM:List("font")
for _, name in ipairs(fonts) do
list[name] = name
end
else
-- Fallback to built-in font names
for path, name in pairs(DF.SharedFonts) do
list[name] = name
end
end
return list
end
-- Fetch actual font path from SharedMedia by name (like MPlusTimer does)
function DF:GetFontPath(fontName)
if not fontName then return "Fonts\\FRIZQT__.TTF" end
-- If fontName looks like a path already (legacy support), return it
if fontName:find("\\") or fontName:find("/") then
return fontName
end
-- Use SharedMedia to get path - exactly like MPlusTimer does
local LSM = GetLSM()
if LSM then
return LSM:Fetch("font", fontName)
end
-- Fallback
return "Fonts\\FRIZQT__.TTF"
end
-- Get font display name from stored value (handles both names and legacy paths)
function DF:GetFontNameFromPath(fontValue)
if not fontValue then return nil end
local list = DF:GetFontList()
-- If it's already a font name in our list, return it directly
if list[fontValue] then
return fontValue
end
-- Legacy path support: if it looks like a path, try to find the font name
if fontValue:find("\\") or fontValue:find("/") then
local LSM = GetLSM()
if LSM then
local fonts = LSM:List("font")
for _, name in ipairs(fonts) do
local registeredPath = LSM:Fetch("font", name)
if registeredPath then
-- Compare paths (case-insensitive, slash-normalized)
local normRegistered = registeredPath:lower():gsub("/", "\\")
local normInput = fontValue:lower():gsub("/", "\\")
if normRegistered == normInput then
return name
end
-- Also try comparing just filenames
local regFilename = registeredPath:match("([^/\\]+)$")
local inputFilename = fontValue:match("([^/\\]+)$")
if regFilename and inputFilename and regFilename:lower() == inputFilename:lower() then
return name
end
end
end
end
-- Return filename without extension as fallback
local filename = fontValue:match("([^/\\]+)$")
if filename then
return filename:gsub("%.[tT][tT][fF]$", ""):gsub("%.[oO][tT][fF]$", "")
end
end
return fontValue
end
-- ============================================================
-- FONT FAMILY SYSTEM (Multi-alphabet support like Platynator)
-- ============================================================
-- Cache for created font families
local fontFamilies = {}
-- Clear font cache (kept for compatibility)
function DF:ClearFontCache()
-- Clear font families when new fonts are registered
wipe(fontFamilies)
end
-- Alphabets supported by WoW font families
local alphabets = {"roman", "korean", "simplifiedchinese", "traditionalchinese", "russian"}
-- Determine user's alphabet based on locale
local locale = GetLocale()
local userAlphabet = "roman"
if locale == "koKR" then
userAlphabet = "korean"
elseif locale == "zhCN" then
userAlphabet = "simplifiedchinese"
elseif locale == "zhTW" then
userAlphabet = "traditionalchinese"
elseif locale == "ruRU" then
userAlphabet = "russian"
end
-- Font alphabet support map
-- Fonts not listed here are assumed to support only "roman"
-- Blizzard fonts and fonts with full Unicode support should include all alphabets
local fontAlphabetSupport = {
-- Blizzard fonts - only list alphabets they actually contain glyphs for.
-- For unlisted alphabets (e.g. Korean, Chinese), GetFontFamilyMembers will
-- fall back to the proper locale-specific font from GameFontNormal.
["Fonts\\FRIZQT__.TTF"] = {"roman", "russian"},
["Fonts\\ARIALN.TTF"] = {"roman", "russian"},
["Fonts\\MORPHEUS.TTF"] = {"roman"},
["Fonts\\SKURRI.TTF"] = {"roman"},
-- Our custom fonts
["Interface\\AddOns\\DandersFrames\\Fonts\\Expressway.ttf"] = {"roman"}, -- Latin only
["Interface\\AddOns\\DandersFrames\\Fonts\\Roboto-SemiBold.ttf"] = {"roman", "russian"}, -- Latin + Cyrillic
["Interface\\AddOns\\DandersFrames\\Fonts\\Roboto-Bold.ttf"] = {"roman", "russian"}, -- Latin + Cyrillic
}
-- Allow registering font alphabet support (for SharedMedia fonts from other addons)
-- Usage: DF:RegisterFontAlphabetSupport("Interface\\AddOns\\MyAddon\\Fonts\\MyFont.ttf", {"roman", "russian"})
function DF:RegisterFontAlphabetSupport(fontPath, supportedAlphabets)
if not fontPath or not supportedAlphabets then return end
local normalizedPath = fontPath:lower():gsub("/", "\\")
fontAlphabetSupport[normalizedPath] = supportedAlphabets
-- Clear font cache so new families are created with updated support
wipe(fontFamilies)
end
-- Check if a font supports a given alphabet
local function FontSupportsAlphabet(fontPath, alphabet)
if not fontPath or not alphabet then return false end
-- Normalize path for comparison (case insensitive, handle both slash types)
local normalizedPath = fontPath:lower():gsub("/", "\\")
-- Check our known fonts
for knownPath, supportedAlphabets in pairs(fontAlphabetSupport) do
if normalizedPath == knownPath:lower() then
for _, supported in ipairs(supportedAlphabets) do
if supported == alphabet then
return true
end
end
return false
end
end
-- Unknown fonts: assume they only support roman alphabet
-- This is safer - better to fall back to Blizzard than show boxes
return alphabet == "roman"
end
-- Base font size used for font families (we'll scale from this)
local BASE_FONT_SIZE = 12
-- Hidden frame used for font preloading/validation
-- Needed early because GetOrCreateFontFamily uses it
local fontValidationFrame = CreateFrame("Frame")
fontValidationFrame:Hide()
local fontValidationString = fontValidationFrame:CreateFontString(nil, "OVERLAY")
-- Preload/validate a font to ensure WoW has it loaded
local function PreloadFont(fontPath)
if not fontPath then return end
-- Attempt to set the font - this forces WoW to load the font file
pcall(function()
fontValidationString:SetFont(fontPath, 12, "")
end)
end
-- Build font family members for CreateFontFamily
-- Uses custom font for supported alphabets, Blizzard fallbacks for others
local function GetFontFamilyMembers(customFontPath, outline)
local members = {}
local coreFont = GameFontNormal
-- Check if GetFontObjectForAlphabet exists (WoW 11.x+)
if not coreFont or not coreFont.GetFontObjectForAlphabet then
return nil
end
for _, alphabet in ipairs(alphabets) do
local forAlphabet = coreFont:GetFontObjectForAlphabet(alphabet)
if not forAlphabet then
return nil -- API not fully available
end
local blizzFile, _, _ = forAlphabet:GetFont()
if not blizzFile then
return nil -- Can't get font info
end
-- Check if custom font supports this alphabet
if FontSupportsAlphabet(customFontPath, alphabet) then
-- Use custom font for this alphabet
table.insert(members, {
alphabet = alphabet,
file = customFontPath,
height = BASE_FONT_SIZE,
flags = outline,
})
else
-- Use Blizzard's default font for unsupported alphabets
table.insert(members, {
alphabet = alphabet,
file = blizzFile,
height = BASE_FONT_SIZE,
flags = outline,
})
end
end
return members
end
-- Create or get a cached font family (keyed by font + outline + shadow)
local fontFamilyCounter = 0
local function GetOrCreateFontFamily(fontPath, outline, useShadow)
-- Check if CreateFontFamily API is available (WoW 11.x+)
if not CreateFontFamily then
return nil
end
-- Create unique key for this font configuration (include shadow state)
local key = (fontPath or "default"):lower() .. "|" .. (outline or "") .. "|" .. (useShadow and "shadow" or "noshadow")
if fontFamilies[key] then
return fontFamilies[key]
end
-- Get font family members
local members = GetFontFamilyMembers(fontPath, outline or "")
if not members then
return nil -- API not available or failed
end
-- Preload all fonts in the family to ensure they're available
-- This is important for fonts that haven't been used yet
for _, member in ipairs(members) do
if member.file and fontValidationString then
pcall(function()
fontValidationString:SetFont(member.file, 12, "")
end)
end
end
-- Generate unique global name
fontFamilyCounter = fontFamilyCounter + 1
local globalName = "DFFont" .. fontFamilyCounter
-- Create font family with multi-alphabet support
local success, fontFamily = pcall(CreateFontFamily, globalName, members)
if success and fontFamily then
fontFamily:SetTextColor(1, 1, 1)
-- Apply shadow to all alphabet font objects if needed (like Platynator does)
if useShadow then
-- Get shadow settings from current db (party or raid mode)
local db
if DF.GetDB then
db = DF:GetDB()
elseif DF.db then
local mode = (DF.GUI and DF.GUI.SelectedMode) or "party"
db = DF.db[mode]
end
local shadowX = db and db.fontShadowOffsetX or 1
local shadowY = db and db.fontShadowOffsetY or -1
local shadowColor = db and db.fontShadowColor or {r = 0, g = 0, b = 0, a = 1}
for _, alphabet in ipairs(alphabets) do
local fontObj = fontFamily:GetFontObjectForAlphabet(alphabet)
if fontObj then
fontObj:SetShadowOffset(shadowX, shadowY)
fontObj:SetShadowColor(shadowColor.r or 0, shadowColor.g or 0, shadowColor.b or 0, shadowColor.a or 1)
end
end
end
fontFamilies[key] = globalName
return globalName
end
return nil
end
function DF:GetTextureList(includeSolid)
local list = {}
local LSM = GetLSM()
-- Add Solid option for backgrounds if requested
if includeSolid then
list["Solid"] = "Solid (No Texture)"
end
if LSM then
-- Use SharedMedia statusbar textures
local textures = LSM:List(LSM.MediaType.STATUSBAR)
for _, name in ipairs(textures) do
local path = LSM:Fetch(LSM.MediaType.STATUSBAR, name)
if path then
list[path] = name
end
end
else
-- Fallback to built-in textures
for k, v in pairs(DF.SharedTextures) do
if k ~= "Solid" or includeSolid then -- Only include Solid if requested
list[k] = v
end
end
end
return list
end
-- Get texture display name from path (with fuzzy matching for SharedMedia compatibility)
function DF:GetTextureNameFromPath(texturePath)
if not texturePath then return nil end
-- Special case for Solid
if texturePath == "Solid" then
return "Solid (No Texture)"
end
-- First try direct lookup in current texture list
local list = DF:GetTextureList()
if list[texturePath] then
return list[texturePath]
end
-- Try with normalized path (replace forward slashes with backslashes)
local normalizedPath = texturePath:gsub("/", "\\")
if list[normalizedPath] then
return list[normalizedPath]
end
-- Try reverse - backslashes to forward slashes
normalizedPath = texturePath:gsub("\\", "/")
if list[normalizedPath] then
return list[normalizedPath]
end
-- Try case-insensitive search
local lowerPath = texturePath:lower()
for path, name in pairs(list) do
if path:lower() == lowerPath then
return name
end
end
-- Try matching without "Interface\" or "Interface/" prefix
local strippedPath = texturePath:gsub("^[Ii]nterface[/\\]", ""):lower()
for path, name in pairs(list) do
local strippedListPath = path:gsub("^[Ii]nterface[/\\]", ""):lower()
if strippedPath == strippedListPath then
return name
end
end
-- Last resort: Ask SharedMedia directly
local LSM = GetLSM()
if LSM then
local textures = LSM:List(LSM.MediaType.STATUSBAR)
for _, name in ipairs(textures) do
local registeredPath = LSM:Fetch(LSM.MediaType.STATUSBAR, name)
if registeredPath then
local normRegistered = registeredPath:lower():gsub("/", "\\")
local normInput = texturePath:lower():gsub("/", "\\")
if normRegistered == normInput then
return name
end
-- Also try comparing just filenames
local regFilename = registeredPath:match("([^/\\]+)$")
local inputFilename = texturePath:match("([^/\\]+)$")
if regFilename and inputFilename and regFilename:lower() == inputFilename:lower() then
return name
end
end
end
end
-- If still no match, return just the filename portion as a cleaner display
local filename = texturePath:match("([^/\\]+)$")
if filename then
return filename
end
return nil
end
-- ============================================================
-- SHARED MEDIA: SOUNDS
-- ============================================================
function DF:GetSoundList()
-- Returns a table of soundName -> soundName for dropdown compatibility
local list = {}
local LSM = GetLSM()
if LSM then
local sounds = LSM:List(LSM.MediaType.SOUND)
for _, name in ipairs(sounds) do
list[name] = name
end
end
return list
end
function DF:GetSoundPath(soundName)
if not soundName then return nil end
-- If it looks like a path already, return it
if soundName:find("\\") or soundName:find("/") then
return soundName
end
local LSM = GetLSM()
if LSM then
return LSM:Fetch(LSM.MediaType.SOUND, soundName)
end
return nil
end
-- Get font path by name (for SharedMedia compatibility)
function DF:GetFont(name)
local LSM = GetLSM()
if LSM then
return LSM:Fetch("font", name) or name
end
-- Check if name is already a path
if DF.SharedFonts[name] then
return name
end
-- Try to find path by display name
for path, displayName in pairs(DF.SharedFonts) do
if displayName == name then
return path
end
end
return name
end
-- Default fallback font
local FALLBACK_FONT = "Fonts\\FRIZQT__.TTF"
-- Safely set a font on a fontstring with fallback
-- Uses font families for multi-alphabet support (Cyrillic, CJK, etc.) when available
-- Returns true if successful, false if had to use fallback
function DF:SafeSetFont(fontString, fontNameOrPath, fontSize, outline)
if not fontString then return false end
fontSize = fontSize or 10
outline = outline or ""
-- Normalize "NONE" to empty string (NONE is not a valid WoW font flag)
if outline == "NONE" then outline = "" end
-- Handle shadow as a special case
local useShadow = (outline == "SHADOW")
local actualOutline = useShadow and "" or outline
local LSM = GetLSM()
local fontPath
-- If it looks like a path, use it directly (legacy support)
if fontNameOrPath and (fontNameOrPath:find("\\") or fontNameOrPath:find("/")) then
fontPath = fontNameOrPath
elseif LSM and fontNameOrPath then
-- Get path from SharedMedia
fontPath = LSM:Fetch("font", fontNameOrPath)
end
-- Use fallback if no font path
if not fontPath then
fontPath = FALLBACK_FONT
end
-- Preload the font to ensure it's available
PreloadFont(fontPath)
-- Try to use font family for multi-alphabet support (WoW 11.x+)
local fontFamilyName = GetOrCreateFontFamily(fontPath, actualOutline, useShadow)
if fontFamilyName and _G[fontFamilyName] then
-- IMPORTANT: First reset to a font object to clear any direct SetFont() state
-- This makes the fontString receptive to SetFontObject() changes
-- (fontStrings created with SetFont() don't respond well to SetFontObject() otherwise)
fontString:SetFontObject(GameFontNormal)
-- Now apply our font family
fontString:SetFontObject(_G[fontFamilyName])
-- Use SetTextScale to achieve desired size (font family uses BASE_FONT_SIZE)
local scale = fontSize / BASE_FONT_SIZE
fontString:SetTextScale(scale)
-- Force WoW to re-render the text with new font properties
-- This is needed because switching between font families with different outline flags
-- may not immediately update the rendered text without a text refresh
-- Note: Some fontStrings have "secret" text that cannot be read or compared,
-- so we wrap this in pcall to handle those cases safely
pcall(function()
local text = fontString:GetText()
if text and text ~= "" then
fontString:SetText("")
fontString:SetText(text)
end
end)
-- Apply shadow directly to fontString (font family shadow is on the font object,
-- but we need to apply to each fontString for proper settings)
if useShadow then
local db
if DF.GetDB then
db = DF:GetDB()
elseif DF.db then
local mode = (DF.GUI and DF.GUI.SelectedMode) or "party"
db = DF.db[mode]
end
local shadowX = db and db.fontShadowOffsetX or 1
local shadowY = db and db.fontShadowOffsetY or -1
local shadowColor = db and db.fontShadowColor or {r = 0, g = 0, b = 0, a = 1}
fontString:SetShadowOffset(shadowX, shadowY)
fontString:SetShadowColor(shadowColor.r or 0, shadowColor.g or 0, shadowColor.b or 0, shadowColor.a or 1)
else
fontString:SetShadowOffset(0, 0)
end
return true
end
-- Fallback: Direct SetFont (no multi-alphabet support, or older WoW version)
local success = fontString:SetFont(fontPath, fontSize, actualOutline)
-- Reset text scale in case it was set before by font family code
if fontString.SetTextScale then
fontString:SetTextScale(1)
end
if not success then
-- Ultimate fallback
fontString:SetFont(FALLBACK_FONT, fontSize, actualOutline)
end
-- Apply or clear shadow
if useShadow then
-- Get shadow settings from current db (party or raid mode)
local db
if DF.GetDB then
db = DF:GetDB()
elseif DF.db then
local mode = (DF.GUI and DF.GUI.SelectedMode) or "party"
db = DF.db[mode]
end
local shadowX = db and db.fontShadowOffsetX or 1
local shadowY = db and db.fontShadowOffsetY or -1
local shadowColor = db and db.fontShadowColor or {r = 0, g = 0, b = 0, a = 1}
fontString:SetShadowOffset(shadowX, shadowY)
fontString:SetShadowColor(shadowColor.r or 0, shadowColor.g or 0, shadowColor.b or 0, shadowColor.a or 1)
else
fontString:SetShadowOffset(0, 0)
end
return success
end
-- Get texture path by name (for SharedMedia compatibility)
function DF:GetTexture(name)
-- Special case for Solid - shouldn't reach here but safeguard
if name == "Solid" then
return nil
end
local LSM = GetLSM()
if LSM then
return LSM:Fetch(LSM.MediaType.STATUSBAR, name) or name
end
-- Check if name is already a path
if DF.SharedTextures[name] then
return name
end
-- Try to find path by display name
for path, displayName in pairs(DF.SharedTextures) do
if displayName == name then
return path
end
end
return name
end
-- ============================================================
-- DEFAULT SETTINGS (exported from profile v2.9.8)
-- ============================================================
DF.PartyDefaults = {
-- Internal migration flags
_blizzDispelIndicator = 1,
_blizzOnlyDispellable = false,
_defensiveBarMigrated = true,
_defensiveIconMigrated = true,
-- Global Font Shadow Settings (applies when outline is SHADOW)
fontShadowOffsetX = 1,
fontShadowOffsetY = -1,
fontShadowColor = {r = 0, g = 0, b = 0, a = 1},
-- Absorb Bar
absorbBarAnchor = "TOPRIGHT",
absorbBarAttachedClampMode = 1,
absorbBarBackgroundColor = {r = 0, g = 0, b = 0, a = 1},
absorbBarBlendMode = "BLEND",
absorbBarBorderColor = {r = 1, g = 0, b = 0.29803922772408, a = 1},
absorbBarBorderEnabled = true,
absorbBarBorderSize = 4,
absorbBarColor = {r = 0, g = 0.83529418706894, b = 1, a = 0.80208319425583},
absorbBarFrameLevel = 11,
absorbBarHeight = 7,
absorbBarMode = "ATTACHED_OVERFLOW",
absorbBarOrientation = "HORIZONTAL",
absorbBarOverlayReverse = false,
absorbBarOvershieldAlpha = 0.8,
absorbBarOvershieldColor = nil,
absorbBarOvershieldReverse = false,
absorbBarOvershieldStyle = "SPARK",
absorbBarReverse = false,
absorbBarShowOvershield = false,
absorbBarStrata = "MEDIUM",
absorbBarTexture = "Interface\\AddOns\\DandersFrames\\Media\\DF_Stripes_Dense",
absorbBarWidth = 46,
absorbBarX = 0,
absorbBarY = 0,
showAbsorbBar = true,
-- AFK Icon
afkIconAlpha = 0.8,
afkIconAnchor = "BOTTOM",
afkIconEnabled = true,
afkIconFrameLevel = 0,
afkIconHideInCombat = true,
afkIconScale = 1,
afkIconShowText = true,
afkIconShowTimer = true,
afkIconText = "AFK",
afkIconTextColor = {r = 1, g = 0.7725490927696228, b = 0.5411764979362488, a = 1},
afkIconX = 0,
afkIconY = 2,
-- Aggro Highlight
aggroColorHighThreat = {r = 1, g = 1, b = 0.47},
aggroColorHighestThreat = {r = 1, g = 0.6, b = 0},
aggroColorTanking = {r = 1, g = 0, b = 0},
aggroHighlightAlpha = 0.7500000596046448,
aggroHighlightInset = -2,
aggroHighlightMode = "GLOW",
aggroHighlightThickness = 1,
aggroOnlyTanking = false,
aggroUseCustomColors = false,
-- Anchor/Position
anchorPoint = "CENTER",
anchorX = 0,
anchorY = -325,
-- Background
backgroundClassAlpha = 1,
backgroundColor = {r = 0.5137255191802979, g = 0.5137255191802979, b = 0.5137255191802979, a = 0.7531240582466125},
backgroundColorMode = "CUSTOM",
backgroundMode = "BACKGROUND",
backgroundTexture = "Interface\\AddOns\\DandersFrames\\Media\\DF_Minimalist",
missingHealthClassAlpha = 0.8,
missingHealthColor = {r = 0.5, g = 0, b = 0, a = 0.8},
missingHealthColorHigh = {r = 0.05098039656877518, g = 1, b = 0, a = 1},
missingHealthColorHighUseClass = false,
missingHealthColorHighWeight = 1,
missingHealthColorLow = {r = 1, g = 0, b = 0, a = 1},
missingHealthColorLowUseClass = false,
missingHealthColorLowWeight = 2,
missingHealthColorMedium = {r = 1, g = 1, b = 0, a = 1},
missingHealthColorMediumUseClass = false,
missingHealthColorMediumWeight = 2,
missingHealthColorMode = "CUSTOM",
missingHealthGradientAlpha = 0.8,
missingHealthTexture = "Interface\\AddOns\\DandersFrames\\Media\\DF_Minimalist",
-- Border
borderColor = {r = 0, g = 0, b = 0, a = 1},
borderSize = 1,
showFrameBorder = true,
-- Boss Debuffs
bossDebuffHighlight = true,
bossDebuffScale = 1.2,
bossDebuffsAnchor = "TOPLEFT",
bossDebuffsBorderScale = 1,
bossDebuffsClickCastingEnabled = true,
bossDebuffsEnabled = true,
bossDebuffsFrameLevel = 35,
bossDebuffsGrowth = "RIGHT",
bossDebuffsIconHeight = 20,
bossDebuffsIconWidth = 20,
bossDebuffsMax = 4,
bossDebuffsOffsetX = 3,
bossDebuffsOffsetY = -13,
bossDebuffsScale = 1,
bossDebuffsScaleText = true,
bossDebuffsShowCountdown = true,
bossDebuffsShowDebugOverlay = true,
bossDebuffsShowNumbers = true,
bossDebuffsSpacing = 5,
bossDebuffsTextScale = 1,
bossDebuffsTextOffsetX = 0,
bossDebuffsTextOffsetY = 0,
-- Buff settings
buffAlpha = 1,
buffAnchor = "BOTTOMRIGHT",
buffBorderEnabled = false,
buffBorderInset = 1,
buffBorderThickness = 1,
buffClickThrough = true,
buffClickThroughInCombatOnly = false,
buffClickThroughKeybinds = true,
buffCountdownFont = "Fonts\\FRIZQT__.TTF",
buffCountdownOutline = "OUTLINE",
buffCountdownScale = 1,
buffCountdownX = 0,
buffCountdownY = 0,
buffDeduplicateDefensives = true,
buffDisableMouse = false,
buffDurationAnchor = "CENTER",
buffDurationColorByTime = true,
buffDurationHideAboveEnabled = false,
buffDurationHideAboveThreshold = 10,
buffDurationFont = "DF Roboto SemiBold",
buffDurationOutline = "SHADOW",
buffDurationScale = 1.2000000476837,
buffDurationX = -2,
buffDurationY = 2,
buffExpiringBorderColor = {r = 1, g = 0.50196081399918, b = 0, a = 1},
buffExpiringBorderColorByTime = false,
buffExpiringBorderEnabled = true,
buffExpiringBorderInset = 1,
buffExpiringBorderPulsate = true,
buffExpiringBorderThickness = 2,
buffExpiringEnabled = true,
buffExpiringThreshold = 30,
buffExpiringThresholdMode = "PERCENT",
buffExpiringTintColor = {r = 1, g = 0, b = 0.12156863510609, a = 0.46354159712791},
buffExpiringTintEnabled = false,
buffFilterCancelable = false,
buffFilterMode = "BLIZZARD",
buffFilterPlayer = true,
buffFilterRaid = false,
-- Aura Source Mode
auraSourceMode = "BLIZZARD", -- "BLIZZARD" or "DIRECT"
-- Direct Mode: Buff Filters
directBuffShowAll = false, -- Show all buffs (ignores sub-filters)
directBuffOnlyMine = true, -- Restrict all buff filters to player-cast only
directBuffFilterRaid = false, -- RAID filter
directBuffFilterRaidInCombat = true, -- RAID_IN_COMBAT filter
directBuffFilterCancelable = false, -- CANCELABLE filter
directBuffFilterNotCancelable = false, -- NOT_CANCELABLE filter
directBuffFilterImportant = false, -- IMPORTANT filter (12.0.1)
directBuffFilterBigDefensive = true, -- BIG_DEFENSIVE filter (12.0.1)
directBuffFilterExternalDefensive = true, -- EXTERNAL_DEFENSIVE filter (12.0.0)
directBuffSortOrder = "DEFAULT", -- "DEFAULT" / "TIME" / "NAME"
-- Direct Mode: Debuff Filters
directDebuffShowAll = false, -- Show all debuffs (ignores sub-filters)
directDebuffFilterRaid = true, -- RAID filter
directDebuffFilterRaidInCombat = true, -- RAID_IN_COMBAT filter
directDebuffFilterCrowdControl = true, -- CROWD_CONTROL filter
directDebuffFilterImportant = true, -- IMPORTANT filter (12.0.1)
directDebuffSortOrder = "DEFAULT", -- "DEFAULT" / "TIME" / "NAME"
buffGrowth = "LEFT_UP",
buffHideSwipe = false,
buffMax = 5,
buffOffsetX = -1,
buffOffsetY = 3,
buffPaddingX = -2,
buffPaddingY = -2,
buffScale = 1,
buffShowCountdown = false,
buffShowDuration = true,
buffSize = 24,
buffStackAnchor = "BOTTOMRIGHT",
buffStackFont = "DF Roboto SemiBold",
buffStackMinimum = 2,
buffStackOutline = "SHADOW",
buffStackScale = 1,
buffStackX = 0,
buffStackY = 0,
buffWrap = 3,
buffWrapOffsetX = 0,
buffWrapOffsetY = 0,
showBuffs = true,
-- Center Status Icon
centerStatusIconAnchor = "CENTER",
centerStatusIconEnabled = true,
centerStatusIconFrameLevel = 0,
centerStatusIconHide = false,
centerStatusIconScale = 1,
centerStatusIconX = 0,
centerStatusIconY = 0,
-- Class Color
classColorAlpha = 1,
colorPickerGlobalOverride = false,
colorPickerOverride = true,
-- Dead/Fade Settings
deadBackgroundAlpha = 0.3,
deadBackgroundColor = {r = 0.2, g = 0.2, b = 0.2, a = 1},
deadFadeEnabled = false,
deadHealthBarAlpha = 0.3,
deadHealthTextAlpha = 0.3,
deadNameAlpha = 0.5,
deadUseCustomBgColor = false,
fadeDeadAuras = 1,
fadeDeadBackground = 1,
fadeDeadBackgroundColor = {r = 1, g = 0, b = 0, a = 1},
fadeDeadFrames = true,
fadeDeadHealthBar = 1,
fadeDeadIcons = 1,
fadeDeadName = 1,
fadeDeadPowerBar = 0,
fadeDeadStatusText = 1,
fadeDeadUseCustomColor = false,
-- Health threshold fading (fade when health above threshold)
healthFadeEnabled = false,
healthFadeAlpha = 0.5,
healthFadeThreshold = 100,
hfCancelOnDispel = true,
-- Debuff settings
debuffAlpha = 1,
debuffAnchor = "BOTTOMLEFT",
debuffBorderColorBleed = {r = 1, g = 0, b = 0},
debuffBorderColorByType = true,
debuffBorderColorCurse = {r = 0.6, g = 0, b = 1},
debuffBorderColorDisease = {r = 0.6, g = 0.4, b = 0},
debuffBorderColorMagic = {r = 0.2, g = 0.6, b = 1},
debuffBorderColorNone = {r = 0, g = 0, b = 0, a = 1},
debuffBorderColorPoison = {r = 0, g = 0.6, b = 0},
debuffBorderEnabled = true,
debuffBorderInset = 1,
debuffBorderThickness = 2,
debuffClickThrough = true,
debuffClickThroughInCombatOnly = false,
debuffClickThroughKeybinds = true,
debuffCountdownFont = "Fonts\\FRIZQT__.TTF",
debuffCountdownOutline = "OUTLINE",
debuffCountdownScale = 1,
debuffCountdownX = 0,
debuffCountdownY = 0,
debuffDisableMouse = false,
debuffDurationAnchor = "CENTER",
debuffDurationColorByTime = false,
debuffDurationHideAboveEnabled = false,
debuffDurationHideAboveThreshold = 10,
debuffDurationFont = "DF Roboto SemiBold",
debuffDurationOutline = "SHADOW",
debuffDurationScale = 1,
debuffDurationX = 0,
debuffDurationY = 0,
debuffExpiringBorderColor = {r = 1, g = 0.27843138575554, b = 0, a = 1},