-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.lua
More file actions
2491 lines (2279 loc) · 101 KB
/
Core.lua
File metadata and controls
2491 lines (2279 loc) · 101 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 AbstractUI = LibStub("AceAddon-3.0"):NewAddon("AbstractUI", "AceConsole-3.0", "AceEvent-3.0")
local LSM = LibStub("LibSharedMedia-3.0")
AbstractUI.version = "1.0.0"
-- Define reload confirmation dialog
StaticPopupDialogs["AbstractUI_RELOAD_CONFIRM"] = {
text = "This action requires a UI reload. Reload now?",
button1 = "Yes",
button2 = "No",
OnAccept = function()
if not InCombatLockdown() then
C_UI.Reload()
else
print("|cffff0000AbstractUI:|r Cannot reload UI while in combat. Please leave combat and run /reload.")
end
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
}
-- ============================================================================
-- 1. DATABASE DEFAULTS
-- ============================================================================
local defaults = {
profile = {
theme = {
active = "AbstractTransparent", -- Active framework theme
font = "Friz Quadrata TT",
fontSize = 12,
bgColor = {0.1, 0.1, 0.1, 0.8},
borderColor = {0, 0, 0, 1},
customThemes = {}, -- User-created themes
},
modules = {
skins = true,
bar = true,
UIButtons = true,
tooltips = true,
mailbox = true,
maps = true,
actionbars = true,
unitframes = true,
cooldowns = true,
resourceBars = true,
castBar = true,
tweaks = true,
setup = true,
addonmanager = true
}
}
}
-- ============================================================================
-- 2. INITIALIZATION
-- ============================================================================
function AbstractUI:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("AbstractUIDB", defaults, true)
-- Memory debug tracking
self.memoryDebugEnabled = false
self.memoryDebugTicker = nil
-- Register slash commands
self:RegisterChatCommand("aui", "SlashCommand")
self:RegisterChatCommand("AbstractUI", "SlashCommand")
self:RegisterChatCommand("auimove", "ToggleMoveMode")
self:RegisterChatCommand("demo", "OpenDemo")
self:RegisterChatCommand("auimemory", "ToggleMemoryDebug")
self:RegisterChatCommand("auigc", "ForceGarbageCollection")
self:RegisterChatCommand("addonsort", "TestAddonSort")
end
function AbstractUI:OnEnable()
-- Load custom themes FIRST before validating
self:LoadCustomThemes()
-- Validate and migrate theme setting
local ColorPalette = _G.AbstractUI_ColorPalette
if ColorPalette and self.db.profile.theme.active then
local currentTheme = self.db.profile.theme.active
-- Check if the current theme exists in the palette
if not ColorPalette.palettes[currentTheme] then
-- Theme doesn't exist, fall back to AbstractUIDefault
self.db.profile.theme.active = "AbstractUIDefault"
self:Print("Previous theme not found. Switched to AbstractUI Default theme.")
end
-- Set the active theme in ColorPalette
ColorPalette:SetActiveTheme(self.db.profile.theme.active)
end
-- Send the message after all modules have registered
C_Timer.After(0.1, function()
self:SendMessage("AbstractUI_DB_READY")
end)
-- Register options after modules load
-- NOTE: No longer using AceConfig/AceConfigDialog - we have our own custom framework now!
-- Options panel is opened via AbstractUI:OpenConfig() which uses Framework/AbstractOptionsPanel.lua
-- C_Timer.After(0.2, function()
-- AceConfig:RegisterOptionsTable("AbstractUI", function() return self:GetOptions() end)
-- AceConfigDialog:AddToBlizOptions("AbstractUI", "Abstract UI")
-- ... (commented out old AceGUI code)
-- end)
-- Initialize Framework
if _G.AbstractUI_FrameFactory then
_G.AbstractUI_FrameFactory:Initialize(self)
-- Apply saved theme
local savedTheme = self.db.profile.theme.active
if self.FrameFactory and savedTheme then
self.FrameFactory:SetTheme(savedTheme)
end
end
-- Load Focus Frame if present
if UnitFrames and UnitFrames.CreateFocusFrame then
UnitFrames:CreateFocusFrame()
end
end
function AbstractUI:SlashCommand(input)
if not input or input:trim() == "" then
self:OpenConfig()
elseif input:lower() == "move" then
self:ToggleMoveMode()
else
self:OpenConfig()
end
end
function AbstractUI:ToggleMemoryDebug()
self.memoryDebugEnabled = not self.memoryDebugEnabled
if self.memoryDebugEnabled then
-- Cancel existing ticker if any
if self.memoryDebugTicker then
self.memoryDebugTicker:Cancel()
end
-- Store baseline for delta tracking
UpdateAddOnMemoryUsage()
self.memoryDebugBaseline = GetAddOnMemoryUsage("AbstractUI")
self.memoryDebugLastReading = self.memoryDebugBaseline
-- Create new ticker that runs every 10 seconds with detailed diagnostics
self.memoryDebugTicker = C_Timer.NewTicker(10, function()
UpdateAddOnMemoryUsage()
local memory = GetAddOnMemoryUsage("AbstractUI")
local memoryMB = memory / 1024
local delta = memory - self.memoryDebugLastReading
local deltaMB = delta / 1024
self.memoryDebugLastReading = memory
-- Print memory with delta
print(string.format("|cff00ff00AbstractUI Memory:|r %.2f MB (%.0f KB) |cffffaa00[+%.2f MB/10s]|r", memoryMB, memory, deltaMB))
-- Diagnostic information
local diagnostics = {}
-- Count active C_Timer tickers (approximation via module checks)
local tickerCount = 0
local CooldownMgr = self:GetModule("CooldownManager", true)
if CooldownMgr and CooldownMgr.overlayTimer then tickerCount = tickerCount + 1 end
local Maps = self:GetModule("Maps", true)
if Maps then
if Maps.clockTicker then tickerCount = tickerCount + 1 end
if Maps.coordsTicker then tickerCount = tickerCount + 1 end
end
local BrokerBar = self:GetModule("BrokerBar", true)
if BrokerBar and BrokerBar.updateTicker then tickerCount = tickerCount + 1 end
table.insert(diagnostics, string.format("Tickers: %d", tickerCount))
-- Count highlighted spells (potential leak source)
if CooldownMgr and CooldownMgr.highlightedSpells then
local count = 0
for _ in pairs(CooldownMgr.highlightedSpells) do count = count + 1 end
if count > 0 then
table.insert(diagnostics, string.format("Highlights: %d", count))
end
end
-- Count registered events
local ActionBars = self:GetModule("ActionBars", true)
if ActionBars and ActionBars.cursorUpdateFrame then
table.insert(diagnostics, "CursorFrame: Active")
end
-- Print diagnostics if any
if #diagnostics > 0 then
print("|cff888888 → " .. table.concat(diagnostics, " | ") .. "|r")
end
end)
-- Print initial value
local memoryMB = self.memoryDebugBaseline / 1024
print(string.format("|cff00ff00AbstractUI Memory Debug Enabled|r - Current: %.2f MB (%.0f KB)", memoryMB, self.memoryDebugBaseline))
print("|cff00ff00AbstractUI:|r Memory will be printed every 10 seconds with growth tracking. Use /auimemory to disable.")
else
-- Cancel ticker
if self.memoryDebugTicker then
self.memoryDebugTicker:Cancel()
self.memoryDebugTicker = nil
end
self.memoryDebugBaseline = nil
self.memoryDebugLastReading = nil
print("|cff00ff00AbstractUI Memory Debug Disabled|r")
end
end
function AbstractUI:ForceGarbageCollection()
-- Get memory before GC
UpdateAddOnMemoryUsage()
local beforeMemory = GetAddOnMemoryUsage("AbstractUI")
local beforeMB = beforeMemory / 1024
-- Force garbage collection
collectgarbage("collect")
-- Wait a moment for collection to complete
C_Timer.After(0.1, function()
UpdateAddOnMemoryUsage()
local afterMemory = GetAddOnMemoryUsage("AbstractUI")
local afterMB = afterMemory / 1024
local freed = beforeMemory - afterMemory
local freedMB = freed / 1024
print(string.format("|cff00ff00AbstractUI Garbage Collection:|r"))
print(string.format(" Before: %.2f MB (%.0f KB)", beforeMB, beforeMemory))
print(string.format(" After: %.2f MB (%.0f KB)", afterMB, afterMemory))
print(string.format(" Freed: %.2f MB (%.0f KB)", freedMB, freed))
if freedMB < 0.1 then
print("|cffff8800 ⚠ Warning: Very little memory freed - possible permanent leak!|r")
end
end)
end
function AbstractUI:OpenDemo()
local demo = self:GetModule("FrameworkDemo", true)
if demo then
demo:Toggle()
else
self:Print("Framework Demo module not loaded.")
end
end
function AbstractUI:TestAddonSort()
print("|cff9482c9AbstractUI:|r Testing addon sort button creation...")
local tweaks = self:GetModule("Tweaks", true)
if tweaks then
tweaks:SetupAddonListSorting()
tweaks:CreateAddonSortButton()
else
print("|cffff0000AbstractUI:|r Tweaks module not loaded!")
end
end
-- ============================================================================
-- 3. UTILITY FUNCTIONS
-- ============================================================================
-- Reference resolution for default layouts (effective UI resolution at 2560x1440 with auto-scaling)
AbstractUI.REFERENCE_WIDTH = 2133
AbstractUI.REFERENCE_HEIGHT = 1200
-- Scale position from reference resolution to current resolution
function AbstractUI:ScalePosition(x, y)
local screenWidth = GetScreenWidth()
local screenHeight = GetScreenHeight()
local scaleX = screenWidth / self.REFERENCE_WIDTH
local scaleY = screenHeight / self.REFERENCE_HEIGHT
return x * scaleX, y * scaleY
end
-- Scale all movable frames to current resolution
function AbstractUI:ScaleLayoutToResolution()
local screenWidth = GetScreenWidth()
local screenHeight = GetScreenHeight()
local scaleX = screenWidth / self.REFERENCE_WIDTH
local scaleY = screenHeight / self.REFERENCE_HEIGHT
print("|cff00ff00AbstractUI:|r Scaling layout from " .. self.REFERENCE_WIDTH .. "x" .. self.REFERENCE_HEIGHT .. " to " .. math.floor(screenWidth) .. "x" .. math.floor(screenHeight))
print("|cff00ff00Scale factors:|r X=" .. string.format("%.2f", scaleX) .. " Y=" .. string.format("%.2f", scaleY))
-- Scale Bar module positions
if _G.Bar and _G.Bar.db and _G.Bar.db.profile and _G.Bar.db.profile.bars then
for barID, barData in pairs(_G.Bar.db.profile.bars) do
if barData.x and barData.y then
barData.x = math.floor(barData.x * scaleX)
barData.y = math.floor(barData.y * scaleY)
end
end
end
-- Scale UIButtons position
if _G.UIButtons and _G.UIButtons.db and _G.UIButtons.db.profile and _G.UIButtons.db.profile.position then
local pos = _G.UIButtons.db.profile.position
if pos.x and pos.y then
pos.x = math.floor(pos.x * scaleX)
pos.y = math.floor(pos.y * scaleY)
end
end
-- Scale UnitFrames positions
if _G.UnitFrames and _G.UnitFrames.db and _G.UnitFrames.db.profile then
local uf = _G.UnitFrames.db.profile
for _, frame in pairs({"player", "target", "targettarget", "focus", "pet"}) do
if uf[frame] and uf[frame].position then
local pos = uf[frame].position
if pos.x and pos.y then
pos.x = math.floor(pos.x * scaleX)
pos.y = math.floor(pos.y * scaleY)
end
end
end
end
-- Scale CooldownManager position
if _G.CooldownManager and _G.CooldownManager.db and _G.CooldownManager.db.profile then
local cd = _G.CooldownManager.db.profile
if cd.essential and cd.essential.position then
cd.essential.position.x = math.floor(cd.essential.position.x * scaleX)
cd.essential.position.y = math.floor(cd.essential.position.y * scaleY)
end
if cd.utility and cd.utility.position then
cd.utility.position.x = math.floor(cd.utility.position.x * scaleX)
cd.utility.position.y = math.floor(cd.utility.position.y * scaleY)
end
end
-- Scale Maps position
if _G.Maps and _G.Maps.db and _G.Maps.db.profile then
local maps = _G.Maps.db.profile
if maps.minimap and maps.minimap.position then
local pos = maps.minimap.position
if pos.x and pos.y then
pos.x = math.floor(pos.x * scaleX)
pos.y = math.floor(pos.y * scaleY)
end
end
end
print("|cff00ff00AbstractUI:|r Layout scaled to your resolution!")
StaticPopup_Show("AbstractUI_RELOAD_CONFIRM")
end
function AbstractUI:OpenConfig()
-- Use custom AbstractUI Options Panel (zero AceGUI dependency)
local optionsPanel = _G.AbstractUI_OptionsPanel
if optionsPanel then
local success, err = pcall(function()
optionsPanel:Toggle(self)
end)
if not success then
self:Print("|cffff0000Error opening options panel:|r " .. tostring(err))
end
else
self:Print("Options panel not loaded yet. Please try again in a moment.")
end
end
-- Apply themed backdrop to a frame using ColorPalette
function AbstractUI:ApplyThemedBackdrop(frame)
if not frame then return end
-- Clear any backdrop on the parent frame itself
if frame.SetBackdrop then
frame:SetBackdrop(nil)
end
-- Force recreation of backdrop to apply new settings
if frame.muiBackdrop then
frame.muiBackdrop:Hide()
frame.muiBackdrop:SetParent(nil)
frame.muiBackdrop = nil
end
-- Create new backdrop with correct settings
frame.muiBackdrop = CreateFrame("Frame", nil, frame, "BackdropTemplate")
frame.muiBackdrop:SetAllPoints()
local level = frame:GetFrameLevel()
frame.muiBackdrop:SetFrameLevel(level > 0 and level - 1 or 0)
-- Set backdrop parameters
frame.muiBackdrop:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8X8",
edgeFile = "Interface\\Buttons\\WHITE8X8",
tile = false, tileSize = 0, edgeSize = 1,
insets = { left = 1, right = 1, top = 1, bottom = 1 }
})
-- Use framework colors if available
local ColorPalette = _G.AbstractUI_ColorPalette
if ColorPalette then
local r, g, b, a = ColorPalette:GetColor('panel-bg')
frame.muiBackdrop:SetBackdropColor(r, g, b, a)
frame.muiBackdrop:SetBackdropBorderColor(ColorPalette:GetColor('panel-border'))
else
-- Fallback to database colors
local cfg = self.db.profile.theme
frame.muiBackdrop:SetBackdropColor(unpack(cfg.bgColor))
frame.muiBackdrop:SetBackdropBorderColor(unpack(cfg.borderColor))
end
frame.muiBackdrop:Show()
end
-- ============================================================================
-- 4. OPTIONS TABLE
-- ============================================================================
function AbstractUI:GetThemeOptions()
local ColorPalette = _G.AbstractUI_ColorPalette
if not ColorPalette then
return {
header = {
type = "header",
name = "Theme System Not Loaded",
order = 1,
},
desc = {
type = "description",
name = "The theme system is not yet initialized. Please /reload and try again.",
order = 2,
},
}
end
-- Get available themes
local availableThemes = {}
-- Get all registered themes from ColorPalette
for themeName, _ in pairs(ColorPalette.palettes) do
table.insert(availableThemes, themeName)
end
-- Add custom themes
local customThemes = self.db.profile.theme.customThemes or {}
for themeName, _ in pairs(customThemes) do
if not ColorPalette.palettes[themeName] then
table.insert(availableThemes, themeName)
end
end
-- Function to convert theme names to readable format
local function GetDisplayName(themeName)
-- Add spaces before capital letters (except first)
local display = themeName:gsub("(%u)", " %1"):gsub("^ ", "")
return display
end
-- Sort alphabetically by display name
table.sort(availableThemes, function(a, b)
return GetDisplayName(a) < GetDisplayName(b)
end)
-- Build theme selection dropdown values
local themeValues = {}
for _, name in ipairs(availableThemes) do
themeValues[name] = GetDisplayName(name)
end
local options = {
header = {
type = "header",
name = "Theme Management",
order = 1
},
description = {
type = "description",
name = "Select an existing theme or create your own custom theme by adjusting the colors below.",
order = 2,
fontSize = "medium",
},
activeTheme = {
type = "select",
name = "Active Theme",
desc = "Select which theme to use for the AbstractUI framework.",
order = 3,
values = themeValues,
get = function() return self.db.profile.theme.active end,
set = function(_, value)
-- If it's a custom theme, reload it from the database first
if self.db.profile.theme.customThemes and self.db.profile.theme.customThemes[value] then
local themeData = self.db.profile.theme.customThemes[value]
if ColorPalette then
ColorPalette:RegisterPalette(value, themeData)
end
end
self.db.profile.theme.active = value
if self.FrameFactory then
self.FrameFactory:SetTheme(value)
end
if ColorPalette then
ColorPalette:SetActiveTheme(value)
end
if self.FontKit then
self.FontKit:SetActiveTheme(value)
end
-- Clear temp colors when switching themes
self.tempThemeColors = nil
-- Update color swatches to show new theme colors
self:UpdateThemeColorSwatches()
-- Notify modules that theme has changed
self:SendMessage("AbstractUI_THEME_CHANGED", value)
self:Print("Theme changed to " .. value .. ". Some changes may require a /reload to take full effect.")
-- Refresh options to show current theme colors
end,
},
spacer1 = {
type = "description",
name = " ",
order = 3.5,
},
customThemeHeader = {
type = "header",
name = "Custom Theme Editor",
order = 4
},
customThemeDesc = {
type = "description",
name = "Create a custom theme by adjusting the colors below. These colors are shown from the currently selected theme. To create a custom theme, adjust the colors and then save with a new name.",
order = 5,
fontSize = "medium",
},
customThemeName = {
type = "input",
name = "New Theme Name",
desc = "Enter a name for your custom theme before saving.",
order = 6,
width = "full",
get = function() return self.customThemeName or "" end,
set = function(_, v)
self.customThemeName = v
end,
},
saveCustomTheme = {
type = "execute",
name = "Save Custom Theme",
desc = "Save current color settings as a new custom theme.",
order = 7,
func = function()
self:SaveCustomTheme()
end,
},
deleteCustomTheme = {
type = "execute",
name = "Delete Custom Theme",
desc = "Delete the currently selected custom theme (built-in themes cannot be deleted).",
order = 8,
disabled = function()
local active = self.db.profile.theme.active
local builtInThemes = {
"AbstractUIDefault", "AbstractGlass", "AbstractGreen",
"AbstractTransparent", "AbstractTransparentGold",
"AbstractDeathKnight", "AbstractDemonHunter", "AbstractDruid",
"AbstractEvoker", "AbstractHunter", "AbstractMage",
"AbstractMonk", "AbstractPaladin", "AbstractPriest",
"AbstractRogue", "AbstractShaman", "AbstractWarlock",
"AbstractWarrior", "NeonSciFi"
}
for _, themeName in ipairs(builtInThemes) do
if active == themeName then
return true
end
end
return false
end,
func = function()
self:DeleteCustomTheme()
end,
confirm = function()
return "Are you sure you want to delete the theme '" .. self.db.profile.theme.active .. "'?"
end,
},
spacer2 = {
type = "description",
name = " ",
order = 8.5,
},
colorsHeader = {
type = "header",
name = "Theme Colors",
order = 9
},
colorsDesc = {
type = "description",
name = "Click any color rectangle below to change its color.",
order = 10,
},
colorPanelBg = {
type = "color",
name = "Panel Background",
desc = "Main background color for panels and frames",
order = 11,
width = "inline",
hasAlpha = true,
get = function()
local r, g, b, a = ColorPalette:GetColor('panel-bg')
return {r, g, b, a}
end,
set = function(_, value)
self:SetThemeColor('panel-bg', value[1], value[2], value[3], value[4])
end,
},
colorPanelBorder = {
type = "color",
name = "Panel Border",
desc = "Border color for panels and frames",
order = 12,
width = "inline",
hasAlpha = true,
get = function()
local r, g, b, a = ColorPalette:GetColor('panel-border')
return {r, g, b, a}
end,
set = function(_, value)
self:SetThemeColor('panel-border', value[1], value[2], value[3], value[4])
end,
},
colorAccentPrimary = {
type = "color",
name = "Accent Primary",
desc = "Primary accent color for highlights and emphasis",
order = 13,
width = "inline",
hasAlpha = true,
get = function()
local r, g, b, a = ColorPalette:GetColor('accent-primary')
return {r, g, b, a}
end,
set = function(_, value)
self:SetThemeColor('accent-primary', value[1], value[2], value[3], value[4])
end,
},
colorButtonBg = {
type = "color",
name = "Button Background",
desc = "Background color for buttons",
order = 14,
width = "inline",
hasAlpha = true,
get = function()
local r, g, b, a = ColorPalette:GetColor('button-bg')
return {r, g, b, a}
end,
set = function(_, value)
self:SetThemeColor('button-bg', value[1], value[2], value[3], value[4])
end,
},
colorButtonHover = {
type = "color",
name = "Button Hover",
desc = "Button color when hovering with mouse",
order = 15,
width = "inline",
hasAlpha = true,
get = function()
local r, g, b, a = ColorPalette:GetColor('button-hover')
return {r, g, b, a}
end,
set = function(_, value)
self:SetThemeColor('button-hover', value[1], value[2], value[3], value[4])
end,
},
colorTextPrimary = {
type = "color",
name = "Text Primary",
desc = "Primary text color",
order = 16,
width = "inline",
hasAlpha = true,
get = function()
local r, g, b, a = ColorPalette:GetColor('text-primary')
return {r, g, b, a}
end,
set = function(_, value)
self:SetThemeColor('text-primary', value[1], value[2], value[3], value[4])
end,
},
colorTextSecondary = {
type = "color",
name = "Text Secondary",
desc = "Secondary text color for less prominent text",
order = 17,
width = "inline",
hasAlpha = true,
get = function()
local r, g, b, a = ColorPalette:GetColor('text-secondary')
return {r, g, b, a}
end,
set = function(_, value)
self:SetThemeColor('text-secondary', value[1], value[2], value[3], value[4])
end,
},
colorTabActive = {
type = "color",
name = "Tab Active",
desc = "Color for active/selected tabs",
order = 18,
width = "inline",
hasAlpha = true,
get = function()
local r, g, b, a = ColorPalette:GetColor('tab-active')
return {r, g, b, a}
end,
set = function(_, value)
self:SetThemeColor('tab-active', value[1], value[2], value[3], value[4])
end,
},
spacer2 = {
type = "description",
name = " ",
order = 19,
},
resetThemeColors = {
type = "execute",
name = "Reset to Theme Defaults",
desc = "Reset all color changes back to the original theme defaults",
order = 19.5,
func = function()
-- Clear temp colors
self.tempThemeColors = nil
-- Reload the original palette for the active theme
local ColorPalette = _G.AbstractUI_ColorPalette
if ColorPalette then
local activeTheme = self.db.profile.theme.active
-- Force re-registration from the theme file
self:LoadTheme(activeTheme)
self:UpdateThemeColorSwatches()
end
self:Print("Theme colors reset to defaults")
end,
},
spacer8 = {
type = "description",
name = " ",
order = 19.75,
},
openColorEditor = {
type = "execute",
name = "Open Theme Editor",
desc = "Opens a visual mockup window where you can click on elements to edit their colors",
order = 20,
func = function()
self:OpenColorEditorFrame()
end,
},
}
return options
end
function AbstractUI:SetThemeColor(colorKey, r, g, b, a)
local ColorPalette = _G.AbstractUI_ColorPalette
if not ColorPalette then return end
-- Store in temp colors
if not self.tempThemeColors then
self.tempThemeColors = {}
end
self.tempThemeColors[colorKey] = {r = r, g = g, b = b, a = a}
-- Apply the color immediately to preview
local activeTheme = self.db.profile.theme.active
local fullPalette = ColorPalette.palettes[activeTheme]
if fullPalette then
-- Create a copy and update with temp colors
local updatedPalette = {}
for k, v in pairs(fullPalette) do
updatedPalette[k] = v
end
for tempKey, tempColor in pairs(self.tempThemeColors) do
updatedPalette[tempKey] = tempColor
end
-- Re-register the theme with updated colors
ColorPalette:RegisterPalette(activeTheme, updatedPalette)
end
-- Update color swatch frames if they exist
self:UpdateThemeColorSwatches()
end
function AbstractUI:OpenColorPickerForThemeColor(colorKey, colorName)
local ColorPalette = _G.AbstractUI_ColorPalette
if not ColorPalette then
self:Print("Color system not initialized.")
return
end
local r, g, b, a = ColorPalette:GetColor(colorKey)
ColorPickerFrame:SetupColorPickerAndShow({
r = r, g = g, b = b,
opacity = a,
hasOpacity = true,
swatchFunc = function()
local nr, ng, nb = ColorPickerFrame:GetColorRGB()
local na = ColorPickerFrame:GetColorAlpha()
-- Store in temp colors
if not self.tempThemeColors then
self.tempThemeColors = {}
end
self.tempThemeColors[colorKey] = {r = nr, g = ng, b = nb, a = na}
-- Apply the color immediately to preview
local activeTheme = self.db.profile.theme.active
local fullPalette = ColorPalette.palettes[activeTheme]
if fullPalette then
-- Create a copy and update with temp colors
local updatedPalette = {}
for k, v in pairs(fullPalette) do
updatedPalette[k] = v
end
for tempKey, tempColor in pairs(self.tempThemeColors) do
updatedPalette[tempKey] = tempColor
end
-- Re-register the theme with updated colors
ColorPalette:RegisterPalette(activeTheme, updatedPalette)
end
-- Update color swatch frames if they exist
self:UpdateThemeColorSwatches()
end,
cancelFunc = function()
-- Restore original color
if not self.tempThemeColors then
self.tempThemeColors = {}
end
self.tempThemeColors[colorKey] = {r = r, g = g, b = b, a = a}
local activeTheme = self.db.profile.theme.active
local fullPalette = ColorPalette.palettes[activeTheme]
if fullPalette then
ColorPalette:RegisterPalette(activeTheme, fullPalette)
end
self:UpdateThemeColorSwatches()
end,
})
end
function AbstractUI:UpdateThemeColorSwatches()
-- This will update the color swatch frames when they're created
if self.themeColorSwatches then
local ColorPalette = _G.AbstractUI_ColorPalette
if not ColorPalette then return end
for colorKey, swatchData in pairs(self.themeColorSwatches) do
if swatchData and swatchData.texture then
-- Check if there's a temp color for this key (unsaved changes)
local r, g, b, a
if self.tempThemeColors and self.tempThemeColors[colorKey] then
local tempColor = self.tempThemeColors[colorKey]
r, g, b, a = tempColor.r, tempColor.g, tempColor.b, tempColor.a
else
-- Use the color from the active theme
r, g, b, a = ColorPalette:GetColor(colorKey)
end
swatchData.texture:SetColorTexture(r, g, b, a)
end
end
end
end
function AbstractUI:OpenColorEditorFrame()
-- Create or show the color editor frame
if self.colorEditorFrame then
self.colorEditorFrame:Show()
return
end
local ColorPalette = _G.AbstractUI_ColorPalette
local FontKit = _G.AbstractUI_FontKit
if not ColorPalette or not FontKit then
self:Print("Framework not initialized.")
return
end
-- Create main frame styled like a real AbstractUI window
local frame = CreateFrame("Frame", "AbstractUI_ColorEditorFrame", UIParent, "BackdropTemplate")
frame:SetSize(800, 600)
frame:SetPoint("CENTER")
frame:SetFrameStrata("DIALOG")
frame:EnableMouse(true)
frame:SetMovable(true)
-- Function to get current color
local function GetCurrentColor(key)
local color = self.tempThemeColors and self.tempThemeColors[key]
if color then
return color.r, color.g, color.b, color.a
end
return ColorPalette:GetColor(key)
end
-- Function to update frame colors
local function UpdateFrameColors()
-- Update main frame
frame:SetBackdropColor(GetCurrentColor("panel-bg"))
frame:SetBackdropBorderColor(GetCurrentColor("panel-border"))
-- Update title bar
if frame.titleBg then
frame.titleBg:SetColorTexture(GetCurrentColor("panel-bg"))
end
-- Update inner panel
if frame.innerPanel then
frame.innerPanel:SetBackdropColor(GetCurrentColor("panel-bg"))
frame.innerPanel:SetBackdropBorderColor(GetCurrentColor("accent-primary"))
end
-- Update buttons
for _, btn in ipairs(frame.mockButtons or {}) do
btn:SetBackdropColor(GetCurrentColor("button-bg"))
btn:SetBackdropBorderColor(GetCurrentColor("accent-primary"))
end
-- Update tabs
for i, tab in ipairs(frame.mockTabs or {}) do
if i == 2 then
tab:SetBackdropColor(GetCurrentColor("tab-active"))
else
tab:SetBackdropColor(GetCurrentColor("button-bg"))
end
tab:SetBackdropBorderColor(GetCurrentColor("accent-primary"))
end
-- Update text
if frame.titleText then
frame.titleText:SetTextColor(GetCurrentColor("text-primary"))
end
if frame.headerText then
frame.headerText:SetTextColor(GetCurrentColor("text-primary"))
end
if frame.descText then
frame.descText:SetTextColor(GetCurrentColor("text-secondary"))
end
for _, btn in ipairs(frame.mockButtons or {}) do
if btn.text then
btn.text:SetTextColor(GetCurrentColor("text-primary"))
end
end
for _, tab in ipairs(frame.mockTabs or {}) do
if tab.text then
tab.text:SetTextColor(GetCurrentColor("text-primary"))
end
end
end
-- Apply backdrop styled like settings window
frame:SetBackdrop({
bgFile = "Interface\\Buttons\\WHITE8X8",
edgeFile = "Interface\\Buttons\\WHITE8X8",
tile = false,
edgeSize = 1,
insets = { left = 1, right = 1, top = 1, bottom = 1 }
})
-- Title bar background (used for dragging, not clickable for color)
local titleBg = frame:CreateTexture(nil, "ARTWORK")
titleBg:SetPoint("TOPLEFT", 0, 0)
titleBg:SetPoint("TOPRIGHT", 0, 0)
titleBg:SetHeight(60)
frame.titleBg = titleBg
-- Make title bar draggable (not clickable for color picker)
local titleBar = CreateFrame("Frame", nil, frame)
titleBar:SetPoint("TOPLEFT", 0, 0)
titleBar:SetPoint("TOPRIGHT", 0, 0)
titleBar:SetHeight(60)
titleBar:EnableMouse(true)
titleBar:RegisterForDrag("LeftButton")
titleBar:SetScript("OnDragStart", function()
frame:StartMoving()
end)
titleBar:SetScript("OnDragStop", function()
frame:StopMovingOrSizing()
end)
-- Title text
local title = FontKit:CreateFontString(frame, "title", "large")