- add Enable/Disable to the Pet and Stance Bar

- unlocking works right on the petbar now
This commit is contained in:
Hendrik Leppkes
2008-03-05 14:17:12 +00:00
parent 23f723b892
commit 45f86eff26
4 changed files with 127 additions and 43 deletions
+5
View File
@@ -93,6 +93,11 @@ function BT4ActionBars:ApplyConfig()
end
end
-- we do not allow to disable the actionbars module
function BT4ActionBars:ToggleModule()
return
end
function BT4ActionBars:UpdateButtons(force)
for i,v in ipairs(self.actionbars) do
for j,button in ipairs(v.buttons) do
+12 -9
View File
@@ -32,20 +32,12 @@ end
function Bartender4:UpdateModuleConfigs()
self:Lock()
for k,v in AceAddon:IterateModulesOfAddon(self) do
if type(v.ApplyConfig) == "function" then
if v:IsEnabled() and type(v.ApplyConfig) == "function" then
v:ApplyConfig()
end
end
end
function Bartender4:Update()
for k,v in AceAddon:IterateModulesOfAddon("Bartender4") do
if type(v.Update) == "function" then
v:Update()
end
end
end
function Bartender4:CombatLockdown()
self:Lock()
LibStub("AceConfigDialog-3.0"):Close("Bartender4")
@@ -84,3 +76,14 @@ function Bartender4:Merge(target, source)
end
return target
end
Bartender4.modulePrototype = {}
function Bartender4.modulePrototype:ToggleModule(info, value)
self.db.profile.enabled = value
if value and not self:IsEnabled() then
self:Enable()
elseif not value and self:IsEnabled() then
self:Disable()
end
end
Bartender4:SetDefaultModulePrototype(Bartender4.modulePrototype)
+69 -23
View File
@@ -19,7 +19,7 @@ local defaults = { profile = Bartender4:Merge({
function PetBarMod:OnInitialize()
self.db = Bartender4.db:RegisterNamespace("PetBar", defaults)
self:SetEnabledState(self.db.profile.enabled)
self:SetupOptions()
end
@@ -37,28 +37,37 @@ function PetBarMod:OnEnable()
self.bar:ClearSetPoint("CENTER")
self.bar:SetScript("OnEvent", PetBar.OnEvent)
self.bar:RegisterEvent("PLAYER_CONTROL_LOST")
self.bar:RegisterEvent("PLAYER_CONTROL_GAINED")
self.bar:RegisterEvent("PLAYER_FARSIGHT_FOCUS_CHANGED")
self.bar:RegisterEvent("UNIT_PET")
self.bar:RegisterEvent("UNIT_FLAGS")
self.bar:RegisterEvent("UNIT_AURA")
self.bar:RegisterEvent("PET_BAR_UPDATE")
self.bar:RegisterEvent("PET_BAR_UPDATE_COOLDOWN")
self.bar:RegisterEvent("PET_BAR_SHOWGRID")
self.bar:RegisterEvent("PET_BAR_HIDEGRID")
self.bar:SetAttribute("unit", "pet")
RegisterUnitWatch(self.bar, false)
self.bar:ApplyConfig()
end
self.bar.disabled = nil
RegisterUnitWatch(self.bar, false)
self.bar:RegisterEvent("PLAYER_CONTROL_LOST")
self.bar:RegisterEvent("PLAYER_CONTROL_GAINED")
self.bar:RegisterEvent("PLAYER_FARSIGHT_FOCUS_CHANGED")
self.bar:RegisterEvent("UNIT_PET")
self.bar:RegisterEvent("UNIT_FLAGS")
self.bar:RegisterEvent("UNIT_AURA")
self.bar:RegisterEvent("PET_BAR_UPDATE")
self.bar:RegisterEvent("PET_BAR_UPDATE_COOLDOWN")
self.bar:RegisterEvent("PET_BAR_SHOWGRID")
self.bar:RegisterEvent("PET_BAR_HIDEGRID")
self:ApplyConfig()
self:SetupOptions()
end
function PetBarMod:OnDisable()
if not self.bar then return end
self.bar.disabled = true
UnregisterUnitWatch(self.bar)
self.bar:UnregisterAllEvents()
self.bar:Hide()
self:SetupOptions()
end
function PetBarMod:CreatePetButton(id)
@@ -87,19 +96,44 @@ function PetBarMod:CreatePetButton(id)
end
function PetBarMod:SetupOptions()
self.options = Bartender4.ButtonBar.prototype:GetOptionObject()
ActionBars.options.args["Pet"] = {
order = 30,
type = "group",
name = "Pet Bar",
desc = "Configure the Pet Bar",
childGroups = "tab",
if not self.options then
self.options = Bartender4.ButtonBar.prototype:GetOptionObject()
local enabled = {
type = "toggle",
order = 1,
name = "Enabled",
desc = "Enable the PetBar",
get = function() return self.db.profile.enabled end,
set = "ToggleModule",
handler = self,
}
ActionBars.options.args["Pet"].args = self.options.table
self.options:AddElement("general", "enabled", enabled)
self.disabledoptions = {
general = {
type = "group",
name = "General Settings",
cmdInline = true,
order = 1,
args = {
enabled = enabled,
}
}
}
ActionBars.options.args["Pet"] = {
order = 30,
type = "group",
name = "Pet Bar",
desc = "Configure the Pet Bar",
childGroups = "tab",
}
end
ActionBars.options.args["Pet"].args = self:IsEnabled() and self.options.table or self.disabledoptions
end
function PetBarMod:ApplyConfig()
if not self:IsEnabled() then return end
self.bar:ApplyConfig(self.db.profile)
end
@@ -174,6 +208,8 @@ function PetButtonPrototype:ClearSetPoint(...)
self:SetPoint(...)
end
PetBar.button_width = 30
PetBar.button_height = 30
function PetBar:OnEvent(event, arg1)
if event == "PET_BAR_UPDATE" or
(event == "UNIT_PET" and arg1 == "player") or
@@ -196,3 +232,13 @@ function PetBar:ApplyConfig()
self:ForAll("Update")
self:ForAll("ApplyStyle", self.config.style)
end
function PetBar:Unlock()
UnregisterUnitWatch(self)
ButtonBar.Unlock(self)
end
function PetBar:Lock()
ButtonBar.Lock(self)
RegisterUnitWatch(self, false)
end
+41 -11
View File
@@ -19,7 +19,7 @@ local defaults = { profile = Bartender4:Merge({
function StanceBarMod:OnInitialize()
self.db = Bartender4.db:RegisterNamespace("StanceBar", defaults)
self:SetEnabledState(self.db.profile.enabled)
self:SetupOptions()
end
@@ -31,35 +31,65 @@ function StanceBarMod:OnEnable()
self.bar:ApplyConfig()
self.bar:SetScript("OnEvent", StanceBar.OnEvent)
end
self:SetupOptions()
self.bar:RegisterEvent("PLAYER_ENTERING_WORLD")
self.bar:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
self.bar:RegisterEvent("SPELL_UPDATE_COOLDOWN")
self.bar:RegisterEvent("SPELL_UPDATE_USABLE")
self.bar:RegisterEvent("PLAYER_AURAS_CHANGED")
self.bar:RegisterEvent("PLAYER_REGEN_ENABLED")
self.bar:Show()
end
function StanceBarMod:OnDisable()
if not self.bar then return end
self.bar:UnregisterAllEvents()
self.bar:Hide()
self:SetupOptions()
end
function StanceBarMod:SetupOptions()
self.options = Bartender4.ButtonBar.prototype:GetOptionObject()
ActionBars.options.args["stance"] = {
order = 30,
type = "group",
name = "Stance Bar",
desc = "Configure the Stance Bar",
childGroups = "tab",
disabled = function() return GetNumShapeshiftForms() == 0 end,
if not self.options then
self.options = Bartender4.ButtonBar.prototype:GetOptionObject()
local enabled = {
type = "toggle",
order = 1,
name = "Enabled",
desc = "Enable the StanceBar",
get = function() return self.db.profile.enabled end,
set = "ToggleModule",
handler = self,
}
ActionBars.options.args["stance"].args = self.options.table
self.options:AddElement("general", "enabled", enabled)
self.disabledoptions = {
general = {
type = "group",
name = "General Settings",
cmdInline = true,
order = 1,
args = {
enabled = enabled,
}
}
}
ActionBars.options.args["Stance"] = {
order = 30,
type = "group",
name = "Stance Bar",
desc = "Configure the Stance Bar",
childGroups = "tab",
disabled = function(info) return GetNumShapeshiftForms() == 0 end,
}
end
ActionBars.options.args["Stance"].args = self:IsEnabled() and self.options.table or self.disabledoptions
end
function StanceBarMod:ApplyConfig()
if not self:IsEnabled() then return end
self.bar:ApplyConfig(self.db.profile)
end