add conditions viewer below healthbar, fix hotkeys autosend
|
@ -1,5 +1,23 @@
|
|||
HealthBar = {}
|
||||
|
||||
-- constants
|
||||
local Icons = {}
|
||||
Icons[1] = { tooltip = 'You are poisoned', path = '/game_healthbar/icons/poisoned.png', id = 'condition_poisoned' }
|
||||
Icons[2] = { tooltip = 'You are burning', path = '/game_healthbar/icons/burning.png', id = 'condition_burning' }
|
||||
Icons[4] = { tooltip = 'You are electrified', path = '/game_healthbar/icons/electrified.png', id = 'condition_electrified' }
|
||||
Icons[8] = { tooltip = 'You are freezing', path = '/game_healthbar/icons/drunk.png', id = 'condition_drunk' }
|
||||
Icons[16] = { tooltip = 'You are protected by a magic shield', path = '/game_healthbar/icons/magic_shield.png', id = 'condition_magic_shield' }
|
||||
Icons[32] = { tooltip = 'You are paralysed', path = '/game_healthbar/icons/slowed.png', id = 'condition_slowed' }
|
||||
Icons[64] = { tooltip = 'You are hasted', path = '/game_healthbar/icons/haste.png', id = 'condition_haste' }
|
||||
Icons[128] = { tooltip = 'You may not logout during a fight', path = '/game_healthbar/icons/logout_block.png', id = 'condition_logout_block' }
|
||||
Icons[256] = { tooltip = 'You are drowing', path = '/game_healthbar/icons/drowning.png', id = 'condition_drowning' }
|
||||
Icons[512] = { tooltip = 'You are freezing', path = '/game_healthbar/icons/freezing.png', id = 'condition_freezing' }
|
||||
Icons[1024] = { tooltip = 'You are dazzled', path = '/game_healthbar/icons/dazzled.png', id = 'condition_dazzled' }
|
||||
Icons[2048] = { tooltip = 'You are cursed', path = '/game_healthbar/icons/cursed.png', id = 'condition_cursed' }
|
||||
Icons[4096] = { tooltip = 'You are strenghtened', path = '/game_healthbar/icons/strengthened.png', id = 'condition_strengthened' }
|
||||
Icons[8192] = { tooltip = 'You may not logout or enter a protection zone', path = '/game_healthbar/icons/protection_zone_block.png', id = 'condition_protection_zone_block' }
|
||||
Icons[16384] = { tooltip = 'You are within a protection zone', path = '/game_healthbar/icons/protection_zone.png', id = 'condition_protection_zone' }
|
||||
|
||||
-- private variables
|
||||
local healthBarWindow
|
||||
local healthBar
|
||||
|
@ -10,7 +28,10 @@ local manaLabel
|
|||
-- public functions
|
||||
function HealthBar.init()
|
||||
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
|
||||
onManaChange = HealthBar.onManaChange })
|
||||
onManaChange = HealthBar.onManaChange,
|
||||
onStatesChange = HealthBar.onStatesChange })
|
||||
|
||||
connect(g_game, { onGameEnd = HealthBar.offline })
|
||||
|
||||
healthBarWindow = displayUI('healthbar.otui', GameInterface.getLeftPanel())
|
||||
healthBarButton = TopMenu.addGameToggleButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
|
||||
|
@ -29,7 +50,10 @@ end
|
|||
|
||||
function HealthBar.terminate()
|
||||
disconnect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
|
||||
onManaChange = HealthBar.onManaChange })
|
||||
onManaChange = HealthBar.onManaChange,
|
||||
onStatesChange = HealthBar.onStatesChange })
|
||||
|
||||
disconnect(g_game, { onGameEnd = HealthBar.offline })
|
||||
|
||||
healthBarWindow:destroy()
|
||||
healthBarButton:destroy()
|
||||
|
@ -65,3 +89,34 @@ function HealthBar.onManaChange(localPlayer, mana, maxMana)
|
|||
manaBar:setPercent(percent)
|
||||
end
|
||||
|
||||
function HealthBar.onStatesChange(localPlayer, now, old)
|
||||
local bitsChanged = bit32.bxor(now, old)
|
||||
for i = 1, 32 do
|
||||
if i > bitsChanged then break end
|
||||
local bitChanged = bit32.band(bitsChanged, math.pow(2, i))
|
||||
if bitChanged ~= 0 then
|
||||
HealthBar.toggleIcon(bitChanged)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function HealthBar.toggleIcon(bitChanged)
|
||||
local content = healthBarWindow:recursiveGetChildById('conditions_content')
|
||||
|
||||
local icon = content:getChildById(Icons[bitChanged].id)
|
||||
if icon then
|
||||
icon:destroy()
|
||||
else
|
||||
icon = createWidget('ConditionWidget', content)
|
||||
icon:setId(Icons[bitChanged].id)
|
||||
icon:setImageSource(Icons[bitChanged].path)
|
||||
icon:setTooltip(Icons[bitChanged].tooltip)
|
||||
end
|
||||
end
|
||||
|
||||
function HealthBar.offline()
|
||||
local conditionsContent = healthBarWindow:recursiveGetChildById('conditions_content')
|
||||
local count = conditionsContent:getChildCount()
|
||||
for i = count, 1, -1 do conditionsContent:getChildByIndex(i):destroy() end
|
||||
end
|
||||
|
||||
|
|
|
@ -33,11 +33,17 @@ ManaLabel < GameLabel
|
|||
margin-top: 2
|
||||
text: 0 / 0
|
||||
|
||||
ConditionWidget < UIWidget
|
||||
size: 18 18
|
||||
|
||||
$!first:
|
||||
margin-left: 5
|
||||
|
||||
MiniWindow
|
||||
icon: healthbar.png
|
||||
id: healthBarWindow
|
||||
text: Health Bar
|
||||
height: 64
|
||||
height: 86
|
||||
@onClose: HealthBar.toggle()
|
||||
|
||||
MiniWindowContents
|
||||
|
@ -45,3 +51,13 @@ MiniWindow
|
|||
HealthLabel
|
||||
ManaBar
|
||||
ManaLabel
|
||||
Panel
|
||||
id: conditions_content
|
||||
layout:
|
||||
type: horizontalBox
|
||||
fit-children: true
|
||||
height: 18
|
||||
margin-top: 5
|
||||
anchors.top: prev.bottom
|
||||
anchors.horizontalcenter: parent.horizontalcenter
|
||||
|
||||
|
|
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 933 B |
After Width: | Height: | Size: 445 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 894 B |
After Width: | Height: | Size: 912 B |
After Width: | Height: | Size: 957 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 570 B |
After Width: | Height: | Size: 898 B |
After Width: | Height: | Size: 909 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 628 B |
After Width: | Height: | Size: 1.4 KiB |
|
@ -321,6 +321,7 @@ function HotkeysManager.checkSelectedHotkey(focused)
|
|||
hotkeyText:setText(hotkeyLabelSelectedOnList.value)
|
||||
|
||||
if hotkeyLabelSelectedOnList.value ~= '' then
|
||||
sendAutomatically:setChecked(hotkeyLabelSelectedOnList.autoSend)
|
||||
sendAutomatically:enable()
|
||||
else
|
||||
sendAutomatically:disable()
|
||||
|
@ -431,7 +432,7 @@ function HotkeysManager.onHotkeyTextChange(id, value)
|
|||
else
|
||||
sendAutomatically:disable()
|
||||
sendAutomatically:setChecked(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|