implementing private chat channel basics

This commit is contained in:
AndreFaramir 2012-04-24 08:20:14 -03:00
parent 6d6534f57e
commit 50145ec6b8
2 changed files with 24 additions and 7 deletions

View File

@ -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()

View File

@ -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,8 +135,12 @@ local function doChannelListSubmit()
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
@ -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