mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 21:13:26 +02:00
health bar improvements
This commit is contained in:
@@ -7,11 +7,21 @@ local healthManaPanel = nil
|
||||
function HealthMana.create()
|
||||
healthManaPanel = loadUI("/health_mana/health_mana.otui", Game.gameRightPanel)
|
||||
|
||||
local healthBar = UIProgressBar.create()
|
||||
healthManaPanel:addChild(healthBar)
|
||||
healthBar:setId('healthBar')
|
||||
healthBar:setStyle('HealthBar')
|
||||
|
||||
local healthLabel = UILabel.create()
|
||||
healthManaPanel:addChild(healthLabel)
|
||||
healthLabel:setId('healthLabel')
|
||||
healthLabel:setStyle('HealthLabel')
|
||||
healthLabel:setText('0 / 0')
|
||||
|
||||
local manaBar = UIProgressBar.create()
|
||||
healthManaPanel:addChild(manaBar)
|
||||
manaBar:setId('manaBar')
|
||||
manaBar:setStyle('ManaBar')
|
||||
|
||||
local manaLabel = UILabel.create()
|
||||
healthManaPanel:addChild(manaLabel)
|
||||
@@ -19,7 +29,7 @@ function HealthMana.create()
|
||||
manaLabel:setStyle('ManaLabel')
|
||||
manaLabel:setText('0 / 0')
|
||||
|
||||
healthManaPanel:setHeight(healthLabel:getHeight() + manaLabel:getHeight())
|
||||
healthManaPanel:setHeight(healthBar:getHeight() + manaBar:getHeight() + 4)
|
||||
end
|
||||
|
||||
function HealthMana.destroy()
|
||||
@@ -31,11 +41,17 @@ end
|
||||
function Game.onHealthChange(health, maxHealth)
|
||||
local label = healthManaPanel:getChildById('healthLabel')
|
||||
label:setText(health .. ' / ' .. maxHealth)
|
||||
|
||||
local healthBar = healthManaPanel:getChildById('healthBar')
|
||||
healthBar:setPercent(health / maxHealth * 100)
|
||||
end
|
||||
|
||||
function Game.onManaChange(mana, maxMana)
|
||||
local label = healthManaPanel:getChildById('manaLabel')
|
||||
label:setText(mana .. ' / ' .. maxMana)
|
||||
|
||||
local manaBar = healthManaPanel:getChildById('manaBar')
|
||||
manaBar:setPercent(mana / maxMana * 100)
|
||||
end
|
||||
|
||||
connect(Game, { onLogin = HealthMana.create,
|
||||
|
@@ -1,22 +1,36 @@
|
||||
HealthBar < UIProgressBar
|
||||
color: black
|
||||
height: 15
|
||||
background-color: red
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
ManaBar < UIProgressBar
|
||||
color: black
|
||||
height: 15
|
||||
background-color: blue
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
HealthLabel < Label
|
||||
color: white
|
||||
background-color: red
|
||||
align: center
|
||||
font: verdana-11px-monochrome
|
||||
font: verdana-11px-rounded
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
image: /core_styles/images/empty_rect.png
|
||||
margin.top: 2
|
||||
|
||||
ManaLabel < Label
|
||||
color: white
|
||||
background-color: blue
|
||||
align: center
|
||||
font: verdana-11px-monochrome
|
||||
font: verdana-11px-rounded
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
image: /core_styles/images/empty_rect.png
|
||||
margin.bottom: -1
|
||||
|
||||
UIWindow
|
||||
id: healthManaPanel
|
||||
@@ -25,5 +39,4 @@ UIWindow
|
||||
margin.left: 6
|
||||
margin.right: 6
|
||||
move policy: free updated
|
||||
image: /core_styles/images/empty_rect.png
|
||||
|
||||
|
Reference in New Issue
Block a user