Now Soul Points are shown in the bottom of the HealthBar widget.

This commit is contained in:
kilouco 2012-07-11 00:47:53 -03:00
parent d2bdab42b5
commit 104785818b
2 changed files with 29 additions and 3 deletions

View File

@ -27,11 +27,15 @@ local manaBar
local healthLabel
local manaLabel
local soulLabel
local soulPoints
-- public functions
function HealthBar.init()
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange,
onStatesChange = HealthBar.onStatesChange })
onStatesChange = HealthBar.onStatesChange,
onSoulChange = HealthBar.onSoulChange })
connect(g_game, { onGameEnd = HealthBar.offline })
@ -43,18 +47,22 @@ function HealthBar.init()
healthLabel = healthBarWindow:recursiveGetChildById('healthLabel')
manaLabel = healthBarWindow:recursiveGetChildById('manaLabel')
soulLabel = healthBarWindow:recursiveGetChildById('soulLabel')
if g_game.isOnline() then
local localPlayer = g_game.getLocalPlayer()
HealthBar.onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
HealthBar.onManaChange(localPlayer, localPlayer:getMana(), localPlayer:getMaxMana())
HealthBar.onStatesChange(localPlayer, localPlayer:getStates(), 0)
HealthBar.onSoulChange(localPlayer, localPlayer:getSoul())
end
end
function HealthBar.terminate()
disconnect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange,
onStatesChange = HealthBar.onStatesChange })
onStatesChange = HealthBar.onStatesChange,
onSoulChange = HealthBar.onSoulChange })
disconnect(g_game, { onGameEnd = HealthBar.offline })
@ -66,6 +74,8 @@ function HealthBar.terminate()
manaBar = nil
healthLabel = nil
manaLabel = nil
soulLabel = nil
HealthBar = nil
end
@ -120,6 +130,10 @@ function HealthBar.onStatesChange(localPlayer, now, old)
end
end
function HealthBar.onSoulChange(localPlayer, soul)
soulLabel:setText('Soul: '.. soul)
end
function HealthBar.toggleIcon(bitChanged)
local content = healthBarWindow:recursiveGetChildById('conditionPanel')

View File

@ -34,6 +34,17 @@ ManaLabel < GameLabel
margin-top: 2
text: 0 / 0
SoulLabel < GameLabel
id: soulLabel
color: white
text-align: center
font: verdana-11px-rounded
anchors.top: prev.bottom
anchors.left: parent.left
anchors.right: parent.right
margin-top: 5
text: Soul:
ConditionWidget < UIWidget
size: 18 18
@ -44,7 +55,7 @@ MiniWindow
icon: healthbar.png
id: healthBarWindow
!text: tr('Health Bar')
height: 86
height: 102
@onClose: HealthBar.onMiniWindowClose()
&save: true
@ -62,3 +73,4 @@ MiniWindow
margin-top: 5
anchors.top: prev.bottom
anchors.horizontalcenter: parent.horizontalcenter
SoulLabel