From ccbe491e3c258ad498eea2d9a9a69b1df62a99e5 Mon Sep 17 00:00:00 2001 From: BeniS Date: Thu, 28 Feb 2013 10:22:46 +1300 Subject: [PATCH] Should resolve #289 (please test and give feedback) --- modules/game_console/console.lua | 81 +++++++++++++----------- modules/game_hotkeys/hotkeys_manager.lua | 10 ++- 2 files changed, 51 insertions(+), 40 deletions(-) diff --git a/modules/game_console/console.lua b/modules/game_console/console.lua index eb5ff781..4f5b83dd 100644 --- a/modules/game_console/console.lua +++ b/modules/game_console/console.lua @@ -51,7 +51,7 @@ SayModes = { [3] = { speakTypeDesc = 'yell', icon = '/images/game/console/yell' } } -MAX_HISTORY = 1000 +MAX_HISTORY = 500 MAX_LINES = 100 HELP_CHANNEL = 9 @@ -80,18 +80,20 @@ local ignoreSettings = { } function init() - connect(g_game, { onTalk = onTalk, - onChannelList = onChannelList, - onOpenChannel = onOpenChannel, - onOpenPrivateChannel = onOpenPrivateChannel, - onOpenOwnPrivateChannel = onOpenOwnPrivateChannel, - onCloseChannel = onCloseChannel, - onRuleViolationChannel = onRuleViolationChannel, - onRuleViolationRemove = onRuleViolationRemove, - onRuleViolationCancel = onRuleViolationCancel, - onRuleViolationLock = onRuleViolationLock, - onGameStart = online, - onGameEnd = offline }) + connect(g_game, { + onTalk = onTalk, + onChannelList = onChannelList, + onOpenChannel = onOpenChannel, + onOpenPrivateChannel = onOpenPrivateChannel, + onOpenOwnPrivateChannel = onOpenOwnPrivateChannel, + onCloseChannel = onCloseChannel, + onRuleViolationChannel = onRuleViolationChannel, + onRuleViolationRemove = onRuleViolationRemove, + onRuleViolationCancel = onRuleViolationCancel, + onRuleViolationLock = onRuleViolationLock, + onGameStart = online, + onGameEnd = offline + }) consolePanel = g_ui.loadUI('console', modules.game_interface.getBottomPanel()) consoleTextEdit = consolePanel:getChildById('consoleTextEdit') @@ -142,18 +144,20 @@ end function terminate() save() - disconnect(g_game, { onTalk = onTalk, - onChannelList = onChannelList, - onOpenChannel = onOpenChannel, - onOpenPrivateChannel = onOpenPrivateChannel, - onOpenOwnPrivateChannel = onOpenPrivateChannel, - onCloseChannel = onCloseChannel, - onRuleViolationChannel = onRuleViolationChannel, - onRuleViolationRemove = onRuleViolationRemove, - onRuleViolationCancel = onRuleViolationCancel, - onRuleViolationLock = onRuleViolationLock, - onGameStart = online, - onGameEnd = offline }) + disconnect(g_game, { + onTalk = onTalk, + onChannelList = onChannelList, + onOpenChannel = onOpenChannel, + onOpenPrivateChannel = onOpenPrivateChannel, + onOpenOwnPrivateChannel = onOpenPrivateChannel, + onCloseChannel = onCloseChannel, + onRuleViolationChannel = onRuleViolationChannel, + onRuleViolationRemove = onRuleViolationRemove, + onRuleViolationCancel = onRuleViolationCancel, + onRuleViolationLock = onRuleViolationLock, + onGameStart = online, + onGameEnd = offline + }) if g_game.isOnline() then clear() end @@ -308,15 +312,17 @@ function removeTab(tab) tab = consoleTabBar:getTab(tab) end - if tab == defaultTab or tab == serverTab then return end + if tab == defaultTab or tab == serverTab then + return + end if tab == violationReportTab then g_game.cancelRuleViolation() violationReportTab = nil elseif tab.violationChatName then g_game.closeRuleViolation(tab.violationChatName) - -- notificate the server that we are leaving the channel elseif tab.channelId then + -- notificate the server that we are leaving the channel for k, v in pairs(channels) do if (k == tab.channelId) then channels[k] = nil end end @@ -329,8 +335,7 @@ function removeTab(tab) end function removeCurrentTab() - local tab = consoleTabBar:getCurrentTab() - removeTab(tab) + removeTab(consoleTabBar:getCurrentTab()) end function getTab(name) @@ -984,15 +989,15 @@ function onClickIgnoreButton() removeButton:disable() ignoreListPanel.onChildFocusChange = function() removeButton:enable() end removeButton.onClick = function() - local selection = ignoreListPanel:getFocusedChild() - if selection then - ignoreListPanel:removeChild(selection) - selection:destroy() - end - if ignoreListPanel:getChildCount() == 0 then - removeButton:disable() - end - end + local selection = ignoreListPanel:getFocusedChild() + if selection then + ignoreListPanel:removeChild(selection) + selection:destroy() + end + if ignoreListPanel:getChildCount() == 0 then + removeButton:disable() + end + end local newlyIgnoredPlayers = {} local addName = ignoreWindow:getChildById('ignoreNameEdit') diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index df03b70f..9479881f 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -193,12 +193,18 @@ function save() local hotkeys = hotkeySettings if perServer then + if not hotkeys[G.host] then + hotkeys[G.host] = {} + end hotkeys = hotkeys[G.host] end if perCharacter then - hotkeys[g_game.getCharacterName()] = {} - hotkeys = hotkeys[g_game.getCharacterName()] + local char = g_game.getCharacterName() + if not hotkeys[char] then + hotkeys[hotkeys[char]] = {} + end + hotkeys = hotkeys[char] end table.clear(hotkeys)