mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
introduce startup options
* startup options with -help and -version * many startup options for graphics
This commit is contained in:
59
modules/game_healthbar/healthbar.lua
Normal file
59
modules/game_healthbar/healthbar.lua
Normal file
@@ -0,0 +1,59 @@
|
||||
HealthBar = {}
|
||||
|
||||
-- private variables
|
||||
local healthBarWindow
|
||||
local healthBar
|
||||
local manaBar
|
||||
local healthLabel
|
||||
local manaLabel
|
||||
|
||||
-- public functions
|
||||
function HealthBar.create()
|
||||
healthBarWindow = displayUI('healthbar.otui', g_game.gameRightPanel)
|
||||
healthBarButton = TopMenu.addGameButton('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')
|
||||
end
|
||||
|
||||
function HealthBar.destroy()
|
||||
healthBarWindow:destroy()
|
||||
healthBarWindow = nil
|
||||
healthBarButton:destroy()
|
||||
healthBarButton = nil
|
||||
healthBar = nil
|
||||
manaBar = nil
|
||||
healthLabel = nil
|
||||
manaLabel = nil
|
||||
end
|
||||
|
||||
function HealthBar.toggle()
|
||||
local visible = not healthBarWindow:isExplicitlyVisible()
|
||||
healthBarWindow:setVisible(visible)
|
||||
healthBarButton:setOn(visible)
|
||||
end
|
||||
|
||||
-- hooked events
|
||||
function HealthBar.onHealthChange(localPlayer, health, maxHealth)
|
||||
healthLabel:setText(health .. ' / ' .. maxHealth)
|
||||
healthBar:setPercent(health / maxHealth * 100)
|
||||
end
|
||||
|
||||
function HealthBar.onManaChange(localPlayer, mana, maxMana)
|
||||
manaLabel:setText(mana .. ' / ' .. maxMana)
|
||||
|
||||
local percent
|
||||
if maxMana == 0 then
|
||||
percent = 100
|
||||
else
|
||||
percent = (mana * 100)/maxMana
|
||||
end
|
||||
manaBar:setPercent(percent)
|
||||
end
|
||||
|
||||
connect(g_game, { onGameStart = HealthBar.create,
|
||||
onGameEnd = HealthBar.destroy })
|
||||
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
|
||||
onManaChange = HealthBar.onManaChange })
|
7
modules/game_healthbar/healthbar.otmod
Normal file
7
modules/game_healthbar/healthbar.otmod
Normal file
@@ -0,0 +1,7 @@
|
||||
Module
|
||||
name: game_healthbar
|
||||
description: Displays health and mana points
|
||||
author: OTClient team
|
||||
website: https://github.com/edubart/otclient
|
||||
onLoad: |
|
||||
dofile 'healthbar'
|
47
modules/game_healthbar/healthbar.otui
Normal file
47
modules/game_healthbar/healthbar.otui
Normal file
@@ -0,0 +1,47 @@
|
||||
HealthBar < ProgressBar
|
||||
id: healthBar
|
||||
height: 15
|
||||
background-color: #ff4444
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
ManaBar < ProgressBar
|
||||
id: manaBar
|
||||
height: 15
|
||||
background-color: #4444ff
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
HealthLabel < GameLabel
|
||||
id: healthLabel
|
||||
color: white
|
||||
text-align: center
|
||||
font: verdana-11px-rounded
|
||||
anchors.fill: healthBar
|
||||
margin-top: 2
|
||||
text: 0 / 0
|
||||
|
||||
ManaLabel < GameLabel
|
||||
id: manaLabel
|
||||
color: white
|
||||
text-align: center
|
||||
font: verdana-11px-rounded
|
||||
anchors.fill: manaBar
|
||||
margin-top: 2
|
||||
text: 0 / 0
|
||||
|
||||
UIWindow
|
||||
id: healthManaPanel
|
||||
width: 192
|
||||
height: 34
|
||||
margin-top: 10
|
||||
margin-left: 6
|
||||
margin-right: 6
|
||||
move-policy: free updated
|
||||
|
||||
HealthBar
|
||||
HealthLabel
|
||||
ManaBar
|
||||
ManaLabel
|
BIN
modules/game_healthbar/healthbar.png
Normal file
BIN
modules/game_healthbar/healthbar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 238 B |
Reference in New Issue
Block a user