mirror of
https://github.com/edubart/otclient.git
synced 2025-10-17 13:03:27 +02:00
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:
@@ -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 })
|
||||
|
@@ -4,5 +4,12 @@ Module
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
|
||||
dependecies:
|
||||
- game
|
||||
|
||||
@onLoad: |
|
||||
dofile 'healthbar'
|
||||
HealthBar.init()
|
||||
|
||||
@onUnload: |
|
||||
HealthBar.terminate()
|
||||
|
@@ -32,7 +32,7 @@ ManaLabel < GameLabel
|
||||
margin-top: 2
|
||||
text: 0 / 0
|
||||
|
||||
UIWindow
|
||||
BorderlessGameWindow
|
||||
id: healthManaPanel
|
||||
width: 192
|
||||
height: 34
|
||||
|
Reference in New Issue
Block a user