From 74958b03660402b8ee2fc9e9b2834732c2b94292 Mon Sep 17 00:00:00 2001 From: atomaka Date: Wed, 25 May 2011 22:41:33 -0400 Subject: [PATCH] Save and restore channel to proper frames(s) --- ChatSaver.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ChatSaver.lua b/ChatSaver.lua index 560e5d3..f5cf69e 100644 --- a/ChatSaver.lua +++ b/ChatSaver.lua @@ -5,7 +5,8 @@ local db; function core:OnInitialize() self:RawHook(SlashCmdList,'JOIN','JoinChannel',true); - self:RawHook(SlashCmdList,'LEAVE','JoinChannel',true); + self:RawHook(SlashCmdList,'LEAVE','LeaveChannel',true); + self:Hook('ToggleChatChannel','ToggleChatChannel',true); self:RegisterChatCommand('cs','SlashCommand'); @@ -41,7 +42,9 @@ function core:RejoinChannels(event,message,...) if(found == false) then JoinPermanentChannel(channel); - DEFAULT_CHAT_FRAME.channelList[table.getn(DEFAULT_CHAT_FRAME.channelList) + 1] = channel; + for index,shown in pairs(ChatSaverDB[channel].frames) do + _G['ChatFrame'..index].channelList[table.getn(_G['ChatFrame'..index].channelList) + 1] = channel; + end end end end @@ -63,5 +66,13 @@ function core:LeaveChannel(msg) local number = gsub(msg, "%s*([^%s]+).*", "%1"); local _,name = GetChannelName(number); - ChatSaverDB[name] = nil; + --ChatSaverDB[name] = nil; +end + +function core:ToggleChatChannel(checked,channel) + if(checked) then + ChatSaverDB[channel]['frames'][FCF_GetCurrentChatFrameID()] = true; + else + ChatSaverDB[channel]['frames'][FCF_GetCurrentChatFrameID()] = false; + end end