Maintain dynamic channel list per character.
This commit is contained in:
parent
7a224ea81f
commit
d705949afc
2 changed files with 55 additions and 26 deletions
|
@ -1,44 +1,72 @@
|
||||||
ChatSaver = LibStub('AceAddon-3.0'):NewAddon('ChatSaver','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;
|
||||||
|
|
||||||
local db;
|
local db;
|
||||||
|
|
||||||
function core:OnInitialize()
|
function core:OnInitialize()
|
||||||
self:RegisterEvent('PLAYER_LOGIN','ReloadUI');
|
|
||||||
self:Hook(SlashCmdList,'JOIN','JoinChannel',true);
|
self:Hook(SlashCmdList,'JOIN','JoinChannel',true);
|
||||||
|
self:Hook(SlashCmdList,'LEAVE','LeaveChannel',true);
|
||||||
|
|
||||||
|
self:RegisterChatCommand('cs','SlashCommand');
|
||||||
|
|
||||||
|
if(ChatSaverDB == nil) then ChatSaverDB = {}; end
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:ReloadUI()
|
function core:OnEnable()
|
||||||
channelList = {};
|
self:RegisterEvent('CHAT_MSG_CHANNEL_NOTICE','RejoinChannels');
|
||||||
|
end
|
||||||
|
|
||||||
|
function core:SlashCommand()
|
||||||
|
core:RejoinChannels();
|
||||||
|
end
|
||||||
|
|
||||||
|
function core:RejoinChannels(event,message,...)
|
||||||
|
if(message == 'YOU_LEFT') then
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
local channelList = {};
|
||||||
for i = 1, select("#",GetChannelList()), 2 do
|
for i = 1, select("#",GetChannelList()), 2 do
|
||||||
local index,channel = select(i,GetChannelList());
|
local index,channel = select(i,GetChannelList());
|
||||||
channelList[index] = channel;
|
channelList[index] = channel;
|
||||||
end
|
end
|
||||||
|
|
||||||
--force channel list for now
|
for index,channel in pairs(ChatSaverDB) do
|
||||||
myChannels = {};
|
local found = false;
|
||||||
myChannels[1] = 'General';
|
for jIndex,jChannel in pairs(channelList) do
|
||||||
myChannels[2] = 'Trade';
|
if(jChannel == channel) then
|
||||||
myChannels[3] = 'LocalDefense';
|
found = true;
|
||||||
myChannels[4] = 'ncaheal';
|
end
|
||||||
myChannels[5] = 'ncabads';
|
end
|
||||||
myChannels[6] = 'ncafail';
|
|
||||||
|
|
||||||
for index,channel in pairs(myChannels) do
|
if(found == false) then
|
||||||
if(channel ~= channelList[index]) then
|
|
||||||
print('Channel ',channel,' not joined. Rejoining now!');
|
|
||||||
JoinPermanentChannel(channel);
|
JoinPermanentChannel(channel);
|
||||||
|
DEFAULT_CHAT_FRAME.channelList[table.getn(DEFAULT_CHAT_FRAME.channelList) + 1] = channel;
|
||||||
local i = 1;
|
|
||||||
while ( DEFAULT_CHAT_FRAME.channelList[i] ) do
|
|
||||||
i = i + 1;
|
|
||||||
end
|
|
||||||
DEFAULT_CHAT_FRAME.channelList[i] = channel;
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function core:JoinChannel()
|
function core:InChannels()
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function core:JoinChannel(msg)
|
||||||
|
local name = gsub(msg, "%s*([^%s]+).*", "%1");
|
||||||
--need to store channel in db
|
--need to store channel in db
|
||||||
|
local channelCount = table.getn(ChatSaverDB);
|
||||||
|
ChatSaverDB[channelCount + 1] = name;
|
||||||
|
end
|
||||||
|
|
||||||
|
function core:LeaveChannel(msg)
|
||||||
|
local number = gsub(msg, "%s*([^%s]+).*", "%1");
|
||||||
|
local _,name = GetChannelName(number);
|
||||||
|
|
||||||
|
pos = 9;
|
||||||
|
for index,channel in pairs(ChatSaverDB) do
|
||||||
|
if(channel == name) then
|
||||||
|
pos = index;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.remove(ChatSaverDB,pos);
|
||||||
end
|
end
|
|
@ -6,11 +6,12 @@
|
||||||
## Dependencies:
|
## Dependencies:
|
||||||
## OptionalDeps:
|
## OptionalDeps:
|
||||||
## DefaultState: enabled
|
## DefaultState: enabled
|
||||||
## SavedVariables: 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\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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue