disable options for disabled module + (un)register messages when enabled/disabled

This commit is contained in:
Sumsebrum 2022-02-15 22:59:21 +01:00
parent 86337919b8
commit 3e59a03ce9
12 changed files with 198 additions and 40 deletions

View File

@ -47,13 +47,22 @@ function ACDFrame:Initialize()
ACDNumOne:SetPoint("CENTER", ACDNumFrame, "CENTER", 0, 0)
self.ACDNumOne = ACDNumOne
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_SPEC")
if Gladdy.db.countdown then
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_SPEC")
end
self.faction = UnitFactionGroup("player")
end
function ACDFrame:UpdateFrameOnce()
if Gladdy.db.countdown then
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_SPEC")
else
self:UnregisterAllMessages()
end
self.ACDNumFrame:SetFrameStrata(Gladdy.db.arenaCountdownFrameStrata)
self.ACDNumFrame:SetFrameLevel(Gladdy.db.arenaCountdownFrameLevel)
end
@ -189,6 +198,7 @@ function ACDFrame:GetOptions()
max = 512,
step = 16,
width = "full",
disabled = function() return not Gladdy.db.countdown end,
}),
headerAuraLevel = {
type = "header",
@ -201,6 +211,7 @@ function ACDFrame:GetOptions()
order = 6,
values = Gladdy.frameStrata,
sorting = Gladdy.frameStrataSorting,
disabled = function() return not Gladdy.db.countdown end,
}),
arenaCountdownFrameLevel = Gladdy:option({
type = "range",
@ -210,6 +221,7 @@ function ACDFrame:GetOptions()
step = 1,
order = 7,
width = "full",
disabled = function() return not Gladdy.db.countdown end,
}),
}
end

View File

