NUM_CHAT_WINDOWS constant

This commit is contained in:
Andrew Tomaka 2011-05-29 06:36:07 -04:00
parent ebd2270b45
commit f439389e64

View file

@ -2,10 +2,6 @@ ChatSaver = LibStub('AceAddon-3.0'):NewAddon('ChatSaver','AceConsole-3.0','AceHo
local core = ChatSaver; local core = ChatSaver;
function core:OnInitialize() function core:OnInitialize()
self:RawHook(SlashCmdList,'JOIN','JoinChannel',true);
self:RawHook(SlashCmdList,'LEAVE','LeaveChannel',true);
self:Hook('ToggleChatChannel','ToggleChatChannel',true);
self:RegisterChatCommand('cs','SlashCommand'); self:RegisterChatCommand('cs','SlashCommand');
if(ChatSaverDB == nil) then if(ChatSaverDB == nil) then
@ -17,8 +13,11 @@ function core:OnInitialize()
end end
function core:OnEnable() function core:OnEnable()
self:RegisterEvent('CHANNEL_UI_UPDATE','RejoinChannels'); self:RawHook(SlashCmdList,'JOIN','JoinChannel',true);
self:RawHook(SlashCmdList,'LEAVE','LeaveChannel',true);
self:Hook('ToggleChatChannel','ToggleChatChannel',true);
self:RegisterEvent('CHANNEL_UI_UPDATE','RejoinChannels');
if(core.firstrun) then if(core.firstrun) then
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','SetupChatSaver'); self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','SetupChatSaver');
end end
@ -30,13 +29,13 @@ end
function core:RejoinChannels(...) function core:RejoinChannels(...)
local currentChannels = {}; local currentChannels = {};
for i = 1,select("#",GetChannelList()) do for i = 1,select('#',GetChannelList()) do
currentChannels[select(i,GetChannelList())] = true currentChannels[select(i,GetChannelList())] = true
end end
for channel,_ in pairs(ChatSaverDB) do for channel,_ in pairs(ChatSaverDB) do
if(currentChannels[channel] == nil) then if(currentChannels[channel] == nil) then
JoinPermanentChannel(channel); JoinPermanentChannel(channel); -- does not place in chat frame properly
for index,_ in pairs(ChatSaverDB[channel].frames) do for index,_ in pairs(ChatSaverDB[channel].frames) do
ChatFrame_AddChannel(_G['ChatFrame'..index],channel); ChatFrame_AddChannel(_G['ChatFrame'..index],channel);
end end
@ -47,10 +46,11 @@ function core:RejoinChannels(...)
end end
function core:SetupChatSaver(...) function core:SetupChatSaver(...)
for frame = 1,10 do local chatWindowChannels = { GetChatWindowChannels(frame) };
local frameChannels = { GetChatWindowChannels(frame) };
for i = 1,#frameChannels,2 do for frame = 1,NUM_CHAT_WINDOWS do
local name,zone = frameChannels[i], frameChannels[i+1] for i = 1,#chatWindowChannels,2 do
local name,zone = chatWindowChannels[i], chatWindowChannels[i + 1];
if(zone == 0) then if(zone == 0) then
if(ChatSaverDB[name] == nil) then if(ChatSaverDB[name] == nil) then