Compare commits

..

47 commits

Author SHA1 Message Date
3a3003eff6 Add files to be tracked after Mercurial import. 2011-09-18 21:29:57 -04:00
5c9e38952e Added tag r60-beta for changeset d6af5da2e1ea 2011-08-12 19:11:38 -04:00
ed5089c103 Don't overwrite settings if joining an already joined channel. 2011-08-12 19:11:05 -04:00
0d2ad26892 Monitor all forms of chat changes instead of just slash commands. 2011-08-12 18:42:39 -04:00
76a3df5b2e Remove slash command. 2011-08-12 18:40:45 -04:00
a78df7bc99 Reverting to last release. 2011-08-12 18:38:52 -04:00
a663d6d8aa Added tag r55-beta for changeset 512ac2d65d2c 2011-08-09 06:16:46 -04:00
1a4f3b0f71 Remove random debug stuff. 2011-08-09 06:16:32 -04:00
a005f12194 Use CHANNEL_UI_UPDATE for rejoining channels as well as initial setup. 2011-08-09 06:10:10 -04:00
8d437e2f06 Attempt to use PLAYER_ALIVE for rejoining channels. 2011-08-09 06:00:52 -04:00
e34a237c84 Attempt to use CHANNEL_UI_UPDATE for initial setup. 2011-08-09 05:43:46 -04:00
7536a5e14d Remove hooked functions 2011-08-09 05:30:28 -04:00
5b1d50758d Remove slash command. 2011-08-09 05:27:56 -04:00
d8bb220987 Use CHAT_MSG_CHANNEL_NOTICE to handle channel information instead of hooking functions. 2011-08-09 05:27:31 -04:00
204d62bf9d Added tag r46-release for changeset 43639d15a889 2011-06-29 07:15:08 -04:00
61def6d36d Updating TOC file 2011-06-29 07:13:06 -04:00
44209c946a Added tag r44-beta for changeset c53d6817e699 2011-06-03 21:24:41 -04:00
61e66753a2 Do not attempt to process '/leave' with no message 2011-06-03 09:43:27 -04:00
3e27e26db1 Added tag r42-alpha for changeset dff165a50535 2011-06-03 08:53:57 -04:00
2bdea38132 Added missed variable scoping. 2011-06-03 08:49:37 -04:00
7d55d0ee93 Use GetChannelInfo() to setup initial database. 2011-06-03 08:28:09 -04:00
41f9cd47f3 Tying it all together: Use GetChannelInfo to decide if this channel needs stored when joining. 2011-06-03 07:33:09 -04:00
86a904b502 Typo fixes in new functions: NOY FUNCTIONAL 2011-06-03 05:53:45 -04:00
2dcf64b159 GetChannelInfo function to return number, name, and category of a channel: NOT TESTED 2011-06-03 05:42:15 -04:00
71036313e9 GetChannelTable fucntion to return a list of channels: NOT FUNCTIONAL 2011-06-03 04:56:12 -04:00
dcde240f24 Using GetChannelDisplayInfo() to check channel type; NOT FUNCTIONAL 2011-06-02 16:12:14 -04:00
9c2a744a87 Added tag r34-release for changeset c6373adcf295 2011-06-02 09:53:29 -04:00
034ef82eb2 Fixed silly debugging error 2011-06-02 09:51:18 -04:00
fee07b3a37 Added tag v1.1-release for changeset 50f6183ae551 2011-06-02 08:39:47 -04:00
7892099ef0 Sort saved channels by index before joining 2011-06-02 04:53:40 -04:00
46a0d47d35 Reverting to hooking slash commands instead of event. 2011-06-02 04:37:29 -04:00
db153fe08a Reverted back to version hooking slash commands instead of events for managing stored data. 2011-06-02 04:32:58 -04:00
304dcd0fdc Added sorting by index to attempt to join in the same order. 2011-06-02 00:52:46 -04:00
aa65c554a3 Use CHAT_MSG_CHANNEL_NOTICE instead of hooking join and leave slash functions for stored channels 2011-06-01 14:25:42 -04:00
0b51f257ed Added tag v1.0a-release for changeset ed22c2b79ca1 2011-05-29 11:27:09 -04:00
56cc3d6191 Fixed LUA error in SetupChatServer. Fixes #1 2011-05-29 11:26:59 -04:00
3ec2840580 Added tag v1.0-release for changeset 26f2a6d4de58 2011-05-29 06:48:37 -04:00
f439389e64 NUM_CHAT_WINDOWS constant 2011-05-29 06:36:07 -04:00
ebd2270b45 Added tag v1.0c-beta for changeset ccc87553f2fd 2011-05-27 22:00:39 -04:00
5b92c09df2 TOC Fixes 2011-05-27 21:58:54 -04:00
476a5e4398 Unset frame storage on channel hide to prevent uneeded iteration." 2011-05-27 21:49:47 -04:00
b9c46370a6 Rejoin channels only if not currently in them fixed. 2011-05-27 19:30:56 -04:00
53ca5d2998 Wait until channels joined to store channels on first login 2011-05-27 18:53:50 -04:00
d5c30070b8 Load player's channels if first login after ChatSaver install 2011-05-27 17:54:01 -04:00
827818c6d4 No need to check CHAT_MSG_CHANNEL_NOTICE type 2011-05-27 15:09:58 -04:00
5331debea4 Cleaner verifying joined channels code 2011-05-27 15:08:27 -04:00
2f596575d8 CurseForge Release 2011-05-26 02:38:04 -04:00
3 changed files with 117 additions and 63 deletions

View file

