parent
23ebcd9048
commit
fdc9087870
@ -1,51 +0,0 @@
|
||||
Chat = {}
|
||||
|
||||
-- private variables
|
||||
--[[
|
||||
local SpeakTypes = {
|
||||
say = { color = },
|
||||
whisper = { color = },
|
||||
yell,
|
||||
monsterSay,
|
||||
npcToPlayer,
|
||||
cgannelYellow,
|
||||
channelWhite,
|
||||
channelRed,
|
||||
channelOrange,
|
||||
private,
|
||||
playerToNpc,
|
||||
broadcast,
|
||||
privateRed
|
||||
}
|
||||
]]--
|
||||
|
||||
local chatPanel
|
||||
local chatBuffer
|
||||
|
||||
-- public functions
|
||||
function Chat.create()
|
||||
chatPanel = displayUI('chat.otui', { parent = Game.gameBottomPanel } )
|
||||
chatBuffer = chatPanel:getChildById('chatBuffer')
|
||||
end
|
||||
|
||||
function Chat.destroy()
|
||||
chatPanel:destroy()
|
||||
chatPanel = nil
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
local function onCreatureSpeak(name, level, msgtype, message)
|
||||
style = 'ChatLabel'
|
||||
if name and level > 0 then
|
||||
message = name .. ' [' .. level .. ']: ' .. message
|
||||
style = 'YellowChatLabel'
|
||||
end
|
||||
|
||||
local label = createWidget(style)
|
||||
label:setText(message)
|
||||
chatBuffer:addChild(label)
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = Chat.create,
|
||||
onLogout = Chat.destroy,
|
||||
onCreatureSpeak = onCreatureSpeak})
|
@ -0,0 +1,60 @@
|
||||
Console = {}
|
||||
|
||||
-- private variables
|
||||
local SpeakTypes = {
|
||||
say = { color = '#FFFF00' },
|
||||
whisper = { color = '#FFFF00' },
|
||||
yell = { color = '#FFFF00' },
|
||||
monsterSay = { color = '#FE6500' },
|
||||
npcToPlayer = { color = '#5FF7F7' },
|
||||
channelYellow = { color = '#FFFF00' },
|
||||
channelWhite = { color = '#FFFFFF' },
|
||||
channelRed = { color = '#F55E5E' },
|
||||
channelOrange = { color = '#FE6500' },
|
||||
private = { color = '#FFFF00' },
|
||||
playerToNpc = { color = '#9F9DFD' },
|
||||
broadcast = { color = '#F55E5E' },
|
||||
privateRed = { color = '#F55E5E' }
|
||||
}
|
||||
|
||||
local consolePanel
|
||||
local consoleBuffer
|
||||
|
||||
-- public functions
|
||||
function Console.create()
|
||||
consolePanel = displayUI('console.otui', { parent = Game.gameBottomPanel } )
|
||||
consoleBuffer = consolePanel:getChildById('consoleBuffer')
|
||||
end
|
||||
|
||||
function Console.destroy()
|
||||
consolePanel:destroy()
|
||||
consolePanel = nil
|
||||
end
|
||||
|
||||
function Console.addText(text, color)
|
||||
color = color or 'white'
|
||||
|
||||
local label = createWidget('ConsoleLabel', consoleBuffer)
|
||||
label:setText(text)
|
||||
label:setForegroundColor(color)
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
local function onCreatureSpeak(name, level, speaktypedesc, message)
|
||||
speaktype = SpeakTypes[speaktypedesc]
|
||||
if speaktype == nil then return end
|
||||
|
||||
if name then
|
||||
if Options.showLevelInConsole and level > 0 then
|
||||
message = name .. ' [' .. level .. ']: ' .. message
|
||||
else
|
||||
message = name .. ': ' .. message
|
||||
end
|
||||
end
|
||||
|
||||
Console.addText(message, speaktype.color)
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = Console.create,
|
||||
onLogout = Console.destroy,
|
||||
onCreatureSpeak = onCreatureSpeak})
|
@ -1,7 +1,7 @@
|
||||
Module
|
||||
name: game_chat
|
||||
name: game_console
|
||||
description: Manage chat window
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
onLoad: |
|
||||
require 'chat'
|
||||
require 'console'
|
Loading…
Reference in new issue