Merge pull request #33 from kilouco/master

Soul Points
This commit is contained in:
Eduardo Bart 2012-07-10 21:08:32 -07:00
commit 7666466349
2 changed files with 29 additions and 3 deletions

View File

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

View File

@ -34,6 +34,17 @@ ManaLabel < GameLabel
margin-top: 2 margin-top: 2
text: 0 / 0 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 ConditionWidget < UIWidget
size: 18 18 size: 18 18
@ -44,7 +55,7 @@ MiniWindow
icon: healthbar.png icon: healthbar.png
id: healthBarWindow id: healthBarWindow
!text: tr('Health Bar') !text: tr('Health Bar')
height: 86 height: 102
@onClose: HealthBar.onMiniWindowClose() @onClose: HealthBar.onMiniWindowClose()
&save: true &save: true
@ -62,3 +73,4 @@ MiniWindow
margin-top: 5 margin-top: 5
anchors.top: prev.bottom anchors.top: prev.bottom
anchors.horizontalcenter: parent.horizontalcenter anchors.horizontalcenter: parent.horizontalcenter
SoulLabel