Compare commits
37 commits
v1.0-relea
...
master
Author | SHA1 | Date | |
---|---|---|---|
3a3003eff6 | |||
5c9e38952e | |||
ed5089c103 | |||
0d2ad26892 | |||
76a3df5b2e | |||
a78df7bc99 | |||
a663d6d8aa | |||
1a4f3b0f71 | |||
a005f12194 | |||
8d437e2f06 | |||
e34a237c84 | |||
7536a5e14d | |||
5b1d50758d | |||
d8bb220987 | |||
204d62bf9d | |||
61def6d36d | |||
44209c946a | |||
61e66753a2 | |||
3e27e26db1 | |||
2bdea38132 | |||
7d55d0ee93 | |||
41f9cd47f3 | |||
86a904b502 | |||
2dcf64b159 | |||
71036313e9 | |||
dcde240f24 | |||
9c2a744a87 | |||
034ef82eb2 | |||
fee07b3a37 | |||
7892099ef0 | |||
46a0d47d35 | |||
db153fe08a | |||
304dcd0fdc | |||
aa65c554a3 | |||
0b51f257ed | |||
56cc3d6191 | |||
3ec2840580 |
3 changed files with 77 additions and 34 deletions
109
ChatSaver.lua
109
ChatSaver.lua
|
@ -2,8 +2,6 @@ ChatSaver = LibStub('AceAddon-3.0'):NewAddon('ChatSaver','AceConsole-3.0','AceHo
|
|||
local core = ChatSaver;
|
||||
|
||||
function core:OnInitialize()
|
||||
self:RegisterChatCommand('cs','SlashCommand');
|
||||
|
||||
if(ChatSaverDB == nil) then
|
||||
core.firstrun = true;
|
||||
ChatSaverDB = {};
|
||||
|
@ -13,8 +11,6 @@ function core:OnInitialize()
|
|||
end
|
||||
|
||||
function core:OnEnable()
|
||||
self:RawHook(SlashCmdList,'JOIN','JoinChannel',true);
|
||||
self:RawHook(SlashCmdList,'LEAVE','LeaveChannel',true);
|
||||
self:Hook('ToggleChatChannel','ToggleChatChannel',true);
|
||||
|
||||
self:RegisterEvent('CHANNEL_UI_UPDATE','RejoinChannels');
|
||||
|
@ -23,8 +19,68 @@ function core:OnEnable()
|
|||
end
|
||||
end
|
||||
|
||||
function core:SlashCommand()
|
||||
core:RejoinChannels();
|
||||
--[[
|
||||
-- CHANNEL FUNCTIONS
|
||||
-- Because GetChannelName() and GetChannelDisplayInfo() are less
|
||||
-- than good.
|
||||
]] --
|
||||
|
||||
function core:GetChannelInfo(id)
|
||||
local channelNumber,channelName = GetChannelName(id);
|
||||
local channelTable = core:GetChannelTable();
|
||||
|
||||
if(channelName == nil) then
|
||||
id = channelTable[id];
|
||||
|
||||
if(id ~= nil) then
|
||||
channelNumber,channelName = GetChannelName(id);
|
||||
end
|
||||
end
|
||||
|
||||
return channelNumber,channelName,core:GetChannelCategory(channelNumber);
|
||||
end
|
||||
|
||||
function core:GetChannelTable()
|
||||
local channelList = { GetChannelList() };
|
||||
local channelTable = {};
|
||||
for i = 1,#channelList,2 do
|
||||
channelTable[channelList[i]] = channelList[i + 1];
|
||||
channelTable[channelList[i + 1]] = channelList[i];
|
||||
if(type(channelList[i + 1]) == 'string') then
|
||||
channelTable[channelList[i + 1]:lower()] = channelList[i];
|
||||
end
|
||||
end
|
||||
|
||||
return channelTable;
|
||||
end
|
||||
|
||||
function core:GetChannelCategory(number)
|
||||
for i = 1,GetNumDisplayChannels(),1 do
|
||||
local _,_,_,channelNumber,_,_,category = GetChannelDisplayInfo(i);
|
||||
|
||||
if(channelNumber == number) then
|
||||
return category;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--[[ EVENT FUNCTIONS ]] --
|
||||
|
||||
function core:ProcessChannelChange(_,message,_,_,_,_,_,_,index,name)
|
||||
if message == 'YOU_JOINED' then
|
||||
local number,_,category = core:GetChannelInfo(name)
|
||||
|
||||
if category == 'CHANNEL_CATEGORY_CUSTOM' then
|
||||
if ChatSaverDB[name] == nil then
|
||||
ChatSaverDB[name] = {}
|
||||
ChatSaverDB[name]['frames'] = {}
|
||||
ChatSaverDB[name]['index'] = number
|
||||
ChatSaverDB[name]['frames'][DEFAULT_CHAT_FRAME:GetID()] = true
|
||||
end
|
||||
end
|
||||
elseif message == 'YOU_LEFT' then
|
||||
ChatSaverDB[name] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function core:RejoinChannels(...)
|
||||
|
@ -33,7 +89,13 @@ function core:RejoinChannels(...)
|
|||
currentChannels[select(i,GetChannelList())] = true
|
||||
end
|
||||
|
||||
local sortedChannels = {};
|
||||
for channel,_ in pairs(ChatSaverDB) do
|
||||
table.insert(sortedChannels,channel);
|
||||
end
|
||||
table.sort(sortedChannels,function(a,b) return ChatSaverDB[a].index < ChatSaverDB[b].index end);
|
||||
|
||||
for _,channel in pairs(sortedChannels) do
|
||||
if(currentChannels[channel] == nil) then
|
||||
JoinPermanentChannel(channel); -- does not place in chat frame properly
|
||||
for index,_ in pairs(ChatSaverDB[channel].frames) do
|
||||
|
@ -43,20 +105,20 @@ function core:RejoinChannels(...)
|
|||
end
|
||||
|
||||
self:UnregisterEvent('CHANNEL_UI_UPDATE');
|
||||
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','ProcessChannelChange')
|
||||
end
|
||||
|
||||
function core:SetupChatSaver(...)
|
||||
local chatWindowChannels = { GetChatWindowChannels(frame) };
|
||||
|
||||
for frame = 1,NUM_CHAT_WINDOWS do
|
||||
local chatWindowChannels = { GetChatWindowChannels(frame) };
|
||||
for i = 1,#chatWindowChannels,2 do
|
||||
local name,zone = chatWindowChannels[i], chatWindowChannels[i + 1];
|
||||
|
||||
if(zone == 0) then
|
||||
local number,name,category = core:GetChannelInfo(chatWindowChannels[i]);
|
||||
|
||||
if(category == 'CHANNEL_CATEGORY_CUSTOM') then
|
||||
if(ChatSaverDB[name] == nil) then
|
||||
ChatSaverDB[name] = {};
|
||||
ChatSaverDB[name]['frames'] = {};
|
||||
ChatSaverDB[name]['index'] = GetChannelName(name);
|
||||
ChatSaverDB[name]['index'] = number;
|
||||
end
|
||||
|
||||
ChatSaverDB[name]['frames'][frame] = true;
|
||||
|
@ -65,29 +127,10 @@ function core:SetupChatSaver(...)
|
|||
end
|
||||
|
||||
self:UnregisterEvent('CHAT_MSG_CHANNEL_NOTICE');
|
||||
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','ProcessChannelChange')
|
||||
end
|
||||
|
||||
function core:JoinChannel(msg)
|
||||
self.hooks[SlashCmdList].JOIN(msg);
|
||||
|
||||
local name = gsub(msg, "%s*([^%s]+).*", "%1");
|
||||
|
||||
if(strlen(name) > 0 and string.match(name,"%a+")) then
|
||||
ChatSaverDB[name] = {};
|
||||
ChatSaverDB[name]['frames'] = {};
|
||||
ChatSaverDB[name]['index'] = GetChannelName(name);
|
||||
ChatSaverDB[name]['frames'][DEFAULT_CHAT_FRAME:GetID()] = true;
|
||||
end
|
||||
end
|
||||
|
||||
function core:LeaveChannel(msg)
|
||||
self.hooks[SlashCmdList].LEAVE(msg);
|
||||
|
||||
local number = gsub(msg, "%s*([^%s]+).*", "%1");
|
||||
local _,name = GetChannelName(number);
|
||||
|
||||
ChatSaverDB[name] = nil;
|
||||
end
|
||||
--[[ HOOKED FUNCTIONS ]] --
|
||||
|
||||
function core:ToggleChatChannel(checked,channel)
|
||||
if(ChatSaverDB[channel] == nil) then
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
## Interface: 40100
|
||||
## Interface: 42000
|
||||
## Title: ChatSaver
|
||||
## Version: @project-version@
|
||||
## Author: Gaffer
|
||||
|
|
0
README
Normal file
0
README
Normal file
Loading…
Reference in a new issue