healthmana module

This commit is contained in:
Henrique
2011-11-03 21:10:12 -02:00
parent f444dc624c
commit 5d54971568
10 changed files with 311 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
Module
name: health_mana
description: Displays health and mana points
author: OTClient team
website: https://github.com/edubart/otclient
autoLoad: true
dependencies:
- game
onLoad: |
require 'viplist'
return true

View File

@@ -0,0 +1,42 @@
HealthMana = {}
-- private variables
local healthManaPanel = nil
-- public functions
function HealthMana.create()
healthManaPanel = loadUI("/health_mana/health_mana.otui", Game.gameRightPanel)
local healthLabel = UILabel.create()
healthManaPanel:addChild(healthLabel)
healthLabel:setId('healthLabel')
healthLabel:setStyle('HealthLabel')
healthLabel:setText('0 / 0')
local manaLabel = UILabel.create()
healthManaPanel:addChild(manaLabel)
manaLabel:setId('manaLabel')
manaLabel:setStyle('ManaLabel')
manaLabel:setText('0 / 0')
healthManaPanel:setHeight(healthLabel:getHeight() + manaLabel:getHeight())
end
function HealthMana.destroy()
healthManaPanel:destroy()
healthManaPanel = nil
end
-- hooked events
function Game.onHealthChange(health, maxHealth)
local label = healthManaPanel:getChildById('healthLabel')
label:setText(health .. ' / ' .. maxHealth)
end
function Game.onManaChange(mana, maxMana)
local label = healthManaPanel:getChildById('manaLabel')
label:setText(mana .. ' / ' .. maxMana)
end
connect(Game, { onLogin = HealthMana.create,
onLogout = HealthMana.destroy })

View File

@@ -0,0 +1,42 @@
HealthMana = {}
-- private variables
local healthManaPanel = nil
-- public functions
function HealthMana.create()
healthManaPanel = loadUI("/health_mana/health_mana.otui", Game.gameRightPanel)
local healthLabel = UILabel.create()
healthManaPanel:addChild(healthLabel)
healthLabel:setId('healthLabel')
healthLabel:setStyle('HealthLabel')
healthLabel:setText('0 / 0')
local manaLabel = UILabel.create()
healthManaPanel:addChild(manaLabel)
manaLabel:setId('manaLabel')
manaLabel:setStyle('ManaLabel')
manaLabel:setText('1 / 1')
healthManaPanel:setHeight(healthLabel:getHeight() + manaLabel:getHeight())
end
function HealthMana.destroy()
healthManaPanel:destroy()
healthManaPanel = nil
end
-- hooked events
function Game.onHealthChange(health, maxHealth)
local label = healthManaPanel:getChildById('healthLabel')
label:setText(health .. ' / ' .. maxHealth)
end
function Game.onManaChange(mana, maxMana)
local label = healthManaPanel:getChildById('manaLabel')
label:setText(mana .. ' / ' .. maxMana)
end
connect(Game, { onLogin = HealthMana.create,
onLogout = HealthMana.destroy })

View File

@@ -0,0 +1,14 @@
Module
name: health_mana
description: Displays health and mana points
author: OTClient team
website: https://github.com/edubart/otclient
autoLoad: true
dependencies:
- game
onLoad: |
require 'health_mana'
return true

View File

@@ -0,0 +1,29 @@
HealthLabel < Label
color: white
background-color: red
align: center
font: verdana-11px-monochrome
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
image: /core_styles/images/empty_rect.png
ManaLabel < Label
color: white
background-color: blue
align: center
font: verdana-11px-monochrome
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
image: /core_styles/images/empty_rect.png
UIWindow
id: healthManaPanel
width: 192
margin.top: 6
margin.left: 6
margin.right: 6
move policy: free updated
image: /core_styles/images/empty_rect.png

View File

@@ -0,0 +1,29 @@
HealthLabel < Label
color: red
background-color: green
align: center
font: verdana-11px-monochrome
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
image: /core_styles/images/empty_rect.png
ManaLabel < Label
color: blue
background-color: red
align: center
font: verdana-11px-monochrome
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
image: /core_styles/images/empty_rect.png
UIWindow
id: healthManaPanel
width: 192
margin.top: 6
margin.left: 6
margin.right: 6
move policy: free updated
image: /core_styles/images/empty_rect.png