Make Classes tab settings account-wide, keep overrides per profile
This commit is contained in:
+29
-72
@@ -96,70 +96,17 @@ end
|
||||
|
||||
HideCoAUI.SetActiveProfileName = SetActiveProfileName
|
||||
|
||||
local function GetActiveClassSettings()
|
||||
local function GetClassSettings()
|
||||
|
||||
local name = GetActiveProfileName()
|
||||
local profile = HideCoADB.profiles[name]
|
||||
|
||||
if not profile then
|
||||
profile = { classSettings = CreateDefaultClassSettings() }
|
||||
HideCoADB.profiles[name] = profile
|
||||
if not HideCoADB.classSettings then
|
||||
HideCoADB.classSettings = CreateDefaultClassSettings()
|
||||
end
|
||||
|
||||
if not profile.classSettings then
|
||||
profile.classSettings = CreateDefaultClassSettings()
|
||||
end
|
||||
|
||||
return profile.classSettings
|
||||
return HideCoADB.classSettings
|
||||
|
||||
end
|
||||
|
||||
HideCoAUI.GetActiveClassSettings = GetActiveClassSettings
|
||||
|
||||
local function CopyProfile(sourceName, destName)
|
||||
|
||||
local source = HideCoADB.profiles[sourceName]
|
||||
|
||||
if not source or not source.classSettings then
|
||||
return
|
||||
end
|
||||
|
||||
local copy = {}
|
||||
|
||||
for class, settings in pairs(source.classSettings) do
|
||||
copy[class] = {}
|
||||
for frameName, value in pairs(settings) do
|
||||
copy[class][frameName] = value
|
||||
end
|
||||
end
|
||||
|
||||
if not HideCoADB.profiles[destName] then
|
||||
HideCoADB.profiles[destName] = {}
|
||||
end
|
||||
|
||||
HideCoADB.profiles[destName].classSettings = copy
|
||||
|
||||
HideCoAUI.ApplySetting()
|
||||
|
||||
end
|
||||
|
||||
HideCoAUI.CopyProfile = CopyProfile
|
||||
|
||||
local function ResetProfile()
|
||||
|
||||
local name = GetActiveProfileName()
|
||||
|
||||
if not HideCoADB.profiles[name] then
|
||||
HideCoADB.profiles[name] = {}
|
||||
end
|
||||
|
||||
HideCoADB.profiles[name].classSettings = CreateDefaultClassSettings()
|
||||
|
||||
HideCoAUI.ApplySetting()
|
||||
|
||||
end
|
||||
|
||||
HideCoAUI.ResetProfile = ResetProfile
|
||||
HideCoAUI.GetClassSettings = GetClassSettings
|
||||
|
||||
local function DeleteProfile(name)
|
||||
|
||||
@@ -168,7 +115,7 @@ local function DeleteProfile(name)
|
||||
for charKey, assigned in pairs(HideCoADB.charProfile) do
|
||||
if assigned == name then
|
||||
-- Unassigning falls back to the character's own auto-created
|
||||
-- profile (see GetActiveProfileName/GetActiveClassSettings),
|
||||
-- profile (see GetActiveProfileName/GetProfileOverride),
|
||||
-- which gets recreated on demand if it doesn't exist.
|
||||
HideCoADB.charProfile[charKey] = nil
|
||||
end
|
||||
@@ -183,7 +130,7 @@ local function EnsureProfileOverride(name)
|
||||
local profile = HideCoADB.profiles[name]
|
||||
|
||||
if not profile then
|
||||
profile = { classSettings = CreateDefaultClassSettings() }
|
||||
profile = {}
|
||||
HideCoADB.profiles[name] = profile
|
||||
end
|
||||
|
||||
@@ -239,7 +186,7 @@ HideCoAUI.GetProfileNames = GetProfileNames
|
||||
|
||||
local function SetAllClassesHidden(hide)
|
||||
|
||||
local classSettings = GetActiveClassSettings()
|
||||
local classSettings = GetClassSettings()
|
||||
|
||||
for _, class in ipairs(HideCoAUI.CUSTOM_CLASSES) do
|
||||
for _, frameName in ipairs(HideCoAUI.FRAMES) do
|
||||
@@ -265,7 +212,7 @@ HideCoAUI.ShowAllFrames = ShowAllFrames
|
||||
|
||||
local function ShouldHideForClass(playerClass, frameName)
|
||||
|
||||
local classSettings = GetActiveClassSettings()[playerClass]
|
||||
local classSettings = GetClassSettings()[playerClass]
|
||||
|
||||
if not classSettings or classSettings[frameName] == nil then
|
||||
return true
|
||||
@@ -356,11 +303,24 @@ f:SetScript("OnEvent", function(self, event, arg1)
|
||||
HideCoADB.charProfile = {}
|
||||
end
|
||||
|
||||
-- Legacy pre-profile saved variables stored a single flat classSettings
|
||||
-- table shared by every character. Fold it into whichever character
|
||||
-- happens to load next so those hide/show choices don't just vanish.
|
||||
local legacyFlatClassSettings = HideCoADB.classSettings
|
||||
HideCoADB.classSettings = nil
|
||||
-- An older saved-variable format duplicated classSettings per profile
|
||||
-- instead of sharing one account-wide table. Pull whichever profile
|
||||
-- still has one as the seed so existing hide/show choices survive
|
||||
-- the upgrade to a single global classSettings.
|
||||
if not HideCoADB.classSettings then
|
||||
for _, profile in pairs(HideCoADB.profiles) do
|
||||
if profile.classSettings then
|
||||
HideCoADB.classSettings = profile.classSettings
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not HideCoADB.classSettings then
|
||||
HideCoADB.classSettings = CreateDefaultClassSettings()
|
||||
end
|
||||
|
||||
EnsureClassSettingsComplete(HideCoADB.classSettings)
|
||||
|
||||
local charKey = GetCharacterKey()
|
||||
|
||||
@@ -395,14 +355,11 @@ f:SetScript("OnEvent", function(self, event, arg1)
|
||||
end
|
||||
|
||||
if not HideCoADB.profiles[charKey] then
|
||||
HideCoADB.profiles[charKey] = { classSettings = legacyFlatClassSettings or CreateDefaultClassSettings() }
|
||||
HideCoADB.profiles[charKey] = {}
|
||||
end
|
||||
|
||||
for name, profile in pairs(HideCoADB.profiles) do
|
||||
if not profile.classSettings then
|
||||
profile.classSettings = CreateDefaultClassSettings()
|
||||
end
|
||||
EnsureClassSettingsComplete(profile.classSettings)
|
||||
profile.classSettings = nil
|
||||
EnsureProfileOverride(name)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user