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() menu:addSeparator()
local creatureName = creatureThing:getName() local creatureName = creatureThing:getName()
menu:addOption('Message to ' .. creatureName, function() g_game.openPrivateChannel(creatureName) end) 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) menu:addOption('Add to VIP list', function() g_game.addVip(creatureName) end)
local localPlayerShield = localPlayer:asCreature():getShield() local localPlayerShield = localPlayer:asCreature():getShield()

View File

@ -52,6 +52,7 @@ local currentMessageIndex = 0
local MaxHistory = 1000 local MaxHistory = 1000
local channelsWindow local channelsWindow
local MAX_LINES = 100 local MAX_LINES = 100
local ownPrivateName
-- private functions -- private functions
local function navigateMessageHistory(step) local function navigateMessageHistory(step)
@ -108,11 +109,12 @@ local function onOpenChannel(channelId, channelName)
Console.addChannel(channelName, channelId) Console.addChannel(channelName, channelId)
end end
local function onOpenPrivateChannel(receiver) local function onOpenPrivateChannel(channelId, channelName)
local privateTab = Console.getTab(receiver) local privateTab = Console.getTab(channelName)
if privateTab == nil then if privateTab == nil then
Console.addTab(receiver, true) Console.addChannel(channelName, channelId, true)
end end
ownPrivateName = channelName
end end
local function onCloseChannel(channelId) local function onCloseChannel(channelId)
@ -121,7 +123,7 @@ local function onCloseChannel(channelId)
local tab = Console.getTab(channel) local tab = Console.getTab(channel)
if tab then if tab then
consoleTabBar:removeTab(tab) consoleTabBar:removeTab(tab)
end end
end end
end end
@ -133,7 +135,11 @@ local function doChannelListSubmit()
else else
local selectedChannelLabel = channelListPanel:getFocusedChild() local selectedChannelLabel = channelListPanel:getFocusedChild()
if not selectedChannelLabel then return end 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 end
channelsWindow:destroy() channelsWindow:destroy()
@ -169,7 +175,7 @@ function Console.init()
connect(g_game, { onCreatureSpeak = onCreatureSpeak, connect(g_game, { onCreatureSpeak = onCreatureSpeak,
onChannelList = onChannelList, onChannelList = onChannelList,
onOpenChannel = onOpenChannel, onOpenChannel = onOpenChannel,
onOpenPrivateChannel = onOpenPrivateChannel, onOpenOwnPrivateChannel = onOpenPrivateChannel,
onCloseChannel = onCloseChannel, onCloseChannel = onCloseChannel,
onGameEnd = Console.clear }) onGameEnd = Console.clear })
@ -203,7 +209,7 @@ function Console.terminate()
disconnect(g_game, { onCreatureSpeak = onCreatureSpeak, disconnect(g_game, { onCreatureSpeak = onCreatureSpeak,
onChannelList = onChannelList, onChannelList = onChannelList,
onOpenChannel = onOpenChannel, onOpenChannel = onOpenChannel,
onOpenPrivateChannel = onOpenPrivateChannel, onOpenOwnPrivateChannel = onOpenPrivateChannel,
onCloseChannel = onCloseChannel, onCloseChannel = onCloseChannel,
onGameEnd = Console.clear }) onGameEnd = Console.clear })
@ -229,6 +235,8 @@ function Console.terminate()
consoleTabBar = nil consoleTabBar = nil
Console = nil Console = nil
ownPrivateName = nil
end end
function Console.clear() function Console.clear()
@ -447,3 +455,8 @@ function Console.sayModeChange(sayMode)
buttom:setIcon(SayModes[sayMode].icon) buttom:setIcon(SayModes[sayMode].icon)
buttom.sayMode = sayMode buttom.sayMode = sayMode
end end
function Console.getOwnPrivateTab()
if not ownPrivateName then return end
return Console.getTab(ownPrivateName)
end