implementing private chat channel basics
This commit is contained in:
parent
6d6534f57e
commit
50145ec6b8
|
@ -202,6 +202,10 @@ function GameInterface.createThingMenu(menuPosition, lookThing, useThing, creatu
|
|||
menu:addSeparator()
|
||||
local creatureName = creatureThing:getName()
|
||||
menu:addOption('Message to ' .. creatureName, function() g_game.openPrivateChannel(creatureName) end)
|
||||
if Console.getOwnPrivateTab() then
|
||||
menu:addOption('Invite to private chat', function() g_game.inviteToOwnChannel(creatureName) end)
|
||||
menu:addOption('Exclude from private chat', function() g_game.excludeFromOwnChannel(creatureName) end) -- [TODO] must be removed after message's popup labels been implemented
|
||||
end
|
||||
menu:addOption('Add to VIP list', function() g_game.addVip(creatureName) end)
|
||||
|
||||
local localPlayerShield = localPlayer:asCreature():getShield()
|
||||
|
|
|
@ -52,6 +52,7 @@ local currentMessageIndex = 0
|
|||
local MaxHistory = 1000
|
||||
local channelsWindow
|
||||
local MAX_LINES = 100
|
||||
local ownPrivateName
|
||||
|
||||
-- private functions
|
||||
local function navigateMessageHistory(step)
|
||||
|
@ -108,11 +109,12 @@ local function onOpenChannel(channelId, channelName)
|
|||
Console.addChannel(channelName, channelId)
|
||||
end
|
||||
|
||||
local function onOpenPrivateChannel(receiver)
|
||||
local privateTab = Console.getTab(receiver)
|
||||
local function onOpenPrivateChannel(channelId, channelName)
|
||||
local privateTab = Console.getTab(channelName)
|
||||
if privateTab == nil then
|
||||
Console.addTab(receiver, true)
|
||||
Console.addChannel(channelName, channelId, true)
|
||||
end
|
||||
ownPrivateName = channelName
|
||||
end
|
||||
|
||||
local function onCloseChannel(channelId)
|
||||
|
@ -133,7 +135,11 @@ local function doChannelListSubmit()
|
|||
else
|
||||
local selectedChannelLabel = channelListPanel:getFocusedChild()
|
||||
if not selectedChannelLabel then return end
|
||||
g_game.joinChannel(selectedChannelLabel.channelId)
|
||||
if selectedChannelLabel.channelId == 0xFFFF then
|
||||
g_game.openOwnChannel()
|
||||
else
|
||||
g_game.joinChannel(selectedChannelLabel.channelId)
|
||||
end
|
||||
end
|
||||
|
||||
channelsWindow:destroy()
|
||||
|
@ -169,7 +175,7 @@ function Console.init()
|
|||
connect(g_game, { onCreatureSpeak = onCreatureSpeak,
|
||||
onChannelList = onChannelList,
|
||||
onOpenChannel = onOpenChannel,
|
||||
onOpenPrivateChannel = onOpenPrivateChannel,
|
||||
onOpenOwnPrivateChannel = onOpenPrivateChannel,
|
||||
onCloseChannel = onCloseChannel,
|
||||
onGameEnd = Console.clear })
|
||||
|
||||
|
@ -203,7 +209,7 @@ function Console.terminate()
|
|||
disconnect(g_game, { onCreatureSpeak = onCreatureSpeak,
|
||||
onChannelList = onChannelList,
|
||||
onOpenChannel = onOpenChannel,
|
||||
onOpenPrivateChannel = onOpenPrivateChannel,
|
||||
onOpenOwnPrivateChannel = onOpenPrivateChannel,
|
||||
onCloseChannel = onCloseChannel,
|
||||
onGameEnd = Console.clear })
|
||||
|
||||
|
@ -229,6 +235,8 @@ function Console.terminate()
|
|||
consoleTabBar = nil
|
||||
|
||||
Console = nil
|
||||
|
||||
ownPrivateName = nil
|
||||
end
|
||||
|
||||
function Console.clear()
|
||||
|
@ -447,3 +455,8 @@ function Console.sayModeChange(sayMode)
|
|||
buttom:setIcon(SayModes[sayMode].icon)
|
||||
buttom.sayMode = sayMode
|
||||
end
|
||||
|
||||
function Console.getOwnPrivateTab()
|
||||
if not ownPrivateName then return end
|
||||
return Console.getTab(ownPrivateName)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue