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

1
BUGS
View File

@ -11,3 +11,4 @@ some animated hits are displayed as 2 hits instead of one
numpad on windows doesn't work correctly
skulls is rendering outside map bounds
these are some issues when skill progressbar is 0% or 100%
paste on x11 platform does not work correctly when doing ctrl+c in google chrome

1
TODO
View File

@ -65,6 +65,7 @@ Low priority TODO
[bart] reapply anchor styles when adding new childs
[bart] ui text selection
[bart] make set of background/icon/image width alone work
[bart] check for recursive anchors to print a error and avoid crashes
== Client modules
[bart] make possible to reload modules

View File

@ -12,6 +12,7 @@ Module
importStyle 'styles/lineedits.otui'
importStyle 'styles/checkboxes.otui'
importStyle 'styles/progressbars.otui'
importStyle 'styles/tabbars.otui'
importStyle 'styles/windows.otui'
importStyle 'styles/listboxes.otui'
importStyle 'styles/items.otui'

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 284 B

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 286 B

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 B

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

View File

@ -18,3 +18,23 @@ Button < UIButton
color: #f0ad4d88
image-color: #ffffff88
ConsoleButton < UIButton
size: 20 20
image-source: /core_styles/images/consolebutton.png
image-color: white
image-clip: 0 0 20 20
image-border: 2
icon-color: white
color: #aaaaaa
$hover !on:
image-clip: 0 20 20 20
color: white
$disabled:
image-color: #ffffff66
icon-color: #888888
$on:
image-clip: 0 40 20 20
color: #80c7f8

View File

@ -1,5 +1,34 @@
TabBar < UITabBar
TabBarTabButton < UIButton
TabBarCloseButton < UIButton
TabBarPrevButton < UIButton
TabBarNextButton < UIButton
TabBarPanel < Panel
TabBarButton < UIButton
size: 20 20
image-source: /core_styles/images/consolebutton.png
image-color: white
image-clip: 0 0 20 20
image-border: 2
icon-color: white
color: #aaaaaa
anchors.top: parent.top
margin-left: 5
padding: 5
$first:
anchors.left: parent.left
$!first:
anchors.left: prev.right
$hover !checked:
image-clip: 0 20 20 20
color: white
$disabled:
image-color: #ffffff66
icon-color: #888888
$checked:
image-clip: 0 40 20 20
color: #80c7f8
$on !checked:
color: #F55E5E

View File

@ -11,6 +11,7 @@ Module
require 'uicheckbox'
require 'uicombobox'
require 'uiprogressbar'
require 'uitabbar'
require 'uipopupmenu'
require 'uiwindow'
require 'tooltip/tooltip'

View File

@ -1 +1,84 @@
UITabBar = extends(UIWidget)
-- private functions
local function onTabClick(tabButton)
tabButton.tabBar:selectTab(tabButton)
end
local function tabBlink(tabButton)
if tabButton.blinking then
tabButton:setOn(not tabButton:isOn())
scheduleEvent(function() tabBlink(tabButton) end, 300)
end
end
-- public functions
function UITabBar.create()
local tabbar = UITabBar.internalCreate()
tabbar.tabs = {}
return tabbar
end
function UITabBar:setContentWidget(widget)
self.contentWidget = widget
if #self.tabs > 0 then
self.contentWidget:addChild(self.tabs[1].tabPanel)
end
end
function UITabBar:addTab(text, panel)
if panel == nil then
panel = createWidget(self:getStyleName() .. 'Panel')
end
local tabButton = createWidget(self:getStyleName() .. 'Button', self)
tabButton.tabPanel = panel
tabButton.tabBar = self
tabButton:setText(text)
tabButton:setWidth(tabButton:getTextSize().width + tabButton:getPaddingLeft() + tabButton:getPaddingRight())
connect(tabButton, { onClick = onTabClick })
table.insert(self.tabs, tabButton)
if #self.tabs == 1 then
self:selectTab(tabButton)
end
return tabButton
end
function UITabBar:selectTab(tabButton)
if self.contentWidget then
local selectedWidget = self.contentWidget:getFirstChild()
if selectedWidget then
self.contentWidget:removeChild(selectedWidget)
end
self.contentWidget:addChild(tabButton.tabPanel)
tabButton.tabPanel:fill('parent')
end
tabButton:setChecked(true)
tabButton:setOn(false)
tabButton.blinking = false
if self.currentTabButton then
self.currentTabButton:setChecked(false)
end
self.currentTabButton = tabButton
end
function UITabBar:blinkTab(tabButton)
if not tabButton:isChecked() then
tabButton:setOn(true)
tabButton.blinking = true
tabBlink(tabButton)
end
end
function UITabBar:getTabPanel(tabButton)
return tabButton.tabPanel
end
function UITabBar:getCurrentTabPanel()
if self.currentTabButton then
return self.currentTabButton.tabPanel
end
end

