mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 19:44:54 +02:00
add chat buffer
This commit is contained in:
@@ -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})
|
@@ -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
|
||||
|
Reference in New Issue
Block a user