Move frame-override storage from per-character to per-profile

The Character Override tab's enabled toggle and frame checkboxes now
live on each named profile (profiles[name].override) instead of being
keyed by character. This lets the tab's new profile-list dropdown pick
which profile's override to view/edit without touching which profile
is actually assigned/active for the character - selecting an entry
only changes what you're editing. Existing per-character override data
is migrated into the character's currently active profile on load.

Also style the profile dropdown with ElvUI when available, matching
the rest of the options panel.
This commit is contained in:
2026-07-08 00:18:44 +02:00
parent 3d048cb081
commit 83a1cda15c
2 changed files with 110 additions and 32 deletions
+55 -23
View File
@@ -181,48 +181,64 @@ end
HideCoA.DeleteProfile = DeleteProfile HideCoA.DeleteProfile = DeleteProfile
local function EnsureCharacterOverride(charKey) local function EnsureProfileOverride(name)
if not HideCoADB.characterOverrides then local profile = HideCoADB.profiles[name]
HideCoADB.characterOverrides = {}
if not profile then
profile = { classSettings = CreateDefaultClassSettings() }
HideCoADB.profiles[name] = profile
end end
local override = HideCoADB.characterOverrides[charKey] if not profile.override then
profile.override = { enabled = false, frameSettings = {} }
if not override then
override = { enabled = false, frameSettings = {} }
HideCoADB.characterOverrides[charKey] = override
end end
for _, frameName in ipairs(HideCoA.FRAMES) do for _, frameName in ipairs(HideCoA.FRAMES) do
if override.frameSettings[frameName] == nil then if profile.override.frameSettings[frameName] == nil then
override.frameSettings[frameName] = true profile.override.frameSettings[frameName] = true
end end
end end
return override return profile.override
end end
local function GetCharacterOverride() local function GetProfileOverride(name)
return EnsureCharacterOverride(GetCharacterKey()) return EnsureProfileOverride(name)
end end
HideCoA.GetCharacterOverride = GetCharacterOverride HideCoA.GetProfileOverride = GetProfileOverride
local function SetCharacterOverrideEnabled(enabled) local function SetProfileOverrideEnabled(name, enabled)
GetCharacterOverride().enabled = enabled GetProfileOverride(name).enabled = enabled
HideCoA.ApplySetting() HideCoA.ApplySetting()
end end
HideCoA.SetCharacterOverrideEnabled = SetCharacterOverrideEnabled HideCoA.SetProfileOverrideEnabled = SetProfileOverrideEnabled
local function SetCharacterOverrideFrameHidden(frameName, hide) local function SetProfileOverrideFrameHidden(name, frameName, hide)
GetCharacterOverride().frameSettings[frameName] = hide GetProfileOverride(name).frameSettings[frameName] = hide
HideCoA.ApplySetting() HideCoA.ApplySetting()
end end
HideCoA.SetCharacterOverrideFrameHidden = SetCharacterOverrideFrameHidden HideCoA.SetProfileOverrideFrameHidden = SetProfileOverrideFrameHidden
local function GetProfileNames()
local names = {}
for name in pairs(HideCoADB.profiles) do
table.insert(names, name)
end
table.sort(names)
return names
end
HideCoA.GetProfileNames = GetProfileNames
local function SetAllClassesHidden(hide) local function SetAllClassesHidden(hide)
@@ -264,7 +280,7 @@ end
local function ShouldHideFrame(frameName) local function ShouldHideFrame(frameName)
local override = GetCharacterOverride() local override = GetProfileOverride(GetActiveProfileName())
if override.enabled then if override.enabled then
return override.frameSettings[frameName] return override.frameSettings[frameName]
@@ -372,18 +388,34 @@ f:SetScript("OnEvent", function(self, event, arg1)
HideCoADB.profiles[charKey] = { classSettings = CreateDefaultClassSettings() } HideCoADB.profiles[charKey] = { classSettings = CreateDefaultClassSettings() }
end end
for _, profile in pairs(HideCoADB.profiles) do for name, profile in pairs(HideCoADB.profiles) do
if not profile.classSettings then if not profile.classSettings then
profile.classSettings = CreateDefaultClassSettings() profile.classSettings = CreateDefaultClassSettings()
end end
EnsureClassSettingsComplete(profile.classSettings) EnsureClassSettingsComplete(profile.classSettings)
EnsureProfileOverride(name)
end end
if not HideCoADB.charProfile[charKey] then if not HideCoADB.charProfile[charKey] then
HideCoADB.charProfile[charKey] = charKey HideCoADB.charProfile[charKey] = charKey
end end
EnsureCharacterOverride(charKey) -- The override toggle used to live per-character; fold any existing
-- per-character override into whichever profile is currently active
-- for this character so nobody's existing choice silently vanishes.
if HideCoADB.characterOverrides and HideCoADB.characterOverrides[charKey] then
local activeName = GetActiveProfileName()
local activeProfile = HideCoADB.profiles[activeName]
if activeProfile and not activeProfile.override then
activeProfile.override = HideCoADB.characterOverrides[charKey]
EnsureProfileOverride(activeName)
end
HideCoADB.characterOverrides[charKey] = nil
end
HideCoADB.selectedProfile = nil HideCoADB.selectedProfile = nil
+55 -9
View File
@@ -243,12 +243,17 @@ characterOverrideTitle:SetPoint("TOPLEFT", 16, -16)
characterOverrideTitle:SetFont(titleFont, titleSize + 4, "OUTLINE") characterOverrideTitle:SetFont(titleFont, titleSize + 4, "OUTLINE")
characterOverrideTitle:SetText("Character Override") characterOverrideTitle:SetText("Character Override")
local characterNameText = characterOverridePanel:CreateFontString(nil, "ARTWORK", "GameFontHighlight") local overrideProfileDropdown = CreateFrame("Frame", "HideCoAOverrideProfileDropDown", characterOverridePanel, "UIDropDownMenuTemplate")
characterNameText:SetPoint("TOPLEFT", characterOverrideTitle, "BOTTOMLEFT", 0, -12) overrideProfileDropdown:SetPoint("TOPLEFT", characterOverrideTitle, "BOTTOMLEFT", -16, -12)
characterNameText:SetText(HideCoA.GetCharacterKey())
if ElvSkins then
ElvSkins:HandleDropDownBox(overrideProfileDropdown, 180)
end
UIDropDownMenu_SetWidth(overrideProfileDropdown, 180)
local overrideEnabledCheck = CreateFrame("CheckButton", "HideCoAOverrideEnabledCheck", characterOverridePanel, "InterfaceOptionsCheckButtonTemplate") local overrideEnabledCheck = CreateFrame("CheckButton", "HideCoAOverrideEnabledCheck", characterOverridePanel, "InterfaceOptionsCheckButtonTemplate")
overrideEnabledCheck:SetPoint("TOPLEFT", characterNameText, "BOTTOMLEFT", 0, -12) overrideEnabledCheck:SetPoint("TOPLEFT", overrideProfileDropdown, "BOTTOMLEFT", 16, -8)
_G[overrideEnabledCheck:GetName() .. "Text"]:SetText("Override class options for this character") _G[overrideEnabledCheck:GetName() .. "Text"]:SetText("Override class options for this character")
if ElvSkins then if ElvSkins then
@@ -256,6 +261,7 @@ if ElvSkins then
end end
local overrideChecks = {} local overrideChecks = {}
local selectedOverrideProfile = nil
local overridePreviousAnchor = overrideEnabledCheck local overridePreviousAnchor = overrideEnabledCheck
local overridePreviousSpacing = -16 local overridePreviousSpacing = -16
@@ -273,7 +279,9 @@ for _, frameName in ipairs(HideCoA.FRAMES) do
end end
check:SetScript("OnClick", function(self) check:SetScript("OnClick", function(self)
HideCoA.SetCharacterOverrideFrameHidden(self.frameName, self:GetChecked() and true or false) if selectedOverrideProfile then
HideCoA.SetProfileOverrideFrameHidden(selectedOverrideProfile, self.frameName, self:GetChecked() and true or false)
end
end) end)
AddCheckboxFeedback(check) AddCheckboxFeedback(check)
@@ -298,7 +306,11 @@ end
local function RefreshCharacterOverrideTab() local function RefreshCharacterOverrideTab()
local override = HideCoA.GetCharacterOverride() if not selectedOverrideProfile then
return
end
local override = HideCoA.GetProfileOverride(selectedOverrideProfile)
overrideEnabledCheck:SetChecked(override.enabled) overrideEnabledCheck:SetChecked(override.enabled)
@@ -309,14 +321,48 @@ local function RefreshCharacterOverrideTab()
end end
overrideEnabledCheck:SetScript("OnClick", function(self) local function SelectOverrideProfile(name)
HideCoA.SetCharacterOverrideEnabled(self:GetChecked() and true or false) selectedOverrideProfile = name
UIDropDownMenu_SetText(overrideProfileDropdown, name)
RefreshCharacterOverrideTab() RefreshCharacterOverrideTab()
end
local function OverrideProfileDropDown_OnClick(self)
SelectOverrideProfile(self.value)
end
UIDropDownMenu_Initialize(overrideProfileDropdown, function(self, level)
if not (HideCoADB and HideCoADB.profiles) then
return
end
for _, name in ipairs(HideCoA.GetProfileNames()) do
local info = UIDropDownMenu_CreateInfo()
info.text = name
info.value = name
info.func = OverrideProfileDropDown_OnClick
info.checked = (selectedOverrideProfile == name)
UIDropDownMenu_AddButton(info, level)
end
end)
overrideEnabledCheck:SetScript("OnClick", function(self)
if selectedOverrideProfile then
HideCoA.SetProfileOverrideEnabled(selectedOverrideProfile, self:GetChecked() and true or false)
RefreshCharacterOverrideTab()
end
end) end)
AddCheckboxFeedback(overrideEnabledCheck) AddCheckboxFeedback(overrideEnabledCheck)
characterOverridePanel:SetScript("OnShow", RefreshCharacterOverrideTab) characterOverridePanel:SetScript("OnShow", function()
SelectOverrideProfile(selectedOverrideProfile or HideCoA.GetActiveProfileName())
end)
InterfaceOptions_AddCategory(characterOverridePanel) InterfaceOptions_AddCategory(characterOverridePanel)