From fe0281fdb7280bd7c38d229df8fc19c1964103f5 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Thu, 16 Apr 2009 17:04:41 +0200 Subject: [PATCH] Small improvements to the behaviour of the secure environment. Fixes a rare bug when adding/removing buttons from a bar. --- ActionBar.lua | 2 +- ActionButton.lua | 5 ++++- Bar.lua | 2 ++ ButtonBar.lua | 2 ++ StateBar.lua | 8 +++++++- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ActionBar.lua b/ActionBar.lua index 194ddd3..a3c6ed3 100644 --- a/ActionBar.lua +++ b/ActionBar.lua @@ -26,7 +26,6 @@ function ActionBar:ApplyConfig(config) if not self.config.position.x then initialPosition(self) end self:UpdateButtons() - self:UpdateSelfCast() -- also calls UpdateStates end -- Update the number of buttons in our bar, creating new ones if necessary @@ -71,6 +70,7 @@ function ActionBar:UpdateButtons(numbuttons) -- need to re-set clickthrough after creating new buttons self:SetClickThrough() + self:UpdateSelfCast() -- update selfcast and states end function ActionBar:SkinChanged(...) diff --git a/ActionButton.lua b/ActionButton.lua index fc935c4..9bc3f22 100644 --- a/ActionButton.lua +++ b/ActionButton.lua @@ -241,7 +241,7 @@ function onUpdate(self, elapsed) end local function updateIcon(self) - if self.BT4init and self.action then + if self.action then if specialButtons[self.action] then if not LBF then self.normalTexture:SetTexCoord(0, 0, 0, 0) @@ -260,7 +260,10 @@ local function updateIcon(self) end local function updateFunc(self) + local parent = self:GetParent() + if not self.BT4init or not parent.BT4BarType then return end updateIcon(self) + if self.SecureInit and not InCombatLockdown() then local parent = self:GetParent() parent:SetFrameRef("upd", self) diff --git a/Bar.lua b/Bar.lua index f8f50c9..6fbaaf0 100644 --- a/Bar.lua +++ b/Bar.lua @@ -199,6 +199,8 @@ end Universal Bar Prototype ===================================================================================]]-- +Bar.BT4BarType = "Bar" + function Bar:ApplyConfig(config) if config then self.config = config diff --git a/ButtonBar.lua b/ButtonBar.lua index f990a47..b51eb0f 100644 --- a/ButtonBar.lua +++ b/ButtonBar.lua @@ -52,6 +52,8 @@ function Bartender4.ButtonBar:SkinChanged(SkinID, Gloss, Backdrop, Group, Button bar:SkinChanged(SkinID, Gloss, Backdrop, Colors, Button) end +ButtonBar.BT4BarType = "ButtonBar" + function ButtonBar:UpdateSkin() if not self.LBFGroup then return end local config = self.config diff --git a/StateBar.lua b/StateBar.lua index ffa0433..2fffe96 100644 --- a/StateBar.lua +++ b/StateBar.lua @@ -35,6 +35,8 @@ function Bartender4.StateBar:Create(id, config, name) return bar end +StateBar.BT4BarType = "StateBar" + function StateBar:ApplyConfig(config) ButtonBar.ApplyConfig(self, config) -- We cannot call UpdateStates or UpdateSelfCast now, because the buttons are not yet created *sad* @@ -158,7 +160,9 @@ function StateBar:UpdateStates(returnOnly) ]]) UnregisterStateDriver(self, "page") - RegisterStateDriver(self, "page", statedriver or "") + self:SetAttribute("state-page", "0") + + RegisterStateDriver(self, "page", statedriver or "0") self:SetAttribute("_onstate-assist-help", [[ local state = (newstate ~= "nil") and newstate or nil @@ -181,7 +185,9 @@ function StateBar:UpdateStates(returnOnly) end UnregisterStateDriver(self, "assist-help") + self:SetAttribute("state-assist-help", "nil") UnregisterStateDriver(self, "assist-harm") + self:SetAttribute("state-assist-harm", "nil") if self.config.autoassist then RegisterStateDriver(self, "assist-help", ("%s%s[help]nil; [target=targettarget, help]targettarget; nil"):format(preSelf, preFocus))