ActionBars - Hide when not in combat
adamjedlicka opened this issue ยท 3 comments
I too wouldn't mind this, I know when I was a ModDev for WoW addons. There was a condition built into the api for these kind of conditions. Below is a snippet I used and modified based on my needs. Perhaps W* has similar code.
local f = CreateFrame('frame', nil, nil, 'SecureHandlerStateTemplate')
f:SetFrameRef('PlayerFrame', PlayerFrame)
f:SetFrameRef('TargetFrame', TargetFrame)
f:SetFrameRef('FocusFrame', FocusFrame)
f:SetFrameRef('ComboFrame', ComboFrame)
f:SetAttribute('_onstate-combat', [=[ -- Securely toggle visibility in combat
if newstate == 'show' then
self:GetFrameRef('PlayerFrame'):Show()
if UnitExists('target') then
self:GetFrameRef('TargetFrame'):Show()
end
if UnitExists('focus') then
self:GetFrameRef('FocusFrame'):Show()
end
else
self:GetFrameRef('PlayerFrame'):Hide()
self:GetFrameRef('TargetFrame'):Hide()
self:GetFrameRef('FocusFrame'):Hide()
self:GetFrameRef('ComboFrame'):Hide()
end
]=])
RegisterStateDriver(f, 'combat', '[combat] show; hide')
local function HideFrame(self) -- Insecurely hide out of combat if shown
if not InCombatLockdown() then self:Hide() end
end
PlayerFrame:HookScript('OnShow', HideFrame)
TargetFrame:HookScript('OnShow', HideFrame)
FocusFrame:HookScript('OnShow', HideFrame)
ComboFrame:HookScript('OnShow', HideFrame)
f:SetScript('OnEvent', function(self, event)
if GetComboPoints('player', 'target') > 0 then -- Show ComboFrame upon entering combat if we have points
ComboFrame:Show()
end
end)
f:RegisterEvent('PLAYER_REGEN_DISABLED')
It would be a good idea to show the skill bar when moused over when the player chooses to have it hidden when not in combat. Otherwise, if you want to change your selected mount, potion, path skill, etc., you would have to do that in combat or you would have to deselect the "show only in combat" option. By adding show on mouseover functionality to the "show only in combat" choice, you can easily avoid those issues and still keep that bar hidden when you want it to be.