Converted cooldownbar to miniwindow

This commit is contained in:
Samuel
2012-10-13 21:33:04 +02:00
parent 053d29a64b
commit 7f864003d8
5 changed files with 106 additions and 84 deletions

View File

@@ -1,4 +1,6 @@
cooldownPanel = nil
cooldownWindow = nil
cooldownButton = nil
contentsPanel = nil
spellCooldownPanel = nil
function init()
@@ -7,11 +9,17 @@ function init()
onSpellGroupCooldown = onSpellGroupCooldown,
onSpellCooldown = onSpellCooldown })
cooldownPanel = g_ui.displayUI('cooldown.otui')
cooldownPanel:hide()
spellCooldownPanel = cooldownPanel:getChildById('spellCooldownPanel')
cooldownButton = TopMenu.addRightGameToggleButton('cooldownButton', tr('Cooldowns'), 'cooldown.png', toggle)
cooldownButton:setOn(true)
cooldownButton:hide()
cooldownWindow = g_ui.loadUI('cooldown.otui', modules.game_interface.getRightPanel())
cooldownWindow:disableResize()
cooldownWindow:setup()
contentsPanel = cooldownWindow:getChildById('contentsPanel')
spellCooldownPanel = contentsPanel:getChildById('spellCooldownPanel')
if g_game.isOnline() then
show()
end
@@ -23,18 +31,34 @@ function terminate()
onSpellGroupCooldown = onSpellGroupCooldown,
onSpellCooldown = onSpellCooldown })
spellCooldownPanel:destroy()
cooldownPanel:destroy()
cooldownButton:destroy()
cooldownWindow:destroy()
end
function onMiniWindowClose()
cooldownButton:setOn(false)
end
function toggle()
if cooldownButton:isOn() then
cooldownWindow:close()
cooldownButton:setOn(false)
else
cooldownWindow:open()
cooldownButton:setOn(true)
end
end
function show()
if g_game.getFeature(GameSpellList) then
cooldownPanel:show()
cooldownWindow:show()
cooldownButton:show()
end
end
function hide()
cooldownPanel:hide()
cooldownWindow:hide()
cooldownButton:hide()
end
function updateProgressRect(progressRect, interval, init)
@@ -61,7 +85,7 @@ function onSpellCooldown(iconId, duration)
if not otcIconId then return end
local icon = cooldownPanel:getChildById(spellName)
local icon = spellCooldownPanel:getChildById(spellName)
if not icon then
icon = g_ui.createWidget('SpellIcon', spellCooldownPanel)
icon:setId(spellName)
@@ -78,8 +102,8 @@ end
function onSpellGroupCooldown(groupId, duration)
if not SpellGroups[groupId] then return end
local icon = cooldownPanel:getChildById('groupIcon' .. SpellGroups[groupId])
local progressRect = cooldownPanel:getChildById('progressRect' .. SpellGroups[groupId])
local icon = contentsPanel:getChildById('groupIcon' .. SpellGroups[groupId])
local progressRect = contentsPanel:getChildById('progressRect' .. SpellGroups[groupId])
if icon then
icon:setOn(true)
removeEvent(icon.event)