Initial commit: HideCoA addon
This commit is contained in:
+127
@@ -0,0 +1,127 @@
|
||||
local panel = CreateFrame("Frame")
|
||||
panel.name = "HideCoAUI"
|
||||
|
||||
local title = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
|
||||
title:SetPoint("TOPLEFT", 16, -16)
|
||||
title:SetText("HideCoAUI")
|
||||
|
||||
local subtitle = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
|
||||
subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
|
||||
subtitle:SetText("Select a class, then toggle the checkboxes to hide its class resource:")
|
||||
|
||||
local sidebar = CreateFrame("Frame", nil, panel)
|
||||
sidebar:SetPoint("TOPLEFT", subtitle, "BOTTOMLEFT", 0, -12)
|
||||
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 classTitle = content:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
|
||||
classTitle:SetPoint("TOPLEFT", content, "TOPLEFT", 0, 0)
|
||||
|
||||
local titleFont, titleSize = classTitle:GetFont()
|
||||
classTitle:SetFont(titleFont, titleSize + 4, "OUTLINE")
|
||||
|
||||
local checks = {}
|
||||
local selectedClass = nil
|
||||
|
||||
local previousAnchor = classTitle
|
||||
local previousSpacing = -12
|
||||
|
||||
for _, frameName in ipairs(HideCoA.FRAMES) do
|
||||
|
||||
local check = CreateFrame("CheckButton", "HideCoAClassCheck" .. frameName, content, "InterfaceOptionsCheckButtonTemplate")
|
||||
check:SetPoint("TOPLEFT", previousAnchor, "BOTTOMLEFT", 0, previousSpacing)
|
||||
_G[check:GetName() .. "Text"]:SetText("Hide " .. frameName)
|
||||
|
||||
check.frameName = frameName
|
||||
|
||||
check:SetScript("OnClick", function(self)
|
||||
|
||||
if not selectedClass then
|
||||
return
|
||||
end
|
||||
|
||||
HideCoADB.classSettings[selectedClass][self.frameName] = self:GetChecked() and true or false
|
||||
HideCoA.ApplySetting()
|
||||
|
||||
end)
|
||||
|
||||
checks[frameName] = check
|
||||
previousAnchor = check
|
||||
previousSpacing = -8
|
||||
|
||||
end
|
||||
|
||||
local TAB_HEIGHT = 18
|
||||
|
||||
local tabButtons = {}
|
||||
|
||||
local function SelectClass(class)
|
||||
|
||||
selectedClass = class
|
||||
|
||||
local displayName = (LOCALIZED_CLASS_NAMES_MALE and LOCALIZED_CLASS_NAMES_MALE[class]) or class
|
||||
classTitle:SetText(displayName)
|
||||
|
||||
local color = RAID_CLASS_COLORS and RAID_CLASS_COLORS[class]
|
||||
if color then
|
||||
classTitle:SetTextColor(color.r, color.g, color.b)
|
||||
else
|
||||
classTitle:SetTextColor(1, 1, 1)
|
||||
end
|
||||
|
||||
for _, frameName in ipairs(HideCoA.FRAMES) do
|
||||
checks[frameName]:SetChecked(HideCoADB.classSettings[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, 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(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)
|
||||
|
||||
tabButtons[class] = button
|
||||
|
||||
end
|
||||
|
||||
panel:SetScript("OnShow", function()
|
||||
SelectClass(selectedClass or HideCoA.CUSTOM_CLASSES[1])
|
||||
end)
|
||||
|
||||
InterfaceOptions_AddCategory(panel)
|
||||
Reference in New Issue
Block a user