@ -1,81 +1,137 @@
ChatSaver = LibStub('AceAddon-3.0'):NewAddon('ChatSaver','AceConsole-3.0','AceHook-3.0','AceEvent-3.0'); ChatSaver = LibStub('AceAddon-3.0'):NewAddon('ChatSaver','AceConsole-3.0','AceHook-3.0','AceEvent-3.0');
local core = ChatSaver; local core = ChatSaver;
core.verified = false;
function core:OnInitialize() function core:OnInitialize()
self:RawHook(SlashCmdList,'JOIN','JoinChannel',true); if(ChatSaverDB == nil) then
self:RawHook(SlashCmdList,'LEAVE','LeaveChannel',true); core.firstrun = true;
self:Hook('ToggleChatChannel','ToggleChatChannel',true); ChatSaverDB = {};
else
self:RegisterChatCommand('cs','SlashCommand'); core.firstrun = false;
end
if(ChatSaverDB == nil) then ChatSaverDB = {}; end
end end
function core:OnEnable() function core:OnEnable()
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','RejoinChannels'); self:Hook('ToggleChatChannel','ToggleChatChannel',true);
end
function core:SlashCommand() self:RegisterEvent('CHANNEL_UI_UPDATE','RejoinChannels');
core.verified = false if(core.firstrun) then
core:RejoinChannels(); self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','SetupChatSaver');
end
function core:RejoinChannels(event,message,...)
if(message == 'YOU_LEFT' or core.verified == true) then
return;
end
local channelList = {};
for i = 1, select("#",GetChannelList()), 2 do
local index,channel = select(i,GetChannelList());
channelList[index] = channel;
end
for channel,information in pairs(ChatSaverDB) do
local found = false;
for jIndex,jChannel in pairs(channelList) do
if(jChannel == channel) then
found = true;
end end
end end
if(found == false) then --[[
JoinPermanentChannel(channel); -- CHANNEL FUNCTIONS
for index,shown in pairs(ChatSaverDB[channel].frames) do -- Because GetChannelName() and GetChannelDisplayInfo() are less
if(shown) then -- than good.
_G['ChatFrame'..index].channelList[table.getn(_G['ChatFrame'..index].channelList) + 1] = channel; ]] --
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
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
end end
core.verified = true; --[[ 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 end
function core:JoinChannel(msg) function core:RejoinChannels(...)
self.hooks[SlashCmdList].JOIN(msg); local currentChannels = {};
for i = 1,select('#',GetChannelList()) do
currentChannels[select(i,GetChannelList())] = true
end
local name = gsub(msg, "%s*([^%s]+).*", "%1"); 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);
if(strlen(name) > 0 and string.match(name,"%a+")) then 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
ChatFrame_AddChannel(_G['ChatFrame'..index],channel);
end
end
end
self:UnregisterEvent('CHANNEL_UI_UPDATE');
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','ProcessChannelChange')
end
function core:SetupChatSaver(...)
for frame = 1,NUM_CHAT_WINDOWS do
local chatWindowChannels = { GetChatWindowChannels(frame) };
for i = 1,#chatWindowChannels,2 do
local number,name,category = core:GetChannelInfo(chatWindowChannels[i]);
if(category == 'CHANNEL_CATEGORY_CUSTOM') 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;
ChatSaverDB[name]['frames'][DEFAULT_CHAT_FRAME:GetID()] = true; end
ChatSaverDB[name]['frames'][frame] = true;
end
end end
end end
function core:LeaveChannel(msg) self:UnregisterEvent('CHAT_MSG_CHANNEL_NOTICE');
self.hooks[SlashCmdList].LEAVE(msg); self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','ProcessChannelChange')
local number = gsub(msg, "%s*([^%s]+).*", "%1");
local _,name = GetChannelName(number);
ChatSaverDB[name] = nil;
end end
--[[ HOOKED FUNCTIONS ]] --
function core:ToggleChatChannel(checked,channel) function core:ToggleChatChannel(checked,channel)
if(ChatSaverDB[channel] == nil) then if(ChatSaverDB[channel] == nil) then
return; return;
@ -84,6 +140,6 @@ function core:ToggleChatChannel(checked,channel)
if(checked) then if(checked) then
ChatSaverDB[channel]['frames'][FCF_GetCurrentChatFrameID()] = true; ChatSaverDB[channel]['frames'][FCF_GetCurrentChatFrameID()] = true;
else else
ChatSaverDB[channel]['frames'][FCF_GetCurrentChatFrameID()] = false; ChatSaverDB[channel]['frames'][FCF_GetCurrentChatFrameID()] = nil;
end end
end end

View file

@ -1,17 +1,15 @@
## Interface: 40000 ## Interface: 42000
## Title: ChatSaver ## Title: ChatSaver
## Version: 1.0 ## Version: @project-version@
## Author: Gaffer ## Author: Gaffer
## Notes: Saves chat channels and restores them if World of Warcraft loses them. ## Notes: Saves chat channels and restores them if World of Warcraft loses them.
## Dependencies:
## OptionalDeps:
## DefaultState: enabled ## DefaultState: enabled
## SavedVariablesPerCharacter: ChatSaverDB ## SavedVariablesPerCharacter: ChatSaverDB
Libs\LibStub\LibStub.lua Libs\LibStub\LibStub.lua
Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml Libs\CallbackHandler-1.0\CallbackHandler-1.0.xml
Libs\AceAddon-3.0\AceAddon-3.0.xml Libs\AceAddon-3.0\AceAddon-3.0.xml
Libs\AceAddon-3.0\AceConsole-3.0.xml Libs\AceConsole-3.0\AceConsole-3.0.xml
Libs\AceEvent-3.0\AceEvent-3.0.xml Libs\AceEvent-3.0\AceEvent-3.0.xml
Libs\AceHook-3.0\AceHook-3.0.xml Libs\AceHook-3.0\AceHook-3.0.xml

0
README Normal file
View file