View Single Post
02-23-14, 08:38 AM   #7
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
I think this should work for hiding the combo frame as well, for some reason it's not parented to the target frame.
Lua Code:
  1. local f = CreateFrame('frame', nil, nil, 'SecureHandlerStateTemplate')
  2. f:SetFrameRef('PlayerFrame', PlayerFrame)
  3. f:SetFrameRef('TargetFrame', TargetFrame)
  4. f:SetFrameRef('FocusFrame', FocusFrame)
  5. f:SetFrameRef('ComboFrame', ComboFrame)
  6. f:SetAttribute('_onstate-combat', [=[ -- Securely toggle visibility in combat
  7.     if newstate == 'show' then
  8.         self:GetFrameRef('PlayerFrame'):Show()
  9.         if UnitExists('target') then
  10.             self:GetFrameRef('TargetFrame'):Show()
  11.         end
  12.         if UnitExists('focus') then
  13.             self:GetFrameRef('FocusFrame'):Show()
  14.         end
  15.     else
  16.         self:GetFrameRef('PlayerFrame'):Hide()
  17.         self:GetFrameRef('TargetFrame'):Hide()
  18.         self:GetFrameRef('FocusFrame'):Hide()
  19.         self:GetFrameRef('ComboFrame'):Hide()
  20.     end
  21. ]=])
  22. RegisterStateDriver(f, 'combat', '[combat] show; hide')
  23.  
  24. local function HideFrame(self) -- Insecurely hide out of combat if shown
  25.     if not InCombatLockdown() then self:Hide() end
  26. end
  27. PlayerFrame:HookScript('OnShow', HideFrame)
  28. TargetFrame:HookScript('OnShow', HideFrame)
  29. FocusFrame:HookScript('OnShow', HideFrame)
  30. ComboFrame:HookScript('OnShow', HideFrame)
  31.  
  32. f:SetScript('OnEvent', function(self, event)
  33.     if GetComboPoints('player', 'target') > 0 then -- Show ComboFrame upon entering combat if we have points
  34.         ComboFrame:Show()
  35.     end
  36. end)
  37. f:RegisterEvent('PLAYER_REGEN_DISABLED')
  Reply With Quote