textmessage

This commit is contained in:
Henrique
2011-09-04 14:21:42 -03:00
parent bdbfa5b6ac
commit b69dc5487f
6 changed files with 69 additions and 19 deletions

View File

@@ -20,6 +20,7 @@ local function createMainInterface()
Game.gameMapUi = Game.gameUi:getChildById('gameMap')
Game.gameUi.onKeyPress = onGameKeyPress
createTextInterface()
createVipWindow()
end

View File

@@ -1,15 +1,56 @@
local textMessageWidget
importStyles('/game/ui/textmessage.otui')
function Game.onTextMessage(message)
if textMessageWidget then
textMessageWidget:destroy()
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 }
}
function createTextInterface()
bottomLabelWidget = UILabel.create()
Game.gameMapUi:addChild(bottomLabelWidget)
centerLabelWidget = UILabel.create()
Game.gameMapUi:addChild(centerLabelWidget)
end
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
local newTextMessageWidget = loadUI('/game/ui/textmessage.otui', Game.gameMapUi)
time = #message * 75
newTextMessageWidget:setText(message)
scheduleEvent(function()
newTextMessageWidget:destroy()
end, time)
textMessageWidget = newTextMessageWidget
end

View File

@@ -1,8 +1,16 @@
Label
CenterLabel < Label
font: tibia-12px-rounded
height: 16
align: center
anchors.top: parent.verticalCenter
anchors.bottom: parent.verticalCenter
anchors.left: parent.left
anchors.right: parent.right
BottomLabel < Label
font: tibia-12px-rounded
color: white
height: 16
align: center
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.right: parent.right