Skip to content

Instantly share code, notes, and snippets.

@GabeStah
Created September 19, 2014 03:51
Show Gist options
  • Save GabeStah/8a9b1bddce927dd1652e to your computer and use it in GitHub Desktop.
Save GabeStah/8a9b1bddce927dd1652e to your computer and use it in GitHub Desktop.
function(event)
-- BEGIN CONFIG
local extraFrames = {
'Minimap'
}
-- END CONFIG
local GetValue = function(...)
if not WeakAuras.CustomValues then WeakAuras.CustomValues = {} end
if not ... then return end
local count, data = #{...}
if count and (count > 1) then
for i,v in pairs({...}) do
if i==1 then WeakAuras.CustomValues[v] = WeakAuras.CustomValues[v] or {} data = WeakAuras.CustomValues[v]
else if i ~= count then if not data[v] then data[v] = {} else data = data[v] end else data = data[v] end end
end
else data = WeakAuras.CustomValues[select(1, ...)] end
return data
end
local SetValue = function(value, ...)
if not WeakAuras.CustomValues then WeakAuras.CustomValues = {} end
if not ... then return end
local count, data = #{...}
for i,v in pairs({...}) do
if i==1 then if count and count == 1 then WeakAuras.CustomValues[v] = value else
WeakAuras.CustomValues[v] = WeakAuras.CustomValues[v] or {}
data = WeakAuras.CustomValues[v] end
else if i ~= count then if not data[v] then data[v] = {} end data = data[v] else data[v] = value end end
end
end
if event == 'PLAYER_LOGIN' then
local visibleFrames = {}
for count=1,NUM_CHAT_WINDOWS do
local window = _G["ChatFrame"..count]
local tab =_G[('ChatFrame%sTab'):format(count)]
if window and window:IsVisible() then
tinsert(visibleFrames, window:GetName())
end
if tab and tab:IsVisible() then
tinsert(visibleFrames, tab:GetName())
end
end
if extraFrames then
for i,name in pairs(extraFrames) do
tinsert(visibleFrames, name)
end
end
SetValue(visibleFrames, 'HiddenCombatFrames')
elseif event == 'PLAYER_REGEN_DISABLED' or event == 'PLAYER_REGEN_ENABLED' then
print(event)
local frames = GetValue('HiddenCombatFrames')
for i,frame in pairs(frames) do
if event == 'PLAYER_REGEN_DISABLED' then
_G[frame]:Hide()
elseif event == 'PLAYER_REGEN_ENABLED' then
print(('%s %s'):format('Showing', frame))
_G[frame]:Show()
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment