From 4f31e91de57a45239d36ce0ac3382f8d53f9f5c1 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Sat, 16 Feb 2008 18:04:50 +0000 Subject: [PATCH] StanceBar - increase default scale of the stance buttons - add events to update the bar - add OnDisable --- StanceBar.lua | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/StanceBar.lua b/StanceBar.lua index 8610e6c..cddfa90 100644 --- a/StanceBar.lua +++ b/StanceBar.lua @@ -7,7 +7,10 @@ local StanceBar = setmetatable({}, {__index = ButtonBar}) local StanceButtonPrototype = CreateFrame("CheckButton") local StanceButton_MT = {__index = StanceButtonPrototype} -local defaults = { profile = Bartender4:Merge({ enabled = true }, Bartender4.ButtonBar.defaults) } +local defaults = { profile = Bartender4:Merge({ + enabled = true, + scale = 1.5, +}, Bartender4.ButtonBar.defaults) } function StanceBarMod:OnInitialize() self.db = Bartender4.db:RegisterNamespace("StanceBar", defaults) @@ -16,9 +19,25 @@ function StanceBarMod:OnInitialize() end function StanceBarMod:OnEnable() - self.bar = setmetatable(Bartender4.ButtonBar:Create("stance", nil, self.db.profile), {__index = StanceBar}) - self.bar:ClearSetPoint("CENTER") - self.bar:ApplyConfig() + if not self.bar then + self.bar = setmetatable(Bartender4.ButtonBar:Create("stance", nil, self.db.profile), {__index = StanceBar}) + + self.bar:ClearSetPoint("CENTER") + self.bar:ApplyConfig() + self.bar:SetScript("OnEvent", StanceBar.OnEvent) + end + 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") +end + +function StanceBarMod:OnDisable() + if not self.bar then return end + self.bar:UnregisterAllEvents() + self.bar:Hide() end function StanceBarMod:SetupOptions() @@ -110,3 +129,11 @@ function StanceBar:UpdateStanceButtons() self:UpdateButtonLayout() end + +function StanceBar:OnEvent(event, ...) + if InCombatLockdown() then + self:ForAll("Update") + else + self:UpdateStanceButtons() + end +end