Files
hide-coa-ui/Options.lua
T
Narcasung ea4849fc10 Revamp options UI: dropdown-based class picker and per-character override tab
Replaces the 21-tab class sidebar with a single Classes tab driven by a
dropdown plus Hide All/Show All bulk actions. Reworks the old Profiles tab
into "Character Override": a single toggle that lets a character's frame
hide/show choices bypass its class settings, backed by a new
characterOverrides table alongside the existing profile data. Adds an
empty About tab, restyles sidebar tabs gold/white, and drops the unused
subtitle line.
2026-07-07 23:23:25 +02:00

310 lines
9.2 KiB
Lua

local ElvSkins
if ElvUI then
local E = unpack(ElvUI)
ElvSkins = E:GetModule("Skins")
end
local panel = CreateFrame("Frame")
panel.name = "HideCoAUI"
local title = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText("HideCoAUI")
local sidebar = CreateFrame("Frame", nil, panel)
sidebar:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -20)
sidebar:SetPoint("BOTTOMLEFT", panel, "BOTTOMLEFT", 16, 16)
sidebar:SetWidth(150)
local content = CreateFrame("Frame", nil, panel)
content:SetPoint("TOPLEFT", sidebar, "TOPRIGHT", 16, 0)
content:SetPoint("BOTTOMRIGHT", panel, "BOTTOMRIGHT", -16, 16)
local classesContent = CreateFrame("Frame", nil, content)
classesContent:SetAllPoints(content)
local characterOverrideContent = CreateFrame("Frame", nil, content)
characterOverrideContent:SetAllPoints(content)
characterOverrideContent:Hide()
local aboutContent = CreateFrame("Frame", nil, content)
aboutContent:SetAllPoints(content)
aboutContent:Hide()
-- CLASSES TAB --
local classesTitle = classesContent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
classesTitle:SetPoint("TOPLEFT", classesContent, "TOPLEFT", 0, 0)
local titleFont, titleSize = classesTitle:GetFont()
classesTitle:SetFont(titleFont, titleSize + 4, "OUTLINE")
classesTitle:SetText("Classes")
local hideAllButton = CreateFrame("Button", "HideCoAHideAllButton", classesContent, "UIPanelButtonTemplate")
hideAllButton:SetPoint("TOPLEFT", classesTitle, "BOTTOMLEFT", 0, -12)
hideAllButton:SetSize(100, 22)
hideAllButton:SetText("Hide All")
local showAllButton = CreateFrame("Button", "HideCoAShowAllButton", classesContent, "UIPanelButtonTemplate")
showAllButton:SetPoint("LEFT", hideAllButton, "RIGHT", 8, 0)
showAllButton:SetSize(100, 22)
showAllButton:SetText("Show All")
if ElvSkins then
ElvSkins:HandleButton(hideAllButton)
ElvSkins:HandleButton(showAllButton)
end
local classDropDown = CreateFrame("Frame", "HideCoAClassDropDown", classesContent, "UIDropDownMenuTemplate")
classDropDown:SetPoint("TOPLEFT", hideAllButton, "BOTTOMLEFT", -16, -16)
if ElvSkins then
ElvSkins:HandleDropDownBox(classDropDown, 140)
end
local checks = {}
local selectedClass = nil
local previousAnchor = classDropDown
local previousSpacing = -16
local previousXOffset = 16
for _, frameName in ipairs(HideCoA.FRAMES) do
local check = CreateFrame("CheckButton", "HideCoAClassCheck" .. frameName, classesContent, "InterfaceOptionsCheckButtonTemplate")
check:SetPoint("TOPLEFT", previousAnchor, "BOTTOMLEFT", previousXOffset, previousSpacing)
_G[check:GetName() .. "Text"]:SetText("Hide " .. frameName)
check.frameName = frameName
if ElvSkins then
ElvSkins:HandleCheckBox(check)
end
check:SetScript("OnClick", function(self)
if not selectedClass then
return
end
HideCoA.GetActiveClassSettings()[selectedClass][self.frameName] = self:GetChecked() and true or false
HideCoA.ApplySetting()
end)
checks[frameName] = check
previousAnchor = check
previousSpacing = -8
previousXOffset = 0
end
local function SelectClass(class)
selectedClass = class
local displayName = (LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[class]) or class
for _, frameName in ipairs(HideCoA.FRAMES) do
checks[frameName]:SetChecked(HideCoA.GetActiveClassSettings()[class][frameName])
end
UIDropDownMenu_SetText(classDropDown, displayName)
end
local function ClassDropDown_OnClick(self)
SelectClass(self.value)
end
UIDropDownMenu_Initialize(classDropDown, function(self, level)
for _, class in ipairs(HideCoA.CUSTOM_CLASSES) do
local displayName = (LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[class]) or class
local info = UIDropDownMenu_CreateInfo()
info.text = displayName
info.value = class
info.func = ClassDropDown_OnClick
info.checked = (selectedClass == class)
UIDropDownMenu_AddButton(info, level)
end
end)
UIDropDownMenu_SetWidth(classDropDown, 140)
hideAllButton:SetScript("OnClick", function()
HideCoA.HideAllFrames()
if selectedClass then
SelectClass(selectedClass)
end
end)
showAllButton:SetScript("OnClick", function()
HideCoA.ShowAllFrames()
if selectedClass then
SelectClass(selectedClass)
end
end)
-- CHARACTER OVERRIDE TAB --
local characterOverrideTitle = characterOverrideContent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
characterOverrideTitle:SetPoint("TOPLEFT", characterOverrideContent, "TOPLEFT", 0, 0)
characterOverrideTitle:SetFont(titleFont, titleSize + 4, "OUTLINE")
characterOverrideTitle:SetText("Character Override")
local overrideEnabledCheck = CreateFrame("CheckButton", "HideCoAOverrideEnabledCheck", characterOverrideContent, "InterfaceOptionsCheckButtonTemplate")
overrideEnabledCheck:SetPoint("TOPLEFT", characterOverrideTitle, "BOTTOMLEFT", 0, -12)
_G[overrideEnabledCheck:GetName() .. "Text"]:SetText("Override class options for this character.")
if ElvSkins then
ElvSkins:HandleCheckBox(overrideEnabledCheck)
end
local overrideChecks = {}
local overridePreviousAnchor = overrideEnabledCheck
local overridePreviousSpacing = -16
for _, frameName in ipairs(HideCoA.FRAMES) do
local check = CreateFrame("CheckButton", "HideCoAOverrideCheck" .. frameName, characterOverrideContent, "InterfaceOptionsCheckButtonTemplate")
check:SetPoint("TOPLEFT", overridePreviousAnchor, "BOTTOMLEFT", 0, overridePreviousSpacing)
_G[check:GetName() .. "Text"]:SetText("Hide " .. frameName)
check.frameName = frameName
if ElvSkins then
ElvSkins:HandleCheckBox(check)
end
check:SetScript("OnClick", function(self)
HideCoA.SetCharacterOverrideFrameHidden(self.frameName, self:GetChecked() and true or false)
end)
overrideChecks[frameName] = check
overridePreviousAnchor = check
overridePreviousSpacing = -8
end
local function SetOverrideCheckEnabled(check, enabled)
if enabled then
check:Enable()
_G[check:GetName() .. "Text"]:SetTextColor(1, 1, 1)
else
check:Disable()
_G[check:GetName() .. "Text"]:SetTextColor(0.5, 0.5, 0.5)
end
end
local function RefreshCharacterOverrideTab()
local override = HideCoA.GetCharacterOverride()
overrideEnabledCheck:SetChecked(override.enabled)
for _, frameName in ipairs(HideCoA.FRAMES) do
overrideChecks[frameName]:SetChecked(override.frameSettings[frameName])
SetOverrideCheckEnabled(overrideChecks[frameName], override.enabled)
end
end
overrideEnabledCheck:SetScript("OnClick", function(self)
HideCoA.SetCharacterOverrideEnabled(self:GetChecked() and true or false)
RefreshCharacterOverrideTab()
end)
-- ABOUT TAB --
local aboutTitle = aboutContent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
aboutTitle:SetPoint("TOPLEFT", aboutContent, "TOPLEFT", 0, 0)
aboutTitle:SetFont(titleFont, titleSize + 4, "OUTLINE")
aboutTitle:SetText("About")
-- SIDEBAR TABS --
local TAB_HEIGHT = 18
local function CreateTabButton(name, index)
local button = CreateFrame("Button", "HideCoATab" .. name, sidebar)
button:SetHeight(TAB_HEIGHT)
button:SetPoint("TOPLEFT", sidebar, "TOPLEFT", 0, -(index - 1) * TAB_HEIGHT)
button:SetPoint("RIGHT", sidebar, "RIGHT", 0, 0)
local selectedTexture = button:CreateTexture(nil, "BACKGROUND")
selectedTexture:SetAllPoints()
selectedTexture:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
selectedTexture:SetBlendMode("ADD")
selectedTexture:Hide()
button.selectedTexture = selectedTexture
button:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD")
local text = button:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
text:SetPoint("LEFT", 4, 0)
text:SetText(name)
text:SetTextColor(1, 0.82, 0)
button.text = text
return button
end
local classesTabButton = CreateTabButton("Classes", 1)
local characterOverrideTabButton = CreateTabButton("Character Override", 2)
local aboutTabButton = CreateTabButton("About", 3)
local sidebarTabButtons = { classesTabButton, characterOverrideTabButton, aboutTabButton }
local function SelectTab(activeButton, contentFrame)
classesContent:Hide()
characterOverrideContent:Hide()
aboutContent:Hide()
contentFrame:Show()
for _, button in ipairs(sidebarTabButtons) do
if button == activeButton then
button.selectedTexture:Show()
button.text:SetTextColor(1, 1, 1)
else
button.selectedTexture:Hide()
button.text:SetTextColor(1, 0.82, 0)
end
end
end
local function ShowClassesTab()
SelectTab(classesTabButton, classesContent)
SelectClass(selectedClass or HideCoA.CUSTOM_CLASSES[1])
end
local function ShowCharacterOverrideTab()
SelectTab(characterOverrideTabButton, characterOverrideContent)
RefreshCharacterOverrideTab()
end
local function ShowAboutTab()
SelectTab(aboutTabButton, aboutContent)
end
classesTabButton:SetScript("OnClick", ShowClassesTab)
characterOverrideTabButton:SetScript("OnClick", ShowCharacterOverrideTab)
aboutTabButton:SetScript("OnClick", ShowAboutTab)
panel:SetScript("OnShow", ShowClassesTab)
InterfaceOptions_AddCategory(panel)