This commit is contained in:
Kamil 2012-07-11 11:20:31 +02:00 committed by Eduardo Bart
parent 4aeb9edfae
commit de873448b5
1 changed files with 13 additions and 8 deletions

View File

@ -54,7 +54,6 @@ local channels
local channelsWindow local channelsWindow
local ownPrivateName local ownPrivateName
local messageHistory = {} local messageHistory = {}
local lastChannels = {}
local currentMessageIndex = 0 local currentMessageIndex = 0
local ignoreNpcMessages = false local ignoreNpcMessages = false
@ -137,6 +136,9 @@ local function onCloseChannel(channelId)
if tab then if tab then
consoleTabBar:removeTab(tab) consoleTabBar:removeTab(tab)
end end
for k, v in pairs(channels) do
if (k == tab.channelId) then channels[k] = nil end
end
end end
end end
@ -187,10 +189,9 @@ local function onGameStart()
if tab then if tab then
addEvent(function() consoleTabBar:selectTab(tab) end, false) addEvent(function() consoleTabBar:selectTab(tab) end, false)
end end
for _, channelid in pairs(lastChannels) do for _, channelId in ipairs(g_settings.getList('last-channels')) do
g_game.joinChannel(channelid) g_game.joinChannel(channelId)
end end
lastChannels = {}
end end
-- public functions -- public functions
@ -270,13 +271,14 @@ function Console.terminate()
end end
function Console.clear() function Console.clear()
lastChannels = {} local lastChannels = {}
for channelid, channelname in pairs(channels) do for channelid, channelname in pairs(channels) do
table.insert(lastChannels, tonumber(channelid)) table.insert(lastChannels, channelid)
local tab = consoleTabBar:getTab(channelname) local tab = consoleTabBar:getTab(channelname)
consoleTabBar:removeTab(tab) consoleTabBar:removeTab(tab)
end end
g_settings.setList('last-channels', lastChannels)
channels = {} channels = {}
consoleTabBar:getTab(tr('Default')).tabPanel:getChildById('consoleBuffer'):destroyChildren() consoleTabBar:getTab(tr('Default')).tabPanel:getChildById('consoleBuffer'):destroyChildren()
@ -332,6 +334,9 @@ function Console.removeCurrentTab()
-- notificate the server that we are leaving the channel -- notificate the server that we are leaving the channel
if tab.channelId then if tab.channelId then
for k, v in pairs(channels) do
if (k == tab.channelId) then channels[k] = nil end
end
g_game.leaveChannel(tab.channelId) g_game.leaveChannel(tab.channelId)
elseif tab:getText() == "NPCs" then elseif tab:getText() == "NPCs" then
g_game.closeNpcChannel() g_game.closeNpcChannel()