Exp bar on healthinfo module

master
Ricardo Ianelli 11 years ago
parent b08d0ff157
commit 9c0c19b5b2

@ -20,15 +20,18 @@ Icons[65536] = { tooltip = tr('You are hungry'), path = '/images/game/states/hun
healthInfoWindow = nil
healthBar = nil
manaBar = nil
experienceBar = nil
soulBar = nil
healthLabel = nil
manaLabel = nil
experienceLabel = nil
soulLabel = nil
capLabel = nil
function init()
connect(LocalPlayer, { onHealthChange = onHealthChange,
onManaChange = onManaChange,
onLevelChange = onLevelChange,
onStatesChange = onStatesChange,
onSoulChange = onSoulChange,
onFreeCapacityChange = onFreeCapacityChange })
@ -42,8 +45,10 @@ function init()
healthInfoWindow:disableResize()
healthBar = healthInfoWindow:recursiveGetChildById('healthBar')
manaBar = healthInfoWindow:recursiveGetChildById('manaBar')
experienceBar = healthInfoWindow:recursiveGetChildById('experienceBar')
healthLabel = healthInfoWindow:recursiveGetChildById('healthLabel')
manaLabel = healthInfoWindow:recursiveGetChildById('manaLabel')
experienceLabel = healthInfoWindow:recursiveGetChildById('experienceLabel')
soulBar = healthInfoWindow:recursiveGetChildById('soulBar')
soulLabel = healthInfoWindow:recursiveGetChildById('soulLabel')
capLabel = healthInfoWindow:recursiveGetChildById('capLabel')
@ -52,6 +57,7 @@ function init()
local localPlayer = g_game.getLocalPlayer()
onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
onManaChange(localPlayer, localPlayer:getMana(), localPlayer:getMaxMana())
onLevelChange(localPlayer, localPlayer:getLevel(), localPlayer:getLevelPercent())
onStatesChange(localPlayer, localPlayer:getStates(), 0)
onSoulChange(localPlayer, localPlayer:getSoul())
onFreeCapacityChange(localPlayer, localPlayer:getFreeCapacity())
@ -63,6 +69,7 @@ end
function terminate()
disconnect(LocalPlayer, { onHealthChange = onHealthChange,
onManaChange = onManaChange,
onLevelChange = onLevelChange,
onStatesChange = onStatesChange,
onSoulChange = onSoulChange,
onFreeCapacityChange = onFreeCapacityChange })
@ -90,6 +97,13 @@ function hideLabels()
healthInfoWindow:setHeight(math.max(healthInfoWindow.minimizedHeight, healthInfoWindow:getHeight() - removeHeight))
end
function hideExperience()
experienceBar:hide()
experienceLabel:hide()
local removeHeight = experienceBar:getHeight() + experienceBar:getMarginTop() + experienceBar:getMarginBottom()
healthInfoWindow:setHeight(math.max(healthInfoWindow.minimizedHeight, healthInfoWindow:getHeight() - removeHeight))
end
function onMiniWindowClose()
healthInfoButton:setOn(false)
end
@ -116,6 +130,11 @@ function onManaChange(localPlayer, mana, maxMana)
manaBar:setPercent(percent)
end
function onLevelChange(localPlayer, value, percent)
experienceLabel:setText(percent .. "%")
experienceBar:setPercent(percent)
end
function onSoulChange(localPlayer, soul)
soulLabel:setText(tr('Soul') .. ': ' .. soul)
end
@ -151,5 +170,4 @@ function toggleIcon(bitChanged)
icon:setImageSource(Icons[bitChanged].path)
icon:setTooltip(Icons[bitChanged].tooltip)
end
end
end

@ -14,6 +14,15 @@ ManaBar < ProgressBar
anchors.left: parent.left
anchors.right: parent.right
margin-top: 4
ExperienceBar < ProgressBar
id: experienceBar
height: 15
background-color: yellow
anchors.top: prev.bottom
anchors.left: parent.left
anchors.right: parent.right
margin-top: 4
HealthLabel < GameLabel
id: healthLabel
@ -32,6 +41,15 @@ ManaLabel < GameLabel
anchors.fill: manaBar
margin-top: 2
text: 0 / 0
ExperienceLabel < GameLabel
id: experienceLabel
color: white
text-align: center
font: verdana-11px-rounded
anchors.fill: experienceBar
margin-top: 2
text: 0 / 0
SoulLabel < GameLabel
id: soulLabel
@ -66,7 +84,7 @@ MiniWindow
icon: /images/topbuttons/healthinfo
id: healthInfoWindow
!text: tr('Health Info')
height: 102
height: 117
@onClose: modules.game_healthinfo.onMiniWindowClose()
&save: true
@ -75,6 +93,8 @@ MiniWindow
HealthLabel
ManaBar
ManaLabel
ExperienceBar
ExperienceLabel
Panel
id: conditionPanel
layout:
@ -89,4 +109,4 @@ MiniWindow
border-color: #00000077
background-color: #ffffff11
SoulLabel
CapLabel
CapLabel
Loading…
Cancel
Save