forked from EllesmereGaming/EllesmereUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEllesmereUI_Profiles.lua
More file actions
2015 lines (1864 loc) · 89.2 KB
/
EllesmereUI_Profiles.lua
File metadata and controls
2015 lines (1864 loc) · 89.2 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
-------------------------------------------------------------------------------
-- EllesmereUI_Profiles.lua
--
-- Global profile system: import/export, presets, spec assignment.
-- Handles serialization (LibDeflate + custom serializer) and profile
-- management across all EllesmereUI addons.
--
-- Load order (via TOC):
-- 1. Libs/LibDeflate.lua
-- 2. EllesmereUI_Lite.lua
-- 3. EllesmereUI.lua
-- 4. EllesmereUI_Widgets.lua
-- 5. EllesmereUI_Presets.lua
-- 6. EllesmereUI_Profiles.lua -- THIS FILE
-------------------------------------------------------------------------------
local EllesmereUI = _G.EllesmereUI
-------------------------------------------------------------------------------
-- LibDeflate reference (loaded before us via TOC)
-- LibDeflate registers via LibStub, not as a global, so use LibStub to get it.
-------------------------------------------------------------------------------
local LibDeflate = LibStub and LibStub("LibDeflate", true) or _G.LibDeflate
-------------------------------------------------------------------------------
-- Addon registry: maps addon folder names to their DB accessor info.
-- Each entry: { svName, globalName, isFlat }
-- svName = SavedVariables name (e.g. "EllesmereUINameplatesDB")
-- globalName = global variable holding the AceDB object (e.g. "_ECME_AceDB")
-- isFlat = true if the DB is a flat table (Nameplates), false if AceDB
--
-- Order matters for UI display.
-------------------------------------------------------------------------------
local ADDON_DB_MAP = {
{ folder = "EllesmereUINameplates", display = "Nameplates", svName = "EllesmereUINameplatesDB", globalName = nil, isFlat = true },
{ folder = "EllesmereUIActionBars", display = "Action Bars", svName = "EllesmereUIActionBarsDB", globalName = nil, isFlat = false },
{ folder = "EllesmereUIUnitFrames", display = "Unit Frames", svName = "EllesmereUIUnitFramesDB", globalName = nil, isFlat = false },
{ folder = "EllesmereUICooldownManager", display = "Cooldown Manager", svName = "EllesmereUICooldownManagerDB", globalName = "_ECME_AceDB", isFlat = false },
{ folder = "EllesmereUIResourceBars", display = "Resource Bars", svName = "EllesmereUIResourceBarsDB", globalName = "_ERB_AceDB", isFlat = false },
{ folder = "EllesmereUIAuraBuffReminders", display = "AuraBuff Reminders", svName = "EllesmereUIAuraBuffRemindersDB", globalName = "_EABR_AceDB", isFlat = false },
{ folder = "EllesmereUICursor", display = "Cursor", svName = "EllesmereUICursorDB", globalName = "_ECL_AceDB", isFlat = false },
}
EllesmereUI._ADDON_DB_MAP = ADDON_DB_MAP
-------------------------------------------------------------------------------
-- Serializer: Lua table <-> string (no AceSerializer dependency)
-- Handles: string, number, boolean, nil, table (nested), color tables
-------------------------------------------------------------------------------
local Serializer = {}
local function SerializeValue(v, parts)
local t = type(v)
if t == "string" then
parts[#parts + 1] = "s"
-- Length-prefixed to avoid delimiter issues
parts[#parts + 1] = #v
parts[#parts + 1] = ":"
parts[#parts + 1] = v
elseif t == "number" then
parts[#parts + 1] = "n"
parts[#parts + 1] = tostring(v)
parts[#parts + 1] = ";"
elseif t == "boolean" then
parts[#parts + 1] = v and "T" or "F"
elseif t == "nil" then
parts[#parts + 1] = "N"
elseif t == "table" then
parts[#parts + 1] = "{"
-- Serialize array part first (integer keys 1..n)
local n = #v
for i = 1, n do
SerializeValue(v[i], parts)
end
-- Then hash part (non-integer keys, or integer keys > n)
for k, val in pairs(v) do
local kt = type(k)
if kt == "number" and k >= 1 and k <= n and k == math.floor(k) then
-- Already serialized in array part
else
parts[#parts + 1] = "K"
SerializeValue(k, parts)
SerializeValue(val, parts)
end
end
parts[#parts + 1] = "}"
end
end
function Serializer.Serialize(tbl)
local parts = {}
SerializeValue(tbl, parts)
return table.concat(parts)
end
-- Deserializer
local function DeserializeValue(str, pos)
local tag = str:sub(pos, pos)
if tag == "s" then
-- Find the colon after the length
local colonPos = str:find(":", pos + 1, true)
if not colonPos then return nil, pos end
local len = tonumber(str:sub(pos + 1, colonPos - 1))
if not len then return nil, pos end
local val = str:sub(colonPos + 1, colonPos + len)
return val, colonPos + len + 1
elseif tag == "n" then
local semi = str:find(";", pos + 1, true)
if not semi then return nil, pos end
return tonumber(str:sub(pos + 1, semi - 1)), semi + 1
elseif tag == "T" then
return true, pos + 1
elseif tag == "F" then
return false, pos + 1
elseif tag == "N" then
return nil, pos + 1
elseif tag == "{" then
local tbl = {}
local idx = 1
local p = pos + 1
while p <= #str do
local c = str:sub(p, p)
if c == "}" then
return tbl, p + 1
elseif c == "K" then
-- Key-value pair
local key, val
key, p = DeserializeValue(str, p + 1)
val, p = DeserializeValue(str, p)
if key ~= nil then
tbl[key] = val
end
else
-- Array element
local val
val, p = DeserializeValue(str, p)
tbl[idx] = val
idx = idx + 1
end
end
return tbl, p
end
return nil, pos + 1
end
function Serializer.Deserialize(str)
if not str or #str == 0 then return nil end
local val, _ = DeserializeValue(str, 1)
return val
end
EllesmereUI._Serializer = Serializer
-------------------------------------------------------------------------------
-- Deep copy utility
-------------------------------------------------------------------------------
local function DeepCopy(src)
if type(src) ~= "table" then return src end
local copy = {}
for k, v in pairs(src) do
copy[k] = DeepCopy(v)
end
return copy
end
local function DeepMerge(dst, src)
for k, v in pairs(src) do
if type(v) == "table" and type(dst[k]) == "table" then
DeepMerge(dst[k], v)
else
dst[k] = DeepCopy(v)
end
end
end
EllesmereUI._DeepCopy = DeepCopy
-------------------------------------------------------------------------------
-- CDM spell-layout fields: excluded from main profile snapshots/applies.
-- These are managed exclusively by the CDM Spell Profile export/import.
-------------------------------------------------------------------------------
local CDM_SPELL_KEYS = {
trackedSpells = true,
extraSpells = true,
removedSpells = true,
dormantSpells = true,
customSpells = true,
}
--- Deep-copy a CDM profile, stripping only spell-layout data.
--- Removes per-bar spell lists and specProfiles (CDM spell profiles).
--- Positions (cdmBarPositions, tbbPositions) ARE included in the copy
--- because they belong to the visual/layout profile, not spell assignments.
local function DeepCopyCDMStyleOnly(src)
if type(src) ~= "table" then return src end
local copy = {}
for k, v in pairs(src) do
if k == "specProfiles" then
-- Omit entirely -- spell-layout only
elseif k == "cdmBars" and type(v) == "table" then
-- Deep-copy cdmBars but strip spell fields from each bar entry
local barsCopy = {}
for bk, bv in pairs(v) do
if bk == "bars" and type(bv) == "table" then
local barList = {}
for i, bar in ipairs(bv) do
local barCopy = {}
for fk, fv in pairs(bar) do
if not CDM_SPELL_KEYS[fk] then
barCopy[fk] = DeepCopy(fv)
end
end
barList[i] = barCopy
end
barsCopy[bk] = barList
else
barsCopy[bk] = DeepCopy(bv)
end
end
copy[k] = barsCopy
else
copy[k] = DeepCopy(v)
end
end
return copy
end
--- Merge a CDM style-only snapshot back into the live profile,
--- preserving all existing spell-layout fields.
--- Positions (cdmBarPositions, tbbPositions) ARE applied from the snapshot
--- because they belong to the visual/layout profile.
local function ApplyCDMStyleOnly(profile, snap)
-- Apply top-level non-spell keys
for k, v in pairs(snap) do
if k == "specProfiles" then
-- Never overwrite specProfiles from a style snapshot
elseif k == "_capturedOnce" then
-- Never overwrite -- once captured, always captured
elseif k == "cdmBars" and type(v) == "table" then
if not profile.cdmBars then profile.cdmBars = {} end
for bk, bv in pairs(v) do
if bk == "bars" and type(bv) == "table" then
if not profile.cdmBars.bars then profile.cdmBars.bars = {} end
for i, barSnap in ipairs(bv) do
if not profile.cdmBars.bars[i] then
profile.cdmBars.bars[i] = {}
end
local liveBar = profile.cdmBars.bars[i]
for fk, fv in pairs(barSnap) do
if not CDM_SPELL_KEYS[fk] then
liveBar[fk] = DeepCopy(fv)
end
end
end
else
profile.cdmBars[bk] = DeepCopy(bv)
end
end
else
profile[k] = DeepCopy(v)
end
end
end
-------------------------------------------------------------------------------
-- Profile DB helpers
-- Profiles are stored in EllesmereUIDB.profiles = { [name] = profileData }
-- profileData = {
-- addons = { [folderName] = <snapshot of that addon's profile table> },
-- fonts = <snapshot of EllesmereUIDB.fonts>,
-- customColors = <snapshot of EllesmereUIDB.customColors>,
-- }
-- EllesmereUIDB.activeProfile = "Custom" (name of active profile)
-- EllesmereUIDB.profileOrder = { "Custom", ... }
-- EllesmereUIDB.specProfiles = { [specID] = "profileName" }
-------------------------------------------------------------------------------
local function GetProfilesDB()
if not EllesmereUIDB then EllesmereUIDB = {} end
if not EllesmereUIDB.profiles then EllesmereUIDB.profiles = {} end
if not EllesmereUIDB.profileOrder then EllesmereUIDB.profileOrder = {} end
if not EllesmereUIDB.specProfiles then EllesmereUIDB.specProfiles = {} end
return EllesmereUIDB
end
--- Check if an addon is loaded
local function IsAddonLoaded(name)
if C_AddOns and C_AddOns.IsAddOnLoaded then return C_AddOns.IsAddOnLoaded(name) end
if _G.IsAddOnLoaded then return _G.IsAddOnLoaded(name) end
return false
end
--- Get the live profile table for an addon
local function GetAddonProfile(entry)
if entry.isFlat then
-- Flat DB (Nameplates): the global IS the profile
return _G[entry.svName]
else
-- AceDB-style: profile lives under .profile
local aceDB = entry.globalName and _G[entry.globalName]
if aceDB and aceDB.profile then return aceDB.profile end
-- Fallback for Lite.NewDB addons: look up the current character's profile
local raw = _G[entry.svName]
if raw and raw.profiles then
-- Determine the profile name for this character
local profileName = "Default"
if raw.profileKeys then
local charKey = UnitName("player") .. " - " .. GetRealmName()
profileName = raw.profileKeys[charKey] or "Default"
end
if raw.profiles[profileName] then
return raw.profiles[profileName]
end
end
return nil
end
end
--- Snapshot the current state of all loaded addons into a profile data table
function EllesmereUI.SnapshotAllAddons()
local data = { addons = {} }
for _, entry in ipairs(ADDON_DB_MAP) do
if IsAddonLoaded(entry.folder) then
local profile = GetAddonProfile(entry)
if profile then
if entry.folder == "EllesmereUICooldownManager" then
data.addons[entry.folder] = DeepCopyCDMStyleOnly(profile)
else
data.addons[entry.folder] = DeepCopy(profile)
end
end
end
end
-- Include global font and color settings
data.fonts = DeepCopy(EllesmereUI.GetFontsDB())
local cc = EllesmereUI.GetCustomColorsDB()
data.customColors = DeepCopy(cc)
return data
end
--- Snapshot a single addon's profile
function EllesmereUI.SnapshotAddon(folderName)
for _, entry in ipairs(ADDON_DB_MAP) do
if entry.folder == folderName and IsAddonLoaded(folderName) then
local profile = GetAddonProfile(entry)
if profile then return DeepCopy(profile) end
end
end
return nil
end
--- Snapshot multiple addons (for multi-addon export)
function EllesmereUI.SnapshotAddons(folderList)
local data = { addons = {} }
for _, folderName in ipairs(folderList) do
for _, entry in ipairs(ADDON_DB_MAP) do
if entry.folder == folderName and IsAddonLoaded(folderName) then
local profile = GetAddonProfile(entry)
if profile then
if folderName == "EllesmereUICooldownManager" then
data.addons[folderName] = DeepCopyCDMStyleOnly(profile)
else
data.addons[folderName] = DeepCopy(profile)
end
end
break
end
end
end
-- Always include fonts and colors
data.fonts = DeepCopy(EllesmereUI.GetFontsDB())
data.customColors = DeepCopy(EllesmereUI.GetCustomColorsDB())
return data
end
--- Apply a profile data table to all loaded addons
function EllesmereUI.ApplyProfileData(profileData)
if not profileData or not profileData.addons then return end
for _, entry in ipairs(ADDON_DB_MAP) do
local snap = profileData.addons[entry.folder]
if snap and IsAddonLoaded(entry.folder) then
local profile = GetAddonProfile(entry)
if profile then
if entry.folder == "EllesmereUICooldownManager" then
-- Style-only: preserve all spell-layout fields
ApplyCDMStyleOnly(profile, snap)
elseif entry.isFlat then
-- Flat DB: wipe and copy
local db = _G[entry.svName]
if db then
for k in pairs(db) do
if not k:match("^_") then
db[k] = nil
end
end
for k, v in pairs(snap) do
if not k:match("^_") then
db[k] = DeepCopy(v)
end
end
end
else
-- AceDB: wipe profile and copy
for k in pairs(profile) do profile[k] = nil end
for k, v in pairs(snap) do
profile[k] = DeepCopy(v)
end
end
end
end
end
-- Apply fonts and colors
if profileData.fonts then
local fontsDB = EllesmereUI.GetFontsDB()
for k in pairs(fontsDB) do fontsDB[k] = nil end
for k, v in pairs(profileData.fonts) do
fontsDB[k] = DeepCopy(v)
end
end
if profileData.customColors then
local colorsDB = EllesmereUI.GetCustomColorsDB()
for k in pairs(colorsDB) do colorsDB[k] = nil end
for k, v in pairs(profileData.customColors) do
colorsDB[k] = DeepCopy(v)
end
end
end
--- Trigger live refresh on all loaded addons after a profile apply
function EllesmereUI.RefreshAllAddons()
-- ResourceBars
if _G._ERB_Apply then _G._ERB_Apply() end
-- CDM
if _G._ECME_Apply then _G._ECME_Apply() end
-- Cursor (main dot + trail + GCD/cast circles)
if _G._ECL_Apply then _G._ECL_Apply() end
if _G._ECL_ApplyTrail then _G._ECL_ApplyTrail() end
if _G._ECL_ApplyGCDCircle then _G._ECL_ApplyGCDCircle() end
if _G._ECL_ApplyCastCircle then _G._ECL_ApplyCastCircle() end
-- AuraBuffReminders
if _G._EABR_RequestRefresh then _G._EABR_RequestRefresh() end
-- ActionBars: use the full apply which includes bar positions
if _G._EAB_Apply then _G._EAB_Apply() end
-- UnitFrames
if _G._EUF_ReloadFrames then _G._EUF_ReloadFrames() end
-- Nameplates
if _G._ENP_RefreshAllSettings then _G._ENP_RefreshAllSettings() end
-- Global class/power colors (updates oUF, nameplates, raid frames)
if EllesmereUI.ApplyColorsToOUF then EllesmereUI.ApplyColorsToOUF() end
end
--- Snapshot current font settings; returns a function that checks if they
--- changed and shows a reload popup if so.
function EllesmereUI.CaptureFontState()
local fontsDB = EllesmereUI.GetFontsDB()
local prevFont = fontsDB.global
local prevOutline = fontsDB.outlineMode
return function()
local cur = EllesmereUI.GetFontsDB()
if cur.global ~= prevFont or cur.outlineMode ~= prevOutline then
EllesmereUI:ShowConfirmPopup({
title = "Reload Required",
message = "Font changed. A UI reload is needed to apply the new font.",
confirmText = "Reload Now",
cancelText = "Later",
onConfirm = function() ReloadUI() end,
})
end
end
end
--- Apply a partial profile (specific addons only) by merging into active
function EllesmereUI.ApplyPartialProfile(profileData)
if not profileData or not profileData.addons then return end
for folderName, snap in pairs(profileData.addons) do
for _, entry in ipairs(ADDON_DB_MAP) do
if entry.folder == folderName and IsAddonLoaded(folderName) then
local profile = GetAddonProfile(entry)
if profile then
if folderName == "EllesmereUICooldownManager" then
ApplyCDMStyleOnly(profile, snap)
elseif entry.isFlat then
local db = _G[entry.svName]
if db then
for k, v in pairs(snap) do
if not k:match("^_") then
db[k] = DeepCopy(v)
end
end
end
else
for k, v in pairs(snap) do
profile[k] = DeepCopy(v)
end
end
end
break
end
end
end
-- Always apply fonts and colors if present
if profileData.fonts then
local fontsDB = EllesmereUI.GetFontsDB()
for k, v in pairs(profileData.fonts) do
fontsDB[k] = DeepCopy(v)
end
end
if profileData.customColors then
local colorsDB = EllesmereUI.GetCustomColorsDB()
for k, v in pairs(profileData.customColors) do
colorsDB[k] = DeepCopy(v)
end
end
end
-------------------------------------------------------------------------------
-- Export / Import
-- Format: !EUI_<base64 encoded compressed serialized data>
-- The data table contains:
-- { version = 1, type = "full"|"partial", data = profileData }
-------------------------------------------------------------------------------
local EXPORT_PREFIX = "!EUI_"
local CDM_LAYOUT_PREFIX = "!EUICDM_"
function EllesmereUI.ExportProfile(profileName)
local db = GetProfilesDB()
local profileData = db.profiles[profileName]
if not profileData then return nil end
local payload = { version = 1, type = "full", data = profileData }
local serialized = Serializer.Serialize(payload)
if not LibDeflate then return nil end
local compressed = LibDeflate:CompressDeflate(serialized)
local encoded = LibDeflate:EncodeForPrint(compressed)
return EXPORT_PREFIX .. encoded
end
function EllesmereUI.ExportAddons(folderList)
local profileData = EllesmereUI.SnapshotAddons(folderList)
local payload = { version = 1, type = "partial", data = profileData }
local serialized = Serializer.Serialize(payload)
if not LibDeflate then return nil end
local compressed = LibDeflate:CompressDeflate(serialized)
local encoded = LibDeflate:EncodeForPrint(compressed)
return EXPORT_PREFIX .. encoded
end
--- Export CDM spell profiles for selected spec keys.
--- specKeys = { "250", "251", ... } (specID strings)
function EllesmereUI.ExportCDMSpellLayouts(specKeys)
local cdmEntry
for _, e in ipairs(ADDON_DB_MAP) do
if e.folder == "EllesmereUICooldownManager" then cdmEntry = e; break end
end
if not cdmEntry then return nil end
local profile = GetAddonProfile(cdmEntry)
if not profile or not profile.specProfiles then return nil end
local exported = {}
for _, key in ipairs(specKeys) do
if profile.specProfiles[key] then
exported[key] = DeepCopy(profile.specProfiles[key])
end
end
if not next(exported) then return nil end
local payload = { version = 1, type = "cdm_spells", data = exported }
local serialized = Serializer.Serialize(payload)
if not LibDeflate then return nil end
local compressed = LibDeflate:CompressDeflate(serialized)
local encoded = LibDeflate:EncodeForPrint(compressed)
return EXPORT_PREFIX .. encoded
end
--- Import CDM spell profiles from a string. Overwrites matching spec profiles.
function EllesmereUI.ImportCDMSpellLayouts(importStr)
-- Detect profile strings pasted into the wrong import
if importStr and importStr:sub(1, #EXPORT_PREFIX) == EXPORT_PREFIX then
return false, "This is a UI Profile string, not a CDM Spell Profile. Use the Profile import instead."
end
local layoutData, err = EllesmereUI.DecodeCDMLayoutString(importStr)
if not layoutData then return false, err end
local cdmEntry
for _, e in ipairs(ADDON_DB_MAP) do
if e.folder == "EllesmereUICooldownManager" then cdmEntry = e; break end
end
if not cdmEntry then return false, "Cooldown Manager not found" end
local profile = GetAddonProfile(cdmEntry)
if not profile then return false, "Cooldown Manager profile not available" end
-- Apply bar spell assignments from the decoded layout
if not profile.cdmBars then profile.cdmBars = {} end
if not profile.cdmBars.bars then profile.cdmBars.bars = {} end
if layoutData.bars then
for _, importedBar in ipairs(layoutData.bars) do
-- Find matching bar by key, or append
local found = false
for _, existingBar in ipairs(profile.cdmBars.bars) do
if existingBar.key == importedBar.key then
-- Overwrite spell assignments only
existingBar.trackedSpells = importedBar.trackedSpells and DeepCopy(importedBar.trackedSpells) or existingBar.trackedSpells
existingBar.extraSpells = importedBar.extraSpells and DeepCopy(importedBar.extraSpells) or existingBar.extraSpells
existingBar.removedSpells = importedBar.removedSpells and DeepCopy(importedBar.removedSpells) or existingBar.removedSpells
existingBar.dormantSpells = importedBar.dormantSpells and DeepCopy(importedBar.dormantSpells) or existingBar.dormantSpells
existingBar.customSpells = importedBar.customSpells and DeepCopy(importedBar.customSpells) or existingBar.customSpells
found = true
break
end
end
if not found then
profile.cdmBars.bars[#profile.cdmBars.bars + 1] = DeepCopy(importedBar)
end
end
end
-- Apply tracked buff bar assignments
if layoutData.buffBars then
if not profile.trackedBuffBars then profile.trackedBuffBars = {} end
profile.trackedBuffBars.bars = DeepCopy(layoutData.buffBars)
end
return true, nil, (layoutData.bars and #layoutData.bars or 0)
end
--- Get a list of saved CDM spec profile keys with display info.
--- Returns: { { key="250", name="Blood", icon=... }, ... }
function EllesmereUI.GetCDMSpecProfiles()
local cdmEntry
for _, e in ipairs(ADDON_DB_MAP) do
if e.folder == "EllesmereUICooldownManager" then cdmEntry = e; break end
end
if not cdmEntry then return {} end
local profile = GetAddonProfile(cdmEntry)
if not profile or not profile.specProfiles then return {} end
local result = {}
for specKey in pairs(profile.specProfiles) do
local specID = tonumber(specKey)
local name, icon
if specID and specID > 0 and GetSpecializationInfoByID then
local _, sName, _, sIcon = GetSpecializationInfoByID(specID)
name = sName
icon = sIcon
end
result[#result + 1] = {
key = specKey,
name = name or ("Spec " .. specKey),
icon = icon,
}
end
table.sort(result, function(a, b) return a.key < b.key end)
return result
end
function EllesmereUI.ExportCurrentProfile()
local profileData = EllesmereUI.SnapshotAllAddons()
local payload = { version = 1, type = "full", data = profileData }
local serialized = Serializer.Serialize(payload)
if not LibDeflate then return nil end
local compressed = LibDeflate:CompressDeflate(serialized)
local encoded = LibDeflate:EncodeForPrint(compressed)
return EXPORT_PREFIX .. encoded
end
function EllesmereUI.DecodeImportString(importStr)
if not importStr or #importStr < 5 then return nil, "Invalid string" end
-- Detect CDM layout strings pasted into the wrong import
if importStr:sub(1, #CDM_LAYOUT_PREFIX) == CDM_LAYOUT_PREFIX then
return nil, "This is a CDM bar layout string, not a profile string."
end
if importStr:sub(1, #EXPORT_PREFIX) ~= EXPORT_PREFIX then
return nil, "Not a valid EllesmereUI string. Make sure you copied the entire string."
end
if not LibDeflate then return nil, "LibDeflate not available" end
local encoded = importStr:sub(#EXPORT_PREFIX + 1)
local decoded = LibDeflate:DecodeForPrint(encoded)
if not decoded then return nil, "Failed to decode string" end
local decompressed = LibDeflate:DecompressDeflate(decoded)
if not decompressed then return nil, "Failed to decompress data" end
local payload = Serializer.Deserialize(decompressed)
if not payload or type(payload) ~= "table" then
return nil, "Failed to deserialize data"
end
if payload.version ~= 1 then
return nil, "Unsupported profile version"
end
return payload, nil
end
--- Reset class-dependent fill colors in Resource Bars after a profile import.
--- The exporter's class color may be baked into fillR/fillG/fillB; this
--- resets them to the importer's own class/power colors and clears
--- customColored so the bars use runtime class color lookup.
local function FixupImportedClassColors()
local rbEntry
for _, e in ipairs(ADDON_DB_MAP) do
if e.folder == "EllesmereUIResourceBars" then rbEntry = e; break end
end
if not rbEntry or not IsAddonLoaded(rbEntry.folder) then return end
local profile = GetAddonProfile(rbEntry)
if not profile then return end
local _, classFile = UnitClass("player")
-- CLASS_COLORS and POWER_COLORS are local to ResourceBars, so we
-- use the same lookup the addon uses at init time.
local classColors = EllesmereUI.CLASS_COLOR_MAP
local cc = classColors and classColors[classFile]
-- Health bar: reset to importer's class color
if profile.health and not profile.health.darkTheme then
profile.health.customColored = false
if cc then
profile.health.fillR = cc.r
profile.health.fillG = cc.g
profile.health.fillB = cc.b
end
end
end
--- Import a profile string. Returns: success, errorMsg
--- The caller must provide a name for the new profile.
function EllesmereUI.ImportProfile(importStr, profileName)
local payload, err = EllesmereUI.DecodeImportString(importStr)
if not payload then return false, err end
local db = GetProfilesDB()
if payload.type == "cdm_spells" then
return false, "This is a CDM Spell Profile string. Use the CDM Spell Profile import instead."
end
if payload.type == "full" then
-- Full profile: store as a new named profile
db.profiles[profileName] = DeepCopy(payload.data)
-- Add to order if not present
local found = false
for _, n in ipairs(db.profileOrder) do
if n == profileName then found = true; break end
end
if not found then
table.insert(db.profileOrder, 1, profileName)
end
-- Make it the active profile
db.activeProfile = profileName
EllesmereUI.ApplyProfileData(payload.data)
FixupImportedClassColors()
-- Re-snapshot after fixup so the stored profile has correct colors
db.profiles[profileName] = EllesmereUI.SnapshotAllAddons()
return true, nil
elseif payload.type == "partial" then
-- Partial: copy current profile, overwrite the imported addons
local currentSnap = EllesmereUI.SnapshotAllAddons()
-- Merge imported addon data over current
if payload.data and payload.data.addons then
for folder, snap in pairs(payload.data.addons) do
currentSnap.addons[folder] = DeepCopy(snap)
end
end
-- Merge fonts/colors if present
if payload.data.fonts then
currentSnap.fonts = DeepCopy(payload.data.fonts)
end
if payload.data.customColors then
currentSnap.customColors = DeepCopy(payload.data.customColors)
end
-- Store as new profile
db.profiles[profileName] = currentSnap
local found = false
for _, n in ipairs(db.profileOrder) do
if n == profileName then found = true; break end
end
if not found then
table.insert(db.profileOrder, 1, profileName)
end
db.activeProfile = profileName
EllesmereUI.ApplyProfileData(currentSnap)
FixupImportedClassColors()
-- Re-snapshot after fixup
db.profiles[profileName] = EllesmereUI.SnapshotAllAddons()
return true, nil
end
return false, "Unknown profile type"
end
-------------------------------------------------------------------------------
-- Profile management
-------------------------------------------------------------------------------
function EllesmereUI.SaveCurrentAsProfile(name)
local db = GetProfilesDB()
db.profiles[name] = EllesmereUI.SnapshotAllAddons()
local found = false
for _, n in ipairs(db.profileOrder) do
if n == name then found = true; break end
end
if not found then
table.insert(db.profileOrder, 1, name)
end
db.activeProfile = name
end
function EllesmereUI.DeleteProfile(name)
local db = GetProfilesDB()
db.profiles[name] = nil
for i, n in ipairs(db.profileOrder) do
if n == name then table.remove(db.profileOrder, i); break end
end
-- Clean up spec assignments
for specID, pName in pairs(db.specProfiles) do
if pName == name then db.specProfiles[specID] = nil end
end
-- If deleted profile was active, fall back to Custom
if db.activeProfile == name then
db.activeProfile = "Custom"
end
end
function EllesmereUI.RenameProfile(oldName, newName)
local db = GetProfilesDB()
if not db.profiles[oldName] then return end
db.profiles[newName] = db.profiles[oldName]
db.profiles[oldName] = nil
for i, n in ipairs(db.profileOrder) do
if n == oldName then db.profileOrder[i] = newName; break end
end
for specID, pName in pairs(db.specProfiles) do
if pName == oldName then db.specProfiles[specID] = newName end
end
if db.activeProfile == oldName then
db.activeProfile = newName
end
end
function EllesmereUI.SwitchProfile(name)
local db = GetProfilesDB()
local profileData = db.profiles[name]
if not profileData then return end
db.activeProfile = name
EllesmereUI.ApplyProfileData(profileData)
end
function EllesmereUI.GetActiveProfileName()
local db = GetProfilesDB()
return db.activeProfile or "Custom"
end
function EllesmereUI.GetProfileList()
local db = GetProfilesDB()
return db.profileOrder, db.profiles
end
function EllesmereUI.AssignProfileToSpec(profileName, specID)
local db = GetProfilesDB()
db.specProfiles[specID] = profileName
end
function EllesmereUI.UnassignSpec(specID)
local db = GetProfilesDB()
db.specProfiles[specID] = nil
end
function EllesmereUI.GetSpecProfile(specID)
local db = GetProfilesDB()
return db.specProfiles[specID]
end
-------------------------------------------------------------------------------
-- Auto-save active profile on setting changes
-- Called by addons after any setting change to keep the active profile
-- in sync with live settings.
-------------------------------------------------------------------------------
function EllesmereUI.AutoSaveActiveProfile()
if EllesmereUI._profileSaveLocked then return end
local db = GetProfilesDB()
local name = db.activeProfile or "Custom"
db.profiles[name] = EllesmereUI.SnapshotAllAddons()
end
-------------------------------------------------------------------------------
-- Spec auto-switch handler
-------------------------------------------------------------------------------
do
local specFrame = CreateFrame("Frame")
local lastKnownSpecID = nil
specFrame:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
specFrame:RegisterEvent("PLAYER_ENTERING_WORLD")
specFrame:SetScript("OnEvent", function(_, event, unit)
-- PLAYER_ENTERING_WORLD has no unit arg; PLAYER_SPECIALIZATION_CHANGED
-- fires with "player" as unit. For PEW, always check current spec.
if event == "PLAYER_SPECIALIZATION_CHANGED" and unit ~= "player" then
return
end
local specIdx = GetSpecialization and GetSpecialization() or 0
local specID = specIdx and specIdx > 0
and GetSpecializationInfo(specIdx) or nil
if not specID then return end
-- On PLAYER_ENTERING_WORLD (reload/zone-in), only switch if the spec
-- actually changed. A plain /reload should not override the user's
-- active profile selection.
if event == "PLAYER_ENTERING_WORLD" then
if lastKnownSpecID == nil then
-- First login: record spec but don't force-switch.
-- The user's activeProfile from SavedVariables is correct.
lastKnownSpecID = specID
return
end
if specID == lastKnownSpecID then
return -- spec unchanged, skip
end
end
lastKnownSpecID = specID
local db = GetProfilesDB()
local targetProfile = db.specProfiles[specID]
if targetProfile and db.profiles[targetProfile] then
local current = db.activeProfile or "Custom"
if current ~= targetProfile then
-- Auto-save current before switching
db.profiles[current] = EllesmereUI.SnapshotAllAddons()
EllesmereUI.SwitchProfile(targetProfile)
ReloadUI()
end
end
end)
end
-------------------------------------------------------------------------------
-- Popular Presets & Weekly Spotlight
-- Hardcoded profile strings that ship with the addon.
-- To add a new preset: add an entry to POPULAR_PRESETS with name + string.
-- To update the weekly spotlight: change WEEKLY_SPOTLIGHT.
-------------------------------------------------------------------------------
EllesmereUI.POPULAR_PRESETS = {
{ name = "EllesmereUI", description = "The default EllesmereUI look", exportString = "!EUI_T31wZTnoY6)kZJNZdrfVFZpz7yNKYtID5OzNKTMQCrlrBXtKj1ksnoEs5)7NUrdqaqcsjQeNjzhpvT16qrIl9LV(RBac(LZQ8sQFyvg8)DZMLlpRkm5pZwxLxwuyFa(JZtRtH7Yp5MYI6k4VcsUDz51PlRSTso5ZRwNvvDF6dNvzBNuUPEzEr2BlNJTxrzr2JW1DsMTPQU8UJlxwUUI1wZwMwv9LhFeBT05ZllWl7eKCYYLzv3LTo73EZXLLlNxEFXBtlsVnB9xyn01BU5MJsx)(zPlZyJViXLWgioPAr59tZHgykorUUC98S1hvyDa7FD7HlxTiTWAIhBIDD66xb)Jih4Fbtf6MFF(FrnS4PVK)0vRsNLxCBbE3bjllN9PS5NYEWBYxwNTMnNDtsrryus(SYcQPIWw3nztv2X4CMjdov28hY6SMw5xZRQRSsWFV8MBQYQ)qHRfnaYksVEjRp9tUpFE9Ich2VWMiWCCsan0UDD59)2kwxCx6NrjtrKY85vS5tqYIS8BxutJprN9XIxO0MWmFILptgJI13atPPpYK4GGBz59Oeh05WKk)2I7YiJd3e7RS)ctxawj3ZMU49LCn0ASPAYTnc9K1WS)rX9((6h4kvVK7qPzqYHhp9n)RtyYNz6sVQvzlx(Mxw444gzhEWJFN7X4dEenEHPFv2YSz1zZbbnPkTr5Z7ZQRbRLktsc(9PoQOH6Jgghbu)c(kDht6tcC80yLaM)2rnJTdBurux7jh1BQRbp9qQVHUAg6hMe4)furFx6QvIzHQbi4iMoRgGi4po5VmB(DVFzj1fXIBG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H2(CMQN9DauTlRw1Tm5pE(0)qWqY(zp2NRM8pE(Y9tq6YSvFB4y8ZsIQu4FXBKjUpNPD3ctdj2hVn3n7f(vzRoFzwv5M1mMn0hFj8naKla9bt)0544rZpKjZpKnt1WECtQW3cv5RTizNjAJxvqVctYRiAJu27bj5E4NCt(YLhb3BOl7M785SjYoc3C(r2EXrH2TERc2(oNp2lycEKre46A5tFqBeZPxXgbn6khlLr3hlEHpUXMbBXBVKDF0lGi7JP2uzBCe)3eZXJkO6ZR(5PHEY3Vcp6ZyVvwyBiF)G1XTen8LIFVri)ro8FDRJNcCiEyb9XSoMACt6Jl56d1MK0bydCexBqw70X2fFKQQOWgjoG)mVs5hiDlyyk6oabTJbTlxqW79POQK9gksVhIulH2n((KE62SIm67XFe3Wqe8Di)glmCw7dXdDZof1m(gBY6SvRZVlDn77ZlmZxap7IYLZ1c5R(DDIZyyMCVXB0HPunwaDGsipWc0pp8up)j6eP3I)PWQ1XQLLCKEjPcuUcngeUyT)1J4ge94oWEHRfJFH7aJPGe5J7DmXkq9)cpOT)H2hRPTyYZTgn0Mng6(TMjcOMgZx6aVYrEhxmJ)HZJB3AO1h2Os1kVXv4GgJIwFhy)Z8Q8RZxMx)aipPOsDnVfhthpHgC9BFPHMFAB7lLtnPD28IJGpglSaDlSGNelmRFMTWiW2VcJmi2tgGUoFiGTauKFepeGbJo(VFiNe(GiCo076n38CqiUoek0m2WxzSql)OihxFNypXH(vVgFbgS9cS9dIcCc98TIjIdSq4uOhDJsfZq3O(mdTh2SZlzv(QZ7xdhH)(VRA)0YctmxTddOxeuYsTlgjK2x5m5Olkz2c814Mj28Wwog7QxRWRryzBl1NVQqAUQ1k4qjmu9kKW2rz4Ihjs5PlpVy5duMQn)YXygqfUdyJcxhgDnFafLJiXKJ3RhPOI74xW5pBWVOv0fPhr8bpI)3))p" },
{ name = "Spin the Wheel", description = "Randomize all settings", exportString = nil },
}
EllesmereUI.WEEKLY_SPOTLIGHT = nil -- { name = "...", description = "...", exportString = "!EUI_..." }
-- To set a weekly spotlight, uncomment and fill in:
-- EllesmereUI.WEEKLY_SPOTLIGHT = {
-- name = "Week 1 Spotlight",
-- description = "A clean minimal setup",
-- exportString = "!EUI_...",
-- }
-------------------------------------------------------------------------------
-- Spin the Wheel: global randomizer
-- Randomizes all addon settings except X/Y offsets, scale, and enable flags.
-- Does not touch Party Mode.
-------------------------------------------------------------------------------
function EllesmereUI.SpinTheWheel()
local function rColor()
return { r = math.random(), g = math.random(), b = math.random() }
end
local function rBool() return math.random() > 0.5 end
local function pick(t) return t[math.random(#t)] end
local function rRange(lo, hi) return lo + math.random() * (hi - lo) end
local floor = math.floor
-- Randomize each loaded addon (except Nameplates which has its own randomizer)
for _, entry in ipairs(ADDON_DB_MAP) do
if IsAddonLoaded(entry.folder) and entry.folder ~= "EllesmereUINameplates" then
local profile = GetAddonProfile(entry)
if profile then
EllesmereUI._RandomizeProfile(profile, entry.folder)
end
end
end
-- Nameplates: use the existing randomizer keys from the preset system
if IsAddonLoaded("EllesmereUINameplates") then
local db = _G.EllesmereUINameplatesDB
if db then
EllesmereUI._RandomizeNameplates(db)
end
end
-- Randomize global fonts
local fontsDB = EllesmereUI.GetFontsDB()
local validFonts = {}
for _, name in ipairs(EllesmereUI.FONT_ORDER) do
if name ~= "---" then validFonts[#validFonts + 1] = name end
end
fontsDB.global = pick(validFonts)
local outlineModes = { "none", "outline", "shadow" }
fontsDB.outlineMode = pick(outlineModes)
-- Randomize class colors
local colorsDB = EllesmereUI.GetCustomColorsDB()
colorsDB.class = {}
for token in pairs(EllesmereUI.CLASS_COLOR_MAP) do
colorsDB.class[token] = rColor()
end
end
--- Generic profile randomizer for AceDB-style addons.
--- Skips keys containing "offset", "Offset", "scale", "Scale", "X", "Y",
--- "pos", "Pos", "position", "Position", "anchor", "Anchor" (position-related),
--- and boolean keys that look like enable/disable toggles.
function EllesmereUI._RandomizeProfile(profile, folderName)
local function rColor()
return { r = math.random(), g = math.random(), b = math.random() }
end