# HG changeset patch # User Flick # Date 1241741213 0 # Node ID de1da46dadb3072a3c567cba7240d3dbe958259c # Parent 901c91dc1bf25666ac905495c100bbf12087572f moved unitwatch handling into bar diff -r 901c91dc1bf2 -r de1da46dadb3 classes/Bar.lua --- a/classes/Bar.lua Thu May 07 23:55:00 2009 +0000 +++ b/classes/Bar.lua Fri May 08 00:06:53 2009 +0000 @@ -269,6 +269,14 @@ function Bar:SetConfigMode(mode) self:ShowControls(mode) + if self.unitwatch then + if mode then + UnregisterUnitWatch(self:GetFrame()) + self:GetFrame():Show() + else + RegisterUnitWatch(self:GetFrame()) + end + end for b in self:IterateButtons() do b:ShowGridTemp(mode) b:UpdateActionIDLabel(mode) @@ -276,6 +284,14 @@ end function Bar:SetKeybindMode(mode) + if self.unitwatch then + if mode then + UnregisterUnitWatch(self:GetFrame()) + self:GetFrame():Show() + else + RegisterUnitWatch(self:GetFrame()) + end + end for b in self:IterateButtons() do b:SetKeybindMode(mode) end @@ -300,3 +316,20 @@ function Bar:SkinButton() -- does nothing by default end + +-- pass unit=nil to set up the unit elsewhere, if you want something more complex +function Bar:RegisterUnitWatch( unit, enable ) + local f = self:GetFrame() + if unit then + f:SetAttribute("unit",unit) + end + if not ReAction:GetConfigMode() then + if enable then + RegisterUnitWatch(f) + elseif self.unitwatch then + UnregisterUnitWatch(f) + end + end + self.unitwatch = enable +end + diff -r 901c91dc1bf2 -r de1da46dadb3 modules/PetAction.lua --- a/modules/PetAction.lua Thu May 07 23:55:00 2009 +0000 +++ b/modules/PetAction.lua Fri May 08 00:06:53 2009 +0000 @@ -52,7 +52,6 @@ ReAction.RegisterCallback(self, "OnRefreshBar") ReAction.RegisterCallback(self, "OnEraseBar") ReAction.RegisterCallback(self, "OnRenameBar") - ReAction.RegisterCallback(self, "OnConfigModeChanged") end function module:OnEnable() @@ -73,10 +72,7 @@ function module:OnCreateBar(event, bar, name) if bar.config.type == moduleID then -- auto show/hide when pet exists - bar:GetFrame():SetAttribute("unit","pet") - if not ReAction:GetConfigMode() then - RegisterUnitWatch(bar:GetFrame()) - end + bar:RegisterUnitWatch("pet",true) self:OnRefreshBar(event, bar, name) end end @@ -147,23 +143,6 @@ end -function module:OnConfigModeChanged(event, mode) - for _, bar in ReAction:IterateBars() do - if bar and self.buttons[bar] then - for b in bar:IterateButtons() do - b:UpdateActionIDLabel(mode) - end - local f = bar:GetFrame() - if mode then - UnregisterUnitWatch(f) - f:Show() - else - RegisterUnitWatch(f) - end - end - end -end - ---- Options ---- local Handler = { } local meta = { __index = Handler }