2011-11-03 21:54:53 +01:00
|
|
|
Chat = {}
|
|
|
|
|
|
|
|
-- private variables
|
|
|
|
local chatPanel
|
2011-11-04 00:34:32 +01:00
|
|
|
local chatBuffer
|
|
|
|
|
|
|
|
-- private functions
|
|
|
|
local function onCreatureSpeak(name, level, msgtype, message)
|
|
|
|
style = 'ChatLabel'
|
|
|
|
if name and level > 0 then
|
|
|
|
message = name .. ' [' .. level .. ']: ' .. message
|
|
|
|
style = 'YellowChatLabel'
|
|
|
|
end
|
|
|
|
|
|
|
|
local label = UILabel.create()
|
|
|
|
label:setStyle(style)
|
|
|
|
label:setText(message)
|
|
|
|
chatBuffer:addChild(label)
|
|
|
|
end
|
2011-11-03 21:54:53 +01:00
|
|
|
|
|
|
|
-- public functions
|
|
|
|
function Chat.create()
|
|
|
|
chatPanel = loadUI("/chat/chat.otui", Game.gameBottomPanel)
|
2011-11-04 00:34:32 +01:00
|
|
|
chatBuffer = chatPanel:getChildById('chatBuffer')
|
2011-11-03 21:54:53 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function Chat.destroy()
|
|
|
|
chatPanel:destroy()
|
|
|
|
chatPanel = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
-- hooked events
|
|
|
|
|
|
|
|
connect(Game, { onLogin = Chat.create,
|
2011-11-04 00:34:32 +01:00
|
|
|
onLogout = Chat.destroy,
|
|
|
|
onCreatureSpeak = onCreatureSpeak})
|