Merge pull request #268 from ricardoianelli/master
Added experience bar to healthinfo
This commit is contained in:
		
						commit
						6f37361df0
					
				|  | @ -20,15 +20,18 @@ Icons[65536] = { tooltip = tr('You are hungry'), path = '/images/game/states/hun | ||||||
| healthInfoWindow = nil | healthInfoWindow = nil | ||||||
| healthBar = nil | healthBar = nil | ||||||
| manaBar = nil | manaBar = nil | ||||||
|  | experienceBar = nil | ||||||
| soulBar = nil | soulBar = nil | ||||||
| healthLabel = nil | healthLabel = nil | ||||||
| manaLabel = nil | manaLabel = nil | ||||||
|  | experienceLabel = nil | ||||||
| soulLabel = nil | soulLabel = nil | ||||||
| capLabel = nil | capLabel = nil | ||||||
| 
 | 
 | ||||||
| function init() | function init() | ||||||
|   connect(LocalPlayer, { onHealthChange = onHealthChange, |   connect(LocalPlayer, { onHealthChange = onHealthChange, | ||||||
|                          onManaChange = onManaChange, |                          onManaChange = onManaChange, | ||||||
|  |                          onLevelChange = onLevelChange, | ||||||
|                          onStatesChange = onStatesChange, |                          onStatesChange = onStatesChange, | ||||||
|                          onSoulChange = onSoulChange, |                          onSoulChange = onSoulChange, | ||||||
|                          onFreeCapacityChange = onFreeCapacityChange }) |                          onFreeCapacityChange = onFreeCapacityChange }) | ||||||
|  | @ -42,8 +45,10 @@ function init() | ||||||
|   healthInfoWindow:disableResize() |   healthInfoWindow:disableResize() | ||||||
|   healthBar = healthInfoWindow:recursiveGetChildById('healthBar') |   healthBar = healthInfoWindow:recursiveGetChildById('healthBar') | ||||||
|   manaBar = healthInfoWindow:recursiveGetChildById('manaBar') |   manaBar = healthInfoWindow:recursiveGetChildById('manaBar') | ||||||
|  |   experienceBar = healthInfoWindow:recursiveGetChildById('experienceBar') | ||||||
|   healthLabel = healthInfoWindow:recursiveGetChildById('healthLabel') |   healthLabel = healthInfoWindow:recursiveGetChildById('healthLabel') | ||||||
|   manaLabel = healthInfoWindow:recursiveGetChildById('manaLabel') |   manaLabel = healthInfoWindow:recursiveGetChildById('manaLabel') | ||||||
|  |   experienceLabel = healthInfoWindow:recursiveGetChildById('experienceLabel') | ||||||
|   soulBar = healthInfoWindow:recursiveGetChildById('soulBar') |   soulBar = healthInfoWindow:recursiveGetChildById('soulBar') | ||||||
|   soulLabel = healthInfoWindow:recursiveGetChildById('soulLabel') |   soulLabel = healthInfoWindow:recursiveGetChildById('soulLabel') | ||||||
|   capLabel = healthInfoWindow:recursiveGetChildById('capLabel') |   capLabel = healthInfoWindow:recursiveGetChildById('capLabel') | ||||||
|  | @ -52,6 +57,7 @@ function init() | ||||||
|     local localPlayer = g_game.getLocalPlayer() |     local localPlayer = g_game.getLocalPlayer() | ||||||
|     onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth()) |     onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth()) | ||||||
|     onManaChange(localPlayer, localPlayer:getMana(), localPlayer:getMaxMana()) |     onManaChange(localPlayer, localPlayer:getMana(), localPlayer:getMaxMana()) | ||||||
|  |     onLevelChange(localPlayer, localPlayer:getLevel(), localPlayer:getLevelPercent()) | ||||||
|     onStatesChange(localPlayer, localPlayer:getStates(), 0) |     onStatesChange(localPlayer, localPlayer:getStates(), 0) | ||||||
|     onSoulChange(localPlayer, localPlayer:getSoul()) |     onSoulChange(localPlayer, localPlayer:getSoul()) | ||||||
|     onFreeCapacityChange(localPlayer, localPlayer:getFreeCapacity()) |     onFreeCapacityChange(localPlayer, localPlayer:getFreeCapacity()) | ||||||
|  | @ -63,6 +69,7 @@ end | ||||||
| function terminate() | function terminate() | ||||||
|   disconnect(LocalPlayer, { onHealthChange = onHealthChange, |   disconnect(LocalPlayer, { onHealthChange = onHealthChange, | ||||||
|                             onManaChange = onManaChange, |                             onManaChange = onManaChange, | ||||||
|  |                             onLevelChange = onLevelChange, | ||||||
|                             onStatesChange = onStatesChange, |                             onStatesChange = onStatesChange, | ||||||
|                             onSoulChange = onSoulChange, |                             onSoulChange = onSoulChange, | ||||||
|                             onFreeCapacityChange = onFreeCapacityChange }) |                             onFreeCapacityChange = onFreeCapacityChange }) | ||||||
|  | @ -90,6 +97,13 @@ function hideLabels() | ||||||
|   healthInfoWindow:setHeight(math.max(healthInfoWindow.minimizedHeight, healthInfoWindow:getHeight() - removeHeight)) |   healthInfoWindow:setHeight(math.max(healthInfoWindow.minimizedHeight, healthInfoWindow:getHeight() - removeHeight)) | ||||||
| end | 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() | function onMiniWindowClose() | ||||||
|   healthInfoButton:setOn(false) |   healthInfoButton:setOn(false) | ||||||
| end | end | ||||||
|  | @ -116,6 +130,11 @@ function onManaChange(localPlayer, mana, maxMana) | ||||||
|   manaBar:setPercent(percent) |   manaBar:setPercent(percent) | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  | function onLevelChange(localPlayer, value, percent) | ||||||
|  |   experienceLabel:setText(percent .. "%") | ||||||
|  |   experienceBar:setPercent(percent) | ||||||
|  | end | ||||||
|  | 
 | ||||||
| function onSoulChange(localPlayer, soul) | function onSoulChange(localPlayer, soul) | ||||||
|   soulLabel:setText(tr('Soul') .. ': ' .. soul) |   soulLabel:setText(tr('Soul') .. ': ' .. soul) | ||||||
| end | end | ||||||
|  | @ -152,4 +171,3 @@ function toggleIcon(bitChanged) | ||||||
|     icon:setTooltip(Icons[bitChanged].tooltip) |     icon:setTooltip(Icons[bitChanged].tooltip) | ||||||
|   end |   end | ||||||
| end | end | ||||||
| 
 |  | ||||||
|  |  | ||||||
|  | @ -15,6 +15,15 @@ ManaBar < ProgressBar | ||||||
|   anchors.right: parent.right |   anchors.right: parent.right | ||||||
|   margin-top: 4 |   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 | HealthLabel < GameLabel | ||||||
|   id: healthLabel |   id: healthLabel | ||||||
|   color: white |   color: white | ||||||
|  | @ -33,6 +42,15 @@ ManaLabel < GameLabel | ||||||
|   margin-top: 2 |   margin-top: 2 | ||||||
|   text: 0 / 0 |   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 | SoulLabel < GameLabel | ||||||
|   id: soulLabel |   id: soulLabel | ||||||
|   text-align: right |   text-align: right | ||||||
|  | @ -66,7 +84,7 @@ MiniWindow | ||||||
|   icon: /images/topbuttons/healthinfo |   icon: /images/topbuttons/healthinfo | ||||||
|   id: healthInfoWindow |   id: healthInfoWindow | ||||||
|   !text: tr('Health Info') |   !text: tr('Health Info') | ||||||
|   height: 102 |   height: 117 | ||||||
|   @onClose: modules.game_healthinfo.onMiniWindowClose() |   @onClose: modules.game_healthinfo.onMiniWindowClose() | ||||||
|   &save: true |   &save: true | ||||||
| 
 | 
 | ||||||
|  | @ -75,6 +93,8 @@ MiniWindow | ||||||
|     HealthLabel |     HealthLabel | ||||||
|     ManaBar |     ManaBar | ||||||
|     ManaLabel |     ManaLabel | ||||||
|  |     ExperienceBar | ||||||
|  |     ExperienceLabel | ||||||
|     Panel |     Panel | ||||||
|       id: conditionPanel |       id: conditionPanel | ||||||
|       layout: |       layout: | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Henrique Santiago
						Henrique Santiago