View File

@ -13,7 +13,7 @@ UIGame
InterfacePanel2
id: bottomPanel
height: 144
height: 170
anchors.left: parent.left
anchors.right: rightPanel.left
anchors.bottom: parent.bottom

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

View File

@ -5,16 +5,16 @@ importStyle 'textmessage.otui'
-- private variables
local MessageTypes = {
warning = { color = '#F55E5E', showOnConsole = true, windowLocation = 'center', consoleOption = 'showInfoMessagesInConsole' },
eventAdvance = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' },
eventDefault = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'bottom', consoleOption = 'showEventMessagesInConsole' },
eventOrange = { color = '#FE6500', showOnConsole = true, windowLocation = 'bottom', consoleOption = 'showEventMessagesInConsole' },
statusDefault = { color = '#FFFFFF', showOnConsole = true, windowLocation = 'bottom', consoleOption = 'showStatusMessagesInConsole' },
infoDescription = { color = '#00EB00', showOnConsole = true, windowLocation = 'center', consoleOption = 'showInfoMessagesInConsole' },
statusSmall = { color = '#FFFFFF', showOnConsole = false, windowLocation = 'bottom' },
consoleOrange = { color = '#FE6500', showOnConsole = true },
consoleBlue = { color = '#9F9DFD', showOnConsole = true },
consoleRed = { color = '#F55E5E', showOnConsole = true }
consoleRed = { color = '#F55E5E', consoleChannel = 'Server Log' },
eventOrange = { color = '#FE6500', consoleChannel = 'Default' , windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' },
consoleOrange = { color = '#FE6500', consoleChannel = 'Default' },
warning = { color = '#F55E5E', consoleChannel = 'Server Log', windowLocation = 'center' },
eventAdvance = { color = '#FFFFFF', consoleChannel = 'Server Log', windowLocation = 'center', consoleOption = 'showEventMessagesInConsole' },
eventDefault = { color = '#FFFFFF', consoleChannel = 'Server Log', windowLocation = 'bottom', consoleOption = 'showEventMessagesInConsole' },
statusDefault = { color = '#FFFFFF', consoleChannel = 'Server Log', windowLocation = 'bottom', consoleOption = 'showStatusMessagesInConsole' },
infoDescription = { color = '#00EB00', consoleChannel = 'Server Log', windowLocation = 'center', consoleOption = 'showInfoMessagesInConsole' },
statusSmall = { color = '#FFFFFF', windowLocation = 'bottom' },
consoleBlue = { color = '#9F9DFD', consoleChannel = 'Default' },
}
local bottomLabelWidget
@ -26,9 +26,9 @@ local centerLabelHideEvent
local function displayMessage(msgtype, msg, time)
if not Game.isOnline() then return end
if msgtype.showOnConsole then
if msgtype.consoleChannel ~= nil then
if msgtype.consoleOption == nil or Options[msgtype.consoleOption] then
Console.addText(msg, msgtype.color)
Console.addChannelMessage(msg, msgtype.color, msgtype.consoleChannel)
end
end

View File

@ -44,6 +44,7 @@
#include <otclient/ui/uigame.h>
#include <otclient/core/outfit.h>
void OTClient::registerLuaFunctions()
{
Application::registerLuaFunctions();