@ -76,13 +76,16 @@ function BuffsDebuffs:Initialize()
self.icons = {}
self.trackedCC = {}
self.framePool = {}
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("UNIT_DESTROYED")
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("AURA_FADE")
self:RegisterMessage("AURA_GAIN")
self:RegisterMessage("AURA_GAIN_LIMIT")
self:SetScript("OnEvent", BuffsDebuffs.OnEvent)
if Gladdy.db.buffsEnabled then
self:RegisterMessages(
"JOINED_ARENA",
"UNIT_DESTROYED",
"UNIT_DEATH",
"AURA_FADE",
"AURA_GAIN",
"AURA_GAIN_LIMIT")
self:SetScript("OnEvent", BuffsDebuffs.OnEvent)
end
spellSchoolToOptionValueTable = {
curse = Gladdy.db.buffsBorderColorCurse,
magic = Gladdy.db.buffsBorderColorMagic,
@ -290,6 +293,22 @@ local function styleIcon(aura, auraType)
aura.stacks:SetTextColor(Gladdy.db.buffsFontColor.r, Gladdy.db.buffsFontColor.g, Gladdy.db.buffsFontColor.b, 1)
end
function BuffsDebuffs:UpdateFrameOnce()
if Gladdy.db.buffsEnabled then
self:RegisterMessages(
"JOINED_ARENA",
"UNIT_DESTROYED",
"UNIT_DEATH",
"AURA_FADE",
"AURA_GAIN",
"AURA_GAIN_LIMIT")
self:SetScript("OnEvent", BuffsDebuffs.OnEvent)
else
self:UnregisterAllMessages()
self:SetScript("OnEvent", nil)
end
end
function BuffsDebuffs:UpdateFrame(unit)
--DEBUFFS
self.frames[unit].debuffFrame:SetHeight(Gladdy.db.buffsIconSize)
@ -485,12 +504,14 @@ function BuffsDebuffs:GetOptions()
name = L["Show CC"],
desc = L["Shows all debuffs, which are displayed on the ClassIcon as well"],
order = 4,
disabled = function() return not Gladdy.db.buffsEnabled end,
}),
group = {
type = "group",
childGroups = "tree",
name = L["Frame"],
order = 5,
disabled = function() return not Gladdy.db.buffsEnabled end,
args = {
buffs = {
type = "group",
@ -919,6 +940,7 @@ function BuffsDebuffs:GetOptions()
name = L["Debuff Lists"],
type = "group",
order = 11,
disabled = function() return not Gladdy.db.buffsEnabled end,
childGroups = "tree",
args = select(1, Gladdy:GetAuras(AURA_TYPE_DEBUFF)),
set = function(info, state)
@ -934,6 +956,7 @@ function BuffsDebuffs:GetOptions()
name = L["Buff Lists"],
type = "group",
order = 12,
disabled = function() return not Gladdy.db.buffsEnabled end,
childGroups = "tree",
args = select(1, Gladdy:GetAuras(AURA_TYPE_BUFF)),
set = function(info, state)

View File

@ -48,8 +48,10 @@ local Castbar = Gladdy:NewModule("Cast Bar", 70, {
function Castbar:Initialize()
self.frames = {}
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("JOINED_ARENA")
if Gladdy.db.castBarEnabled then
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("JOINED_ARENA")
end
end
---------------------------
@ -133,6 +135,15 @@ function Castbar:CreateFrame(unit)
self:ResetUnit(unit)
end
function Castbar:UpdateFrameOnce()
if Gladdy.db.castBarEnabled then
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("JOINED_ARENA")
else
self:UnregisterAllMessages()
end
end
function Castbar:UpdateFrame(unit)
local castBar = self.frames[unit]
if (not castBar) then
@ -584,6 +595,7 @@ function Castbar:GetOptions()
childGroups = "tree",
name = L["Frame"],
order = 4,
disabled = function() return not Gladdy.db.castBarEnabled end,
args = {
barFrame = {
type = "group",

View File

@ -82,9 +82,21 @@ local specIcons = {
function Classicon:Initialize()
self.frames = {}
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("UNIT_SPEC")
if Gladdy.db.classIconEnabled then
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("UNIT_SPEC")
end
end
function Classicon:UpdateFrameOnce()
if Gladdy.db.classIconEnabled then
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("UNIT_SPEC")
else
self:UnregisterAllMessages()
end
end
function Classicon:CreateFrame(unit)
@ -191,6 +203,7 @@ function Classicon:GetOptions()
name = L["Show Spec Icon"],
desc = L["Shows Spec Icon once spec is detected"],
order = 4,
disabled = function() return not Gladdy.db.classIconEnabled end,
get = function() return Gladdy.db.classIconSpecIcon end,
set = function(_, value)
Gladdy.db.classIconSpecIcon = value
@ -210,6 +223,7 @@ function Classicon:GetOptions()
childGroups = "tree",
name = L["Frame"],
order = 4,
disabled = function() return not Gladdy.db.classIconEnabled end,
args = {
size = {
type = "group",

View File

@ -20,7 +20,9 @@ local CombatIndicator = Gladdy:NewModule("Combat Indicator", nil, {
function CombatIndicator:Initialize()
self.frames = {}
self:RegisterMessage("JOINED_ARENA")
if Gladdy.db.ciEnabled then
self:RegisterMessage("JOINED_ARENA")
end
self.updateInterval = 0.05
self.combatIndicatorIcon = select(3, GetSpellInfo(674))
end
@ -57,6 +59,14 @@ function CombatIndicator:CreateFrame(unit)
button.ciFrame = ciFrame
end
function CombatIndicator:UpdateFrameOnce()
if Gladdy.db.ciEnabled then
self:RegisterMessage("JOINED_ARENA")
else
self:UnregisterAllMessages()
end
end
function CombatIndicator:UpdateFrame(unit)
local button = Gladdy.buttons[unit]
local ciFrame = self.frames[unit]
@ -133,6 +143,7 @@ function CombatIndicator:GetOptions()
childGroups = "tree",
name = L["Frame"],
order = 4,
disabled = function() return not Gladdy.db.ciEnabled end,
args = {
general = {
type = "group",

View File

@ -79,7 +79,7 @@ end
function Diminishings:Initialize()
self.frames = {}
self:RegisterMessage("UNIT_DEATH", "ResetUnit", "AURA_FADE", "UNIT_DESTROYED")
self:RegisterMessage("UNIT_DESTROYED")
end
function Diminishings:CreateFrame(unit)
@ -434,6 +434,7 @@ function Diminishings:GetOptions()
name = L["DR Duration"],
desc = L["Change the DR Duration in seconds (DR is dynamic between 15-20s)"],
order = 4,
disabled = function() return not Gladdy.db.drEnabled end,
min = 15,
max = 20,
step = .1,
@ -443,6 +444,7 @@ function Diminishings:GetOptions()
childGroups = "tree",
name = L["Frame"],
order = 5,
disabled = function() return not Gladdy.db.drEnabled end,
args = {
icon = {
type = "group",
@ -781,6 +783,7 @@ function Diminishings:GetOptions()
type = "group",
name = L["Categories"],
order = 6,
disabled = function() return not Gladdy.db.drEnabled end,
args = Diminishings:CategoryOptions(),
},
}

View File

@ -31,11 +31,25 @@ local Pets = Gladdy:NewModule("Pets", nil, {
function Pets:Initialize()
self.frames = {}
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("PET_SPOTTED")
self:RegisterMessage("PET_DESTROYED")
self:RegisterMessage("PET_STEALTH")
self:RegisterMessage("ENEMY_SPOTTED")
if Gladdy.db.petEnabled then
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("PET_SPOTTED")
self:RegisterMessage("PET_DESTROYED")
self:RegisterMessage("PET_STEALTH")
self:RegisterMessage("ENEMY_SPOTTED")
end
end
function Pets:UpdateFrameOnce()
if Gladdy.db.petEnabled then
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("PET_SPOTTED")
self:RegisterMessage("PET_DESTROYED")
self:RegisterMessage("PET_STEALTH")
self:RegisterMessage("ENEMY_SPOTTED")
else
self:UnregisterAllMessages()
end
end
function Pets:JOINED_ARENA()
@ -380,6 +394,7 @@ function Pets:GetOptions()
childGroups = "tree",
name = L["Frame"],
order = 3,
disabled = function() return not Gladdy.db.petEnabled end,
args = {
general = {
type = "group",

View File

@ -29,10 +29,23 @@ local Powerbar = Gladdy:NewModule("Power Bar", 90, {
function Powerbar:Initialize()
self.frames = {}
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_SPEC")
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("UNIT_DESTROYED")
if Gladdy.db.powerBarEnabled then
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_SPEC")
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("UNIT_DESTROYED")
end
end
function Powerbar:UpdateFrameOnce()
if Gladdy.db.powerBarEnabled then
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("UNIT_SPEC")
self:RegisterMessage("UNIT_DEATH")
self:RegisterMessage("UNIT_DESTROYED")
else
self:UnregisterAllMessages()
end
end
function Powerbar:CreateFrame(unit)
@ -147,8 +160,16 @@ function Powerbar:UpdateFrame(unit)
if not Gladdy.db.powerBarEnabled then
powerBar:Hide()
powerBar:UnregisterEvent("UNIT_POWER_UPDATE")
powerBar:UnregisterEvent("UNIT_MAXPOWER")
powerBar:UnregisterEvent("UNIT_DISPLAYPOWER")
powerBar:SetScript("OnEvent", nil)
return
else
powerBar:RegisterUnitEvent("UNIT_POWER_UPDATE", unit)
powerBar:RegisterUnitEvent("UNIT_MAXPOWER", unit)
powerBar:RegisterUnitEvent("UNIT_DISPLAYPOWER", unit)
powerBar:SetScript("OnEvent", Powerbar.OnEvent)
powerBar:Show()
end
powerBar.bg:SetTexture(Gladdy:SMFetch("statusbar", "powerBarTexture"))
@ -351,6 +372,7 @@ function Powerbar:GetOptions()
childGroups = "tree",
name = L["Frame"],
order = 4,
disabled = function() return not Gladdy.db.powerBarEnabled end,
args = {
general = {
type = "group",

View File

@ -26,9 +26,21 @@ local Racial = Gladdy:NewModule("Racial", 79, {
function Racial:Initialize()
self.frames = {}
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("RACIAL_USED")
if Gladdy.db.racialEnabled then
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("RACIAL_USED")
end
end
function Racial:UpdateFrameOnce()
if Gladdy.db.racialEnabled then
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("ENEMY_SPOTTED")
self:RegisterMessage("RACIAL_USED")
else
self:UnregisterAllMessages()
end
end
local function iconTimer(self,elapsed)
@ -235,6 +247,7 @@ function Racial:GetOptions()
childGroups = "tree",
name = L["Frame"],
order = 4,
disabled = function() return not Gladdy.db.racialEnabled end,
args = {
general = {
type = "group",

View File

@ -52,12 +52,24 @@ local RangeCheck = Gladdy:NewModule("Range Check", nil, {
})
function RangeCheck:Initialize()
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("ENEMY_STEALTH")
self:RegisterMessage("ENEMY_SPOTTED")
if Gladdy.db.rangeCheckEnabled then
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("ENEMY_STEALTH")
self:RegisterMessage("ENEMY_SPOTTED")
end
self.playerClass = select(2, UnitClass("player"))
end
function RangeCheck:UpdateFrameOnce()
if Gladdy.db.rangeCheckEnabled then
self:RegisterMessage("JOINED_ARENA")
self:RegisterMessage("ENEMY_STEALTH")
self:RegisterMessage("ENEMY_SPOTTED")
else
self:UnregisterAllMessages()
end
end
function RangeCheck:Reset()
self.test = nil
end
@ -268,6 +280,7 @@ function RangeCheck:GetOptions()
childGroups = "tree",
name = L["General"],
order = 5,
disabled = function() return not Gladdy.db.rangeCheckEnabled end,
args = {
general = {
type = "group",
@ -340,6 +353,7 @@ function RangeCheck:GetOptions()
childGroups = "tree",
name = L["Spells"],
order = 5,
disabled = function() return not Gladdy.db.rangeCheckEnabled end,
args = RangeCheck:GetSpells(),
},
}

View File

@ -34,8 +34,10 @@ end
function ShadowsightTimer:Initialize()
self.locale = Gladdy:GetArenaTimer()
self:RegisterMessage("JOINED_ARENA")
self:CreateAnchor()
if Gladdy.db.shadowsightTimerEnabled then
self:RegisterMessage("JOINED_ARENA")
end
end
function ShadowsightTimer:Reset()
@ -106,6 +108,12 @@ function ShadowsightTimer:CreateAnchor()
end
function ShadowsightTimer:UpdateFrameOnce()
if Gladdy.db.shadowsightTimerEnabled then
self:RegisterMessage("JOINED_ARENA")
else
self:UnregisterAllMessages()
end
self.anchor:EnableMouse(not Gladdy.db.shadowsightTimerLocked)
self.anchor:SetFrameStrata(Gladdy.db.shadowsightTimerFrameStrata)
@ -299,23 +307,27 @@ function ShadowsightTimer:GetOptions()
name = L["Locked"],
--desc = L["Turns countdown before the start of an arena match on/off."],
order = 4,
disabled = function() return not Gladdy.db.shadowsightTimerEnabled end,
}),
shadowsightTimerShowTwoTimer = Gladdy:option({
type = "toggle",
name = L["Show two timers"],
order = 5,
disabled = function() return not Gladdy.db.shadowsightTimerEnabled end,
}),
shadowsightAnnounce = Gladdy:option({
type = "toggle",
name = L["Announce"],
--desc = L["Turns countdown before the start of an arena match on/off."],
order = 6,
disabled = function() return not Gladdy.db.shadowsightTimerEnabled end,
}),
group = {
type = "group",
childGroups = "tree",
name = L["Frame"],
order = 7,
disabled = function() return not Gladdy.db.shadowsightTimerEnabled end,
args = {
general = {
type = "group",

View File

@ -29,8 +29,17 @@ local Trinket = Gladdy:NewModule("Trinket", 80, {
function Trinket:Initialize()
self.frames = {}
if Gladdy.db.trinketEnabled then
self:RegisterMessage("JOINED_ARENA")
end
end
self:RegisterMessage("JOINED_ARENA")
function Trinket:UpdateFrameOnce()
if Gladdy.db.trinketEnabled then
self:RegisterMessage("JOINED_ARENA")
else
self:UnregisterAllMessages()
end
end
local function iconTimer(self, elapsed)
@ -272,6 +281,7 @@ function Trinket:GetOptions()
name = L["Colored trinket"],
desc = L["Shows a solid colored icon when off/off CD."],
order = 4,
disabled = function() return not Gladdy.db.trinketEnabled end,
}),
trinketColoredCd = Gladdy:colorOption({
type = "color",
@ -279,9 +289,7 @@ function Trinket:GetOptions()
desc = L["Color of the border"],
order = 5,
hasAlpha = true,
disabled = function()
return not Gladdy.db.trinketColored
end,
disabled = function() return not Gladdy.db.trinketEnabled end,
}),
trinketColoredNoCd = Gladdy:colorOption({
type = "color",
@ -289,15 +297,14 @@ function Trinket:GetOptions()
desc = L["Color of the border"],
order = 6,
hasAlpha = true,
disabled = function()
return not Gladdy.db.trinketColored
end,
disabled = function() return not Gladdy.db.trinketEnabled end,
}),
group = {
type = "group",
childGroups = "tree",
name = L["Frame"],
order = 5,
disabled = function() return not Gladdy.db.trinketEnabled end,
args = {
general = {
type = "group",