Use GetChannelInfo() to setup initial database.

This commit is contained in:
Andrew Tomaka 2011-06-03 08:28:09 -04:00
parent 41f9cd47f3
commit 7d55d0ee93

View file

@ -38,7 +38,11 @@ function core:GetChannelInfo(id)
local channelTable = core:GetChannelTable(); local channelTable = core:GetChannelTable();
if(channelName == nil) then if(channelName == nil) then
channelName = channelTable[channelName]; id = channelTable[id];
if(id ~= nil) then
channelNumber,channelName = GetChannelName(id);
end
end end
return channelNumber,channelName,core:GetChannelCategory(channelNumber); return channelNumber,channelName,core:GetChannelCategory(channelNumber);
@ -61,7 +65,6 @@ end
function core:GetChannelCategory(number) function core:GetChannelCategory(number)
for i = 1,GetNumDisplayChannels(),1 do for i = 1,GetNumDisplayChannels(),1 do
_,_,_,channelNumber,_,_,category = GetChannelDisplayInfo(i); _,_,_,channelNumber,_,_,category = GetChannelDisplayInfo(i);
print(channelNumber,category);
if(channelNumber == number) then if(channelNumber == number) then
return category; return category;
@ -100,13 +103,13 @@ function core:SetupChatSaver(...)
for frame = 1,NUM_CHAT_WINDOWS do for frame = 1,NUM_CHAT_WINDOWS do
local chatWindowChannels = { GetChatWindowChannels(frame) }; local chatWindowChannels = { GetChatWindowChannels(frame) };
for i = 1,#chatWindowChannels,2 do for i = 1,#chatWindowChannels,2 do
local name,zone = chatWindowChannels[i],chatWindowChannels[i + 1]; local number,name,category = core:GetChannelInfo(chatWindowChannels[i]);
if(zone == 0) then if(category == 'CHANNEL_CATEGORY_CUSTOM') then
if(ChatSaverDB[name] == nil) then if(ChatSaverDB[name] == nil) then
ChatSaverDB[name] = {}; ChatSaverDB[name] = {};
ChatSaverDB[name]['frames'] = {}; ChatSaverDB[name]['frames'] = {};
ChatSaverDB[name]['index'] = GetChannelName(name); ChatSaverDB[name]['index'] = number;
end end
ChatSaverDB[name]['frames'][frame] = true; ChatSaverDB[name]['frames'][frame] = true;
@ -118,7 +121,7 @@ function core:SetupChatSaver(...)
end end
function core:StoreChannel(_,_,_,_,_,_,_,_,_,name) function core:StoreChannel(_,_,_,_,_,_,_,_,_,name)
number,channelName,category = core:GetChannelInfo(name); local number,channelName,category = core:GetChannelInfo(name);
if(category == 'CHANNEL_CATEGORY_CUSTOM') then if(category == 'CHANNEL_CATEGORY_CUSTOM') then
ChatSaverDB[name] = {}; ChatSaverDB[name] = {};
@ -135,7 +138,7 @@ end
function core:JoinChannel(msg) function core:JoinChannel(msg)
self.hooks[SlashCmdList].JOIN(msg); self.hooks[SlashCmdList].JOIN(msg);
local name = gsub(msg, "%s*([^%s]+).*", "%1"); local name = gsub(msg,"%s*([^%s]+).*","%1");
if(strlen(name) > 0 and string.match(name,"%a+")) then if(strlen(name) > 0 and string.match(name,"%a+")) then
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','StoreChannel'); self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','StoreChannel');
@ -145,8 +148,8 @@ end
function core:LeaveChannel(msg) function core:LeaveChannel(msg)
self.hooks[SlashCmdList].LEAVE(msg); self.hooks[SlashCmdList].LEAVE(msg);
local number = gsub(msg, "%s*([^%s]+).*", "%1"); local id = gsub(msg,"%s*([^%s]+).*","%1");
local _,name = GetChannelName(number); local _,name = core:GetChannelInfo(id);
ChatSaverDB[name] = nil; ChatSaverDB[name] = nil;
end end