add conditions viewer below healthbar, fix hotkeys autosend

This commit is contained in:
AndreFaramir 2012-03-29 18:46:21 -03:00
parent 6ace984440
commit fd2bc9fb77
20 changed files with 76 additions and 4 deletions

View File

@ -1,5 +1,23 @@
HealthBar = {} 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 -- private variables
local healthBarWindow local healthBarWindow
local healthBar local healthBar
@ -10,7 +28,10 @@ local manaLabel
-- public functions -- public functions
function HealthBar.init() function HealthBar.init()
connect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange, 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()) healthBarWindow = displayUI('healthbar.otui', GameInterface.getLeftPanel())
healthBarButton = TopMenu.addGameToggleButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle) healthBarButton = TopMenu.addGameToggleButton('healthBarButton', 'Healh Bar', 'healthbar.png', HealthBar.toggle)
@ -29,7 +50,10 @@ end
function HealthBar.terminate() function HealthBar.terminate()
disconnect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange, disconnect(LocalPlayer, { onHealthChange = HealthBar.onHealthChange,
onManaChange = HealthBar.onManaChange }) onManaChange = HealthBar.onManaChange,
onStatesChange = HealthBar.onStatesChange })
disconnect(g_game, { onGameEnd = HealthBar.offline })
healthBarWindow:destroy() healthBarWindow:destroy()
healthBarButton:destroy() healthBarButton:destroy()
@ -65,3 +89,34 @@ function HealthBar.onManaChange(localPlayer, mana, maxMana)
manaBar:setPercent(percent) manaBar:setPercent(percent)
end 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

View File

@ -33,11 +33,17 @@ ManaLabel < GameLabel
margin-top: 2 margin-top: 2
text: 0 / 0 text: 0 / 0
ConditionWidget < UIWidget
size: 18 18
$!first:
margin-left: 5
MiniWindow MiniWindow
icon: healthbar.png icon: healthbar.png
id: healthBarWindow id: healthBarWindow
text: Health Bar text: Health Bar
height: 64 height: 86
@onClose: HealthBar.toggle() @onClose: HealthBar.toggle()
MiniWindowContents MiniWindowContents
@ -45,3 +51,13 @@ MiniWindow
HealthLabel HealthLabel
ManaBar ManaBar
ManaLabel ManaLabel
Panel
id: conditions_content
layout:
type: horizontalBox
fit-children: true
height: 18
margin-top: 5
anchors.top: prev.bottom
anchors.horizontalcenter: parent.horizontalcenter

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 912 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 905 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 898 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -321,6 +321,7 @@ function HotkeysManager.checkSelectedHotkey(focused)
hotkeyText:setText(hotkeyLabelSelectedOnList.value) hotkeyText:setText(hotkeyLabelSelectedOnList.value)
if hotkeyLabelSelectedOnList.value ~= '' then if hotkeyLabelSelectedOnList.value ~= '' then
sendAutomatically:setChecked(hotkeyLabelSelectedOnList.autoSend)
sendAutomatically:enable() sendAutomatically:enable()
else else
sendAutomatically:disable() sendAutomatically:disable()