127 lines
2.6 KiB
Lua
127 lines
2.6 KiB
Lua
HideCoA = {}
|
|
|
|
local f = CreateFrame("Frame")
|
|
|
|
HideCoA.CUSTOM_CLASSES = {
|
|
"NECROMANCER",
|
|
"PYROMANCER",
|
|
"CULTIST",
|
|
"STARCALLER",
|
|
"SUNCLERIC",
|
|
"TINKER",
|
|
"SPIRITMAGE",
|
|
"WILDWALKER",
|
|
"REAPER",
|
|
"PROPHET",
|
|
"CHRONOMANCER",
|
|
"SONOFARUGAL",
|
|
"GUARDIAN",
|
|
"STORMBRINGER",
|
|
"DEMONHUNTER",
|
|
"BARBARIAN",
|
|
"WITCHDOCTOR",
|
|
"WITCHHUNTER",
|
|
"FLESHWARDEN",
|
|
"MONK",
|
|
"RANGER",
|
|
}
|
|
|
|
HideCoA.FRAMES = {
|
|
"CoAResourceSegmentBar",
|
|
"CoAResourceOrb",
|
|
"CoAResourceBar",
|
|
}
|
|
|
|
local function ShouldHideForClass(playerClass, frameName)
|
|
|
|
local classSettings = HideCoADB.classSettings[playerClass]
|
|
|
|
if not classSettings or classSettings[frameName] == nil then
|
|
return true
|
|
end
|
|
|
|
return classSettings[frameName]
|
|
|
|
end
|
|
|
|
local hookedFrames = {}
|
|
|
|
local function ApplySetting()
|
|
|
|
local _, playerClass = UnitClass("player")
|
|
|
|
for _, frameName in ipairs(HideCoA.FRAMES) do
|
|
|
|
local frame = _G[frameName]
|
|
|
|
if frame then
|
|
|
|
if not hookedFrames[frameName] then
|
|
|
|
frame:HookScript("OnShow", function(self)
|
|
local _, currentClass = UnitClass("player")
|
|
if ShouldHideForClass(currentClass, frameName) then
|
|
self:Hide()
|
|
end
|
|
end)
|
|
|
|
hookedFrames[frameName] = true
|
|
|
|
end
|
|
|
|
local hide = ShouldHideForClass(playerClass, frameName)
|
|
|
|
if hide then
|
|
frame:Hide()
|
|
else
|
|
frame:Show()
|
|
end
|
|
|
|
if frame.EnableMouse then
|
|
frame:EnableMouse(not hide)
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HideCoA.ApplySetting = ApplySetting
|
|
|
|
f:RegisterEvent("ADDON_LOADED")
|
|
f:RegisterEvent("PLAYER_LOGIN")
|
|
|
|
f:SetScript("OnEvent", function(self, event, arg1)
|
|
|
|
if event == "ADDON_LOADED" and arg1 == "HideCoA" then
|
|
|
|
if not HideCoADB then
|
|
HideCoADB = {}
|
|
end
|
|
|
|
if not HideCoADB.classSettings then
|
|
HideCoADB.classSettings = {}
|
|
end
|
|
|
|
for _, class in ipairs(HideCoA.CUSTOM_CLASSES) do
|
|
|
|
if type(HideCoADB.classSettings[class]) ~= "table" then
|
|
HideCoADB.classSettings[class] = {}
|
|
end
|
|
|
|
for _, frameName in ipairs(HideCoA.FRAMES) do
|
|
if HideCoADB.classSettings[class][frameName] == nil then
|
|
HideCoADB.classSettings[class][frameName] = true
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
elseif event == "PLAYER_LOGIN" then
|
|
|
|
ApplySetting()
|
|
|
|
end
|
|
|
|
end) |