Re-enable dev-only profile export/import

Exporting works pretty well, but importing is rough (mostly because error messaging isn't quite in place, and it's not obvious that you have to close the window to execute the import). I found a generic json serializer, decided to adapt it to WoW, and it seems to work.

But anyway, I saw this code sitting around and figured it wouldn't take too much work to get it in working order. I was mostly right.
This commit is contained in:
Parnic
2022-09-02 21:44:12 -05:00
parent 1de917223f
commit f04c5db493
8 changed files with 439 additions and 15 deletions

View File

@ -7,8 +7,6 @@ local SML = LibStub("LibSharedMedia-3.0")
local ACR = LibStub("AceConfigRegistry-3.0")
local ConfigDialog = LibStub("AceConfigDialog-3.0")
local icon = LibStub("LibDBIcon-1.0", true)
local AceGUI = LibStub("AceGUI-3.0")
local AceSerializer = LibStub("AceSerializer-3.0", 1)
local pendingModuleLoads = {}
local bReadyToRegisterModules = false
@ -92,6 +90,43 @@ end
IceHUD.deepcopy = deepcopy
function IceHUD:removeDefaults(db, defaults, blocker)
-- remove all metatables from the db, so we don't accidentally create new sub-tables through them
setmetatable(db, nil)
-- loop through the defaults and remove their content
for k,v in pairs(defaults) do
if type(v) == "table" and type(db[k]) == "table" then
-- if a blocker was set, dive into it, to allow multi-level defaults
self:removeDefaults(db[k], v, blocker and blocker[k])
if next(db[k]) == nil then
db[k] = nil
end
else
-- check if the current value matches the default, and that its not blocked by another defaults table
if db[k] == defaults[k] and (not blocker or blocker[k] == nil) then
db[k] = nil
end
end
end
end
function IceHUD:populateDefaults(db, defaults, blocker)
-- remove all metatables from the db, so we don't accidentally create new sub-tables through them
setmetatable(db, nil)
-- loop through the defaults and add their content
for k,v in pairs(defaults) do
if type(v) == "table" and type(db[k]) == "table" then
-- if a blocker was set, dive into it, to allow multi-level defaults
self:populateDefaults(db[k], v, blocker and blocker[k])
else
-- check if the current value matches the default, and that its not blocked by another defaults table
if db[k] == nil then
db[k] = defaults[k]
end
end
end
end
IceHUD.Location = "Interface\\AddOns\\IceHUD"
StaticPopupDialogs["ICEHUD_CUSTOM_BAR_CREATED"] =