87d9c83bdb
Only applies when no class has been manually selected yet in the session; a manual selection is remembered across subsequent tab switches.
504 lines
15 KiB
Lua
504 lines
15 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 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(HideCoA.FRAMES) do
|
|
|
|
local check = CreateFrame("CheckButton", "HideCoAClassCheck" .. 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
|
|
|
|
HideCoA.GetActiveClassSettings()[selectedClass][self.frameName] = self:GetChecked() and true or false
|
|
HideCoA.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 HideCoA.GetProfileOverride(HideCoA.GetActiveProfileName()).enabled
|
|
|
|
if overridden then
|
|
overrideNoticeText:Show()
|
|
else
|
|
overrideNoticeText:Hide()
|
|
end
|
|
|
|
for _, frameName in ipairs(HideCoA.FRAMES) do
|
|
|
|
checks[frameName]:SetChecked(HideCoA.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", "HideCoAHideClassButton", classContent, "UIPanelButtonTemplate")
|
|
hideClassButton:SetPoint("TOPLEFT", previousAnchor, "BOTTOMLEFT", 0, -16)
|
|
hideClassButton:SetSize(140, 22)
|
|
hideClassButton:SetText("Hide This Class")
|
|
|
|
showClassButton = CreateFrame("Button", "HideCoAShowClassButton", 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 = HideCoA.GetActiveClassSettings()[selectedClass]
|
|
|
|
for _, frameName in ipairs(HideCoA.FRAMES) do
|
|
classSettings[frameName] = true
|
|
end
|
|
|
|
HideCoA.ApplySetting()
|
|
SelectClass(selectedClass)
|
|
|
|
end)
|
|
|
|
AddClickSound(hideClassButton)
|
|
|
|
showClassButton:SetScript("OnClick", function()
|
|
|
|
if not selectedClass then
|
|
return
|
|
end
|
|
|
|
local classSettings = HideCoA.GetActiveClassSettings()[selectedClass]
|
|
|
|
for _, frameName in ipairs(HideCoA.FRAMES) do
|
|
classSettings[frameName] = false
|
|
end
|
|
|
|
HideCoA.ApplySetting()
|
|
SelectClass(selectedClass)
|
|
|
|
end)
|
|
|
|
AddClickSound(showClassButton)
|
|
|
|
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()
|
|
if not selectedClass then
|
|
local _, ownClass = UnitClass("player")
|
|
if tabButtons[ownClass] then
|
|
selectedClass = ownClass
|
|
end
|
|
end
|
|
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 overrideProfileDropdown = CreateFrame("Frame", "HideCoAOverrideProfileDropDown", characterOverridePanel, "UIDropDownMenuTemplate")
|
|
overrideProfileDropdown:SetPoint("TOPLEFT", characterOverrideTitle, "BOTTOMLEFT", -16, -12)
|
|
|
|
if ElvSkins then
|
|
ElvSkins:HandleDropDownBox(overrideProfileDropdown, 180)
|
|
end
|
|
|
|
UIDropDownMenu_SetWidth(overrideProfileDropdown, 180)
|
|
|
|
local overrideEnabledCheck = CreateFrame("CheckButton", "HideCoAOverrideEnabledCheck", characterOverridePanel, "InterfaceOptionsCheckButtonTemplate")
|
|
overrideEnabledCheck:SetPoint("TOPLEFT", overrideProfileDropdown, "BOTTOMLEFT", 16, -8)
|
|
_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(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)
|
|
if selectedOverrideProfile then
|
|
HideCoA.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 = HideCoA.GetProfileOverride(selectedOverrideProfile)
|
|
|
|
overrideEnabledCheck:SetChecked(override.enabled)
|
|
|
|
for _, frameName in ipairs(HideCoA.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()
|
|
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)
|
|
|
|
AddCheckboxFeedback(overrideEnabledCheck)
|
|
|
|
characterOverridePanel:SetScript("OnShow", function()
|
|
SelectOverrideProfile(selectedOverrideProfile or HideCoA.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: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)
|