Files
hide-coa-ui/Options.lua
T
Narcasung 3d048cb081 Rework Classes/Character Override options UI
- Fix checkbox/button click sound never playing: the sound hook was
  installed before the real OnClick handler, which SetScript then
  silently overwrote. Apply the click-sound hook after each button's
  real handler instead, and extend it to Hide All/Show All and the
  class tabs.
- Split the single bordered box around the Classes tab list and
  checkbox content into two separate boxes with a 3px gap, remove the
  bright edge texture, and lower the fill alpha so it reads closer to
  LootCollector's panel styling.
- Show "Name - Realm" above the Character Override checkbox and drop
  its trailing period.
- Add breathing room around the class name label and tab list.
2026-07-08 00:06:14 +02:00

341 lines
10 KiB
Lua

local ElvSkins
if ElvUI then
local E = unpack(ElvUI)
ElvSkins = E:GetModule("Skins")
end
local function AddClickSound(button)
button:HookScript("OnClick", function()
PlaySound("igMainMenuOptionCheckBoxOn")
end)
end
local function AddCheckboxFeedback(check)
check:HookScript("OnClick", function()
PlaySound("igMainMenuOptionCheckBoxOn")
end)
local text = _G[check:GetName() .. "Text"]
if text then
local point, relativeTo, relativePoint, xOfs, yOfs = text:GetPoint()
check:HookScript("OnMouseDown", function()
text:SetPoint(point, relativeTo, relativePoint, xOfs + 1, yOfs - 2)
end)
check:HookScript("OnMouseUp", function()
text:SetPoint(point, relativeTo, relativePoint, xOfs, yOfs)
end)
end
end
local panel = CreateFrame("Frame")
panel.name = "HideCoAUI"
local title = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText("HideCoAUI")
local titleFont, titleSize = title:GetFont()
InterfaceOptions_AddCategory(panel)
-- CLASSES SUBCATEGORY --
local classesPanel = CreateFrame("Frame")
classesPanel.name = "Classes"
classesPanel.parent = panel.name
local classesTitle = classesPanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
classesTitle:SetPoint("TOPLEFT", 16, -16)
classesTitle:SetFont(titleFont, titleSize + 4, "OUTLINE")
classesTitle:SetText("Classes")
local hideAllButton = CreateFrame("Button", "HideCoAHideAllButton", classesPanel, "UIPanelButtonTemplate")
hideAllButton:SetPoint("TOPLEFT", classesTitle, "BOTTOMLEFT", 0, -12)
hideAllButton:SetSize(100, 22)
hideAllButton:SetText("Hide All")
local showAllButton = CreateFrame("Button", "HideCoAShowAllButton", classesPanel, "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 BOX_BACKDROP = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
tile = true,
tileSize = 16,
insets = { left = 0, right = 0, top = 0, bottom = 0 },
}
local sidebarBox = CreateFrame("Frame", nil, classesPanel)
sidebarBox:SetPoint("TOPLEFT", hideAllButton, "BOTTOMLEFT", 0, -12)
sidebarBox:SetPoint("BOTTOMLEFT", classesPanel, "BOTTOMLEFT", 0, 8)
sidebarBox:SetWidth(158)
sidebarBox:SetBackdrop(BOX_BACKDROP)
sidebarBox:SetBackdropColor(0.08, 0.10, 0.14, 0.5)
local contentBox = CreateFrame("Frame", nil, classesPanel)
contentBox:SetPoint("TOPLEFT", sidebarBox, "TOPRIGHT", 3, 0)
contentBox:SetPoint("BOTTOMRIGHT", classesPanel, "BOTTOMRIGHT", -8, 8)
contentBox:SetBackdrop(BOX_BACKDROP)
contentBox:SetBackdropColor(0.08, 0.10, 0.14, 0.5)
local classSidebar = CreateFrame("Frame", nil, sidebarBox)
classSidebar:SetPoint("TOPLEFT", sidebarBox, "TOPLEFT", 4, -4)
classSidebar:SetPoint("BOTTOMRIGHT", sidebarBox, "BOTTOMRIGHT", -4, 4)
local classContent = CreateFrame("Frame", nil, contentBox)
classContent:SetPoint("TOPLEFT", contentBox, "TOPLEFT", 12, -4)
classContent:SetPoint("BOTTOMRIGHT", contentBox, "BOTTOMRIGHT", -12, 4)
local classLabel = classContent:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
classLabel:SetPoint("TOPLEFT", classContent, "TOPLEFT", 16, -12)
local checks = {}
local selectedClass = nil
local previousAnchor = classLabel
local previousSpacing = -20
for _, frameName in ipairs(HideCoA.FRAMES) do
local check = CreateFrame("CheckButton", "HideCoAClassCheck" .. frameName, classContent, "InterfaceOptionsCheckButtonTemplate")
check:SetPoint("TOPLEFT", previousAnchor, "BOTTOMLEFT", 0, 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)
AddCheckboxFeedback(check)
checks[frameName] = check
previousAnchor = check
previousSpacing = -8
end
local tabButtons = {}
local TAB_HEIGHT = 18
local function SelectClass(class)
selectedClass = class
local displayName = (LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[class]) or class
classLabel:SetText(displayName)
local color = RAID_CLASS_COLORS and RAID_CLASS_COLORS[class]
if color then
classLabel:SetTextColor(color.r, color.g, color.b)
else
classLabel:SetTextColor(1, 1, 1)
end
for _, frameName in ipairs(HideCoA.FRAMES) do
checks[frameName]:SetChecked(HideCoA.GetActiveClassSettings()[class][frameName])
end
for tabClass, button in pairs(tabButtons) do
if tabClass == class then
button.selectedTexture:Show()
else
button.selectedTexture:Hide()
end
end
end
for index, class in ipairs(HideCoA.CUSTOM_CLASSES) do
local button = CreateFrame("Button", "HideCoAClassTab" .. class, classSidebar)
button:SetHeight(TAB_HEIGHT)
button:SetPoint("TOPLEFT", classSidebar, "TOPLEFT", 4, -4 - (index - 1) * TAB_HEIGHT)
button:SetPoint("RIGHT", classSidebar, "RIGHT", -4, 0)
local selectedTexture = button:CreateTexture(nil, "BACKGROUND")
selectedTexture:SetAllPoints()
selectedTexture:SetTexture(1, 1, 1, 0.2)
selectedTexture:Hide()
button.selectedTexture = selectedTexture
button:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD")
local displayName = (LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[class]) or class
local text = button:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
text:SetPoint("LEFT", 4, 0)
text:SetText(displayName)
local color = RAID_CLASS_COLORS and RAID_CLASS_COLORS[class]
if color then
text:SetTextColor(color.r, color.g, color.b)
end
button:SetScript("OnClick", function()
SelectClass(class)
end)
AddClickSound(button)
tabButtons[class] = button
end
hideAllButton:SetScript("OnClick", function()
HideCoA.HideAllFrames()
if selectedClass then
SelectClass(selectedClass)
end
end)
AddClickSound(hideAllButton)
showAllButton:SetScript("OnClick", function()
HideCoA.ShowAllFrames()
if selectedClass then
SelectClass(selectedClass)
end
end)
AddClickSound(showAllButton)
classesPanel:SetScript("OnShow", function()
SelectClass(selectedClass or HideCoA.CUSTOM_CLASSES[1])
end)
InterfaceOptions_AddCategory(classesPanel)
-- CHARACTER OVERRIDE SUBCATEGORY --
local characterOverridePanel = CreateFrame("Frame")
characterOverridePanel.name = "Character Override"
characterOverridePanel.parent = panel.name
local characterOverrideTitle = characterOverridePanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
characterOverrideTitle:SetPoint("TOPLEFT", 16, -16)
characterOverrideTitle:SetFont(titleFont, titleSize + 4, "OUTLINE")
characterOverrideTitle:SetText("Character Override")
local characterNameText = characterOverridePanel:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
characterNameText:SetPoint("TOPLEFT", characterOverrideTitle, "BOTTOMLEFT", 0, -12)
characterNameText:SetText(HideCoA.GetCharacterKey())
local overrideEnabledCheck = CreateFrame("CheckButton", "HideCoAOverrideEnabledCheck", characterOverridePanel, "InterfaceOptionsCheckButtonTemplate")
overrideEnabledCheck:SetPoint("TOPLEFT", characterNameText, "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, characterOverridePanel, "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)
AddCheckboxFeedback(check)
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)
AddCheckboxFeedback(overrideEnabledCheck)
characterOverridePanel:SetScript("OnShow", RefreshCharacterOverrideTab)
InterfaceOptions_AddCategory(characterOverridePanel)
-- ABOUT SUBCATEGORY --
local aboutPanel = CreateFrame("Frame")
aboutPanel.name = "About"
aboutPanel.parent = panel.name
local aboutTitle = aboutPanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
aboutTitle:SetPoint("TOPLEFT", 16, -16)
aboutTitle:SetFont(titleFont, titleSize + 4, "OUTLINE")
aboutTitle:SetText("About")
InterfaceOptions_AddCategory(aboutPanel)
-- Jump straight to the Classes subcategory when the HideCoAUI parent node itself is opened.
panel:SetScript("OnShow", function(self)
InterfaceOptionsFrame_OpenToCategory(classesPanel)
self:Hide()
end)