View Single Post
11-02-22, 04:57 PM   #14
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,335
Originally Posted by Deadlyz View Post
Code:
hooksecurefunc(self.spellbar, "SetPoint", function(spellBar, _, _, _, _, _, shouldIgnore)
	if not shouldIgnore then
		spellBar:ClearAllPoints()

		-- Default anchor on large frame with ToT shown
		spellBar:SetPoint("TOPLEFT", self, "BOTTOMLEFT", 43, -100, true)
	end
end)
You need to set this hook outside or it'll keep hooking itself indefinitely. Eventually, this will cause a stack overflow when the hook is called.



This is the alternative I came up with. It only applies the position hook once.
Lua Code:
  1. --  Doesn't need to be done, but saves some (not all) processing
  2. TargetFrame:UnregisterEvent("UNIT_AURA");
  3. FocusFrame:UnregisterEvent("UNIT_AURA");
  4.  
  5. local function ReleaseAllAuras(self)
  6.     for obj in self.auraPools:EnumerateActive() do obj:Hide(); end
  7.     self.auraPools:ReleaseAll()--   Cleanup
  8. end
  9.  
  10. hooksecurefunc(TargetFrame,"UpdateAuras",ReleaseAllAuras);
  11. hooksecurefunc(FocusFrame,"UpdateAuras",ReleaseAllAuras);
  12.  
  13. local function SpellBar_SetPoint(self)
  14.     local meta=getmetatable(self).__index;--    Calls through self will trigger our hook, so we're making them through the metatable
  15.     meta.ClearAllPoints(self);
  16.     meta.SetPoint(self,"TOPLEFT",meta.GetParent(self),"BOTTOMLEFT",43,-28);
  17. end
  18.  
  19. hooksecurefunc(TargetFrame.spellbar,"SetPoint",SpellBar_SetPoint);
  20. hooksecurefunc(FocusFrame.spellbar,"SetPoint",SpellBar_SetPoint);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote