mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
OMG the chat is finally scrolling!
* implement UIScrollArea * rework console to allow scrolling * many core ui changes in the way.. so maybe we will have new bugs * fix in UIScrollBar
This commit is contained in:
@@ -43,7 +43,7 @@ local SayModes = {
|
||||
}
|
||||
|
||||
local consolePanel
|
||||
local consoleBuffer
|
||||
local consoleContentPanel
|
||||
local consoleTabBar
|
||||
local consoleLineEdit
|
||||
local channels
|
||||
@@ -51,6 +51,7 @@ local messageHistory = { }
|
||||
local currentMessageIndex = 0
|
||||
local MaxHistory = 1000
|
||||
local channelsWindow
|
||||
local MAX_LINES = 100
|
||||
|
||||
-- private functions
|
||||
local function navigateMessageHistory(step)
|
||||
@@ -159,9 +160,9 @@ function Console.init()
|
||||
|
||||
consolePanel = displayUI('console.otui', GameInterface.getBottomPanel())
|
||||
consoleLineEdit = consolePanel:getChildById('consoleLineEdit')
|
||||
consoleBuffer = consolePanel:getChildById('consoleBuffer')
|
||||
consoleContentPanel = consolePanel:getChildById('consoleContentPanel')
|
||||
consoleTabBar = consolePanel:getChildById('consoleTabBar')
|
||||
consoleTabBar:setContentWidget(consoleBuffer)
|
||||
consoleTabBar:setContentWidget(consoleContentPanel)
|
||||
channels = {}
|
||||
|
||||
Console.addChannel('Default', 0)
|
||||
@@ -208,7 +209,7 @@ function Console.terminate()
|
||||
consolePanel:destroy()
|
||||
consolePanel = nil
|
||||
consoleLineEdit = nil
|
||||
consoleBuffer = nil
|
||||
consoleContentPanel = nil
|
||||
consoleTabBar = nil
|
||||
|
||||
Console = nil
|
||||
@@ -323,13 +324,15 @@ function Console.addTabText(text, speaktype, tab)
|
||||
end
|
||||
|
||||
local panel = consoleTabBar:getTabPanel(tab)
|
||||
local label = createWidget('ConsoleLabel', panel)
|
||||
local consoleBuffer = panel:getChildById('consoleBuffer')
|
||||
local label = createWidget('ConsoleLabel', consoleBuffer)
|
||||
label:setId('consoleLabel' .. panel:getChildCount())
|
||||
label:setText(text)
|
||||
label:setColor(speaktype.color)
|
||||
consoleTabBar:blinkTab(tab)
|
||||
|
||||
if panel:getChildCount() > 10 then
|
||||
panel:removeChild(panel:getFirstChild())
|
||||
if consoleBuffer:getChildCount() > MAX_LINES then
|
||||
consoleBuffer:getFirstChild():destroy()
|
||||
end
|
||||
end
|
||||
|
||||
|
@@ -5,9 +5,30 @@ ConsoleLabel < UILabel
|
||||
|
||||
ConsoleTabBar < TabBar
|
||||
ConsoleTabBarPanel < TabBarPanel
|
||||
layout:
|
||||
type: verticalBox
|
||||
align-bottom: true
|
||||
id: consoleTab
|
||||
|
||||
ScrollablePanel
|
||||
id: consoleBuffer
|
||||
// height = max lines * 14
|
||||
anchors.fill: parent
|
||||
margin-right: 12
|
||||
vertical-scrollbar: consoleScrollBar
|
||||
layout:
|
||||
type: verticalBox
|
||||
align-bottom: true
|
||||
border-width: 1
|
||||
border-color: #101317
|
||||
background: #00000044
|
||||
inverted-scroll: true
|
||||
padding: 1
|
||||
|
||||
VerticalScrollBar
|
||||
id: consoleScrollBar
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
step: 14
|
||||
|
||||
ConsoleTabBarButton < TabBarButton
|
||||
|
||||
Panel
|
||||
@@ -60,15 +81,16 @@ Panel
|
||||
@onClick: g_game.requestChannels()
|
||||
|
||||
Panel
|
||||
id: consoleBuffer
|
||||
id: consoleContentPanel
|
||||
anchors.top: prev.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: consoleLineEdit.top
|
||||
margin-right: 6
|
||||
margin-left: 6
|
||||
margin-right: 6
|
||||
margin-bottom: 4
|
||||
margin-top: 4
|
||||
padding: 1
|
||||
focusable: false
|
||||
|
||||
TabButton
|
||||
|
Reference in New Issue
Block a user