Rename addon from HideCoA to HideCoAUI

Moves addon files into a HideCoAUI subfolder (repo root now holds
LICENSE/README for packaging), renames HideCoA.toc and the HideCoA.lua
global table to HideCoAUI throughout, and fixes the ADDON_LOADED
arg1 check accordingly. HideCoADB (SavedVariables) is left untouched
to preserve existing user settings.
This commit is contained in:
2026-07-08 15:18:16 +02:00
parent 899f872577
commit e65a737a31
4 changed files with 72 additions and 72 deletions
+437
View File
@@ -0,0 +1,437 @@
HideCoAUI = {}
local f = CreateFrame("Frame")
HideCoAUI.CUSTOM_CLASSES = {
"NECROMANCER",
"PYROMANCER",
"CULTIST",
"STARCALLER",
"SUNCLERIC",
"TINKER",
"SPIRITMAGE",
"WILDWALKER",
"REAPER",
"PROPHET",
"CHRONOMANCER",
"SONOFARUGAL",
"GUARDIAN",
"STORMBRINGER",
"DEMONHUNTER",
"BARBARIAN",
"WITCHDOCTOR",
"WITCHHUNTER",
"FLESHWARDEN",
"MONK",
"RANGER",
}
HideCoAUI.FRAMES = {
"CoAResourceSegmentBar",
"CoAResourceOrb",
"CoAResourceBar",
"CoAMultiCastActionBarFrame",
}
local function CreateDefaultClassSettings()
local classSettings = {}
for _, class in ipairs(HideCoAUI.CUSTOM_CLASSES) do
classSettings[class] = {}
for _, frameName in ipairs(HideCoAUI.FRAMES) do
classSettings[class][frameName] = true
end
end
return classSettings
end
local function EnsureClassSettingsComplete(classSettings)
for _, class in ipairs(HideCoAUI.CUSTOM_CLASSES) do
if type(classSettings[class]) ~= "table" then
classSettings[class] = {}
end
for _, frameName in ipairs(HideCoAUI.FRAMES) do
if classSettings[class][frameName] == nil then
classSettings[class][frameName] = true
end
end
end
end
local function GetCharacterKey()
local _, classToken = UnitClass("player")
local className = (LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[classToken]) or classToken
return UnitName("player") .. " - " .. className .. " - " .. GetRealmName()
end
HideCoAUI.GetCharacterKey = GetCharacterKey
local function GetActiveProfileName()
local charKey = GetCharacterKey()
local assigned = HideCoADB.charProfile and HideCoADB.charProfile[charKey]
if assigned and HideCoADB.profiles[assigned] then
return assigned
end
return charKey
end
HideCoAUI.GetActiveProfileName = GetActiveProfileName
local function SetActiveProfileName(name)
HideCoADB.charProfile[GetCharacterKey()] = name
end
HideCoAUI.SetActiveProfileName = SetActiveProfileName
local function GetActiveClassSettings()
local name = GetActiveProfileName()
local profile = HideCoADB.profiles[name]
if not profile then
profile = { classSettings = CreateDefaultClassSettings() }
HideCoADB.profiles[name] = profile
end
if not profile.classSettings then
profile.classSettings = CreateDefaultClassSettings()
end
return profile.classSettings
end
HideCoAUI.GetActiveClassSettings = GetActiveClassSettings
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)
HideCoADB.profiles[name] = nil
for charKey, assigned in pairs(HideCoADB.charProfile) do
if assigned == name then
-- Unassigning falls back to the character's own auto-created
-- profile (see GetActiveProfileName/GetActiveClassSettings),
-- which gets recreated on demand if it doesn't exist.
HideCoADB.charProfile[charKey] = nil
end
end
end
HideCoAUI.DeleteProfile = DeleteProfile
local function EnsureProfileOverride(name)
local profile = HideCoADB.profiles[name]
if not profile then
profile = { classSettings = CreateDefaultClassSettings() }
HideCoADB.profiles[name] = profile
end
if not profile.override then
profile.override = { enabled = false, frameSettings = {} }
end
for _, frameName in ipairs(HideCoAUI.FRAMES) do
if profile.override.frameSettings[frameName] == nil then
profile.override.frameSettings[frameName] = true
end
end
return profile.override
end
local function GetProfileOverride(name)
return EnsureProfileOverride(name)
end
HideCoAUI.GetProfileOverride = GetProfileOverride
local function SetProfileOverrideEnabled(name, enabled)
GetProfileOverride(name).enabled = enabled
HideCoAUI.ApplySetting()
end
HideCoAUI.SetProfileOverrideEnabled = SetProfileOverrideEnabled
local function SetProfileOverrideFrameHidden(name, frameName, hide)
GetProfileOverride(name).frameSettings[frameName] = hide
HideCoAUI.ApplySetting()
end
HideCoAUI.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
HideCoAUI.GetProfileNames = GetProfileNames
local function SetAllClassesHidden(hide)
local classSettings = GetActiveClassSettings()
for _, class in ipairs(HideCoAUI.CUSTOM_CLASSES) do
for _, frameName in ipairs(HideCoAUI.FRAMES) do
classSettings[class][frameName] = hide
end
end
end
local function HideAllFrames()
SetAllClassesHidden(true)
HideCoAUI.ApplySetting()
end
HideCoAUI.HideAllFrames = HideAllFrames
local function ShowAllFrames()
SetAllClassesHidden(false)
HideCoAUI.ApplySetting()
end
HideCoAUI.ShowAllFrames = ShowAllFrames
local function ShouldHideForClass(playerClass, frameName)
local classSettings = GetActiveClassSettings()[playerClass]
if not classSettings or classSettings[frameName] == nil then
return true
end
return classSettings[frameName]
end
local function ShouldHideFrame(frameName)
local override = GetProfileOverride(GetActiveProfileName())
if override.enabled then
return override.frameSettings[frameName]
end
local _, playerClass = UnitClass("player")
return ShouldHideForClass(playerClass, frameName)
end
local hookedFrames = {}
local seenNaturalShow = {}
local function ApplySetting()
for _, frameName in ipairs(HideCoAUI.FRAMES) do
local frame = _G[frameName]
if frame then
if not hookedFrames[frameName] then
frame:HookScript("OnShow", function(self)
seenNaturalShow[frameName] = true
if ShouldHideFrame(frameName) then
self:Hide()
end
end)
hookedFrames[frameName] = true
end
local hide = ShouldHideFrame(frameName)
if hide then
frame:Hide()
elseif seenNaturalShow[frameName] then
-- The server never Show()s a frame the current class doesn't use,
-- so its data (powerType, maxValue, ...) is never populated. Forcing
-- Show() on it exposes that uninitialized state and crashes the
-- server's own OnUpdate handler. Only force-show a frame we've
-- already seen the game display naturally at least once.
frame:Show()
end
if frame.EnableMouse then
frame:EnableMouse(not hide)
end
end
end
end
HideCoAUI.ApplySetting = ApplySetting
f:RegisterEvent("ADDON_LOADED")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" and arg1 == "HideCoAUI" then
if not HideCoADB then
HideCoADB = {}
end
if not HideCoADB.profiles then
HideCoADB.profiles = {}
end
if not HideCoADB.charProfile then
HideCoADB.charProfile = {}
end
-- Legacy pre-profile saved variables stored a single flat classSettings
-- table shared by every character. Fold it into whichever character
-- happens to load next so those hide/show choices don't just vanish.
local legacyFlatClassSettings = HideCoADB.classSettings
HideCoADB.classSettings = nil
local charKey = GetCharacterKey()
-- The profile-name syntax used to be "realm - character"; rename any
-- existing profile created under that scheme to the new ordering
-- instead of leaving it orphaned in the list.
local ancientCharKey = GetRealmName() .. " - " .. UnitName("player")
if HideCoADB.profiles[ancientCharKey] and not HideCoADB.profiles[charKey] then
HideCoADB.profiles[charKey] = HideCoADB.profiles[ancientCharKey]
HideCoADB.profiles[ancientCharKey] = nil
end
-- The syntax was later "character - realm", without the class; rename
-- any existing profile/assignment created under that scheme too.
local legacyCharKey = UnitName("player") .. " - " .. GetRealmName()
if HideCoADB.profiles[legacyCharKey] and not HideCoADB.profiles[charKey] then
HideCoADB.profiles[charKey] = HideCoADB.profiles[legacyCharKey]
HideCoADB.profiles[legacyCharKey] = nil
end
if HideCoADB.charProfile[legacyCharKey] then
local assigned = HideCoADB.charProfile[legacyCharKey]
HideCoADB.charProfile[charKey] = (assigned == legacyCharKey) and charKey or assigned
HideCoADB.charProfile[legacyCharKey] = nil
end
if HideCoADB.characterOverrides and HideCoADB.characterOverrides[legacyCharKey] and not HideCoADB.characterOverrides[charKey] then
HideCoADB.characterOverrides[charKey] = HideCoADB.characterOverrides[legacyCharKey]
HideCoADB.characterOverrides[legacyCharKey] = nil
end
if not HideCoADB.profiles[charKey] then
HideCoADB.profiles[charKey] = { classSettings = legacyFlatClassSettings or CreateDefaultClassSettings() }
end
for name, profile in pairs(HideCoADB.profiles) do
if not profile.classSettings then
profile.classSettings = CreateDefaultClassSettings()
end
EnsureClassSettingsComplete(profile.classSettings)
EnsureProfileOverride(name)
end
if not HideCoADB.charProfile[charKey] then
HideCoADB.charProfile[charKey] = charKey
end
-- 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
elseif event == "PLAYER_LOGIN" then
ApplySetting()
end
end)
+10
View File
@@ -0,0 +1,10 @@
## Interface: 30300
## Title: Hide CoA Class UI
## Notes: Hides the Conquest of Azeroth class frame.
## Author: Narcasung
## Version: 1.0
## SavedVariables: HideCoADB
## OptionalDeps: ElvUI
HideCoAUI.lua
Options.lua
+564
View File
@@ -0,0 +1,564 @@
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")
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:SetText("Classes")
local hideAllButton = CreateFrame("Button", "HideCoAUIHideAllButton", classesPanel, "UIPanelButtonTemplate")
hideAllButton:SetPoint("TOPLEFT", classesTitle, "BOTTOMLEFT", 0, -12)
hideAllButton:SetSize(100, 22)
hideAllButton:SetText("Hide All")
local showAllButton = CreateFrame("Button", "HideCoAUIShowAllButton", 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",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true,
tileSize = 16,
edgeSize = 16,
insets = { left = 5, right = 5, top = 5, bottom = 5 },
}
local BOX_BACKDROP_ELVUI = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
tile = true,
tileSize = 16,
insets = { left = 0, right = 0, top = 0, bottom = 0 },
}
local function SkinBox(box)
if ElvUI then
box:SetBackdrop(BOX_BACKDROP_ELVUI)
box:SetBackdropColor(0.08, 0.10, 0.14, 0.5)
else
box:SetBackdrop(BOX_BACKDROP)
box:SetBackdropColor(0.08, 0.10, 0.14, 0.5)
box:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
end
end
local sidebarBox = CreateFrame("Frame", nil, classesPanel)
sidebarBox:SetPoint("TOPLEFT", hideAllButton, "BOTTOMLEFT", 0, -12)
sidebarBox:SetPoint("BOTTOMLEFT", classesPanel, "BOTTOMLEFT", 0, 8)
sidebarBox:SetWidth(158)
SkinBox(sidebarBox)
local contentBox = CreateFrame("Frame", nil, classesPanel)
contentBox:SetPoint("TOPLEFT", sidebarBox, "TOPRIGHT", 3, 0)
contentBox:SetPoint("BOTTOMRIGHT", classesPanel, "BOTTOMRIGHT", -8, 8)
SkinBox(contentBox)
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 classLabelHeader = CreateFrame("Frame", nil, classContent)
classLabelHeader:SetPoint("TOPLEFT", classContent, "TOPLEFT", 0, -19)
classLabelHeader:SetPoint("TOPRIGHT", classContent, "TOPRIGHT", 0, -19)
classLabelHeader:SetHeight(18)
local classLabel = classLabelHeader:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
classLabel:SetPoint("TOP")
classLabel:SetPoint("BOTTOM")
classLabel:SetJustifyH("CENTER")
local classLabelLeft = classLabelHeader:CreateTexture(nil, "ARTWORK")
classLabelLeft:SetHeight(8)
classLabelLeft:SetPoint("LEFT", 0, 0)
classLabelLeft:SetPoint("RIGHT", classLabel, "LEFT", -5, 0)
classLabelLeft:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
classLabelLeft:SetTexCoord(0.81, 0.94, 0.5, 1)
local classLabelRight = classLabelHeader:CreateTexture(nil, "ARTWORK")
classLabelRight:SetHeight(8)
classLabelRight:SetPoint("RIGHT", 0, 0)
classLabelRight:SetPoint("LEFT", classLabel, "RIGHT", 5, 0)
classLabelRight:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
classLabelRight:SetTexCoord(0.81, 0.94, 0.5, 1)
local overrideNoticeText = classContent:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
overrideNoticeText:SetPoint("TOPLEFT", classLabelHeader, "BOTTOMLEFT", 16, -8)
overrideNoticeText:SetTextColor(1, 0.35, 0.35)
overrideNoticeText:SetText("These settings are currently overridden")
overrideNoticeText:Hide()
local checks = {}
local selectedClass = nil
local previousAnchor = classLabelHeader
local previousSpacing = -19
local previousXOffset = 16
for _, frameName in ipairs(HideCoAUI.FRAMES) do
local check = CreateFrame("CheckButton", "HideCoAUIClassCheck" .. frameName, classContent, "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
HideCoAUI.GetActiveClassSettings()[selectedClass][self.frameName] = self:GetChecked() and true or false
HideCoAUI.ApplySetting()
end)
AddCheckboxFeedback(check)
checks[frameName] = check
previousAnchor = check
previousSpacing = -8
previousXOffset = 0
end
local tabButtons = {}
local TAB_HEIGHT = 18
local hideClassButton, showClassButton
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
local _, ownClass = UnitClass("player")
local overridden = (class == ownClass) and HideCoAUI.GetProfileOverride(HideCoAUI.GetActiveProfileName()).enabled
if overridden then
overrideNoticeText:Show()
else
overrideNoticeText:Hide()
end
for _, frameName in ipairs(HideCoAUI.FRAMES) do
checks[frameName]:SetChecked(HideCoAUI.GetActiveClassSettings()[class][frameName])
if overridden then
checks[frameName]:Disable()
_G[checks[frameName]:GetName() .. "Text"]:SetTextColor(0.5, 0.5, 0.5)
else
checks[frameName]:Enable()
_G[checks[frameName]:GetName() .. "Text"]:SetTextColor(1, 1, 1)
end
end
if overridden then
hideClassButton:Disable()
showClassButton:Disable()
else
hideClassButton:Enable()
showClassButton:Enable()
end
for tabClass, button in pairs(tabButtons) do
if tabClass == class then
button.selectedTexture:Show()
else
button.selectedTexture:Hide()
end
end
end
hideClassButton = CreateFrame("Button", "HideCoAUIHideClassButton", classContent, "UIPanelButtonTemplate")
hideClassButton:SetPoint("TOPLEFT", previousAnchor, "BOTTOMLEFT", 0, -16)
hideClassButton:SetSize(140, 22)
hideClassButton:SetText("Hide This Class")
showClassButton = CreateFrame("Button", "HideCoAUIShowClassButton", classContent, "UIPanelButtonTemplate")
showClassButton:SetPoint("LEFT", hideClassButton, "RIGHT", 8, 0)
showClassButton:SetSize(140, 22)
showClassButton:SetText("Show This Class")
if ElvSkins then
ElvSkins:HandleButton(hideClassButton)
ElvSkins:HandleButton(showClassButton)
end
hideClassButton:SetScript("OnClick", function()
if not selectedClass then
return
end
local classSettings = HideCoAUI.GetActiveClassSettings()[selectedClass]
for _, frameName in ipairs(HideCoAUI.FRAMES) do
classSettings[frameName] = true
end
HideCoAUI.ApplySetting()
SelectClass(selectedClass)
end)
AddClickSound(hideClassButton)
showClassButton:SetScript("OnClick", function()
if not selectedClass then
return
end
local classSettings = HideCoAUI.GetActiveClassSettings()[selectedClass]
for _, frameName in ipairs(HideCoAUI.FRAMES) do
classSettings[frameName] = false
end
HideCoAUI.ApplySetting()
SelectClass(selectedClass)
end)
AddClickSound(showClassButton)
for index, class in ipairs(HideCoAUI.CUSTOM_CLASSES) do
local button = CreateFrame("Button", "HideCoAUIClassTab" .. 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()
HideCoAUI.HideAllFrames()
if selectedClass then
SelectClass(selectedClass)
end
end)
AddClickSound(hideAllButton)
showAllButton:SetScript("OnClick", function()
HideCoAUI.ShowAllFrames()
if selectedClass then
SelectClass(selectedClass)
end
end)
AddClickSound(showAllButton)
classesPanel:SetScript("OnShow", function()
if not selectedClass then
local _, ownClass = UnitClass("player")
if tabButtons[ownClass] then
selectedClass = ownClass
end
end
SelectClass(selectedClass or HideCoAUI.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:SetText("Character Override")
local overrideProfileDropdown = CreateFrame("Frame", "HideCoAUIOverrideProfileDropDown", characterOverridePanel, "UIDropDownMenuTemplate")
overrideProfileDropdown:SetPoint("TOPLEFT", characterOverrideTitle, "BOTTOMLEFT", -16, -12)
if ElvSkins then
ElvSkins:HandleDropDownBox(overrideProfileDropdown, 180)
end
UIDropDownMenu_SetWidth(overrideProfileDropdown, 180)
local deleteProfileButton = CreateFrame("Button", "HideCoAUIDeleteProfileButton", characterOverridePanel, "UIPanelButtonTemplate")
local overrideProfileDropdownArrow = _G[overrideProfileDropdown:GetName() .. "Button"]
deleteProfileButton:SetPoint("LEFT", overrideProfileDropdownArrow or overrideProfileDropdown, "RIGHT", 8, 2)
deleteProfileButton:SetSize(110, 22)
deleteProfileButton:SetText("Delete Profile")
if ElvSkins then
ElvSkins:HandleButton(deleteProfileButton)
end
local deleteProfileBlockedText = characterOverridePanel:CreateFontString(nil, "ARTWORK", "GameFontDisableSmall")
deleteProfileBlockedText:SetPoint("TOPLEFT", overrideProfileDropdown, "BOTTOMLEFT", 16, -6)
deleteProfileBlockedText:SetText("Can't delete currently logged character profile")
deleteProfileBlockedText:Hide()
local overrideEnabledCheck = CreateFrame("CheckButton", "HideCoAUIOverrideEnabledCheck", characterOverridePanel, "InterfaceOptionsCheckButtonTemplate")
overrideEnabledCheck:SetPoint("TOPLEFT", deleteProfileBlockedText, "BOTTOMLEFT", 0, -28)
_G[overrideEnabledCheck:GetName() .. "Text"]:SetText("Override class options for this character")
if ElvSkins then
ElvSkins:HandleCheckBox(overrideEnabledCheck)
end
local overrideChecks = {}
local selectedOverrideProfile = nil
local overridePreviousAnchor = overrideEnabledCheck
local overridePreviousSpacing = -16
for _, frameName in ipairs(HideCoAUI.FRAMES) do
local check = CreateFrame("CheckButton", "HideCoAUIOverrideCheck" .. 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)
if selectedOverrideProfile then
HideCoAUI.SetProfileOverrideFrameHidden(selectedOverrideProfile, self.frameName, self:GetChecked() and true or false)
end
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()
if not selectedOverrideProfile then
return
end
local override = HideCoAUI.GetProfileOverride(selectedOverrideProfile)
overrideEnabledCheck:SetChecked(override.enabled)
for _, frameName in ipairs(HideCoAUI.FRAMES) do
overrideChecks[frameName]:SetChecked(override.frameSettings[frameName])
SetOverrideCheckEnabled(overrideChecks[frameName], override.enabled)
end
end
local function SelectOverrideProfile(name)
selectedOverrideProfile = name
UIDropDownMenu_SetText(overrideProfileDropdown, name)
RefreshCharacterOverrideTab()
if name == HideCoAUI.GetActiveProfileName() then
deleteProfileButton:Disable()
deleteProfileBlockedText:Show()
else
deleteProfileButton:Enable()
deleteProfileBlockedText:Hide()
end
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(HideCoAUI.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
HideCoAUI.SetProfileOverrideEnabled(selectedOverrideProfile, self:GetChecked() and true or false)
RefreshCharacterOverrideTab()
end
end)
AddCheckboxFeedback(overrideEnabledCheck)
StaticPopupDialogs["HIDECOA_DELETE_PROFILE"] = {
text = "Delete profile '%s'?\n\nThis cannot be undone.",
button1 = "Delete",
button2 = "Cancel",
OnAccept = function(self, profileName)
HideCoAUI.DeleteProfile(profileName)
SelectOverrideProfile(HideCoAUI.GetActiveProfileName())
end,
timeout = 0,
whileDead = 1,
hideOnEscape = 1,
}
deleteProfileButton:SetScript("OnClick", function()
if not selectedOverrideProfile or selectedOverrideProfile == HideCoAUI.GetActiveProfileName() then
return
end
StaticPopup_Show("HIDECOA_DELETE_PROFILE", selectedOverrideProfile, nil, selectedOverrideProfile)
end)
AddClickSound(deleteProfileButton)
characterOverridePanel:SetScript("OnShow", function()
SelectOverrideProfile(selectedOverrideProfile or HideCoAUI.GetActiveProfileName())
end)
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: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)