notificate the server when leaving a channel, focus npc channel when talking to a npc
This commit is contained in:
parent
2b206a74a9
commit
91a7ed8371
|
@ -112,9 +112,9 @@ end
|
||||||
function Console.addTab(name, focus)
|
function Console.addTab(name, focus)
|
||||||
local tab = consoleTabBar:addTab(name)
|
local tab = consoleTabBar:addTab(name)
|
||||||
if focus then
|
if focus then
|
||||||
consoleTabBar:selectTab(tab)
|
consoleTabBar:selectTab(tab)
|
||||||
else
|
else
|
||||||
consoleTabBar:blinkTab(tab)
|
consoleTabBar:blinkTab(tab)
|
||||||
end
|
end
|
||||||
return tab
|
return tab
|
||||||
end
|
end
|
||||||
|
@ -132,6 +132,13 @@ function Console.removeCurrentTab()
|
||||||
if tab:getText() == "Default" or tab:getText() == "Server Log" then return end
|
if tab:getText() == "Default" or tab:getText() == "Server Log" then return end
|
||||||
|
|
||||||
consoleTabBar:removeTab(tab)
|
consoleTabBar:removeTab(tab)
|
||||||
|
|
||||||
|
-- notificate the server that we are leaving the channel
|
||||||
|
if tab.channelId then
|
||||||
|
Game.leaveChannel(tab.channelId)
|
||||||
|
elseif tab:getText() == "NPCs" then
|
||||||
|
Game.closeNpcChannel()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Console.getTab(name)
|
function Console.getTab(name)
|
||||||
|
@ -150,8 +157,10 @@ function Console.addChannel(name, id)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Console.addPrivateText(text, speaktype, name, isPrivateCommand)
|
function Console.addPrivateText(text, speaktype, name, isPrivateCommand)
|
||||||
|
local focus = false
|
||||||
if speaktype.speakType == SpeakPrivateNpcToPlayer then
|
if speaktype.speakType == SpeakPrivateNpcToPlayer then
|
||||||
name = 'NPCs'
|
name = 'NPCs'
|
||||||
|
focus = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local privateTab = Console.getTab(name)
|
local privateTab = Console.getTab(name)
|
||||||
|
@ -159,9 +168,11 @@ function Console.addPrivateText(text, speaktype, name, isPrivateCommand)
|
||||||
if Options.showPrivateMessagesInConsole or (isPrivateCommand and not privateTab) then
|
if Options.showPrivateMessagesInConsole or (isPrivateCommand and not privateTab) then
|
||||||
privateTab = Console.getTab('Default')
|
privateTab = Console.getTab('Default')
|
||||||
else
|
else
|
||||||
privateTab = Console.addTab(name, false)
|
privateTab = Console.addTab(name, focus)
|
||||||
end
|
end
|
||||||
privateTab.npcChat = speaktype.npcChat
|
privateTab.npcChat = speaktype.npcChat
|
||||||
|
elseif focus then
|
||||||
|
consoleTabBar:selectTab(privateTab)
|
||||||
end
|
end
|
||||||
Console.addTabText(text, speaktype, privateTab)
|
Console.addTabText(text, speaktype, privateTab)
|
||||||
end
|
end
|
||||||
|
@ -295,7 +306,14 @@ local function onCreatureSpeak(name, level, speaktype, message, channelId, creat
|
||||||
if speaktype.private then
|
if speaktype.private then
|
||||||
Console.addPrivateText(message, speaktype, name, false)
|
Console.addPrivateText(message, speaktype, name, false)
|
||||||
else
|
else
|
||||||
Console.addText(message, speaktype, channels[channelId])
|
local channel = channels[channelId]
|
||||||
|
|
||||||
|
if channel then
|
||||||
|
Console.addText(message, speaktype, channel)
|
||||||
|
else
|
||||||
|
-- server sent a message on a channel that we are not aware of, must leave it
|
||||||
|
Game.leaveChannel(channelId)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue