mirror of
https://github.com/edubart/otclient.git
synced 2025-12-01 07:36:49 +01:00
reorganize modules
This commit is contained in:
36
modules/game_chat/chat.lua
Normal file
36
modules/game_chat/chat.lua
Normal 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})
|
||||
Reference in New Issue
Block a user