mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
fix and move textmessage to a module
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
require 'textmessage'
|
||||
|
||||
-- private functions
|
||||
local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardCtrlModifier then
|
||||
@@ -18,7 +16,7 @@ end
|
||||
function Game.createInterface()
|
||||
Background.hide()
|
||||
CharacterList.destroyLoadBox()
|
||||
Game.gameUi = loadUI('/game/ui/gameinterface.otui', UI.root)
|
||||
Game.gameUi = loadUI('/game/game.otui', UI.root)
|
||||
Game.gameMapPanel = Game.gameUi:getChildById('mapPanel')
|
||||
Game.gameRightPanel = Game.gameUi:getChildById('rightPanel')
|
||||
Game.gameBottomPanel = Game.gameUi:getChildById('bottomPanel')
|
||||
|
@@ -1,58 +0,0 @@
|
||||
TextMessage = {}
|
||||
|
||||
-- require styles
|
||||
importStyles '/game/ui/textmessage.otui'
|
||||
|
||||
-- private variables
|
||||
local bottomLabelWidget, centerLabelWidget
|
||||
local messageTypes = {
|
||||
first = 12,
|
||||
{ type = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false },
|
||||
{ type = 'MessageOrange', color = '#C87832', showOnConsole = true, showOnWindow = false },
|
||||
{ type = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
|
||||
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
|
||||
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
|
||||
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = true, showOnWindow = true, windowLocation = 'BottomLabel' },
|
||||
{ type = 'MessageGreen', color = '#3FBE32', showOnConsole = true, showOnWindow = true, windowLocation = 'CenterLabel' },
|
||||
{ type = 'MessageWhite', color = '#FFFFFF', showOnConsole = false, showOnWindow = true, windowLocation = 'BottomLabel' },
|
||||
{ type = 'MessageBlue', color = '#3264C8', showOnConsole = true, showOnWindow = false },
|
||||
{ type = 'MessageRed', color = '#C83200', showOnConsole = true, showOnWindow = false }
|
||||
}
|
||||
|
||||
-- public functions
|
||||
function TextMessage.create()
|
||||
bottomLabelWidget = UILabel.create()
|
||||
Game.gameMapPanel:addChild(bottomLabelWidget)
|
||||
|
||||
centerLabelWidget = UILabel.create()
|
||||
Game.gameMapPanel:addChild(centerLabelWidget)
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
function Game.onTextMessage(type, message)
|
||||
local messageType = messageTypes[type - messageTypes.first]
|
||||
|
||||
if messageType.showOnConsole then
|
||||
-- TODO
|
||||
end
|
||||
|
||||
if messageType.showOnWindow then
|
||||
local label
|
||||
if messageType.windowLocation == 'BottomLabel' then
|
||||
label = bottomLabelWidget
|
||||
elseif messageType.windowLocation == 'CenterLabel' then
|
||||
label = centerLabelWidget
|
||||
end
|
||||
|
||||
label:setVisible(true)
|
||||
label:setForegroundColor(messageType.color)
|
||||
label:setText(message)
|
||||
|
||||
label:setStyle(messageType.windowLocation)
|
||||
|
||||
time = #message * 75
|
||||
scheduleEvent(function()
|
||||
label:setVisible(false)
|
||||
end, time)
|
||||
end
|
||||
end
|
@@ -1,17 +0,0 @@
|
||||
CenterLabel < Label
|
||||
font: verdana-11px-rounded
|
||||
height: 16
|
||||
align: center
|
||||
anchors.top: parent.verticalCenter
|
||||
anchors.bottom: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
BottomLabel < Label
|
||||
font: verdana-11px-rounded
|
||||
height: 16
|
||||
align: center
|
||||
margin.bottom: 2
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
Reference in New Issue
Block a user