-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlizzardSkin.lua
More file actions
1903 lines (1798 loc) · 58.6 KB
/
BlizzardSkin.lua
File metadata and controls
1903 lines (1798 loc) · 58.6 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 AceAddon = LibStub("AceAddon-3.0")
local addon = AceAddon and AceAddon:GetAddon("SimpleUnitFrames", true)
if not addon then
return
end
local SKINNABLE_FRAMES = {
character = { "CharacterFrame", "InspectFrame" },
spellbook = {
"SpellBookFrame",
"PlayerSpellsFrame",
"PlayerSpellsFrame.SpellBookFrame",
"PlayerSpellsFrame.TalentsFrame",
"PlayerSpellsFrame.SpecFrame",
"PlayerSpellsFrame.HeroTalentsContainer",
"ClassTalentFrame",
"ClassTalentFrame.TalentsTab",
"ClassTalentFrame.SpecTab",
"ClassTalentFrame.HeroTalentsTab",
"ClassTalentLoadoutDialog",
"ClassTalentLoadoutEditDialog",
"ClassTalentLoadoutImportDialog",
"ClassTalentLoadoutViewDialog",
"HeroTalentsSelectionDialog",
},
collections = { "CollectionsJournal", "MountJournal", "PetJournal", "PetJournalParent", "ToyBox", "HeirloomsJournal", "WardrobeCollectionFrame", "WardrobeFrame" },
questlog = { "QuestLogFrame", "QuestMapFrame" },
lfg = { "LFDParentFrame", "PVEFrame", "PVPQueueFrame", "HonorFrame", "ConquestFrame", "RolePollPopup", "CompactRaidFrameManager", "CompactRaidFrameManagerDisplayFrame" },
map = { "WorldMapFrame", "WorldMapFrame.BorderFrame", "WorldMapFrame.NavBar", "WorldMapFrame.ScrollContainer", "QuestMapFrame", "QuestMapFrame.DetailsFrame", "QuestMapFrame.QuestsFrame", "FlightMapFrame" },
calendar = { "CalendarFrame", "TimeManagerFrame", "StopwatchFrame", "TimeManagerClockButton" },
professions = { "ProfessionsFrame", "ProfessionsFrame.CraftingPage", "ProfessionsFrame.SpecPage", "ProfessionsFrame.OrdersPage", "ProfessionsFrame.RecipeList", "TradeSkillFrame", "ProfessionsBookFrame", "ProfessionsCustomerOrdersFrame" },
dressup = { "DressUpFrame", "SideDressUpFrame" },
gossip = { "GossipFrame" },
merchant = { "MerchantFrame" },
mail = { "MailFrame", "OpenMailFrame", "SendMailFrame" },
economy = { "AuctionHouseFrame", "VoidStorageFrame", "ItemSocketingFrame", "TradeFrame", "ReforgingFrame" },
friends = { "FriendsFrame", "SocialFrame", "WhoFrame", "ChannelFrame" },
guild = {
"GuildFrame",
"CommunitiesFrame",
"LookingForGuildFrame",
"CommunitiesFrame.GuildFinderFrame",
"CommunitiesFrame.Chat",
"CommunitiesFrame.Chat.InsetFrame",
"CommunitiesFrame.MemberList",
"CommunitiesFrame.GuildBenefitsFrame",
"CommunitiesFrame.GuildInfoFrame",
"CommunitiesFrame.NotificationSettingsDialog",
"CommunitiesFrame.ChatTab",
"CommunitiesFrame.RosterTab",
"CommunitiesFrame.GuildBenefitsTab",
"CommunitiesFrame.GuildInfoTab",
},
housing = { "HousingDashboardFrame", "HouseEditorFrame", "HousingHouseSettingsFrame", "HousingModelPreviewFrame" },
achievement = { "AchievementFrame", "WeeklyRewardsFrame", "WeeklyRewardsFrame.BorderContainer", "WeeklyRewardsFrame.SelectRewardFrame", "PVPMatchResults", "PVPMatchScoreboard" },
encounter = { "EncounterJournal" },
}
local REQUIRED_ADDONS = {
Blizzard_AchievementUI = true,
Blizzard_Collections = true,
Blizzard_EncounterJournal = true,
Blizzard_FriendsFrame = true,
Blizzard_GuildUI = true,
Blizzard_InspectUI = true,
Blizzard_Communities = true,
Blizzard_MerchantUI = true,
Blizzard_AuctionHouseUI = true,
Blizzard_Calendar = true,
Blizzard_ChallengesUI = true,
Blizzard_PVPMatch = true,
Blizzard_PVPUI = true,
Blizzard_ReforgingUI = true,
Blizzard_QuestLog = true,
Blizzard_PlayerSpells = true,
Blizzard_TalentUI = true,
Blizzard_TimeManager = true,
Blizzard_TradeSkillUI = true,
Blizzard_WeeklyRewards = true,
Blizzard_VoidStorageUI = true,
Blizzard_WorldMap = true,
}
local GROUP_ADDONS = {
character = { "Blizzard_CharacterUI", "Blizzard_InspectUI" },
spellbook = { "Blizzard_PlayerSpells", "Blizzard_TalentUI" },
collections = { "Blizzard_Collections" },
questlog = { "Blizzard_QuestLog" },
lfg = { "Blizzard_PVPUI", "Blizzard_ChallengesUI", "Blizzard_PVPMatch" },
map = { "Blizzard_WorldMap" },
calendar = { "Blizzard_Calendar", "Blizzard_TimeManager" },
professions = { "Blizzard_Professions", "Blizzard_TradeSkillUI" },
dressup = { "Blizzard_DressUpFrame" },
gossip = { "Blizzard_GossipUI" },
merchant = { "Blizzard_MerchantUI" },
mail = { "Blizzard_MailUI" },
economy = { "Blizzard_AuctionHouseUI", "Blizzard_VoidStorageUI", "Blizzard_ReforgingUI" },
friends = { "Blizzard_FriendsFrame", "Blizzard_Communities" },
guild = { "Blizzard_GuildUI", "Blizzard_Communities" },
housing = {},
achievement = { "Blizzard_AchievementUI", "Blizzard_WeeklyRewards", "Blizzard_PVPMatch" },
encounter = { "Blizzard_EncounterJournal" },
}
local TEXTURE_BLOCKLIST = {}
local TEXTURE_ALLOWLIST = {}
local SKIN_REGISTRY_MERGED = false
local ACTIVE_APPLY_REPORT = nil
local SKINNED_FRAME_BUCKETS = {}
local SKINNED_FRAME_SET = setmetatable({}, { __mode = "k" })
local LAZY_TOPLEVEL_REFS = {
CollectionsJournal = true,
MountJournal = true,
PetJournal = true,
PetJournalParent = true,
ToyBox = true,
HeirloomsJournal = true,
WardrobeCollectionFrame = true,
WardrobeFrame = true,
CalendarFrame = true,
EncounterJournal = true,
QuestLogFrame = true,
InspectFrame = true,
AuctionHouseFrame = true,
VoidStorageFrame = true,
ItemSocketingFrame = true,
ReforgingFrame = true,
FlightMapFrame = true,
PVPQueueFrame = true,
HonorFrame = true,
ConquestFrame = true,
}
local LAZY_NESTED_ROOTS = {
ClassTalentFrame = true,
ProfessionsFrame = true,
}
local SOFT_NESTED_HINTS = {
".NineSlice",
".Inset",
".MiniBorderFrame",
".ScrollBar.Background",
}
local SPELLBOOK_TEXTURE_HARD_EXCLUDES = {
"bookbg",
"parchment",
"paper",
"page",
"abilitiesbook",
}
local SPELLBOOK_CHROME_ALLOW_HINTS = {
"nineslice", "border", "edge", "corner", "inset", "header", "title", "navbar", "search", "tab",
}
local SPELLBOOK_CONTENT_EXCLUDE_HINTS = {
"spell", "ability", "icon", "button", "slot", "row", "list", "container", "backgroundtile", "paper", "bookbg", "parchment",
}
local AGGRESSIVE_INCLUDE_HINTS = {
"nine", "slice", "frame", "border", "edge", "corner", "inset", "header", "title", "background", "backdrop", "trim", "shadow",
}
local AGGRESSIVE_EXCLUDE_HINTS = {
"icon", "item", "slot", "portrait", "model", "avatar", "artifact", "reward", "currency",
"map", "quest", "poi", "pin", "minimap", "blob", "illustration", "splash", "preview",
"spellicon", "abilitiesbook", "paper", "parchment", "bookbg", "tab", "uipanelbutton",
}
local MAP_CHROME_ALLOW_HINTS = {
"borderframe", "navbar", "nineslice", "inset", "scrollbar", "header", "title", "edge", "corner",
}
local MAP_CONTENT_EXCLUDE_HINTS = {
"worldmap", "questmap", "mapcanvas", "maptile", "mapoverlay", "poi", "pin", "cursor", "fog",
}
local function AddUniqueString(list, value)
if type(value) ~= "string" or value == "" then
return
end
for i = 1, #list do
if list[i] == value then
return
end
end
list[#list + 1] = value
end
local function MergeSkinRegistryData()
if SKIN_REGISTRY_MERGED then
return
end
SKIN_REGISTRY_MERGED = true
if not addon.GetBlizzardSkinRegistry then
return
end
local registry = addon:GetBlizzardSkinRegistry()
if type(registry) ~= "table" then
return
end
local groups = registry.groups
if type(groups) == "table" then
for groupKey, refs in pairs(groups) do
if type(groupKey) == "string" and type(refs) == "table" then
SKINNABLE_FRAMES[groupKey] = SKINNABLE_FRAMES[groupKey] or {}
for i = 1, #refs do
AddUniqueString(SKINNABLE_FRAMES[groupKey], refs[i])
end
end
end
end
local required = registry.requiredAddons
if type(required) == "table" then
for addonName, enabled in pairs(required) do
if enabled == true and type(addonName) == "string" and addonName ~= "" then
REQUIRED_ADDONS[addonName] = true
end
end
end
local groupAddons = registry.groupAddons
if type(groupAddons) == "table" then
for groupKey, addonList in pairs(groupAddons) do
if type(groupKey) == "string" and type(addonList) == "table" then
GROUP_ADDONS[groupKey] = GROUP_ADDONS[groupKey] or {}
for i = 1, #addonList do
AddUniqueString(GROUP_ADDONS[groupKey], addonList[i])
end
end
end
end
local blocklist = registry.textureBlocklist
if type(blocklist) == "table" then
for key, value in pairs(blocklist) do
if value == true then
TEXTURE_BLOCKLIST[key] = true
end
end
end
local allowlist = registry.textureAllowlist
if type(allowlist) == "table" then
for key, value in pairs(allowlist) do
if value == true then
TEXTURE_ALLOWLIST[key] = true
end
end
end
end
MergeSkinRegistryData()
local function AddReportSample(report, key, value, maxCount)
if not (report and type(key) == "string" and type(value) == "string" and value ~= "") then
return
end
report[key] = report[key] or {}
local list = report[key]
local limit = tonumber(maxCount) or 12
if #list >= limit then
return
end
for i = 1, #list do
if list[i] == value then
return
end
end
list[#list + 1] = value
end
local function CopyTableDeepLocal(source)
local copy = {}
for key, value in pairs(source or {}) do
copy[key] = (type(value) == "table") and CopyTableDeepLocal(value) or value
end
return copy
end
local function Increment(report, key)
if not report then
return
end
report[key] = (report[key] or 0) + 1
end
local function GetDomainReport(report, domainKey)
if not (report and type(domainKey) == "string" and domainKey ~= "") then
return nil
end
report.domains = report.domains or {}
local domain = report.domains[domainKey]
if not domain then
domain = {
seen = 0,
applied = 0,
missing = 0,
protected = 0,
forbidden = 0,
already = 0,
}
report.domains[domainKey] = domain
end
return domain
end
local function TrackSkinnedFrame(groupKey, frame)
if not frame then
return
end
local bucketKey = (type(groupKey) == "string" and groupKey ~= "") and groupKey or "__adhoc"
local bucket = SKINNED_FRAME_BUCKETS[bucketKey]
if not bucket then
bucket = {}
SKINNED_FRAME_BUCKETS[bucketKey] = bucket
end
if not SKINNED_FRAME_SET[frame] then
SKINNED_FRAME_SET[frame] = true
bucket[#bucket + 1] = frame
end
end
local function IsBlockedValue(value)
if value == nil then
return false
end
return TEXTURE_BLOCKLIST[value] == true
end
local function IsAllowedValue(value)
if value == nil then
return false
end
return TEXTURE_ALLOWLIST[value] == true
end
local function SafeGetRegions(owner)
if not (owner and owner.GetRegions) then
return {}
end
local results = { pcall(owner.GetRegions, owner) }
if results[1] ~= true then
return {}
end
table.remove(results, 1)
return results
end
local function SafeGetChildren(owner)
if not (owner and owner.GetChildren) then
return {}
end
local results = { pcall(owner.GetChildren, owner) }
if results[1] ~= true then
return {}
end
table.remove(results, 1)
return results
end
local function SafeGetNumChildren(owner)
if not (owner and owner.GetNumChildren) then
return 0
end
local ok, count = pcall(owner.GetNumChildren, owner)
if ok and type(count) == "number" then
return count
end
return 0
end
local function SafeGetObjectType(owner)
if not (owner and owner.GetObjectType) then
return nil
end
local ok, objectType = pcall(owner.GetObjectType, owner)
if ok and type(objectType) == "string" then
return objectType
end
return nil
end
local function SafeGetName(owner)
if not (owner and owner.GetName) then
return ""
end
local ok, name = pcall(owner.GetName, owner)
if ok and type(name) == "string" then
return name
end
return ""
end
local STRONG_PLUS_INCLUDE_HINTS = {
"nine", "slice", "frame", "border", "edge", "corner", "inset", "dialog", "panel",
"background", "backdrop", "bookbg", "parchment", "title", "header", "shadow",
"titlebg", "title-bg", "portraitframe", "metal", "trim", "decor",
"ui-", "blizzard", "quest", "character", "paperdoll", "journal", "collections",
"pve", "lfg", "calendar", "friends", "guild", "merchant", "mail", "auction",
}
local STRONG_PLUS_EXCLUDE_HINTS = {
"icon", "spellicon", "portrait", "model", "item", "reward", "currency", "avatar",
"cooldown", "minimap", "bag", "slot", "tab", "button", "uipanelbutton",
"card", "preview", "splash", "illustration", "scene", "render", "screenshot",
}
local function ContainsHint(text, hints)
if type(text) ~= "string" then
return false
end
local lowered = text:lower()
for i = 1, #hints do
if lowered:find(hints[i], 1, true) then
return true
end
end
return false
end
local function GetThemeBackdropStyle(intensity)
local theme = addon.GetSUFTheme and addon:GetSUFTheme()
if not theme or not theme.backdrop then
return nil
end
if intensity == "strong" or intensity == "strongplus" then
return theme.backdrop.panel or theme.backdrop.window or theme.backdrop.subtle
end
return theme.backdrop.subtle or theme.backdrop.panel or theme.backdrop.window
end
local function IsContentHeavyGroup(groupKey)
return groupKey == "spellbook" or groupKey == "map" or groupKey == "encounter" or groupKey == "collections" or groupKey == "calendar"
end
local function ScaleColorAlpha(color, alphaScale)
if type(color) ~= "table" then
return color
end
local out = { color[1], color[2], color[3], color[4] or 1 }
out[4] = (out[4] or 1) * (alphaScale or 1)
return out
end
local function CaptureTextureColor(original, texture)
if not (original and texture and texture.GetVertexColor) then
return
end
original.textures = original.textures or {}
if original.textures[texture] then
return
end
local ok, r, g, b, a = pcall(texture.GetVertexColor, texture)
if ok and r then
original.textures[texture] = { r, g, b, a }
end
end
local function TintTexture(original, texture, color, alphaMul)
if not (texture and texture.SetVertexColor and color) then
return
end
CaptureTextureColor(original, texture)
texture:SetVertexColor(color[1], color[2], color[3], (color[4] or 1) * (alphaMul or 1))
end
local function CaptureFontColor(original, fontString)
if not (original and fontString and fontString.GetTextColor) then
return
end
original.fontStrings = original.fontStrings or {}
if original.fontStrings[fontString] then
return
end
local ok, r, g, b, a = pcall(fontString.GetTextColor, fontString)
if ok and r then
original.fontStrings[fontString] = { r, g, b, a }
end
end
local function ShouldSkipContrastFont(fontString)
if not fontString then
return true
end
local text = fontString.GetText and fontString:GetText() or nil
if type(text) == "string" and text:find("|c", 1, true) then
return true
end
local parent = fontString.GetParent and fontString:GetParent() or nil
local function IsSpellbookTree(node)
local guard = 0
while node and guard < 8 do
local name = SafeGetName(node):lower()
if name:find("playerspellsframe", 1, true)
or name:find("spellbookframe", 1, true)
or name:find("classtalentframe", 1, true) then
return true
end
node = node.GetParent and node:GetParent() or nil
guard = guard + 1
end
return false
end
local guard = 0
while parent and guard < 4 do
local parentType = SafeGetObjectType(parent) or ""
if (parentType == "Button" or parentType == "CheckButton") and (not IsSpellbookTree(parent)) then
return true
end
parent = parent.GetParent and parent:GetParent() or nil
guard = guard + 1
end
return false
end
local function GetReadableTextColor(style)
local bg = style and style.bg
if type(bg) ~= "table" then
return { 0.93, 0.93, 0.95, 1 }
end
local r = tonumber(bg[1]) or 0.1
local g = tonumber(bg[2]) or 0.1
local b = tonumber(bg[3]) or 0.1
local luminance = (0.299 * r) + (0.587 * g) + (0.114 * b)
if luminance <= 0.5 then
return { 0.95, 0.95, 0.97, 1.0 }
end
return { 0.10, 0.10, 0.12, 1.0 }
end
local function ApplyContrastAwareTextPass(frame, style, report, groupKey)
if not (frame and style) then
return false
end
local original = frame.__sufBlizzardSkinOriginal
local textColor = GetReadableTextColor(style)
if groupKey == "spellbook" then
textColor = { 0.97, 0.97, 0.98, 1.0 }
elseif groupKey == "collections" then
textColor = { 0.95, 0.95, 0.96, 1.0 }
elseif groupKey == "calendar" then
textColor = { 0.95, 0.95, 0.96, 1.0 }
end
local changed = false
local seen = {}
local function TryApply(fontString)
if not (fontString and fontString.SetTextColor and not seen[fontString]) then
return
end
seen[fontString] = true
if groupKey ~= "spellbook" and ShouldSkipContrastFont(fontString) then
return
end
local rawText = fontString.GetText and fontString:GetText() or nil
if type(rawText) == "string" and rawText:find("|c", 1, true) then
return
end
CaptureFontColor(original, fontString)
fontString:SetTextColor(textColor[1], textColor[2], textColor[3], textColor[4] or 1)
changed = true
Increment(report, "contrastTextAdjusted")
end
local function Walk(owner, depth)
if not owner or depth > 6 then
return
end
local regions = SafeGetRegions(owner)
for i = 1, #regions do
local region = regions[i]
if SafeGetObjectType(region) == "FontString" then
TryApply(region)
end
end
local children = SafeGetChildren(owner)
for i = 1, #children do
local child = children[i]
if SafeGetObjectType(child) == "FontString" then
TryApply(child)
end
Walk(child, depth + 1)
end
end
Walk(frame, 0)
return changed
end
local function TintKnownTextureKeys(original, owner, keys, color)
if not (owner and type(keys) == "table" and color) then
return false
end
local changed = false
for i = 1, #keys do
local key = keys[i]
local tex = owner[key]
if tex and tex.SetVertexColor then
TintTexture(original, tex, color, 1)
changed = true
end
end
return changed
end
local function TintNineSlice(original, owner, bgColor, borderColor, tintCenters)
if not owner then
return false
end
local changed = false
local ns = owner.NineSlice or owner
if not ns then
return false
end
local borderKeys = {
"TopEdge", "BottomEdge", "LeftEdge", "RightEdge",
"TopLeftCorner", "TopRightCorner", "BottomLeftCorner", "BottomRightCorner",
"Border",
}
for i = 1, #borderKeys do
local tex = ns[borderKeys[i]]
if tex and tex.SetVertexColor and borderColor then
TintTexture(original, tex, borderColor, 1)
changed = true
end
end
if tintCenters ~= false then
local centerKeys = { "Center", "Bg", "Background", "Inset", "TitleBG", "Header" }
for i = 1, #centerKeys do
local tex = ns[centerKeys[i]]
if tex and tex.SetVertexColor and bgColor then
TintTexture(original, tex, bgColor, 1)
changed = true
end
end
end
return changed
end
local function ApplyThemeToFrameTextures(frame, style, groupKey)
if not (frame and style) then
return false
end
local original = frame.__sufBlizzardSkinOriginal
local bgColor = style.bg
local borderColor = style.border
if groupKey == "spellbook" or groupKey == "encounter" or groupKey == "collections" or groupKey == "calendar" then
borderColor = ScaleColorAlpha(borderColor, 0.55)
end
local changed = false
local tintCenters = not IsContentHeavyGroup(groupKey)
if TintNineSlice(original, frame, bgColor, borderColor, tintCenters) then
changed = true
end
local borderKeys = {
"TopEdge", "BottomEdge", "LeftEdge", "RightEdge",
"TopLeftCorner", "TopRightCorner", "BottomLeftCorner", "BottomRightCorner",
"TopBorder", "BottomBorder", "LeftBorder", "RightBorder",
"Border", "TopTileStreaks", "PortraitFrame",
}
local bgKeys = {
"Bg", "BG", "Background", "BackgroundTile", "Center",
"TitleBg", "TitleBG", "InsetBg", "Inset", "Header",
}
if TintKnownTextureKeys(original, frame, borderKeys, borderColor) then
changed = true
end
local allowWideBgTint = not IsContentHeavyGroup(groupKey)
local chromeBgKeys = { "TitleBg", "TitleBG", "Header" }
if allowWideBgTint and TintKnownTextureKeys(original, frame, bgKeys, bgColor) then
changed = true
elseif (not allowWideBgTint) and TintKnownTextureKeys(original, frame, chromeBgKeys, bgColor) then
changed = true
end
local extraTargets = {
frame.Inset,
frame.InsetFrame,
frame.BorderFrame,
frame.Bg,
frame.Background,
}
for i = 1, #extraTargets do
if TintNineSlice(original, extraTargets[i], bgColor, borderColor, tintCenters) then
changed = true
end
if TintKnownTextureKeys(original, extraTargets[i], borderKeys, borderColor) then
changed = true
end
if allowWideBgTint and TintKnownTextureKeys(original, extraTargets[i], bgKeys, bgColor) then
changed = true
end
if allowWideBgTint and extraTargets[i] and extraTargets[i].SetVertexColor and bgColor then
TintTexture(original, extraTargets[i], bgColor, 1)
changed = true
end
end
return changed
end
local function ChooseStrongPlusTint(style, texture)
if not (style and texture) then
return nil
end
local name = texture.GetName and texture:GetName() or ""
local atlas = texture.GetAtlas and texture:GetAtlas() or ""
local path = texture.GetTexture and texture:GetTexture() or ""
local probe = table.concat({ tostring(name), tostring(atlas), tostring(path) }, " "):lower()
local accent = style.border or style.bg
local bg = style.bg
local border = style.border or style.bg
if probe:find("background", 1, true) or probe:find("center", 1, true) or probe:find("inset", 1, true) then
return bg
end
if probe:find("highlight", 1, true) or probe:find("selection", 1, true) then
return accent
end
return border
end
local function IsStrongPlusTextureEligible(texture, aggressive, groupKey)
if not (texture and texture.GetObjectType and texture:GetObjectType() == "Texture") then
return false
end
if texture.IsForbidden and texture:IsForbidden() then
return false
end
local name = texture.GetName and texture:GetName() or ""
local atlas = texture.GetAtlas and texture:GetAtlas() or ""
local path = texture.GetTexture and texture:GetTexture() or ""
local allowed = IsAllowedValue(path) or IsAllowedValue(name) or IsAllowedValue(atlas)
if allowed then
Increment(ACTIVE_APPLY_REPORT, "allowlistBypass")
end
if (not allowed) and (IsBlockedValue(path) or IsBlockedValue(name) or IsBlockedValue(atlas)) then
Increment(ACTIVE_APPLY_REPORT, "blockedByTextureBlocklist")
local sample = tostring(path or atlas or name or "")
if sample ~= "" then
AddReportSample(ACTIVE_APPLY_REPORT, "blockedTextureSamples", sample, 20)
end
return false
end
local probe = table.concat({ tostring(name), tostring(atlas), tostring(path) }, " ")
if probe == "" then
return false
end
local loweredProbe = probe:lower()
local function HasParentNameHint(tex, hints, maxDepth)
local p = tex and tex.GetParent and tex:GetParent() or nil
local depth = 0
while p and depth < (maxDepth or 8) do
local n = SafeGetName(p):lower()
if n ~= "" then
for i = 1, #hints do
if n:find(hints[i], 1, true) then
return true
end
end
end
p = p.GetParent and p:GetParent() or nil
depth = depth + 1
end
return false
end
local layer = texture.GetDrawLayer and texture:GetDrawLayer() or nil
if groupKey == "spellbook" then
for i = 1, #SPELLBOOK_TEXTURE_HARD_EXCLUDES do
if loweredProbe:find(SPELLBOOK_TEXTURE_HARD_EXCLUDES[i], 1, true) then
return false
end
end
local isChrome = ContainsHint(probe, SPELLBOOK_CHROME_ALLOW_HINTS)
if ContainsHint(probe, SPELLBOOK_CONTENT_EXCLUDE_HINTS) and not isChrome then
return false
end
if HasParentNameHint(texture, { "spell", "ability", "button", "entry", "list", "container", "talent" }, 10) and not isChrome then
return false
end
if layer == "ARTWORK" and not isChrome then
return false
end
end
if groupKey == "map" then
local isChrome = ContainsHint(probe, MAP_CHROME_ALLOW_HINTS)
if ContainsHint(probe, MAP_CONTENT_EXCLUDE_HINTS) and not isChrome then
return false
end
local parent = texture.GetParent and texture:GetParent() or nil
local guard = 0
local chromeParent = false
while parent and guard < 8 do
local parentName = SafeGetName(parent):lower()
if parentName ~= "" then
if parentName:find("borderframe", 1, true)
or parentName:find("navbar", 1, true)
or parentName:find("nineslice", 1, true)
or parentName:find("inset", 1, true)
or parentName:find("scrollbar", 1, true) then
chromeParent = true
break
end
if parentName:find("worldmapframe.scrollcontainer", 1, true)
or parentName:find("worldmapframe.mapcanvas", 1, true)
or parentName:find("questmapframe.mapframe", 1, true) then
return false
end
end
parent = parent.GetParent and parent:GetParent() or nil
guard = guard + 1
end
if layer == "ARTWORK" and (not chromeParent) and (not isChrome) then
return false
end
end
local parent = texture.GetParent and texture:GetParent() or nil
local guard = 0
while parent and guard < 6 do
local parentType = parent.GetObjectType and parent:GetObjectType() or ""
local parentName = parent.GetName and parent:GetName() or ""
if parentType == "Button" or parentType == "CheckButton" then
return false
end
if type(parentName) == "string" and parentName ~= "" then
local lowered = parentName:lower()
if lowered:find("tab", 1, true) or lowered:find("button", 1, true) then
return false
end
end
parent = parent.GetParent and parent:GetParent() or nil
guard = guard + 1
end
if (not aggressive) and ContainsHint(probe, STRONG_PLUS_EXCLUDE_HINTS) then
return false
end
if aggressive then
if ContainsHint(probe, AGGRESSIVE_EXCLUDE_HINTS) then
return false
end
local w = texture.GetWidth and texture:GetWidth() or 0
local h = texture.GetHeight and texture:GetHeight() or 0
local isLargeArt = (w >= 220 and h >= 120)
local isChrome = ContainsHint(probe, AGGRESSIVE_INCLUDE_HINTS)
if isLargeArt and not isChrome then
return false
end
if layer ~= "BACKGROUND" and layer ~= "BORDER" and (not isChrome) then
return false
end
return true
end
local w = texture.GetWidth and texture:GetWidth() or 0
local h = texture.GetHeight and texture:GetHeight() or 0
local isLargeArt = (w >= 180 and h >= 90)
if isLargeArt then
local isKnownChrome = loweredProbe:find("border", 1, true)
or loweredProbe:find("edge", 1, true)
or loweredProbe:find("corner", 1, true)
or loweredProbe:find("title", 1, true)
or loweredProbe:find("header", 1, true)
or loweredProbe:find("nineslice", 1, true)
if not isKnownChrome then
return false
end
end
if not ContainsHint(probe, STRONG_PLUS_INCLUDE_HINTS) then
if w < 64 and h < 64 then
return false
end
local layer = texture.GetDrawLayer and texture:GetDrawLayer() or nil
if layer ~= "BACKGROUND" and layer ~= "BORDER" and layer ~= "ARTWORK" then
return false
end
end
return true
end
local function ResolveFrameReference(ref)
if type(ref) ~= "string" or ref == "" then
return nil
end
if not ref:find(".", 1, true) then
return _G[ref]
end
local obj = _G
for segment in ref:gmatch("[^%.]+") do
if obj == nil then
return nil
end
local ok, nextObj = pcall(function()
return obj[segment]
end)
if not ok then
return nil
end
obj = nextObj
if obj == nil then
return nil
end
end
return obj
end
local function ApplyStrongPlusTexturePass(frame, style, report, groupKey)
if not (frame and style) then
return false
end
local original = frame.__sufBlizzardSkinOriginal
local changed = false
local cfg = (addon and addon.GetBlizzardSkinSettings) and addon:GetBlizzardSkinSettings() or {}
local labMode = cfg and cfg.labMode == true
local aggressive = labMode and cfg and cfg.aggressiveRecursive == true
local reassertHooks = labMode and cfg and cfg.aggressiveReassertHooks == true
local hookBudget = 4000
local function IsAncestorSkinned(owner)
local node = owner
local guard = 0
while node and guard < 8 do
if node.__sufBlizzardSkinned then
return true
end
node = node.GetParent and node:GetParent() or nil
guard = guard + 1
end
return false
end
local function EnsureTextureReassertHook(texture)
if not (hooksecurefunc and texture and texture.SetVertexColor) then
return
end
if texture.__sufStrongPlusHooked == true then
return
end
if (tonumber(report and report.reassertHooked) or 0) >= hookBudget then
Increment(report, "reassertHookBudgetDrops")
return
end
hooksecurefunc(texture, "SetVertexColor", function(sel, _, _, _, a)
if not sel or sel.__sufStrongPlusApplying then
return
end
if not (addon and addon.GetBlizzardSkinSettings) then
return
end
local currentCfg = addon:GetBlizzardSkinSettings()
if not currentCfg or currentCfg.enabled ~= true then
return
end
if tostring(currentCfg.intensity or "subtle") ~= "strongplus" then
return
end
if currentCfg.labMode ~= true or currentCfg.aggressiveReassertHooks ~= true then
return
end
if not IsAncestorSkinned(sel.GetParent and sel:GetParent() or nil) then
return
end
local sName = (sel.GetName and sel:GetName() or ""):lower()
local sAtlas = (sel.GetAtlas and sel:GetAtlas() or ""):lower()
local sPath = tostring(sel.GetTexture and sel:GetTexture() or ""):lower()
local sProbe = table.concat({ sName, sAtlas, sPath }, " ")
local sw = sel.GetWidth and sel:GetWidth() or 0
local sh = sel.GetHeight and sel:GetHeight() or 0
local isChrome = sProbe:find("border", 1, true)
or sProbe:find("edge", 1, true)
or sProbe:find("corner", 1, true)
or sProbe:find("nineslice", 1, true)
or sProbe:find("trim", 1, true)
or sProbe:find("header", 1, true)
if (sw >= 220 and sh >= 120) and (not isChrome) then
return
end
local contentHints = {
"playerspellsframe", "classtalentframe", "worldmapframe", "questmapframe",
"spellbook", "talent", "spec", "specialization", "card", "paper", "parchment", "mapcanvas",
}
for i = 1, #contentHints do
if sProbe:find(contentHints[i], 1, true) then
return
end
end
local parent = sel.GetParent and sel:GetParent() or nil
local guard = 0
while parent and guard < 8 do
local pname = SafeGetName(parent):lower()
if pname:find("playerspellsframe", 1, true)
or pname:find("classtalentframe", 1, true)