mirror of
https://github.com/edubart/otclient.git
synced 2025-12-16 05:39:47 +01:00
create in game interface panels and renable about and options windows
This commit is contained in:
@@ -1,37 +1,41 @@
|
||||
importStyles('/game/ui/textmessage.otui')
|
||||
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 }
|
||||
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()
|
||||
-- public functions
|
||||
function TextMessage.create()
|
||||
bottomLabelWidget = UILabel.create()
|
||||
Game.gameMapUi:addChild(bottomLabelWidget)
|
||||
|
||||
|
||||
centerLabelWidget = UILabel.create()
|
||||
Game.gameMapUi: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
|
||||
@@ -39,18 +43,16 @@ function Game.onTextMessage(type, message)
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user