From de873448b5ce2267bb6efb8cefb443aae2223589 Mon Sep 17 00:00:00 2001 From: Kamil Date: Wed, 11 Jul 2012 11:20:31 +0200 Subject: [PATCH] Updated. --- modules/game_console/console.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index 2f04c951..b93ff201 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -54,7 +54,6 @@ local channels local channelsWindow local ownPrivateName local messageHistory = {} -local lastChannels = {} local currentMessageIndex = 0 local ignoreNpcMessages = false @@ -137,6 +136,9 @@ local function onCloseChannel(channelId) if tab then consoleTabBar:removeTab(tab) end + for k, v in pairs(channels) do + if (k == tab.channelId) then channels[k] = nil end + end end end @@ -187,10 +189,9 @@ local function onGameStart() if tab then addEvent(function() consoleTabBar:selectTab(tab) end, false) end - for _, channelid in pairs(lastChannels) do - g_game.joinChannel(channelid) + for _, channelId in ipairs(g_settings.getList('last-channels')) do + g_game.joinChannel(channelId) end - lastChannels = {} end -- public functions @@ -270,13 +271,14 @@ function Console.terminate() end function Console.clear() - lastChannels = {} + local lastChannels = {} for channelid, channelname in pairs(channels) do - table.insert(lastChannels, tonumber(channelid)) + table.insert(lastChannels, channelid) local tab = consoleTabBar:getTab(channelname) consoleTabBar:removeTab(tab) end - + + g_settings.setList('last-channels', lastChannels) channels = {} consoleTabBar:getTab(tr('Default')).tabPanel:getChildById('consoleBuffer'):destroyChildren() @@ -332,6 +334,9 @@ function Console.removeCurrentTab() -- notificate the server that we are leaving the channel 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) elseif tab:getText() == "NPCs" then g_game.closeNpcChannel() @@ -544,4 +549,4 @@ end function Console.ignoreNpcMessages(ignore) ignoreNpcMessages = ignore -end +end \ No newline at end of file