mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
implement status messages
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
require 'textmessage'
|
||||
|
||||
-- private functions
|
||||
local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardCtrlModifier then
|
||||
@@ -13,15 +15,16 @@ local function onGameKeyPress(self, keyCode, keyChar, keyboardModifiers)
|
||||
end
|
||||
|
||||
local function createMainInterface()
|
||||
gameUi = loadUI('/game/ui/gameinterface.otui', UI.root)
|
||||
gameUi.onKeyPress = onGameKeyPress
|
||||
Game.gameUi = loadUI('/game/ui/gameinterface.otui', UI.root)
|
||||
Game.gameMapUi = Game.gameUi:getChildById('gameMap')
|
||||
Game.gameUi.onKeyPress = onGameKeyPress
|
||||
end
|
||||
|
||||
|
||||
local function destroyMainInterface()
|
||||
if gameUi then
|
||||
gameUi:destroy()
|
||||
gameUi = nil
|
||||
Game.gameUi:destroy()
|
||||
Game.gameUi = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
15
modules/game/textmessage.lua
Normal file
15
modules/game/textmessage.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
local textMessageWidget
|
||||
|
||||
function Game.onTextMessage(message)
|
||||
if textMessageWidget then
|
||||
textMessageWidget:destroy()
|
||||
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
|
8
modules/game/ui/textmessage.otui
Normal file
8
modules/game/ui/textmessage.otui
Normal file
@@ -0,0 +1,8 @@
|
||||
Label
|
||||
font: tibia-12px-rounded
|
||||
color: white
|
||||
height: 16
|
||||
align: center
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
Reference in New Issue
Block a user