implement some chat functionality, but not complete yet

This commit is contained in:
Eduardo Bart
2012-01-12 21:47:31 -02:00
parent c1cf53829e
commit 830ebdbea9
18 changed files with 212 additions and 47 deletions

View File

@@ -20,11 +20,19 @@ local SpeakTypes = {
local consolePanel
local consoleBuffer
local consoleTabBar
local defaultChannelTab
local serverLogTab
local current
-- public functions
function Console.create()
consolePanel = displayUI('console.otui', { parent = Game.gameBottomPanel } )
consoleBuffer = consolePanel:getChildById('consoleBuffer')
consoleTabBar = consolePanel:getChildById('consoleTabBar')
consoleTabBar:setContentWidget(consoleBuffer)
defaultChannelTab = consoleTabBar:addTab('Default')
serverLogTab = consoleTabBar:addTab('Server Log')
end
function Console.destroy()
@@ -32,16 +40,25 @@ function Console.destroy()
consolePanel = nil
end
function Console.addText(text, color)
function Console.addText(text, color, channelTab)
color = color or 'white'
if Options.showTimestampsInConsole then
text = os.date('%H:%M') .. ' ' .. text
end
local label = createWidget('ConsoleLabel', consoleBuffer)
local label = createWidget('ConsoleLabel', consoleTabBar:getTabPanel(channelTab))
label:setText(text)
label:setColor(color)
consoleTabBar:blinkTab(channelTab)
end
function Console.addChannelMessage(text, color, channel)
if channel == 'Server Log' then
Console.addText(text, color, serverLogTab)
elseif channel == 'Default' then
Console.addText(text, color, defaultChannelTab)
end
end
-- hooked events
@@ -57,7 +74,8 @@ local function onCreatureSpeak(name, level, speaktypedesc, message, channelId, c
end
end
Console.addText(message, speaktype.color)
local channelPanel = consoleTabBar:getTabPanel(defaultChannelTab)
Console.addText(message, speaktype.color, channelPanel)
end
connect(Game, { onLogin = Console.create,

View File

@@ -3,48 +3,58 @@ ConsoleLabel < UILabel
height: 14
color: yellow
SayModeButton < UIButton
size: 26 26
icon: /core_styles/icons/say.png
image-source: /core_styles/images/top_button.png
image-color: white
image-clip: 0 0 26 26
image-border: 3
$hover:
image-source: /core_styles/images/top_button.png
clip: 26 0 26 26
border: 3
$pressed:
image-source: /core_styles/images/top_button.png
image-clip: 52 0 26 26
image-border: 3
$disabled:
image-color: #ffffff66
ConsoleTabBar < TabBar
ConsoleTabBarPanel < TabBarPanel
layout:
type: verticalBox
align-bottom: true
ConsoleTabBarButton < TabBarButton
Panel
id: consolePanel
anchors.fill: parent
ConsoleButton
id: prevChannelButton
icon: /core_styles/icons/leftarrow.png
anchors.left: parent.left
anchors.top: parent.top
margin-left: 6
margin-top: 6
enabled: false
ConsoleTabBar
id: consoleTabBar
height: 20
anchors.left: prev.right
anchors.top: prev.top
anchors.right: next.left
margin-left: 5
ConsoleButton
id: nextChannelButton
icon: /core_styles/icons/rightarrow.png
anchors.right: parent.right
anchors.top: parent.top
margin-right: 5
margin-top: 6
enabled: false
Panel
id: consoleBuffer
anchors.top: parent.top
anchors.top: prev.bottom
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
margin-bottom: 4
margin-top: 4
focusable: false
SayModeButton
ConsoleButton
id: sayModeButton
icon: /core_styles/icons/say.png
size: 20 20
anchors.left: parent.left
anchors.bottom: parent.bottom