Update to cooldown panel

- Removed cooldowns from game interface
- Using UIProgressRect
This commit is contained in:
Samuel
2012-10-09 02:46:23 +02:00
parent 01993c133d
commit 286a0fea58
10 changed files with 214 additions and 129 deletions

View File

@@ -0,0 +1,93 @@
cooldownPanel = nil
spellCooldownPanel = nil
function init()
connect(g_game, { onGameStart = show,
onGameEnd = hide,
onSpellGroupCooldown = onSpellGroupCooldown,
onSpellCooldown = onSpellCooldown })
cooldownPanel = g_ui.displayUI('cooldown.otui')
cooldownPanel:hide()
spellCooldownPanel = cooldownPanel:getChildById('spellCooldownPanel')
if g_game.isOnline() then
show()
end
end
function terminate()
disconnect(g_game, { onGameStart = show,
onGameEnd = hide,
onSpellGroupCooldown = onSpellGroupCooldown,
onSpellCooldown = onSpellCooldown })
spellCooldownPanel:destroy()
cooldownPanel:destroy()
end
function show()
if g_game.getFeature(GameSpellList) then
cooldownPanel:show()
end
end
function hide()
cooldownPanel:hide()
end
function updateProgressRect(progressRect, interval, init)
if init then
progressRect:setPercent(0)
else
progressRect:setPercent(progressRect:getPercent() + 4)
end
if progressRect:getPercent() < 100 then
removeEvent(progressRect.event)
progressRect.event = scheduleEvent(function() updateProgressRect(progressRect, interval) end, interval)
end
end
function onSpellCooldown(iconId, duration)
local spellName = SpelllistSettings[modules.game_spelllist.getSpelllistProfile()].spellIcons[iconId]
if not spellName then return end
local otcIconId = tonumber(SpellInfo[modules.game_spelllist.getSpelllistProfile()][spellName].icon)
if not otcIconId and SpellIcons[SpellInfo[modules.game_spelllist.getSpelllistProfile()][spellName].icon] then
otcIconId = SpellIcons[SpellInfo[modules.game_spelllist.getSpelllistProfile()][spellName].icon][1]
end
if not otcIconId then return end
local icon = cooldownPanel:getChildById(spellName)
if not icon then
icon = g_ui.createWidget('SpellIcon', spellCooldownPanel)
icon:setId(spellName)
icon:setImageSource('/game_cooldown/icons/' .. SpelllistSettings[modules.game_spelllist.getSpelllistProfile()].iconFile)
icon:setTooltip(spellformula)
icon:setImageClip(modules.game_spelllist.getIconImageClip(otcIconId))
icon.event = scheduleEvent(function() icon:destroy() end, duration)
local progressRect = g_ui.createWidget('ProgressRect', icon)
updateProgressRect(progressRect, duration/25, true)
end
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])
if icon then
icon:setOn(true)
removeEvent(icon.event)
icon.event = scheduleEvent(function() icon:setOn(false) end, duration)
end
if progressRect then
removeEvent(progressRect.event)
updateProgressRect(progressRect, duration/25, true)
end
end

View File

@@ -0,0 +1,9 @@
Module
name: game_cooldown
description: Spellcooldowns
author: OTClient team
website: www.otclient.info
sandboxed: true
scripts: [ cooldown.lua ]
@onLoad: init()
@onUnload: terminate()

View File

@@ -0,0 +1,104 @@
SpellGroupIcon < UIWidget
size: 22 22
image-size: 22 22
image-source: /game_cooldown/icons/cooldownIcons.png
focusable: false
SpellIcon < UIWidget
size: 22 22
image-size: 22 22
margin-left: 2
anchors.top: prev.top
anchors.left: prev.right
focusable: false
$first:
margin-top: 3
anchors.top: parent.top
anchors.left: parent.left
ProgressRect < UIProgressRect
background: #585858AA
percent: 100
anchors.fill: parent
focusable: false
Panel
id: spellPanel
layout:
type: anchor
height: 28
width: 250
anchors.top: parent.top
anchors.left: parent.left
margin-top: 70
margin-left: 10
border-width: 1
border-color: #00000077
background-color: #ffffff11
focusable: false
SpellGroupIcon
id: groupIconAttack
image-clip: 0 0 20 20
anchors.top: parent.top
anchors.left: parent.left
margin-top: 3
margin-left: 3
$on:
image-clip: 0 20 20 20
ProgressRect
id: progressRectAttack
anchors.fill: groupIconAttack
!tooltip: tr('Attack')
SpellGroupIcon
id: groupIconHealing
image-clip: 20 0 20 20
anchors.top: parent.top
anchors.left: groupIconAttack.right
margin-top: 3
margin-left: 3
$on:
image-clip: 20 20 20 20
ProgressRect
id: progressRectHealing
anchors.fill: groupIconHealing
!tooltip: tr('Healing')
SpellGroupIcon
id: groupIconSupport
image-clip: 40 0 20 20
anchors.top: parent.top
anchors.left: groupIconHealing.right
margin-top: 3
margin-left: 3
$on:
image-clip: 40 20 20 20
ProgressRect
id: progressRectSupport
anchors.fill: groupIconSupport
!tooltip: tr('Support')
SpellGroupIcon
id: groupIconSpecial
image-clip: 60 0 20 20
anchors.top: parent.top
anchors.left: groupIconSupport.right
margin-top: 3
margin-left: 3
$on:
image-clip: 60 20 20 20
ProgressRect
id: progressRectSpecial
anchors.fill: groupIconSpecial
!tooltip: tr('Special')
Panel
id: spellCooldownPanel
anchors.fill: parent
margin-left: 102

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB