diff --git a/modules/game_healthbar/healthbar.lua b/modules/game_healthbar/healthbar.lua index bc861cb8..9fb144fc 100644 --- a/modules/game_healthbar/healthbar.lua +++ b/modules/game_healthbar/healthbar.lua @@ -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 + diff --git a/modules/game_healthbar/healthbar.otui b/modules/game_healthbar/healthbar.otui index d687bb4d..bdeb2d37 100644 --- a/modules/game_healthbar/healthbar.otui +++ b/modules/game_healthbar/healthbar.otui @@ -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 + diff --git a/modules/game_healthbar/icons/bleeding.png b/modules/game_healthbar/icons/bleeding.png new file mode 100644 index 00000000..024ee7e1 Binary files /dev/null and b/modules/game_healthbar/icons/bleeding.png differ diff --git a/modules/game_healthbar/icons/burning.png b/modules/game_healthbar/icons/burning.png new file mode 100644 index 00000000..9d503ca9 Binary files /dev/null and b/modules/game_healthbar/icons/burning.png differ diff --git a/modules/game_healthbar/icons/cursed.png b/modules/game_healthbar/icons/cursed.png new file mode 100644 index 00000000..6171bd92 Binary files /dev/null and b/modules/game_healthbar/icons/cursed.png differ diff --git a/modules/game_healthbar/icons/dazzled.png b/modules/game_healthbar/icons/dazzled.png new file mode 100644 index 00000000..01e42acc Binary files /dev/null and b/modules/game_healthbar/icons/dazzled.png differ diff --git a/modules/game_healthbar/icons/drowning.png b/modules/game_healthbar/icons/drowning.png new file mode 100644 index 00000000..88c4dadc Binary files /dev/null and b/modules/game_healthbar/icons/drowning.png differ diff --git a/modules/game_healthbar/icons/drunk.png b/modules/game_healthbar/icons/drunk.png new file mode 100644 index 00000000..e83af44a Binary files /dev/null and b/modules/game_healthbar/icons/drunk.png differ diff --git a/modules/game_healthbar/icons/electrified.png b/modules/game_healthbar/icons/electrified.png new file mode 100644 index 00000000..38e67a8e Binary files /dev/null and b/modules/game_healthbar/icons/electrified.png differ diff --git a/modules/game_healthbar/icons/freezing.png b/modules/game_healthbar/icons/freezing.png new file mode 100644 index 00000000..04acfb04 Binary files /dev/null and b/modules/game_healthbar/icons/freezing.png differ diff --git a/modules/game_healthbar/icons/haste.png b/modules/game_healthbar/icons/haste.png new file mode 100644 index 00000000..9f39a968 Binary files /dev/null and b/modules/game_healthbar/icons/haste.png differ diff --git a/modules/game_healthbar/icons/hungry.png b/modules/game_healthbar/icons/hungry.png new file mode 100644 index 00000000..829e1911 Binary files /dev/null and b/modules/game_healthbar/icons/hungry.png differ diff --git a/modules/game_healthbar/icons/logout_block.png b/modules/game_healthbar/icons/logout_block.png new file mode 100644 index 00000000..4244dfe3 Binary files /dev/null and b/modules/game_healthbar/icons/logout_block.png differ diff --git a/modules/game_healthbar/icons/magic_shield.png b/modules/game_healthbar/icons/magic_shield.png new file mode 100644 index 00000000..4286a01e Binary files /dev/null and b/modules/game_healthbar/icons/magic_shield.png differ diff --git a/modules/game_healthbar/icons/poisoned.png b/modules/game_healthbar/icons/poisoned.png new file mode 100644 index 00000000..3aae9ccd Binary files /dev/null and b/modules/game_healthbar/icons/poisoned.png differ diff --git a/modules/game_healthbar/icons/protection_zone.png b/modules/game_healthbar/icons/protection_zone.png new file mode 100644 index 00000000..741f4df2 Binary files /dev/null and b/modules/game_healthbar/icons/protection_zone.png differ diff --git a/modules/game_healthbar/icons/protection_zone_Block.png b/modules/game_healthbar/icons/protection_zone_Block.png new file mode 100644 index 00000000..47bcade8 Binary files /dev/null and b/modules/game_healthbar/icons/protection_zone_Block.png differ diff --git a/modules/game_healthbar/icons/slowed.png b/modules/game_healthbar/icons/slowed.png new file mode 100644 index 00000000..b1ab2405 Binary files /dev/null and b/modules/game_healthbar/icons/slowed.png differ diff --git a/modules/game_healthbar/icons/strengthened.png b/modules/game_healthbar/icons/strengthened.png new file mode 100644 index 00000000..29e827dd Binary files /dev/null and b/modules/game_healthbar/icons/strengthened.png differ diff --git a/modules/game_hotkeys/hotkeys_manager.lua b/modules/game_hotkeys/hotkeys_manager.lua index 1058d711..e611c6d1 100644 --- a/modules/game_hotkeys/hotkeys_manager.lua +++ b/modules/game_hotkeys/hotkeys_manager.lua @@ -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