restore inventory and healthbar

* make inventory/healthbar work again allowing reload
* changes in top menu toggle buttons
* all modules are now reloadable by default
* fix warning when using fade in
* remove some unused files
This commit is contained in:
Eduardo Bart
2012-03-23 10:48:05 -03:00
parent b301aa1a2b
commit 239f58296e
41 changed files with 134 additions and 407 deletions

View File

@@ -8,17 +8,29 @@ local healthLabel
local manaLabel
-- public functions
function HealthBar.create()
function HealthBar.init()
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange })
healthBarWindow = displayUI('healthbar.otui', GameInterface.getRightPanel())
healthBarButton = TopMenu.addGameButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
healthBarButton = TopMenu.addGameToggleButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
healthBarButton:setOn(true)
healthBar = healthBarWindow:getChildById('healthBar')
manaBar = healthBarWindow:getChildById('manaBar')
healthLabel = healthBarWindow:getChildById('healthLabel')
manaLabel = healthBarWindow:getChildById('manaLabel')
if g_game.isOnline() then
local localPlayer = g_game.getLocalPlayer()
HealthBar.onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
HealthBar.onManaChange(localPlayer, localPlayer:getMana(), localPlayer:getMaxMana())
end
end
function HealthBar.destroy()
function HealthBar.terminate()
disconnect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange })
healthBarWindow:destroy()
healthBarWindow = nil
healthBarButton:destroy()
@@ -53,7 +65,3 @@ function HealthBar.onManaChange(localPlayer, mana, maxMana)
manaBar:setPercent(percent)
end
connect(g_game, { onGameStart = HealthBar.create,
onGameEnd = HealthBar.destroy })
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange })

View File

@@ -4,5 +4,12 @@ Module
author: OTClient team
website: https://github.com/edubart/otclient
dependecies:
- game
@onLoad: |
dofile 'healthbar'
HealthBar.init()
@onUnload: |
HealthBar.terminate()

View File

@@ -32,7 +32,7 @@ ManaLabel < GameLabel
margin-top: 2
text: 0 / 0
UIWindow
BorderlessGameWindow
id: healthManaPanel
width: 192
height: 34