reorganize modules

This commit is contained in:
Eduardo Bart
2011-12-05 16:27:07 -02:00
parent ffeb34e0e7
commit cf0aab6d4d
90 changed files with 186 additions and 181 deletions

View File

@@ -0,0 +1,36 @@
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 = UI.display('chat.otui', { parent = Game.gameBottomPanel } )
chatBuffer = chatPanel:getChildById('chatBuffer')
end
function Chat.destroy()
chatPanel:destroy()
chatPanel = nil
end
-- hooked events
connect(Game, { onLogin = Chat.create,
onLogout = Chat.destroy,
onCreatureSpeak = onCreatureSpeak})

View File

@@ -0,0 +1,10 @@
Module
name: game_chat
description: Manage chat window
author: OTClient team
website: https://github.com/edubart/otclient
onLoad: |
require 'chat'
return true

View File

@@ -0,0 +1,35 @@
ChatLabel < UILabel
font: verdana-11px-antialised
height: 14
YellowChatLabel < ChatLabel
color: yellow
Panel
id: chatPanel
anchors.fill: parent
Panel
id: chatBuffer
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: chatLineEdit.top
margin-right: 6
margin-left: 6
margin-bottom: 2
margin-top: 6
layout:
type: verticalBox
align-bottom: true
focusable: false
LineEdit
id: chatLineEdit
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
margin-right: 6
margin-left: 6
margin-bottom: 6
always-active: true