Add per-profile class settings with Reset/Copy/Delete and per-character profile assignment

Each profile now owns its own hide/show settings instead of sharing one
global table, and profile selection is tracked per character instead of
account-wide. Adds Reset Profile, Copy From, and Delete a Profile controls
to the Profiles tab, each ElvUI-skinned and gated behind a confirmation
popup.
This commit is contained in:
2026-07-07 22:17:47 +02:00
parent 5818fc66bc
commit 920b1b234b
2 changed files with 373 additions and 35 deletions
+184 -9
View File
@@ -59,7 +59,7 @@ for _, frameName in ipairs(HideCoA.FRAMES) do
return
end
HideCoADB.classSettings[selectedClass][self.frameName] = self:GetChecked() and true or false
HideCoA.GetActiveClassSettings()[selectedClass][self.frameName] = self:GetChecked() and true or false
HideCoA.ApplySetting()
end)
@@ -94,7 +94,7 @@ local function SelectClass(class)
end
for _, frameName in ipairs(HideCoA.FRAMES) do
checks[frameName]:SetChecked(HideCoADB.classSettings[class][frameName])
checks[frameName]:SetChecked(HideCoA.GetActiveClassSettings()[class][frameName])
end
for tabClass, button in pairs(tabButtons) do
@@ -147,22 +147,28 @@ profileContent:Hide()
local profileTitle = profileContent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
profileTitle:SetPoint("TOPLEFT", profileContent, "TOPLEFT", 0, 0)
profileTitle:SetFont(titleFont, titleSize + 4, "OUTLINE")
profileTitle:SetText("Profile")
profileTitle:SetText("Profiles")
local function GetProfileNames()
local names = {}
local hasDefault = false
if HideCoADB and HideCoADB.profiles then
for name in pairs(HideCoADB.profiles) do
if name ~= "Default" then
if name == "Default" then
hasDefault = true
else
table.insert(names, name)
end
end
end
table.sort(names)
table.insert(names, 1, "Default")
if hasDefault then
table.insert(names, 1, "Default")
end
return names
@@ -171,9 +177,14 @@ end
local profileDropDown = CreateFrame("Frame", "HideCoAProfileDropDown", profileContent, "UIDropDownMenuTemplate")
profileDropDown:SetPoint("TOPLEFT", profileTitle, "BOTTOMLEFT", -16, -12)
if ElvSkins then
ElvSkins:HandleDropDownBox(profileDropDown, 140)
end
local function ProfileDropDown_OnClick(self)
HideCoADB.selectedProfile = self.value
HideCoA.SetActiveProfileName(self.value)
UIDropDownMenu_SetText(profileDropDown, self.value)
HideCoA.ApplySetting()
end
UIDropDownMenu_Initialize(profileDropDown, function(self, level)
@@ -184,7 +195,7 @@ UIDropDownMenu_Initialize(profileDropDown, function(self, level)
info.text = name
info.value = name
info.func = ProfileDropDown_OnClick
info.checked = HideCoADB and (HideCoADB.selectedProfile == name)
info.checked = HideCoADB and HideCoADB.charProfile and (HideCoA.GetActiveProfileName() == name)
UIDropDownMenu_AddButton(info, level)
@@ -194,6 +205,170 @@ end)
UIDropDownMenu_SetWidth(profileDropDown, 140)
local resetDesc = profileContent:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
resetDesc:SetPoint("TOPLEFT", profileDropDown, "BOTTOMLEFT", 16, -20)
resetDesc:SetWidth(260)
resetDesc:SetJustifyH("LEFT")
resetDesc:SetText("Reset the currently active profile's settings back to their defaults.")
local resetButton = CreateFrame("Button", "HideCoAResetProfileButton", profileContent, "UIPanelButtonTemplate")
resetButton:SetPoint("TOPLEFT", resetDesc, "BOTTOMLEFT", 0, -8)
resetButton:SetSize(140, 22)
resetButton:SetText("Reset Profile")
if ElvSkins then
ElvSkins:HandleButton(resetButton)
end
StaticPopupDialogs["HIDECOA_CONFIRM_RESET_PROFILE"] = {
text = "Reset the active profile '%s' to its default settings? This cannot be undone.",
button1 = YES,
button2 = NO,
OnAccept = function()
HideCoA.ResetProfile()
if selectedClass then
SelectClass(selectedClass)
end
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
}
resetButton:SetScript("OnClick", function()
StaticPopup_Show("HIDECOA_CONFIRM_RESET_PROFILE", HideCoA.GetActiveProfileName())
end)
local copyDesc = profileContent:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
copyDesc:SetPoint("TOPLEFT", resetButton, "BOTTOMLEFT", 0, -20)
copyDesc:SetWidth(260)
copyDesc:SetJustifyH("LEFT")
copyDesc:SetText("Copy the settings from one existing profile into the currently active profile.")
local copyLabel = profileContent:CreateFontString(nil, "ARTWORK", "GameFontNormal")
copyLabel:SetPoint("TOPLEFT", copyDesc, "BOTTOMLEFT", 0, -8)
copyLabel:SetTextColor(1, 0.82, 0)
copyLabel:SetText("Copy From")
local copyDropDown = CreateFrame("Frame", "HideCoACopyProfileDropDown", profileContent, "UIDropDownMenuTemplate")
copyDropDown:SetPoint("TOPLEFT", copyLabel, "BOTTOMLEFT", -16, -4)
if ElvSkins then
ElvSkins:HandleDropDownBox(copyDropDown, 140)
end
StaticPopupDialogs["HIDECOA_CONFIRM_COPY_PROFILE"] = {
text = "Copy settings from '%s' into the active profile '%s'? This will overwrite the active profile's settings.",
button1 = YES,
button2 = NO,
OnAccept = function(self, data)
HideCoA.CopyProfile(data.sourceName, data.activeName)
UIDropDownMenu_SetText(copyDropDown, "")
if selectedClass then
SelectClass(selectedClass)
end
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
}
local function CopyProfile_OnClick(self)
local sourceName = self.value
local activeName = HideCoA.GetActiveProfileName()
StaticPopup_Show("HIDECOA_CONFIRM_COPY_PROFILE", sourceName, activeName,
{ sourceName = sourceName, activeName = activeName })
end
UIDropDownMenu_Initialize(copyDropDown, function(self, level)
local activeName = HideCoADB and HideCoA.GetActiveProfileName()
for _, name in ipairs(GetProfileNames()) do
if name ~= activeName then
local info = UIDropDownMenu_CreateInfo()
info.text = name
info.value = name
info.func = CopyProfile_OnClick
UIDropDownMenu_AddButton(info, level)
end
end
end)
UIDropDownMenu_SetWidth(copyDropDown, 140)
UIDropDownMenu_SetText(copyDropDown, "")
local deleteDesc = profileContent:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
deleteDesc:SetPoint("TOPLEFT", copyDropDown, "BOTTOMLEFT", 16, -20)
deleteDesc:SetWidth(260)
deleteDesc:SetJustifyH("LEFT")
deleteDesc:SetText("Delete existing and unused profiles from the database to save space, and cleanup the SavedVariables file.")
local deleteLabel = profileContent:CreateFontString(nil, "ARTWORK", "GameFontNormal")
deleteLabel:SetPoint("TOPLEFT", deleteDesc, "BOTTOMLEFT", 0, -8)
deleteLabel:SetTextColor(1, 0.82, 0)
deleteLabel:SetText("Delete a Profile")
local deleteDropDown = CreateFrame("Frame", "HideCoADeleteProfileDropDown", profileContent, "UIDropDownMenuTemplate")
deleteDropDown:SetPoint("TOPLEFT", deleteLabel, "BOTTOMLEFT", -16, -4)
if ElvSkins then
ElvSkins:HandleDropDownBox(deleteDropDown, 140)
end
StaticPopupDialogs["HIDECOA_CONFIRM_DELETE_PROFILE"] = {
text = "Delete profile '%s'? This cannot be undone.",
button1 = YES,
button2 = NO,
OnAccept = function(self, data)
HideCoA.DeleteProfile(data.targetName)
UIDropDownMenu_SetText(deleteDropDown, "")
UIDropDownMenu_SetText(profileDropDown, HideCoA.GetActiveProfileName())
HideCoA.ApplySetting()
end,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
}
local function DeleteProfile_OnClick(self)
local targetName = self.value
StaticPopup_Show("HIDECOA_CONFIRM_DELETE_PROFILE", targetName, nil, { targetName = targetName })
end
UIDropDownMenu_Initialize(deleteDropDown, function(self, level)
for _, name in ipairs(GetProfileNames()) do
if name ~= "Default" then
local info = UIDropDownMenu_CreateInfo()
info.text = name
info.value = name
info.func = DeleteProfile_OnClick
UIDropDownMenu_AddButton(info, level)
end
end
end)
UIDropDownMenu_SetWidth(deleteDropDown, 140)
UIDropDownMenu_SetText(deleteDropDown, "")
local divider = sidebar:CreateTexture(nil, "ARTWORK")
divider:SetHeight(1)
divider:SetTexture(1, 1, 1, 0.3)
@@ -216,7 +391,7 @@ profileTabButton:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighli
local profileTabText = profileTabButton:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
profileTabText:SetPoint("LEFT", 4, 0)
profileTabText:SetText("Profile")
profileTabText:SetText("Profiles")
local function SelectProfileTab()
@@ -229,7 +404,7 @@ local function SelectProfileTab()
profileTabButton.selectedTexture:Show()
UIDropDownMenu_SetText(profileDropDown, HideCoADB.selectedProfile or "Default")
UIDropDownMenu_SetText(profileDropDown, HideCoA.GetActiveProfileName())
end