2012-07-24 07:30:08 +02:00
|
|
|
SpeakTypesSettings = {
|
2012-07-30 14:29:13 +02:00
|
|
|
none = {},
|
2012-07-26 11:12:20 +02:00
|
|
|
say = { speakType = MessageModes.Say, color = '#FFFF00' },
|
|
|
|
whisper = { speakType = MessageModes.Whisper, color = '#FFFF00' },
|
|
|
|
yell = { speakType = MessageModes.Yell, color = '#FFFF00' },
|
|
|
|
broadcast = { speakType = MessageModes.GamemasterPrivateFrom, color = '#F55E5E' },
|
|
|
|
private = { speakType = MessageModes.PrivateTo, color = '#5FF7F7', private = true },
|
|
|
|
privateRed = { speakType = MessageModes.GamemasterTo, color = '#F55E5E', private = true },
|
|
|
|
privatePlayerToPlayer = { speakType = MessageModes.PrivateTo, color = '#9F9DFD', private = true },
|
|
|
|
privatePlayerToNpc = { speakType = MessageModes.NpcTo, color = '#9F9DFD', private = true, npcChat = true },
|
|
|
|
privateNpcToPlayer = { speakType = MessageModes.NpcFrom, color = '#5FF7F7', private = true, npcChat = true },
|
|
|
|
channelYellow = { speakType = MessageModes.Channel, color = '#FFFF00' },
|
|
|
|
channelWhite = { speakType = MessageModes.ChannelManagement, color = '#FFFFFF' },
|
|
|
|
channelRed = { speakType = MessageModes.GamemasterChannel, color = '#F55E5E' },
|
|
|
|
channelOrange = { speakType = MessageModes.ChannelHighlight, color = '#FE6500' },
|
|
|
|
monsterSay = { speakType = MessageModes.MonsterSay, color = '#FE6500', hideInConsole = true},
|
|
|
|
monsterYell = { speakType = MessageModes.MonsterYell, color = '#FE6500', hideInConsole = true},
|
2013-01-27 10:44:15 +01:00
|
|
|
rvrAnswerFrom = { speakType = MessageModes.RVRAnswer, color = '#FE6500' },
|
|
|
|
rvrAnswerTo = { speakType = MessageModes.RVRAnswer, color = '#FE6500' },
|
|
|
|
rvrContinue = { speakType = MessageModes.RVRContinue, color = '#FFFF00' },
|
2012-02-03 05:32:39 +01:00
|
|
|
}
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
SpeakTypes = {
|
2012-07-26 11:12:20 +02:00
|
|
|
[MessageModes.Say] = SpeakTypesSettings.say,
|
|
|
|
[MessageModes.Whisper] = SpeakTypesSettings.whisper,
|
|
|
|
[MessageModes.Yell] = SpeakTypesSettings.yell,
|
2012-07-27 00:29:04 +02:00
|
|
|
[MessageModes.GamemasterBroadcast] = SpeakTypesSettings.broadcast,
|
2012-07-26 11:12:20 +02:00
|
|
|
[MessageModes.PrivateFrom] = SpeakTypesSettings.private,
|
|
|
|
[MessageModes.GamemasterPrivateFrom] = SpeakTypesSettings.privateRed,
|
|
|
|
[MessageModes.NpcTo] = SpeakTypesSettings.privatePlayerToNpc,
|
|
|
|
[MessageModes.NpcFrom] = SpeakTypesSettings.privateNpcToPlayer,
|
|
|
|
[MessageModes.Channel] = SpeakTypesSettings.channelYellow,
|
|
|
|
[MessageModes.ChannelManagement] = SpeakTypesSettings.channelWhite,
|
|
|
|
[MessageModes.GamemasterChannel] = SpeakTypesSettings.channelRed,
|
|
|
|
[MessageModes.ChannelHighlight] = SpeakTypesSettings.channelOrange,
|
|
|
|
[MessageModes.MonsterSay] = SpeakTypesSettings.monsterSay,
|
|
|
|
[MessageModes.MonsterYell] = SpeakTypesSettings.monsterYell,
|
2013-01-27 10:44:15 +01:00
|
|
|
[MessageModes.RVRChannel] = SpeakTypesSettings.channelWhite,
|
|
|
|
[MessageModes.RVRContinue] = SpeakTypesSettings.rvrContinue,
|
|
|
|
[MessageModes.RVRAnswer] = SpeakTypesSettings.rvrAnswerFrom,
|
2012-07-30 14:29:13 +02:00
|
|
|
|
|
|
|
-- ignored types
|
|
|
|
[MessageModes.Spell] = SpeakTypesSettings.none,
|
|
|
|
[MessageModes.BarkLow] = SpeakTypesSettings.none,
|
|
|
|
[MessageModes.BarkLoud] = SpeakTypesSettings.none,
|
2012-01-08 23:32:55 +01:00
|
|
|
}
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
SayModes = {
|
2013-01-21 17:15:22 +01:00
|
|
|
[1] = { speakTypeDesc = 'whisper', icon = '/images/game/console/whisper' },
|
|
|
|
[2] = { speakTypeDesc = 'say', icon = '/images/game/console/say' },
|
|
|
|
[3] = { speakTypeDesc = 'yell', icon = '/images/game/console/yell' }
|
2012-02-03 10:59:04 +01:00
|
|
|
}
|
|
|
|
|
2013-02-27 22:22:46 +01:00
|
|
|
MAX_HISTORY = 500
|
2012-07-24 07:30:08 +02:00
|
|
|
MAX_LINES = 100
|
|
|
|
HELP_CHANNEL = 9
|
2012-04-08 06:13:52 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
consolePanel = nil
|
|
|
|
consoleContentPanel = nil
|
|
|
|
consoleTabBar = nil
|
|
|
|
consoleTextEdit = nil
|
|
|
|
channels = nil
|
|
|
|
channelsWindow = nil
|
2013-01-09 23:03:04 +01:00
|
|
|
ignoreWindow = nil
|
2012-07-24 07:30:08 +02:00
|
|
|
ownPrivateName = nil
|
|
|
|
messageHistory = {}
|
|
|
|
currentMessageIndex = 0
|
|
|
|
ignoreNpcMessages = false
|
2012-08-07 01:43:14 +02:00
|
|
|
defaultTab = nil
|
|
|
|
serverTab = nil
|
2013-01-27 10:44:15 +01:00
|
|
|
violationsChannelId = nil
|
|
|
|
violationWindow = nil
|
|
|
|
violationReportTab = nil
|
2013-02-04 19:33:34 +01:00
|
|
|
ignoredChannels = {}
|
2012-03-18 14:34:39 +01:00
|
|
|
|
2013-01-09 23:03:04 +01:00
|
|
|
local ignoreSettings = {
|
2013-02-01 05:32:15 +01:00
|
|
|
privateMessages = false,
|
|
|
|
yelling = false,
|
|
|
|
players = {}
|
2013-01-09 23:03:04 +01:00
|
|
|
}
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function init()
|
2013-02-27 22:22:46 +01:00
|
|
|
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
|
|
|
|
})
|
2012-03-18 14:34:39 +01:00
|
|
|
|
2013-01-18 23:39:11 +01:00
|
|
|
consolePanel = g_ui.loadUI('console', modules.game_interface.getBottomPanel())
|
2012-03-31 15:43:01 +02:00
|
|
|
consoleTextEdit = consolePanel:getChildById('consoleTextEdit')
|
2012-03-25 19:10:19 +02:00
|
|
|
consoleContentPanel = consolePanel:getChildById('consoleContentPanel')
|
2012-01-13 00:47:31 +01:00
|
|
|
consoleTabBar = consolePanel:getChildById('consoleTabBar')
|
2012-03-25 19:10:19 +02:00
|
|
|
consoleTabBar:setContentWidget(consoleContentPanel)
|
2013-01-05 08:57:31 +01:00
|
|
|
consoleTabBar:setTabSpacing(-1)
|
2012-01-14 02:37:15 +01:00
|
|
|
channels = {}
|
|
|
|
|
2013-01-20 16:40:40 +01:00
|
|
|
consolePanel.onKeyPress = function(self, keyCode, keyboardModifiers)
|
|
|
|
if not (keyboardModifiers == KeyboardCtrlModifier and keyCode == KeyC) then return false end
|
|
|
|
|
|
|
|
local tab = consoleTabBar:getCurrentTab()
|
|
|
|
if not tab then return false end
|
|
|
|
|
|
|
|
local consoleBuffer = tab.tabPanel:getChildById('consoleBuffer')
|
|
|
|
if not consoleBuffer then return false end
|
|
|
|
|
|
|
|
local consoleLabel = consoleBuffer:getFocusedChild()
|
|
|
|
if not consoleLabel or not consoleLabel:hasSelection() then return false end
|
|
|
|
|
|
|
|
g_window.setClipboardText(consoleLabel:getSelection())
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2012-08-07 01:43:14 +02:00
|
|
|
defaultTab = addTab(tr('Default'), true)
|
|
|
|
serverTab = addTab(tr('Server Log'), false)
|
2012-02-04 03:11:18 +01:00
|
|
|
|
2012-06-26 00:13:30 +02:00
|
|
|
g_keyboard.bindKeyPress('Shift+Up', function() navigateMessageHistory(1) end, consolePanel)
|
|
|
|
g_keyboard.bindKeyPress('Shift+Down', function() navigateMessageHistory(-1) end, consolePanel)
|
|
|
|
g_keyboard.bindKeyPress('Tab', function() consoleTabBar:selectNextTab() end, consolePanel)
|
|
|
|
g_keyboard.bindKeyPress('Shift+Tab', function() consoleTabBar:selectPrevTab() end, consolePanel)
|
2012-07-24 07:30:08 +02:00
|
|
|
g_keyboard.bindKeyDown('Enter', sendCurrentMessage, consolePanel)
|
2012-06-26 00:13:30 +02:00
|
|
|
g_keyboard.bindKeyPress('Ctrl+A', function() consoleTextEdit:clearText() end, consolePanel)
|
2012-02-04 03:11:18 +01:00
|
|
|
|
2012-02-03 06:24:45 +01:00
|
|
|
-- apply buttom functions after loaded
|
2012-03-18 14:34:39 +01:00
|
|
|
consolePanel:getChildById('nextChannelButton').onClick = function() consoleTabBar:selectNextTab() end
|
|
|
|
consolePanel:getChildById('prevChannelButton').onClick = function() consoleTabBar:selectPrevTab() end
|
2012-07-24 07:30:08 +02:00
|
|
|
consoleTabBar.onTabChange = onTabChange
|
2012-02-04 03:11:18 +01:00
|
|
|
|
2012-02-03 06:24:45 +01:00
|
|
|
-- tibia like hotkeys
|
2012-06-26 00:13:30 +02:00
|
|
|
g_keyboard.bindKeyDown('Ctrl+O', g_game.requestChannels)
|
2012-07-24 07:30:08 +02:00
|
|
|
g_keyboard.bindKeyDown('Ctrl+E', removeCurrentTab)
|
|
|
|
g_keyboard.bindKeyDown('Ctrl+H', openHelp)
|
2013-01-09 23:03:04 +01:00
|
|
|
|
2013-02-14 18:30:45 +01:00
|
|
|
load()
|
2012-01-08 23:32:55 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function terminate()
|
2013-02-14 18:30:45 +01:00
|
|
|
save()
|
2013-02-27 22:22:46 +01:00
|
|
|
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
|
|
|
|
})
|
2012-03-18 14:34:39 +01:00
|
|
|
|
2012-07-31 05:53:15 +02:00
|
|
|
if g_game.isOnline() then clear() end
|
2012-03-18 14:34:39 +01:00
|
|
|
|
2012-06-26 00:13:30 +02:00
|
|
|
g_keyboard.unbindKeyDown('Ctrl+O')
|
|
|
|
g_keyboard.unbindKeyDown('Ctrl+E')
|
|
|
|
g_keyboard.unbindKeyDown('Ctrl+H')
|
2012-03-18 14:34:39 +01:00
|
|
|
|
2013-01-09 23:03:04 +01:00
|
|
|
saveIgnoreSettings()
|
|
|
|
|
2012-03-22 22:47:52 +01:00
|
|
|
if channelsWindow then
|
|
|
|
channelsWindow:destroy()
|
|
|
|
end
|
2013-01-09 23:03:04 +01:00
|
|
|
|
|
|
|
if ignoreWindow then
|
|
|
|
ignoreWindow:destroy()
|
|
|
|
end
|
2012-03-22 22:47:52 +01:00
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
if violationWindow then
|
|
|
|
violationWindow:destroy()
|
|
|
|
end
|
2013-02-01 05:32:15 +01:00
|
|
|
|
2012-01-08 23:32:55 +01:00
|
|
|
consolePanel:destroy()
|
2012-04-24 13:20:14 +02:00
|
|
|
ownPrivateName = nil
|
2012-04-27 06:54:14 +02:00
|
|
|
|
|
|
|
Console = nil
|
2012-01-08 23:32:55 +01:00
|
|
|
end
|
|
|
|
|
2013-02-14 18:30:45 +01:00
|
|
|
function save()
|
|
|
|
local settings = {}
|
|
|
|
settings.messageHistory = messageHistory
|
|
|
|
g_settings.setNode('game_console', settings)
|
|
|
|
end
|
|
|
|
|
|
|
|
function load()
|
|
|
|
local settings = g_settings.getNode('game_console')
|
|
|
|
if settings then
|
|
|
|
messageHistory = settings.messageHistory or {}
|
|
|
|
end
|
|
|
|
loadIgnoreSettings()
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function onTabChange(tabBar, tab)
|
2012-08-07 01:43:14 +02:00
|
|
|
if tab == defaultTab or tab == serverTab then
|
2012-07-24 07:30:08 +02:00
|
|
|
consolePanel:getChildById('closeChannelButton'):disable()
|
|
|
|
else
|
|
|
|
consolePanel:getChildById('closeChannelButton'):enable()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function clear()
|
2012-07-31 05:53:15 +02:00
|
|
|
-- save last open channels
|
|
|
|
local lastChannelsOpen = g_settings.getNode('lastChannelsOpen') or {}
|
2013-01-30 21:23:26 +01:00
|
|
|
local char = g_game.getCharacterName()
|
2012-07-31 05:53:15 +02:00
|
|
|
local savedChannels = {}
|
|
|
|
local set = false
|
|
|
|
for channelId, channelName in pairs(channels) do
|
|
|
|
if type(channelId) == 'number' then
|
|
|
|
savedChannels[channelName] = channelId
|
|
|
|
set = true
|
2012-07-24 07:30:08 +02:00
|
|
|
end
|
|
|
|
end
|
2012-07-31 05:53:15 +02:00
|
|
|
if set then
|
|
|
|
lastChannelsOpen[char] = savedChannels
|
|
|
|
else
|
|
|
|
lastChannelsOpen[char] = nil
|
|
|
|
end
|
|
|
|
g_settings.setNode('lastChannelsOpen', lastChannelsOpen)
|
2012-07-24 07:30:08 +02:00
|
|
|
|
2012-07-31 05:53:15 +02:00
|
|
|
-- close channels
|
2012-07-24 07:30:08 +02:00
|
|
|
for _, channelName in pairs(channels) do
|
|
|
|
local tab = consoleTabBar:getTab(channelName)
|
|
|
|
consoleTabBar:removeTab(tab)
|
|
|
|
end
|
|
|
|
channels = {}
|
|
|
|
|
2012-08-07 01:43:14 +02:00
|
|
|
defaultTab.tabPanel:getChildById('consoleBuffer'):destroyChildren()
|
|
|
|
serverTab.tabPanel:getChildById('consoleBuffer'):destroyChildren()
|
2012-07-24 07:30:08 +02:00
|
|
|
|
|
|
|
local npcTab = consoleTabBar:getTab('NPCs')
|
|
|
|
if npcTab then
|
|
|
|
consoleTabBar:removeTab(npcTab)
|
|
|
|
end
|
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
if violationReportTab then
|
|
|
|
consoleTabBar:removeTab(violationReportTab)
|
|
|
|
violationReportTab = nil
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
consoleTextEdit:clearText()
|
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
if violationWindow then
|
|
|
|
violationWindow:destroy()
|
|
|
|
violationWindow = nil
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
if channelsWindow then
|
|
|
|
channelsWindow:destroy()
|
|
|
|
channelsWindow = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-03 09:24:07 +01:00
|
|
|
function clearChannel(consoleTabBar)
|
|
|
|
consoleTabBar:getCurrentTab().tabPanel:getChildById('consoleBuffer'):destroyChildren()
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function setTextEditText(text)
|
2012-03-31 15:43:01 +02:00
|
|
|
consoleTextEdit:setText(text)
|
2013-01-24 21:36:04 +01:00
|
|
|
consoleTextEdit:setCursorPos(-1)
|
2012-02-07 06:52:48 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function openHelp()
|
2013-01-18 23:39:11 +01:00
|
|
|
local helpChannel = 9
|
|
|
|
if g_game.getProtocolVersion() <= 810 then
|
|
|
|
helpChannel = 8
|
|
|
|
end
|
|
|
|
g_game.joinChannel(helpChannel)
|
2012-06-08 18:58:08 +02:00
|
|
|
end
|
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
function openPlayerReportRuleViolationWindow()
|
|
|
|
if violationWindow or violationReportTab then return end
|
|
|
|
violationWindow = g_ui.loadUI('violationwindow', rootWidget)
|
|
|
|
violationWindow.onEscape = function()
|
|
|
|
violationWindow:destroy()
|
|
|
|
violationWindow = nil
|
|
|
|
end
|
|
|
|
violationWindow.onEnter = function()
|
|
|
|
local text = violationWindow:getChildById('text'):getText()
|
|
|
|
g_game.talkChannel(MessageModes.RVRChannel, 0, text)
|
|
|
|
violationReportTab = addTab(tr('Report Rule') .. '...', true)
|
|
|
|
addTabText(tr('Please wait patiently for a gamemaster to reply') .. '.', SpeakTypesSettings.privateRed, violationReportTab)
|
|
|
|
violationReportTab.locked = true
|
|
|
|
violationWindow:destroy()
|
|
|
|
violationWindow = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function addTab(name, focus)
|
|
|
|
local tab = getTab(name)
|
2012-12-28 12:05:45 +01:00
|
|
|
if tab then -- is channel already open
|
|
|
|
if not focus then focus = true end
|
2012-07-10 14:15:31 +02:00
|
|
|
else
|
2013-01-03 09:24:07 +01:00
|
|
|
tab = consoleTabBar:addTab(name, nil, processChannelTabMenu)
|
2012-07-10 14:15:31 +02:00
|
|
|
end
|
2012-02-03 05:32:39 +01:00
|
|
|
if focus then
|
2012-02-04 04:03:46 +01:00
|
|
|
consoleTabBar:selectTab(tab)
|
2012-02-03 05:32:39 +01:00
|
|
|
end
|
2012-01-14 02:37:15 +01:00
|
|
|
return tab
|
|
|
|
end
|
2012-01-08 23:32:55 +01:00
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
function removeTab(tab)
|
|
|
|
if type(tab) == 'string' then
|
2013-01-27 12:22:48 +01:00
|
|
|
tab = consoleTabBar:getTab(tab)
|
2013-01-27 10:44:15 +01:00
|
|
|
end
|
|
|
|
|
2013-02-27 22:22:46 +01:00
|
|
|
if tab == defaultTab or tab == serverTab then
|
|
|
|
return
|
|
|
|
end
|
2013-01-03 09:24:07 +01:00
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
if tab == violationReportTab then
|
|
|
|
g_game.cancelRuleViolation()
|
|
|
|
violationReportTab = nil
|
|
|
|
elseif tab.violationChatName then
|
|
|
|
g_game.closeRuleViolation(tab.violationChatName)
|
|
|
|
elseif tab.channelId then
|
2013-02-27 22:22:46 +01:00
|
|
|
-- notificate the server that we are leaving the channel
|
2013-01-03 09:24:07 +01:00
|
|
|
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()
|
|
|
|
end
|
|
|
|
|
|
|
|
consoleTabBar:removeTab(tab)
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function removeCurrentTab()
|
2013-02-27 22:22:46 +01:00
|
|
|
removeTab(consoleTabBar:getCurrentTab())
|
2012-02-03 05:32:39 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function getTab(name)
|
2012-01-14 02:37:15 +01:00
|
|
|
return consoleTabBar:getTab(name)
|
|
|
|
end
|
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
function getChannelTab(channelId)
|
|
|
|
local channel = channels[channelId]
|
|
|
|
if channel then
|
|
|
|
return getTab(channel)
|
|
|
|
end
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
function getRuleViolationsTab()
|
|
|
|
if violationsChannelId then
|
|
|
|
return getChannelTab(violationsChannelId)
|
|
|
|
end
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function getCurrentTab()
|
2012-01-14 02:37:15 +01:00
|
|
|
return consoleTabBar:getCurrentTab()
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function addChannel(name, id)
|
2012-01-14 02:37:15 +01:00
|
|
|
channels[id] = name
|
2013-02-04 19:33:34 +01:00
|
|
|
local focus = not table.find(ignoredChannels, id)
|
|
|
|
local tab = addTab(name, focus)
|
2012-01-14 02:37:15 +01:00
|
|
|
tab.channelId = id
|
|
|
|
return tab
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function addPrivateChannel(receiver)
|
2012-07-10 14:15:31 +02:00
|
|
|
channels[receiver] = receiver
|
2013-02-04 19:33:34 +01:00
|
|
|
return addTab(receiver, false)
|
2012-07-10 14:15:31 +02:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function addPrivateText(text, speaktype, name, isPrivateCommand, creatureName)
|
2012-02-04 04:03:46 +01:00
|
|
|
local focus = false
|
2012-07-26 17:42:15 +02:00
|
|
|
if speaktype.npcChat then
|
2012-02-03 07:20:58 +01:00
|
|
|
name = 'NPCs'
|
2012-02-04 04:03:46 +01:00
|
|
|
focus = true
|
2012-02-03 07:20:58 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
local privateTab = getTab(name)
|
2012-01-14 02:37:15 +01:00
|
|
|
if privateTab == nil then
|
2013-01-18 23:39:11 +01:00
|
|
|
if (modules.client_options.getOption('showPrivateMessagesInConsole') and not focus) or (isPrivateCommand and not privateTab) then
|
2012-08-07 01:43:14 +02:00
|
|
|
privateTab = defaultTab
|
2012-01-14 02:37:15 +01:00
|
|
|
else
|
2012-07-24 07:30:08 +02:00
|
|
|
privateTab = addTab(name, focus)
|
2012-06-10 02:12:28 +02:00
|
|
|
channels[name] = name
|
2012-01-14 02:37:15 +01:00
|
|
|
end
|
|
|
|
privateTab.npcChat = speaktype.npcChat
|
2012-02-04 04:03:46 +01:00
|
|
|
elseif focus then
|
|
|
|
consoleTabBar:selectTab(privateTab)
|
2012-01-14 02:37:15 +01:00
|
|
|
end
|
2012-07-24 07:30:08 +02:00
|
|
|
addTabText(text, speaktype, privateTab, creatureName)
|
2012-01-14 02:37:15 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function addText(text, speaktype, tabName, creatureName)
|
|
|
|
local tab = getTab(tabName)
|
2012-02-03 10:59:04 +01:00
|
|
|
if tab ~= nil then
|
2012-07-24 07:30:08 +02:00
|
|
|
addTabText(text, speaktype, tab, creatureName)
|
2012-02-03 10:59:04 +01:00
|
|
|
end
|
2012-01-14 02:37:15 +01:00
|
|
|
end
|
|
|
|
|
2012-10-05 17:50:54 +02:00
|
|
|
-- Contains letter width for font "verdana-11px-antialised" as console is based on it
|
2012-10-09 20:34:39 +02:00
|
|
|
local letterWidth = { -- New line (10) and Space (32) have width 1 because they are printed and not replaced with spacer
|
|
|
|
[10] = 1, [32] = 1, [33] = 3, [34] = 6, [35] = 8, [36] = 7, [37] = 13, [38] = 9, [39] = 3, [40] = 5, [41] = 5, [42] = 6, [43] = 8, [44] = 4, [45] = 5, [46] = 3, [47] = 8,
|
2012-10-06 00:11:41 +02:00
|
|
|
[48] = 7, [49] = 6, [50] = 7, [51] = 7, [52] = 7, [53] = 7, [54] = 7, [55] = 7, [56] = 7, [57] = 7, [58] = 3, [59] = 4, [60] = 8, [61] = 8, [62] = 8, [63] = 6,
|
2012-10-05 17:50:54 +02:00
|
|
|
[64] = 10, [65] = 9, [66] = 7, [67] = 7, [68] = 8, [69] = 7, [70] = 7, [71] = 8, [72] = 8, [73] = 5, [74] = 5, [75] = 7, [76] = 7, [77] = 9, [78] = 8, [79] = 8,
|
|
|
|
[80] = 7, [81] = 8, [82] = 8, [83] = 7, [84] = 8, [85] = 8, [86] = 8, [87] = 12, [88] = 8, [89] = 8, [90] = 7, [91] = 5, [92] = 8, [93] = 5, [94] = 9, [95] = 8,
|
|
|
|
[96] = 5, [97] = 7, [98] = 7, [99] = 6, [100] = 7, [101] = 7, [102] = 5, [103] = 7, [104] = 7, [105] = 3, [106] = 4, [107] = 7, [108] = 3, [109] = 11, [110] = 7,
|
2012-10-06 00:11:41 +02:00
|
|
|
[111] = 7, [112] = 7, [113] = 7, [114] = 6, [115] = 6, [116] = 5, [117] = 7, [118] = 8, [119] = 10, [120] = 8, [121] = 8, [122] = 6, [123] = 7, [124] = 4, [125] = 7, [126] = 8,
|
|
|
|
[127] = 1, [128] = 7, [129] = 6, [130] = 3, [131] = 7, [132] = 6, [133] = 11, [134] = 7, [135] = 7, [136] = 7, [137] = 13, [138] = 7, [139] = 4, [140] = 11, [141] = 6, [142] = 6,
|
|
|
|
[143] = 6, [144] = 6, [145] = 4, [146] = 3, [147] = 7, [148] = 6, [149] = 6, [150] = 7, [151] = 10, [152] = 7, [153] = 10, [154] = 6, [155] = 5, [156] = 11, [157] = 6, [158] = 6,
|
2012-10-05 17:50:54 +02:00
|
|
|
[159] = 8, [160] = 4, [161] = 3, [162] = 7, [163] = 7, [164] = 7, [165] = 8, [166] = 4, [167] = 7, [168] = 6, [169] = 10, [170] = 6, [171] = 8, [172] = 8, [173] = 16, [174] = 10,
|
2012-10-06 00:11:41 +02:00
|
|
|
[175] = 8, [176] = 5, [177] = 8, [178] = 5, [179] = 5, [180] = 6, [181] = 7, [182] = 7, [183] = 3, [184] = 5, [185] = 6, [186] = 6, [187] = 8, [188] = 12, [189] = 12, [190] = 12,
|
2012-10-05 17:50:54 +02:00
|
|
|
[191] = 6, [192] = 9, [193] = 9, [194] = 9, [195] = 9, [196] = 9, [197] = 9, [198] = 11, [199] = 7, [200] = 7, [201] = 7, [202] = 7, [203] = 7, [204] = 5, [205] = 5, [206] = 6,
|
|
|
|
[207] = 5, [208] = 8, [209] = 8, [210] = 8, [211] = 8, [212] = 8, [213] = 8, [214] = 8, [215] = 8, [216] = 8, [217] = 8, [218] = 8, [219] = 8, [220] = 8, [221] = 8, [222] = 7,
|
2012-10-06 00:11:41 +02:00
|
|
|
[223] = 7, [224] = 7, [225] = 7, [226] = 7, [227] = 7, [228] = 7, [229] = 7, [230] = 11, [231] = 6, [232] = 7, [233] = 7, [234] = 7, [235] = 7, [236] = 3, [237] = 4, [238] = 4,
|
2012-10-05 17:50:54 +02:00
|
|
|
[239] = 4, [240] = 7, [241] = 7, [242] = 7, [243] = 7, [244] = 7, [245] = 7, [246] = 7, [247] = 9, [248] = 7, [249] = 7, [250] = 7, [251] = 7, [252] = 7, [253] = 8, [254] = 7, [255] = 8
|
|
|
|
}
|
|
|
|
|
|
|
|
-- Return information about start, end in the string and the highlighted words
|
|
|
|
function getHighlightedText(text)
|
|
|
|
local tmpData = {}
|
|
|
|
|
|
|
|
repeat
|
|
|
|
local tmp = {string.find(text, "{([^}]+)}", tmpData[#tmpData-1])}
|
|
|
|
for _, v in pairs(tmp) do
|
|
|
|
table.insert(tmpData, v)
|
|
|
|
end
|
|
|
|
until not(string.find(text, "{([^}]+)}", tmpData[#tmpData-1]))
|
2012-10-06 00:11:41 +02:00
|
|
|
|
2012-10-05 17:50:54 +02:00
|
|
|
return tmpData
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function addTabText(text, speaktype, tab, creatureName)
|
2013-01-27 10:44:15 +01:00
|
|
|
if not tab or tab.locked or not text or #text == 0 then return end
|
|
|
|
|
2013-01-18 23:39:11 +01:00
|
|
|
if modules.client_options.getOption('showTimestampsInConsole') then
|
2012-01-09 00:28:49 +01:00
|
|
|
text = os.date('%H:%M') .. ' ' .. text
|
|
|
|
end
|
|
|
|
|
2012-01-14 21:14:40 +01:00
|
|
|
local panel = consoleTabBar:getTabPanel(tab)
|
2012-03-25 19:10:19 +02:00
|
|
|
local consoleBuffer = panel:getChildById('consoleBuffer')
|
2012-06-26 00:13:30 +02:00
|
|
|
local label = g_ui.createWidget('ConsoleLabel', consoleBuffer)
|
2013-01-20 16:40:40 +01:00
|
|
|
label:setId('consoleLabel' .. consoleBuffer:getChildCount())
|
2012-01-08 23:32:55 +01:00
|
|
|
label:setText(text)
|
2012-01-14 02:37:15 +01:00
|
|
|
label:setColor(speaktype.color)
|
|
|
|
consoleTabBar:blinkTab(tab)
|
2012-10-06 00:11:41 +02:00
|
|
|
|
2012-10-05 17:50:54 +02:00
|
|
|
-- Overlay for consoleBuffer which shows highlighted words only
|
2013-01-11 08:10:37 +01:00
|
|
|
|
2013-02-26 22:13:50 +01:00
|
|
|
if speaktype.npcChat and (g_game.getCharacterName() ~= creatureName or g_game.getCharacterName() == 'Account Manager') then
|
2012-10-05 17:50:54 +02:00
|
|
|
local highlightData = getHighlightedText(text)
|
2013-02-26 22:13:50 +01:00
|
|
|
if #highlightData > 0 then
|
|
|
|
local labelHighlight = g_ui.createWidget('ConsolePhantomLabel', label)
|
|
|
|
labelHighlight:fill('parent')
|
|
|
|
|
|
|
|
labelHighlight:setId('consoleLabelHighlight' .. consoleBuffer:getChildCount())
|
|
|
|
labelHighlight:setColor("#1f9ffe")
|
|
|
|
|
2012-10-05 17:50:54 +02:00
|
|
|
-- Remove the curly braces
|
|
|
|
for i = 1, #highlightData / 3 do
|
|
|
|
local dataBlock = { _start = highlightData[(i-1)*3+1], _end = highlightData[(i-1)*3+2], words = highlightData[(i-1)*3+3] }
|
|
|
|
text = text:gsub("{"..dataBlock.words.."}", dataBlock.words)
|
|
|
|
|
|
|
|
-- Recalculate positions as braces are removed
|
|
|
|
highlightData[(i-1)*3+1] = dataBlock._start - ((i-1) * 2)
|
|
|
|
highlightData[(i-1)*3+2] = dataBlock._end - (1 + (i-1) * 2)
|
|
|
|
end
|
|
|
|
label:setText(text)
|
|
|
|
|
|
|
|
-- Calculate the positions of the highlighted text and fill with string.char(127) [Width: 1]
|
2013-01-22 21:29:18 +01:00
|
|
|
local drawText = label:getDrawText()
|
2012-10-05 17:50:54 +02:00
|
|
|
local tmpText = ""
|
|
|
|
for i = 1, #highlightData / 3 do
|
|
|
|
local dataBlock = { _start = highlightData[(i-1)*3+1], _end = highlightData[(i-1)*3+2], words = highlightData[(i-1)*3+3] }
|
2012-10-06 00:11:41 +02:00
|
|
|
local lastBlockEnd = (highlightData[(i-2)*3+2] or 1)
|
2012-10-05 17:50:54 +02:00
|
|
|
|
|
|
|
for letter = lastBlockEnd, dataBlock._start-1 do
|
2012-10-09 20:34:39 +02:00
|
|
|
local tmpChar = string.byte(drawText:sub(letter, letter))
|
|
|
|
local fillChar = (tmpChar == 10 or tmpChar == 32) and string.char(tmpChar) or string.char(127)
|
2012-10-23 21:15:59 +02:00
|
|
|
|
2012-10-09 20:34:39 +02:00
|
|
|
tmpText = tmpText .. string.rep(fillChar, letterWidth[tmpChar])
|
2012-10-05 17:50:54 +02:00
|
|
|
end
|
|
|
|
tmpText = tmpText .. dataBlock.words
|
|
|
|
end
|
2012-10-23 21:15:59 +02:00
|
|
|
|
2012-10-09 20:34:39 +02:00
|
|
|
-- Fill the highlight label to the same size as default label
|
|
|
|
local finalBlockEnd = (highlightData[(#highlightData/3-1)*3+2] or 1)
|
|
|
|
for letter = finalBlockEnd, drawText:len() do
|
|
|
|
local tmpChar = string.byte(drawText:sub(letter, letter))
|
|
|
|
local fillChar = (tmpChar == 10 or tmpChar == 32) and string.char(tmpChar) or string.char(127)
|
2012-10-23 21:15:59 +02:00
|
|
|
|
2012-10-09 20:34:39 +02:00
|
|
|
tmpText = tmpText .. string.rep(fillChar, letterWidth[tmpChar])
|
|
|
|
end
|
2012-10-23 21:15:59 +02:00
|
|
|
|
2012-10-05 17:50:54 +02:00
|
|
|
labelHighlight:setText(tmpText)
|
|
|
|
end
|
|
|
|
end
|
2012-01-14 21:14:40 +01:00
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
label.name = creatureName
|
2013-01-27 21:26:20 +01:00
|
|
|
label.onMouseRelease = function (self, mousePos, mouseButton)
|
|
|
|
processMessageMenu(mousePos, mouseButton, creatureName, text, self, tab)
|
2013-01-11 08:10:37 +01:00
|
|
|
end
|
2012-06-09 15:00:08 +02:00
|
|
|
|
2012-03-25 19:10:19 +02:00
|
|
|
if consoleBuffer:getChildCount() > MAX_LINES then
|
|
|
|
consoleBuffer:getFirstChild():destroy()
|
2012-01-14 21:14:40 +01:00
|
|
|
end
|
2012-01-13 00:47:31 +01:00
|
|
|
end
|
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
function removeTabLabelByName(tab, name)
|
|
|
|
local panel = consoleTabBar:getTabPanel(tab)
|
|
|
|
local consoleBuffer = panel:getChildById('consoleBuffer')
|
|
|
|
for _,label in pairs(consoleBuffer:getChildren()) do
|
|
|
|
if label.name == name then
|
|
|
|
label:destroy()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-03 09:24:07 +01:00
|
|
|
function processChannelTabMenu(tab, mousePos, mouseButton)
|
|
|
|
local menu = g_ui.createWidget('PopupMenu')
|
|
|
|
|
|
|
|
channelName = tab:getText()
|
|
|
|
if tab ~= defaultTab and tab ~= serverTab then
|
|
|
|
menu:addOption(tr('Close'), function() removeTab(channelName) end)
|
|
|
|
--menu:addOption(tr('Show Server Messages'), function() --[[TODO]] end)
|
|
|
|
menu:addSeparator()
|
|
|
|
end
|
2013-01-27 17:06:47 +01:00
|
|
|
|
|
|
|
if consoleTabBar:getCurrentTab() == tab then
|
|
|
|
menu:addOption(tr('Clear Messages'), function() clearChannel(consoleTabBar) end)
|
|
|
|
end
|
2013-01-03 09:24:07 +01:00
|
|
|
--menu:addOption(tr('Save Messages'), function() --[[TODO]] end)
|
|
|
|
|
|
|
|
menu:display(mousePos)
|
|
|
|
end
|
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
function processMessageMenu(mousePos, mouseButton, creatureName, text, label, tab)
|
2012-05-01 08:49:48 +02:00
|
|
|
if mouseButton == MouseRightButton then
|
2012-06-26 00:13:30 +02:00
|
|
|
local menu = g_ui.createWidget('PopupMenu')
|
2013-01-27 21:26:20 +01:00
|
|
|
if creatureName and #creatureName > 0 then
|
2012-06-04 02:28:19 +02:00
|
|
|
if creatureName ~= g_game.getCharacterName() then
|
2012-05-01 08:49:48 +02:00
|
|
|
menu:addOption(tr('Message to ' .. creatureName), function () g_game.openPrivateChannel(creatureName) end)
|
2012-12-08 19:08:54 +01:00
|
|
|
if not g_game.getLocalPlayer():hasVip(creatureName) then
|
2012-07-09 08:59:16 +02:00
|
|
|
menu:addOption(tr('Add to VIP list'), function () g_game.addVip(creatureName) end)
|
|
|
|
end
|
2013-01-18 23:39:11 +01:00
|
|
|
if modules.game_console.getOwnPrivateTab() then
|
|
|
|
menu:addSeparator()
|
|
|
|
menu:addOption(tr('Invite to private chat'), function() g_game.inviteToOwnChannel(creatureName) end)
|
|
|
|
menu:addOption(tr('Exclude from private chat'), function() g_game.excludeFromOwnChannel(creatureName) end)
|
|
|
|
end
|
2013-01-10 04:20:26 +01:00
|
|
|
if isIgnored(creatureName) then
|
2013-01-10 18:25:32 +01:00
|
|
|
menu:addOption(tr('Unignore') .. ' ' .. creatureName, function() removeIgnoredPlayer(creatureName) end)
|
|
|
|
else
|
|
|
|
menu:addOption(tr('Ignore') .. ' ' .. creatureName, function() addIgnoredPlayer(creatureName) end)
|
|
|
|
end
|
2012-05-01 08:49:48 +02:00
|
|
|
menu:addSeparator()
|
|
|
|
end
|
2012-07-26 11:12:20 +02:00
|
|
|
if modules.game_ruleviolation.hasWindowAccess() then
|
|
|
|
menu:addOption(tr('Rule Violation'), function() modules.game_ruleviolation.show(creatureName, text:match('.+%:%s(.+)')) end)
|
2013-01-26 19:05:34 +01:00
|
|
|
menu:addSeparator()
|
2012-05-01 08:49:48 +02:00
|
|
|
end
|
2012-06-20 02:15:56 +02:00
|
|
|
|
2012-05-01 08:49:48 +02:00
|
|
|
menu:addOption(tr('Copy name'), function () g_window.setClipboardText(creatureName) end)
|
|
|
|
end
|
2013-01-26 19:05:34 +01:00
|
|
|
if label:hasSelection() then
|
|
|
|
menu:addOption(tr('Copy'), function() g_window.setClipboardText(label:getSelection()) end, '(Ctrl+C)')
|
|
|
|
end
|
|
|
|
menu:addOption(tr('Copy message'), function() g_window.setClipboardText(text) end)
|
|
|
|
menu:addOption(tr('Select all'), function() label:selectAll() end)
|
2013-01-27 10:44:15 +01:00
|
|
|
if tab.violations then
|
|
|
|
menu:addSeparator()
|
|
|
|
menu:addOption(tr('Process') .. ' ' .. creatureName, function() processViolation(creatureName, text) end)
|
|
|
|
menu:addOption(tr('Remove') .. ' ' .. creatureName, function() g_game.closeRuleViolation(creatureName) end)
|
|
|
|
end
|
2012-05-01 08:49:48 +02:00
|
|
|
menu:display(mousePos)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function sendCurrentMessage()
|
2012-03-31 15:43:01 +02:00
|
|
|
local message = consoleTextEdit:getText()
|
2012-01-14 02:37:15 +01:00
|
|
|
if #message == 0 then return end
|
2012-03-31 15:43:01 +02:00
|
|
|
consoleTextEdit:clearText()
|
2012-01-14 02:37:15 +01:00
|
|
|
|
2013-01-11 08:10:37 +01:00
|
|
|
-- send message
|
|
|
|
sendMessage(message)
|
|
|
|
end
|
|
|
|
|
|
|
|
function sendMessage(message, tab)
|
|
|
|
local tab = tab or getCurrentTab()
|
2013-01-31 04:10:53 +01:00
|
|
|
if not tab then return end
|
2012-01-14 02:37:15 +01:00
|
|
|
|
2013-01-31 04:10:53 +01:00
|
|
|
-- when talking on server log, the message goes to default channel
|
|
|
|
local name = tab:getText()
|
|
|
|
if tab == serverTab or tab == getRuleViolationsTab() then
|
|
|
|
tab = defaultTab
|
|
|
|
name = defaultTab:getText()
|
|
|
|
end
|
2013-01-27 10:44:15 +01:00
|
|
|
|
2012-02-03 10:59:04 +01:00
|
|
|
-- handling chat commands
|
2013-02-14 19:34:33 +01:00
|
|
|
local channel = tab.channelId
|
2012-02-03 21:27:13 +01:00
|
|
|
local originalMessage = message
|
2012-02-03 10:59:04 +01:00
|
|
|
local chatCommandSayMode
|
|
|
|
local chatCommandPrivate
|
2012-02-03 22:37:42 +01:00
|
|
|
local chatCommandPrivateReady
|
2013-02-14 19:34:33 +01:00
|
|
|
local chatCommandMessage
|
2012-02-04 03:11:18 +01:00
|
|
|
|
2013-02-14 19:34:33 +01:00
|
|
|
-- player used yell command
|
|
|
|
chatCommandMessage = message:match("^%#y (.*)")
|
|
|
|
if chatCommandMessage ~= nil then
|
|
|
|
chatCommandSayMode = 'yell'
|
|
|
|
channel = 0
|
|
|
|
message = chatCommandMessage
|
|
|
|
end
|
2012-02-04 03:11:18 +01:00
|
|
|
|
2013-02-14 19:34:33 +01:00
|
|
|
-- player used whisper
|
2012-02-03 10:59:04 +01:00
|
|
|
local chatCommandMessage = message:match("^%#w (.*)")
|
2013-02-14 19:34:33 +01:00
|
|
|
if chatCommandMessage ~= nil then
|
|
|
|
chatCommandSayMode = 'whisper'
|
|
|
|
message = chatCommandMessage
|
|
|
|
channel = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
-- player say
|
|
|
|
local chatCommandMessage = message:match("^%#s (.*)")
|
|
|
|
if chatCommandMessage ~= nil then
|
|
|
|
chatCommandSayMode = 'say'
|
|
|
|
message = chatCommandMessage
|
|
|
|
channel = 0
|
|
|
|
end
|
2012-02-04 03:11:18 +01:00
|
|
|
|
|
|
|
local findIni, findEnd, chatCommandInitial, chatCommandPrivate, chatCommandEnd, chatCommandMessage = message:find("([%*%@])(.+)([%*%@])(.*)")
|
2012-02-03 10:59:04 +01:00
|
|
|
if findIni ~= nil and findIni == 1 then -- player used private chat command
|
|
|
|
if chatCommandInitial == chatCommandEnd then
|
|
|
|
chatCommandPrivateRepeat = false
|
|
|
|
if chatCommandInitial == "*" then
|
2013-01-24 21:36:04 +01:00
|
|
|
setTextEditText('*'.. chatCommandPrivate .. '* ')
|
2012-02-04 03:11:18 +01:00
|
|
|
end
|
2012-02-03 10:59:04 +01:00
|
|
|
message = chatCommandMessage:trim()
|
2012-02-03 22:37:42 +01:00
|
|
|
chatCommandPrivateReady = true
|
2012-02-03 10:59:04 +01:00
|
|
|
end
|
|
|
|
end
|
2012-02-04 03:11:18 +01:00
|
|
|
|
2012-02-03 10:59:04 +01:00
|
|
|
message = message:gsub("^(%s*)(.*)","%2") -- remove space characters from message init
|
|
|
|
if #message == 0 then return end
|
|
|
|
|
2012-02-03 21:27:13 +01:00
|
|
|
-- add new command to history
|
|
|
|
currentMessageIndex = 0
|
2012-05-01 08:49:48 +02:00
|
|
|
if #messageHistory == 0 or messageHistory[#messageHistory] ~= originalMessage then
|
|
|
|
table.insert(messageHistory, originalMessage)
|
|
|
|
if #messageHistory > MAX_HISTORY then
|
|
|
|
table.remove(messageHistory, 1)
|
|
|
|
end
|
2012-02-03 21:27:13 +01:00
|
|
|
end
|
2012-02-04 03:11:18 +01:00
|
|
|
|
2012-01-14 06:54:20 +01:00
|
|
|
local speaktypedesc
|
2013-02-14 19:34:33 +01:00
|
|
|
if (channel or tab == defaultTab) and not chatCommandPrivateReady then
|
2012-08-07 01:43:14 +02:00
|
|
|
if tab == defaultTab then
|
2012-02-03 10:59:04 +01:00
|
|
|
speaktypedesc = chatCommandSayMode or SayModes[consolePanel:getChildById('sayModeButton').sayMode].speakTypeDesc
|
2012-07-24 07:30:08 +02:00
|
|
|
if speaktypedesc ~= 'say' then sayModeChange(2) end -- head back to say mode
|
2012-01-14 06:54:20 +01:00
|
|
|
else
|
2013-02-14 19:34:33 +01:00
|
|
|
speaktypedesc = chatCommandSayMode or 'channelYellow'
|
2012-01-14 02:37:15 +01:00
|
|
|
end
|
|
|
|
|
2013-02-14 19:34:33 +01:00
|
|
|
g_game.talkChannel(SpeakTypesSettings[speaktypedesc].speakType, channel, message)
|
2012-01-14 02:37:15 +01:00
|
|
|
return
|
|
|
|
else
|
2012-02-03 10:59:04 +01:00
|
|
|
local isPrivateCommand = false
|
2013-01-27 10:44:15 +01:00
|
|
|
local priv = true
|
|
|
|
local tabname = name
|
2012-02-03 22:37:42 +01:00
|
|
|
if chatCommandPrivateReady then
|
2012-02-03 10:59:04 +01:00
|
|
|
speaktypedesc = 'privatePlayerToPlayer'
|
|
|
|
name = chatCommandPrivate
|
|
|
|
isPrivateCommand = true
|
|
|
|
elseif tab.npcChat then
|
2012-02-03 05:32:39 +01:00
|
|
|
speaktypedesc = 'privatePlayerToNpc'
|
2013-01-27 10:44:15 +01:00
|
|
|
elseif tab == violationReportTab then
|
|
|
|
speaktypedesc = 'rvrContinue'
|
|
|
|
tabname = tr('Report Rule') .. '...'
|
|
|
|
elseif tab.violationChatName then
|
|
|
|
speaktypedesc = 'rvrAnswerTo'
|
|
|
|
name = tab.violationChatName
|
|
|
|
tabname = tab.violationChatName .. '\'...'
|
2012-01-14 06:54:20 +01:00
|
|
|
else
|
2012-02-03 05:32:39 +01:00
|
|
|
speaktypedesc = 'privatePlayerToPlayer'
|
2012-01-14 06:54:20 +01:00
|
|
|
end
|
2012-02-04 03:11:18 +01:00
|
|
|
|
2012-01-14 06:54:20 +01:00
|
|
|
|
2012-02-03 05:32:39 +01:00
|
|
|
local speaktype = SpeakTypesSettings[speaktypedesc]
|
2012-02-08 22:23:15 +01:00
|
|
|
local player = g_game.getLocalPlayer()
|
|
|
|
g_game.talkPrivate(speaktype.speakType, name, message)
|
2012-01-14 06:54:20 +01:00
|
|
|
|
2013-01-30 21:23:26 +01:00
|
|
|
message = applyMessagePrefixies(g_game.getCharacterName(), player:getLevel(), message)
|
2013-01-27 10:44:15 +01:00
|
|
|
addPrivateText(message, speaktype, tabname, isPrivateCommand, g_game.getCharacterName())
|
2012-01-13 00:47:31 +01:00
|
|
|
end
|
2012-01-08 23:32:55 +01:00
|
|
|
end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function sayModeChange(sayMode)
|
2012-02-03 10:59:04 +01:00
|
|
|
local buttom = consolePanel:getChildById('sayModeButton')
|
|
|
|
if sayMode == nil then
|
|
|
|
sayMode = buttom.sayMode + 1
|
|
|
|
end
|
2012-02-04 03:11:18 +01:00
|
|
|
|
2012-02-03 10:59:04 +01:00
|
|
|
if sayMode > #SayModes then sayMode = 1 end
|
|
|
|
|
|
|
|
buttom:setIcon(SayModes[sayMode].icon)
|
2012-02-04 03:11:18 +01:00
|
|
|
buttom.sayMode = sayMode
|
2012-02-03 10:59:04 +01:00
|
|
|
end
|
2012-04-24 13:20:14 +02:00
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
function getOwnPrivateTab()
|
2012-04-24 13:20:14 +02:00
|
|
|
if not ownPrivateName then return end
|
2012-07-24 07:30:08 +02:00
|
|
|
return getTab(ownPrivateName)
|
2012-04-24 13:20:14 +02:00
|
|
|
end
|
2012-06-11 10:17:52 +02:00
|
|
|
|
2012-07-27 01:36:51 +02:00
|
|
|
function setIgnoreNpcMessages(ignore)
|
2012-06-11 10:25:04 +02:00
|
|
|
ignoreNpcMessages = ignore
|
2012-07-12 18:45:22 +02:00
|
|
|
end
|
2012-07-24 07:30:08 +02:00
|
|
|
|
|
|
|
function navigateMessageHistory(step)
|
|
|
|
local numCommands = #messageHistory
|
|
|
|
if numCommands > 0 then
|
|
|
|
currentMessageIndex = math.min(math.max(currentMessageIndex + step, 0), numCommands)
|
|
|
|
if currentMessageIndex > 0 then
|
|
|
|
local command = messageHistory[numCommands - currentMessageIndex + 1]
|
2013-01-24 21:36:04 +01:00
|
|
|
setTextEditText(command)
|
2012-07-24 07:30:08 +02:00
|
|
|
else
|
|
|
|
consoleTextEdit:clearText()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function applyMessagePrefixies(name, level, message)
|
|
|
|
if name then
|
2013-01-18 23:39:11 +01:00
|
|
|
if modules.client_options.getOption('showLevelsInConsole') and level > 0 then
|
2012-07-24 07:30:08 +02:00
|
|
|
message = name .. ' [' .. level .. ']: ' .. message
|
|
|
|
else
|
|
|
|
message = name .. ': ' .. message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return message
|
|
|
|
end
|
|
|
|
|
2012-07-27 00:29:04 +02:00
|
|
|
function onTalk(name, level, mode, message, channelId, creaturePos)
|
2012-10-23 21:15:59 +02:00
|
|
|
if mode == MessageModes.GamemasterBroadcast then
|
|
|
|
modules.game_textmessage.displayBroadcastMessage(name .. ': ' .. message)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-07-27 00:29:04 +02:00
|
|
|
if ignoreNpcMessages and mode == MessageModes.NpcFrom then return end
|
2013-01-09 23:03:04 +01:00
|
|
|
|
|
|
|
speaktype = SpeakTypes[mode]
|
2013-01-27 10:44:15 +01:00
|
|
|
|
|
|
|
if not speaktype then
|
|
|
|
perror('unhandled onTalk message mode ' .. mode .. ': ' .. message)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2013-01-30 21:23:26 +01:00
|
|
|
if name ~= g_game.getCharacterName() then
|
2013-01-10 18:25:32 +01:00
|
|
|
if mode == MessageModes.Yell and isIgnoringYelling() then
|
|
|
|
return
|
|
|
|
elseif speaktype.private and isIgnoringPrivate() and mode ~= MessageModes.NpcFrom then
|
|
|
|
return
|
2013-01-19 19:02:22 +01:00
|
|
|
elseif isIgnored(name) then
|
2013-01-10 18:25:32 +01:00
|
|
|
return
|
|
|
|
end
|
2013-01-09 23:03:04 +01:00
|
|
|
end
|
2012-08-07 18:33:08 +02:00
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
if mode == MessageModes.RVRChannel then
|
|
|
|
channelId = violationsChannelId
|
|
|
|
end
|
|
|
|
|
2012-08-07 18:33:08 +02:00
|
|
|
if (mode == MessageModes.Say or mode == MessageModes.Whisper or mode == MessageModes.Yell or
|
|
|
|
mode == MessageModes.Spell or mode == MessageModes.MonsterSay or mode == MessageModes.MonsterYell or
|
|
|
|
mode == MessageModes.NpcFrom or mode == MessageModes.BarkLow or mode == MessageModes.BarkLoud) and
|
|
|
|
creaturePos then
|
2012-10-09 20:34:39 +02:00
|
|
|
-- Remove curly braces from screen message
|
|
|
|
local staticMessage = message
|
|
|
|
if mode == MessageModes.NpcFrom then
|
|
|
|
local highlightData = getHighlightedText(staticMessage)
|
|
|
|
if #highlightData > 0 then
|
|
|
|
for i = 1, #highlightData / 3 do
|
|
|
|
local dataBlock = { _start = highlightData[(i-1)*3+1], _end = highlightData[(i-1)*3+2], words = highlightData[(i-1)*3+3] }
|
|
|
|
staticMessage = staticMessage:gsub("{"..dataBlock.words.."}", dataBlock.words)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-10-23 21:15:59 +02:00
|
|
|
|
2012-08-07 18:33:08 +02:00
|
|
|
local staticText = StaticText.create()
|
2012-10-09 20:34:39 +02:00
|
|
|
staticText:addMessage(name, mode, staticMessage)
|
2012-08-07 18:33:08 +02:00
|
|
|
g_map.addThing(staticText, creaturePos, -1)
|
|
|
|
end
|
|
|
|
|
2012-10-05 00:50:18 +02:00
|
|
|
local defaultMessage = mode <= 3 and true or false
|
2012-07-27 00:29:04 +02:00
|
|
|
|
2012-07-30 14:29:13 +02:00
|
|
|
if speaktype == SpeakTypesSettings.none then return end
|
|
|
|
|
2012-07-24 07:30:08 +02:00
|
|
|
if speaktype.hideInConsole then return end
|
|
|
|
|
|
|
|
local composedMessage = applyMessagePrefixies(name, level, message)
|
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
if mode == MessageModes.RVRAnswer then
|
|
|
|
violationReportTab.locked = false
|
|
|
|
addTabText(composedMessage, speaktype, violationReportTab, name)
|
|
|
|
elseif mode == MessageModes.RVRContinue then
|
|
|
|
addText(composedMessage, speaktype, name .. '\'...', name)
|
|
|
|
elseif speaktype.private then
|
2012-07-24 07:30:08 +02:00
|
|
|
addPrivateText(composedMessage, speaktype, name, false, name)
|
2013-01-18 23:39:11 +01:00
|
|
|
if modules.client_options.getOption('showPrivateMessagesOnScreen') and speaktype ~= SpeakTypesSettings.privateNpcToPlayer then
|
2012-07-30 14:29:13 +02:00
|
|
|
modules.game_textmessage.displayPrivateMessage(name .. ':\n' .. message)
|
|
|
|
end
|
2012-07-24 07:30:08 +02:00
|
|
|
else
|
|
|
|
local channel = tr('Default')
|
|
|
|
if not defaultMessage then
|
|
|
|
channel = channels[channelId]
|
|
|
|
end
|
|
|
|
|
|
|
|
if channel then
|
|
|
|
addText(composedMessage, speaktype, channel, name)
|
2012-12-08 19:08:54 +01:00
|
|
|
else
|
2012-07-24 07:30:08 +02:00
|
|
|
-- server sent a message on a channel that is not open
|
|
|
|
pwarning('message in channel id ' .. channelId .. ' which is unknown, this is a server bug, relogin if you want to see messages in this channel')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:41:59 +02:00
|
|
|
function onOpenChannel(channelId, channelName)
|
2012-07-24 07:30:08 +02:00
|
|
|
addChannel(channelName, channelId)
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:41:59 +02:00
|
|
|
function onOpenPrivateChannel(receiver)
|
2012-07-24 07:30:08 +02:00
|
|
|
addPrivateChannel(receiver)
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:41:59 +02:00
|
|
|
function onOpenOwnPrivateChannel(channelId, channelName)
|
2012-07-24 07:30:08 +02:00
|
|
|
local privateTab = getTab(channelName)
|
|
|
|
if privateTab == nil then
|
|
|
|
addChannel(channelName, channelId)
|
|
|
|
end
|
|
|
|
ownPrivateName = channelName
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:41:59 +02:00
|
|
|
function onCloseChannel(channelId)
|
2012-07-24 07:30:08 +02:00
|
|
|
local channel = channels[channelId]
|
|
|
|
if channel then
|
|
|
|
local tab = getTab(channel)
|
|
|
|
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
|
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
function processViolation(name, text)
|
|
|
|
local tabname = name .. '\'...'
|
|
|
|
local tab = addTab(tabname, true)
|
|
|
|
channels[tabname] = tabname
|
|
|
|
tab.violationChatName = name
|
|
|
|
g_game.openRuleViolation(name)
|
2013-02-04 19:33:34 +01:00
|
|
|
addTabText(text, SpeakTypesSettings.say, tab, name)
|
2013-01-27 10:44:15 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function onRuleViolationChannel(channelId)
|
|
|
|
violationsChannelId = channelId
|
|
|
|
local tab = addChannel(tr('Rule Violations'), channelId)
|
|
|
|
tab.violations = true
|
|
|
|
end
|
|
|
|
|
|
|
|
function onRuleViolationRemove(name)
|
|
|
|
local tab = getRuleViolationsTab()
|
|
|
|
if not tab then return end
|
|
|
|
removeTabLabelByName(tab, name)
|
|
|
|
end
|
|
|
|
|
|
|
|
function onRuleViolationCancel(name)
|
|
|
|
local tab = getTab(name .. '\'...')
|
|
|
|
if not tab then return end
|
|
|
|
addTabText(tr('%s has finished the request', name) .. '.', SpeakTypesSettings.privateRed, tab)
|
|
|
|
tab.locked = true
|
|
|
|
end
|
|
|
|
|
|
|
|
function onRuleViolationLock()
|
|
|
|
if not violationReportTab then return end
|
|
|
|
addTabText(tr('Your request has been closed') .. '.', SpeakTypesSettings.privateRed, violationReportTab)
|
|
|
|
violationReportTab.locked = true
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:41:59 +02:00
|
|
|
function doChannelListSubmit()
|
2012-07-24 07:30:08 +02:00
|
|
|
local channelListPanel = channelsWindow:getChildById('channelList')
|
|
|
|
local openPrivateChannelWith = channelsWindow:getChildById('openPrivateChannelWith'):getText()
|
|
|
|
if openPrivateChannelWith ~= '' then
|
2013-01-30 21:23:26 +01:00
|
|
|
if openPrivateChannelWith:lower() ~= g_game.getCharacterName():lower() then
|
2013-01-09 23:03:04 +01:00
|
|
|
g_game.openPrivateChannel(openPrivateChannelWith)
|
|
|
|
else
|
|
|
|
modules.game_textmessage.displayFailureMessage('You cannot create a private chat channel with yourself.')
|
|
|
|
end
|
2012-07-24 07:30:08 +02:00
|
|
|
else
|
|
|
|
local selectedChannelLabel = channelListPanel:getFocusedChild()
|
|
|
|
if not selectedChannelLabel then return end
|
|
|
|
if selectedChannelLabel.channelId == 0xFFFF then
|
|
|
|
g_game.openOwnChannel()
|
|
|
|
else
|
|
|
|
g_game.joinChannel(selectedChannelLabel.channelId)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
channelsWindow:destroy()
|
|
|
|
end
|
|
|
|
|
2012-07-24 07:41:59 +02:00
|
|
|
function onChannelList(channelList)
|
2012-07-24 07:30:08 +02:00
|
|
|
if channelsWindow then channelsWindow:destroy() end
|
2013-01-18 23:39:11 +01:00
|
|
|
channelsWindow = g_ui.displayUI('channelswindow')
|
2012-07-24 07:30:08 +02:00
|
|
|
local channelListPanel = channelsWindow:getChildById('channelList')
|
|
|
|
channelsWindow.onEnter = doChannelListSubmit
|
|
|
|
channelsWindow.onDestroy = function() channelsWindow = nil end
|
|
|
|
g_keyboard.bindKeyPress('Down', function() channelListPanel:focusNextChild(KeyboardFocusReason) end, channelsWindow)
|
|
|
|
g_keyboard.bindKeyPress('Up', function() channelListPanel:focusPreviousChild(KeyboardFocusReason) end, channelsWindow)
|
|
|
|
|
|
|
|
for k,v in pairs(channelList) do
|
|
|
|
local channelId = v[1]
|
|
|
|
local channelName = v[2]
|
|
|
|
|
|
|
|
if #channelName > 0 then
|
|
|
|
local label = g_ui.createWidget('ChannelListLabel', channelListPanel)
|
|
|
|
label.channelId = channelId
|
|
|
|
label:setText(channelName)
|
|
|
|
|
|
|
|
label:setPhantom(false)
|
|
|
|
label.onDoubleClick = doChannelListSubmit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-09 23:03:04 +01:00
|
|
|
function loadIgnoreSettings()
|
|
|
|
local ignoreNode = g_settings.getNode('IgnorePlayers')
|
|
|
|
if ignoreNode then
|
|
|
|
for i = 1, #ignoreNode do
|
|
|
|
table.insert(ignoreSettings.players, ignoreNode[i])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
ignoreSettings.privateMessages = g_settings.getBoolean('IgnorePrivateMessages')
|
|
|
|
ignoreSettings.yelling = g_settings.getBoolean('IgnoreYelling')
|
|
|
|
end
|
|
|
|
|
|
|
|
function saveIgnoreSettings()
|
|
|
|
local tmpSettings = {}
|
|
|
|
for i = 1, #ignoreSettings.players do
|
|
|
|
table.insert(tmpSettings, ignoreSettings.players[i])
|
|
|
|
end
|
|
|
|
g_settings.set('IgnorePrivateMessages', ignoreSettings.privateMessages)
|
|
|
|
g_settings.set('IgnoreYelling', ignoreSettings.yelling)
|
|
|
|
g_settings.setNode('IgnorePlayers', tmpSettings)
|
|
|
|
end
|
|
|
|
|
|
|
|
function isIgnored(name)
|
2013-01-19 19:02:22 +01:00
|
|
|
return table.find(ignoreSettings.players, name, true)
|
2013-01-10 04:20:26 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function addIgnoredPlayer(name)
|
|
|
|
if not isIgnored(name) then
|
|
|
|
table.insert(ignoreSettings.players, name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function removeIgnoredPlayer(name)
|
|
|
|
table.removevalue(ignoreSettings.players, name)
|
2013-01-09 23:03:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function isIgnoringPrivate()
|
2013-01-10 04:20:26 +01:00
|
|
|
return ignoreSettings.privateMessages
|
2013-01-09 23:03:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function isIgnoringYelling()
|
2013-01-10 04:20:26 +01:00
|
|
|
return ignoreSettings.yelling
|
2013-01-09 23:03:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function onClickIgnoreButton()
|
|
|
|
if ignoreWindow then return end
|
2013-01-18 23:39:11 +01:00
|
|
|
ignoreWindow = g_ui.displayUI('ignorewindow')
|
2013-01-09 23:03:04 +01:00
|
|
|
local ignoreListPanel = ignoreWindow:getChildById('ignoreList')
|
|
|
|
ignoreWindow.onDestroy = function() ignoreWindow = nil end
|
|
|
|
|
|
|
|
local removeButton = ignoreWindow:getChildById('buttonRemove')
|
|
|
|
removeButton:disable()
|
|
|
|
ignoreListPanel.onChildFocusChange = function() removeButton:enable() end
|
|
|
|
removeButton.onClick = function()
|
2013-02-27 22:22:46 +01:00
|
|
|
local selection = ignoreListPanel:getFocusedChild()
|
|
|
|
if selection then
|
|
|
|
ignoreListPanel:removeChild(selection)
|
|
|
|
selection:destroy()
|
|
|
|
end
|
|
|
|
if ignoreListPanel:getChildCount() == 0 then
|
|
|
|
removeButton:disable()
|
|
|
|
end
|
|
|
|
end
|
2013-01-09 23:03:04 +01:00
|
|
|
|
|
|
|
local newlyIgnoredPlayers = {}
|
|
|
|
local addName = ignoreWindow:getChildById('ignoreNameEdit')
|
|
|
|
local addButton = ignoreWindow:getChildById('buttonAdd')
|
|
|
|
local addFunction = function()
|
|
|
|
if addName:getText() == '' then return end
|
|
|
|
if table.find(ignoreSettings.players, addName:getText()) then return end
|
|
|
|
if table.find(newlyIgnoredPlayers, addName:getText()) then return end
|
|
|
|
local label = g_ui.createWidget('IgnoreListLabel', ignoreListPanel)
|
|
|
|
label:setText(addName:getText())
|
|
|
|
table.insert(newlyIgnoredPlayers, addName:getText())
|
|
|
|
label:setPhantom(false)
|
|
|
|
addName:setText('')
|
|
|
|
end
|
|
|
|
addButton.onClick = addFunction
|
|
|
|
ignoreWindow.onEnter = addFunction
|
|
|
|
|
|
|
|
local ignorePrivateMessageBox = ignoreWindow:getChildById('checkboxIgnorePrivateMessages')
|
|
|
|
ignorePrivateMessageBox:setChecked(ignoreSettings.privateMessages)
|
|
|
|
local ignoreYellingBox = ignoreWindow:getChildById('checkboxIgnoreYelling')
|
|
|
|
ignoreYellingBox:setChecked(ignoreSettings.yelling)
|
|
|
|
|
|
|
|
local saveButton = ignoreWindow:getChildById('buttonSave')
|
|
|
|
saveButton.onClick = function()
|
|
|
|
ignoreSettings.players = {}
|
|
|
|
for i = 1, ignoreListPanel:getChildCount() do
|
2013-01-10 18:25:32 +01:00
|
|
|
addIgnoredPlayer(ignoreListPanel:getChildByIndex(i):getText())
|
2013-01-10 04:20:26 +01:00
|
|
|
--table.insert(ignoreSettings.players, ignoreListPanel:getChildByIndex(i):getText())
|
2013-01-09 23:03:04 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
ignoreSettings.yelling = ignoreYellingBox:isChecked()
|
|
|
|
ignoreSettings.privateMessages = ignorePrivateMessageBox:isChecked()
|
|
|
|
ignoreWindow:destroy()
|
|
|
|
end
|
|
|
|
|
|
|
|
for _, name in pairs(ignoreSettings.players) do
|
|
|
|
local label = g_ui.createWidget('IgnoreListLabel', ignoreListPanel)
|
|
|
|
label:setText(name)
|
|
|
|
label:setPhantom(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
function online()
|
|
|
|
if g_game.getProtocolVersion() < 862 then
|
|
|
|
g_keyboard.bindKeyDown('Ctrl+R', openPlayerReportRuleViolationWindow)
|
|
|
|
end
|
2012-07-24 07:30:08 +02:00
|
|
|
-- open last channels
|
2012-07-31 05:53:15 +02:00
|
|
|
local lastChannelsOpen = g_settings.getNode('lastChannelsOpen')
|
2012-07-31 07:38:22 +02:00
|
|
|
if lastChannelsOpen then
|
2013-01-30 21:23:26 +01:00
|
|
|
local savedChannels = lastChannelsOpen[g_game.getCharacterName()]
|
2012-07-31 07:38:22 +02:00
|
|
|
if savedChannels then
|
|
|
|
for channelName, channelId in pairs(savedChannels) do
|
|
|
|
channelId = tonumber(channelId)
|
2012-12-08 19:08:54 +01:00
|
|
|
if channelId ~= -1 and channelId < 100 then
|
2012-07-31 07:38:22 +02:00
|
|
|
if not table.find(channels, channelId) then
|
|
|
|
g_game.joinChannel(channelId)
|
2013-02-04 19:33:34 +01:00
|
|
|
table.insert(ignoredChannels, channelId)
|
2012-07-31 07:38:22 +02:00
|
|
|
end
|
2012-07-24 07:30:08 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-02-04 19:33:34 +01:00
|
|
|
scheduleEvent(function() ignoredChannels = {} end, 3000)
|
2012-07-24 07:30:08 +02:00
|
|
|
end
|
|
|
|
|
2013-01-27 10:44:15 +01:00
|
|
|
function offline()
|
|
|
|
if g_game.getProtocolVersion() < 862 then
|
|
|
|
g_keyboard.unbindKeyDown('Ctrl+R')
|
|
|
|
end
|
|
|
|
clear()
|
|
|
|
end
|