implement chat colors, rework on UI layout update system

This commit is contained in:
Eduardo Bart
2012-01-08 20:32:55 -02:00
parent 23ebcd9048
commit fdc9087870
23 changed files with 205 additions and 136 deletions

View File

@@ -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})

View File

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

View File

@@ -0,0 +1,33 @@
ConsoleLabel < UILabel
font: verdana-11px-antialised
height: 14
color: yellow
Panel
id: consolePanel
anchors.fill: parent
Panel
id: consoleBuffer
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: consoleLineEdit.top
margin-right: 6
margin-left: 6
margin-bottom: 2
margin-top: 6
layout:
type: verticalBox
align-bottom: true
focusable: false
LineEdit
id: consoleLineEdit
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
margin-right: 6
margin-left: 6
margin-bottom: 6
always-active: true