add chat buffer

This commit is contained in:
Eduardo Bart
2011-11-03 21:34:32 -02:00
parent 6aadf896da
commit 39c62942cf
12 changed files with 81 additions and 22 deletions

View File

@@ -2,10 +2,26 @@ Chat = {}
-- private variables
local chatPanel
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
-- public functions
function Chat.create()
chatPanel = loadUI("/chat/chat.otui", Game.gameBottomPanel)
chatBuffer = chatPanel:getChildById('chatBuffer')
end
function Chat.destroy()
@@ -16,4 +32,5 @@ end
-- hooked events
connect(Game, { onLogin = Chat.create,
onLogout = Chat.destroy })
onLogout = Chat.destroy,
onCreatureSpeak = onCreatureSpeak})

View File

@@ -1,6 +1,9 @@
ChatLabel < UILabel
font: verdana-11px-monochrome
height: 16
font: verdana-11px-antialised
height: 14
YellowChatLabel < ChatLabel
color: yellow
Panel
id: chatPanel
@@ -11,12 +14,14 @@ Panel
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: next.top
anchors.bottom: chatLineEdit.top
margin.right: 6
margin.left: 6
margin.bottom: 2
margin.top: 6
layout: verticalBox
layout:
type: verticalBox
align bottom: true
focusable: false
LineEdit

View File

@@ -13,7 +13,7 @@ UIWidget
InterfacePanel2
id: bottomPanel
height: 140
height: 144
anchors.left: parent.left
anchors.right: rightPanel.left
anchors.bottom: parent.bottom

View File

@@ -40,7 +40,7 @@ function Skills.destroy()
end
-- hooked events
function Game.setSkill(id, level, percent)
function Game.onSkillUpdate(id, level, percent)
local skillPanel = skillWindow:getChildById('skillPanel')
local levelLabel = skillPanel:getChildById('skillLevelId' .. (id + 1))

View File

@@ -10,5 +10,3 @@ Module
onLoad: |
require 'skills'
return true