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
|
HideCoAUI.SetActiveProfileName = SetActiveProfileName
|
||||||
|
|
||||||
local function GetActiveClassSettings()
|
local function GetClassSettings()
|
||||||
|
|
||||||
local name = GetActiveProfileName()
|
if not HideCoADB.classSettings then
|
||||||
local profile = HideCoADB.profiles[name]
|
HideCoADB.classSettings = CreateDefaultClassSettings()
|
||||||
|
|
||||||
if not profile then
|
|
||||||
profile = { classSettings = CreateDefaultClassSettings() }
|
|
||||||
HideCoADB.profiles[name] = profile
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if not profile.classSettings then
|
return HideCoADB.classSettings
|
||||||
profile.classSettings = CreateDefaultClassSettings()
|
|
||||||
end
|
|
||||||
|
|
||||||
return profile.classSettings
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
HideCoAUI.GetActiveClassSettings = GetActiveClassSettings
|
HideCoAUI.GetClassSettings = GetClassSettings
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
local function DeleteProfile(name)
|
local function DeleteProfile(name)
|
||||||
|
|
||||||
@@ -168,7 +115,7 @@ local function DeleteProfile(name)
|
|||||||
for charKey, assigned in pairs(HideCoADB.charProfile) do
|
for charKey, assigned in pairs(HideCoADB.charProfile) do
|
||||||
if assigned == name then
|
if assigned == name then
|
||||||
-- Unassigning falls back to the character's own auto-created
|
-- 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.
|
-- which gets recreated on demand if it doesn't exist.
|
||||||
HideCoADB.charProfile[charKey] = nil
|
HideCoADB.charProfile[charKey] = nil
|
||||||
end
|
end
|
||||||
@@ -183,7 +130,7 @@ local function EnsureProfileOverride(name)
|
|||||||
local profile = HideCoADB.profiles[name]
|
local profile = HideCoADB.profiles[name]
|
||||||
|
|
||||||
if not profile then
|
if not profile then
|
||||||
profile = { classSettings = CreateDefaultClassSettings() }
|
profile = {}
|
||||||
HideCoADB.profiles[name] = profile
|
HideCoADB.profiles[name] = profile
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -239,7 +186,7 @@ HideCoAUI.GetProfileNames = GetProfileNames
|
|||||||
|
|
||||||
local function SetAllClassesHidden(hide)
|
local function SetAllClassesHidden(hide)
|
||||||
|
|
||||||
local classSettings = GetActiveClassSettings()
|
local classSettings = GetClassSettings()
|
||||||
|
|
||||||
for _, class in ipairs(HideCoAUI.CUSTOM_CLASSES) do
|
for _, class in ipairs(HideCoAUI.CUSTOM_CLASSES) do
|
||||||
for _, frameName in ipairs(HideCoAUI.FRAMES) do
|
for _, frameName in ipairs(HideCoAUI.FRAMES) do
|
||||||
@@ -265,7 +212,7 @@ HideCoAUI.ShowAllFrames = ShowAllFrames
|
|||||||
|
|
||||||
local function ShouldHideForClass(playerClass, frameName)
|
local function ShouldHideForClass(playerClass, frameName)
|
||||||
|
|
||||||
local classSettings = GetActiveClassSettings()[playerClass]
|
local classSettings = GetClassSettings()[playerClass]
|
||||||
|
|
||||||
if not classSettings or classSettings[frameName] == nil then
|
if not classSettings or classSettings[frameName] == nil then
|
||||||
return true
|
return true
|
||||||
@@ -356,11 +303,24 @@ f:SetScript("OnEvent", function(self, event, arg1)
|
|||||||
HideCoADB.charProfile = {}
|
HideCoADB.charProfile = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Legacy pre-profile saved variables stored a single flat classSettings
|
-- An older saved-variable format duplicated classSettings per profile
|
||||||
-- table shared by every character. Fold it into whichever character
|
-- instead of sharing one account-wide table. Pull whichever profile
|
||||||
-- happens to load next so those hide/show choices don't just vanish.
|
-- still has one as the seed so existing hide/show choices survive
|
||||||
local legacyFlatClassSettings = HideCoADB.classSettings
|
-- the upgrade to a single global classSettings.
|
||||||
HideCoADB.classSettings = nil
|
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()
|
local charKey = GetCharacterKey()
|
||||||
|
|
||||||
@@ -395,14 +355,11 @@ f:SetScript("OnEvent", function(self, event, arg1)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not HideCoADB.profiles[charKey] then
|
if not HideCoADB.profiles[charKey] then
|
||||||
HideCoADB.profiles[charKey] = { classSettings = legacyFlatClassSettings or CreateDefaultClassSettings() }
|
HideCoADB.profiles[charKey] = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
for name, profile in pairs(HideCoADB.profiles) do
|
for name, profile in pairs(HideCoADB.profiles) do
|
||||||
if not profile.classSettings then
|
profile.classSettings = nil
|
||||||
profile.classSettings = CreateDefaultClassSettings()
|
|
||||||
end
|
|
||||||
EnsureClassSettingsComplete(profile.classSettings)
|
|
||||||
EnsureProfileOverride(name)
|
EnsureProfileOverride(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ for _, frameName in ipairs(HideCoAUI.FRAMES) do
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
HideCoAUI.GetActiveClassSettings()[selectedClass][self.frameName] = self:GetChecked() and true or false
|
HideCoAUI.GetClassSettings()[selectedClass][self.frameName] = self:GetChecked() and true or false
|
||||||
HideCoAUI.ApplySetting()
|
HideCoAUI.ApplySetting()
|
||||||
|
|
||||||
end)
|
end)
|
||||||
@@ -216,7 +216,7 @@ local function SelectClass(class)
|
|||||||
|
|
||||||
for _, frameName in ipairs(HideCoAUI.FRAMES) do
|
for _, frameName in ipairs(HideCoAUI.FRAMES) do
|
||||||
|
|
||||||
checks[frameName]:SetChecked(HideCoAUI.GetActiveClassSettings()[class][frameName])
|
checks[frameName]:SetChecked(HideCoAUI.GetClassSettings()[class][frameName])
|
||||||
|
|
||||||
if overridden then
|
if overridden then
|
||||||
checks[frameName]:Disable()
|
checks[frameName]:Disable()
|
||||||
@@ -267,7 +267,7 @@ hideClassButton:SetScript("OnClick", function()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local classSettings = HideCoAUI.GetActiveClassSettings()[selectedClass]
|
local classSettings = HideCoAUI.GetClassSettings()[selectedClass]
|
||||||
|
|
||||||
for _, frameName in ipairs(HideCoAUI.FRAMES) do
|
for _, frameName in ipairs(HideCoAUI.FRAMES) do
|
||||||
classSettings[frameName] = true
|
classSettings[frameName] = true
|
||||||
@@ -286,7 +286,7 @@ showClassButton:SetScript("OnClick", function()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local classSettings = HideCoAUI.GetActiveClassSettings()[selectedClass]
|
local classSettings = HideCoAUI.GetClassSettings()[selectedClass]
|
||||||
|
|
||||||
for _, frameName in ipairs(HideCoAUI.FRAMES) do
|
for _, frameName in ipairs(HideCoAUI.FRAMES) do
|
||||||
classSettings[frameName] = false
|
classSettings[frameName] = false
|
||||||
|
|||||||
@@ -15,10 +15,11 @@ Open the options panel from `Interface > AddOns > HideCoAUI`. It has two
|
|||||||
subcategories:
|
subcategories:
|
||||||
|
|
||||||
- **Classes** — pick a class from the sidebar and toggle which frames are
|
- **Classes** — pick a class from the sidebar and toggle which frames are
|
||||||
hidden for it.
|
hidden for it. These settings are shared account-wide, across every
|
||||||
|
character.
|
||||||
- **Character Override** — assign a profile to the currently logged
|
- **Character Override** — assign a profile to the currently logged
|
||||||
character, and optionally override its frame visibility independently of
|
character, and optionally override its frame visibility independently of
|
||||||
the assigned profile's class settings.
|
the account-wide class settings. Overrides are saved per profile.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user