- add Enable/Disable to the Pet and Stance Bar
- unlocking works right on the petbar now
This commit is contained in:
@@ -93,6 +93,11 @@ function BT4ActionBars:ApplyConfig()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- we do not allow to disable the actionbars module
|
||||||
|
function BT4ActionBars:ToggleModule()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
function BT4ActionBars:UpdateButtons(force)
|
function BT4ActionBars:UpdateButtons(force)
|
||||||
for i,v in ipairs(self.actionbars) do
|
for i,v in ipairs(self.actionbars) do
|
||||||
for j,button in ipairs(v.buttons) do
|
for j,button in ipairs(v.buttons) do
|
||||||
|
|||||||
+12
-9
@@ -32,20 +32,12 @@ end
|
|||||||
function Bartender4:UpdateModuleConfigs()
|
function Bartender4:UpdateModuleConfigs()
|
||||||
self:Lock()
|
self:Lock()
|
||||||
for k,v in AceAddon:IterateModulesOfAddon(self) do
|
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()
|
v:ApplyConfig()
|
||||||
end
|
end
|
||||||
end
|
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()
|
function Bartender4:CombatLockdown()
|
||||||
self:Lock()
|
self:Lock()
|
||||||
LibStub("AceConfigDialog-3.0"):Close("Bartender4")
|
LibStub("AceConfigDialog-3.0"):Close("Bartender4")
|
||||||
@@ -84,3 +76,14 @@ function Bartender4:Merge(target, source)
|
|||||||
end
|
end
|
||||||
return target
|
return target
|
||||||
end
|
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)
|
||||||
|
|||||||
+68
-22
@@ -19,7 +19,7 @@ local defaults = { profile = Bartender4:Merge({
|
|||||||
|
|
||||||
function PetBarMod:OnInitialize()
|
function PetBarMod:OnInitialize()
|
||||||
self.db = Bartender4.db:RegisterNamespace("PetBar", defaults)
|
self.db = Bartender4.db:RegisterNamespace("PetBar", defaults)
|
||||||
|
self:SetEnabledState(self.db.profile.enabled)
|
||||||
self:SetupOptions()
|
self:SetupOptions()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -37,28 +37,37 @@ function PetBarMod:OnEnable()
|
|||||||
self.bar:ClearSetPoint("CENTER")
|
self.bar:ClearSetPoint("CENTER")
|
||||||
|
|
||||||
self.bar:SetScript("OnEvent", PetBar.OnEvent)
|
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")
|
self.bar:SetAttribute("unit", "pet")
|
||||||
RegisterUnitWatch(self.bar, false)
|
|
||||||
|
|
||||||
self.bar:ApplyConfig()
|
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
function PetBarMod:OnDisable()
|
function PetBarMod:OnDisable()
|
||||||
if not self.bar then return end
|
if not self.bar then return end
|
||||||
|
self.bar.disabled = true
|
||||||
|
|
||||||
|
UnregisterUnitWatch(self.bar)
|
||||||
|
|
||||||
self.bar:UnregisterAllEvents()
|
self.bar:UnregisterAllEvents()
|
||||||
self.bar:Hide()
|
self.bar:Hide()
|
||||||
|
self:SetupOptions()
|
||||||
end
|
end
|
||||||
|
|
||||||
function PetBarMod:CreatePetButton(id)
|
function PetBarMod:CreatePetButton(id)
|
||||||
@@ -87,19 +96,44 @@ function PetBarMod:CreatePetButton(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function PetBarMod:SetupOptions()
|
function PetBarMod:SetupOptions()
|
||||||
self.options = Bartender4.ButtonBar.prototype:GetOptionObject()
|
if not self.options then
|
||||||
|
self.options = Bartender4.ButtonBar.prototype:GetOptionObject()
|
||||||
|
|
||||||
ActionBars.options.args["Pet"] = {
|
local enabled = {
|
||||||
order = 30,
|
type = "toggle",
|
||||||
type = "group",
|
order = 1,
|
||||||
name = "Pet Bar",
|
name = "Enabled",
|
||||||
desc = "Configure the Pet Bar",
|
desc = "Enable the PetBar",
|
||||||
childGroups = "tab",
|
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
|
end
|
||||||
|
|
||||||
function PetBarMod:ApplyConfig()
|
function PetBarMod:ApplyConfig()
|
||||||
|
if not self:IsEnabled() then return end
|
||||||
self.bar:ApplyConfig(self.db.profile)
|
self.bar:ApplyConfig(self.db.profile)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -174,6 +208,8 @@ function PetButtonPrototype:ClearSetPoint(...)
|
|||||||
self:SetPoint(...)
|
self:SetPoint(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
PetBar.button_width = 30
|
||||||
|
PetBar.button_height = 30
|
||||||
function PetBar:OnEvent(event, arg1)
|
function PetBar:OnEvent(event, arg1)
|
||||||
if event == "PET_BAR_UPDATE" or
|
if event == "PET_BAR_UPDATE" or
|
||||||
(event == "UNIT_PET" and arg1 == "player") or
|
(event == "UNIT_PET" and arg1 == "player") or
|
||||||
@@ -196,3 +232,13 @@ function PetBar:ApplyConfig()
|
|||||||
self:ForAll("Update")
|
self:ForAll("Update")
|
||||||
self:ForAll("ApplyStyle", self.config.style)
|
self:ForAll("ApplyStyle", self.config.style)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function PetBar:Unlock()
|
||||||
|
UnregisterUnitWatch(self)
|
||||||
|
ButtonBar.Unlock(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function PetBar:Lock()
|
||||||
|
ButtonBar.Lock(self)
|
||||||
|
RegisterUnitWatch(self, false)
|
||||||
|
end
|
||||||
|
|||||||
+40
-10
@@ -19,7 +19,7 @@ local defaults = { profile = Bartender4:Merge({
|
|||||||
|
|
||||||
function StanceBarMod:OnInitialize()
|
function StanceBarMod:OnInitialize()
|
||||||
self.db = Bartender4.db:RegisterNamespace("StanceBar", defaults)
|
self.db = Bartender4.db:RegisterNamespace("StanceBar", defaults)
|
||||||
|
self:SetEnabledState(self.db.profile.enabled)
|
||||||
self:SetupOptions()
|
self:SetupOptions()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -31,35 +31,65 @@ function StanceBarMod:OnEnable()
|
|||||||
self.bar:ApplyConfig()
|
self.bar:ApplyConfig()
|
||||||
self.bar:SetScript("OnEvent", StanceBar.OnEvent)
|
self.bar:SetScript("OnEvent", StanceBar.OnEvent)
|
||||||
end
|
end
|
||||||
|
self:SetupOptions()
|
||||||
self.bar:RegisterEvent("PLAYER_ENTERING_WORLD")
|
self.bar:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
self.bar:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
|
self.bar:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
|
||||||
self.bar:RegisterEvent("SPELL_UPDATE_COOLDOWN")
|
self.bar:RegisterEvent("SPELL_UPDATE_COOLDOWN")
|
||||||
self.bar:RegisterEvent("SPELL_UPDATE_USABLE")
|
self.bar:RegisterEvent("SPELL_UPDATE_USABLE")
|
||||||
self.bar:RegisterEvent("PLAYER_AURAS_CHANGED")
|
self.bar:RegisterEvent("PLAYER_AURAS_CHANGED")
|
||||||
self.bar:RegisterEvent("PLAYER_REGEN_ENABLED")
|
self.bar:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||||
|
self.bar:Show()
|
||||||
end
|
end
|
||||||
|
|
||||||
function StanceBarMod:OnDisable()
|
function StanceBarMod:OnDisable()
|
||||||
if not self.bar then return end
|
if not self.bar then return end
|
||||||
self.bar:UnregisterAllEvents()
|
self.bar:UnregisterAllEvents()
|
||||||
self.bar:Hide()
|
self.bar:Hide()
|
||||||
|
self:SetupOptions()
|
||||||
end
|
end
|
||||||
|
|
||||||
function StanceBarMod:SetupOptions()
|
function StanceBarMod:SetupOptions()
|
||||||
self.options = Bartender4.ButtonBar.prototype:GetOptionObject()
|
if not self.options then
|
||||||
|
self.options = Bartender4.ButtonBar.prototype:GetOptionObject()
|
||||||
|
|
||||||
ActionBars.options.args["stance"] = {
|
local enabled = {
|
||||||
order = 30,
|
type = "toggle",
|
||||||
type = "group",
|
order = 1,
|
||||||
name = "Stance Bar",
|
name = "Enabled",
|
||||||
desc = "Configure the Stance Bar",
|
desc = "Enable the StanceBar",
|
||||||
childGroups = "tab",
|
get = function() return self.db.profile.enabled end,
|
||||||
disabled = function() return GetNumShapeshiftForms() == 0 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
|
end
|
||||||
|
|
||||||
function StanceBarMod:ApplyConfig()
|
function StanceBarMod:ApplyConfig()
|
||||||
|
if not self:IsEnabled() then return end
|
||||||
self.bar:ApplyConfig(self.db.profile)
|
self.bar:ApplyConfig(self.db.profile)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user