Buffer condition/cooldown icons on module init

* This should hopefully avoid some lag with slow hdd computers
master
BeniS 11 years ago
parent 035ce26728
commit f4f9e319d8

@ -6,7 +6,7 @@ local ProgressCallback = {
cooldownWindow = nil
cooldownButton = nil
contentsPanel = nil
spellCooldownPanel = nil
cooldownPanel = nil
lastPlayer = nil
function init()
@ -23,7 +23,13 @@ function init()
cooldownWindow:setup()
contentsPanel = cooldownWindow:getChildById('contentsPanel')
spellCooldownPanel = contentsPanel:getChildById('spellCooldownPanel')
cooldownPanel = contentsPanel:getChildById('cooldownPanel')
-- load cooldown icons
local iconIds = Spells.getSpellIconIds()
for k,id in pairs(iconIds) do
loadIcon(id):destroy()
end
if g_game.isOnline() then
online()
@ -39,6 +45,24 @@ function terminate()
cooldownButton:destroy()
end
function loadIcon(iconId)
local spell, profile, spellName = Spells.getSpellByIcon(iconId)
if not spellName then return end
clientIconId = Spells.getClientId(spellName)
if not clientIconId then return end
local icon = cooldownPanel:getChildById(iconId)
if not icon then
icon = g_ui.createWidget('SpellIcon')
icon:setId(iconId)
end
icon:setImageSource('/images/game/spells/' .. SpelllistSettings[profile].iconFile)
icon:setImageClip(Spells.getImageClip(clientIconId, profile))
return icon
end
function onMiniWindowClose()
cooldownButton:setOn(false)
end
@ -68,7 +92,7 @@ function online()
end
function refresh()
spellCooldownPanel:destroyChildren()
cooldownPanel:destroyChildren()
end
function removeCooldown(progressRect)
@ -117,24 +141,16 @@ function updateCooldown(progressRect, interval)
end
function onSpellCooldown(iconId, duration)
local spell, profile, spellName = Spells.getSpellByIcon(iconId)
if not spellName then return end
clientIconId = Spells.getClientId(spellName)
if not clientIconId then return end
local icon = spellCooldownPanel:getChildById(spellName)
local icon = loadIcon(iconId)
if not icon then
icon = g_ui.createWidget('SpellIcon', spellCooldownPanel)
icon:setId(spellName)
return
end
icon:setImageSource('/images/game/spells/' .. SpelllistSettings[profile].iconFile)
icon:setImageClip(Spells.getImageClip(clientIconId, profile))
icon:setParent(cooldownPanel)
local progressRect = icon:getChildById(spellName)
local progressRect = icon:getChildById(iconId)
if not progressRect then
progressRect = g_ui.createWidget('SpellProgressRect', icon)
progressRect:setId(spellName)
progressRect:setId(iconId)
progressRect.icon = icon
progressRect:fill('parent')
else

@ -87,7 +87,7 @@ MiniWindow
!tooltip: tr('Special')
Panel
id: spellCooldownPanel
id: cooldownPanel
layout:
type: horizontalBox
height: 30
@ -98,4 +98,3 @@ MiniWindow
anchors.right: parent.right
background-color: #ffffff11

@ -48,6 +48,11 @@ function init()
soulLabel = healthInfoWindow:recursiveGetChildById('soulLabel')
capLabel = healthInfoWindow:recursiveGetChildById('capLabel')
-- load condition icons
for k,v in pairs(Icons) do
loadIcon(k):destroy()
end
if g_game.isOnline() then
local localPlayer = g_game.getLocalPlayer()
onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
@ -92,13 +97,19 @@ function toggleIcon(bitChanged)
if icon then
icon:destroy()
else
icon = g_ui.createWidget('ConditionWidget', content)
icon:setId(Icons[bitChanged].id)
icon:setImageSource(Icons[bitChanged].path)
icon:setTooltip(Icons[bitChanged].tooltip)
icon = loadIcon(bitChanged)
icon:setParent(content)
end
end
function loadIcon(bitChanged)
local icon = g_ui.createWidget('ConditionWidget', content)
icon:setId(Icons[bitChanged].id)
icon:setImageSource(Icons[bitChanged].path)
icon:setTooltip(Icons[bitChanged].tooltip)
return icon
end
function offline()
healthInfoWindow:recursiveGetChildById('conditionPanel'):destroyChildren()
end

@ -361,6 +361,16 @@ function Spells.getSpellByIcon(iconId)
return nil
end
function Spells.getSpellIconIds()
local ids = {}
for profile,data in pairs(SpellInfo) do
for k,spell in pairs(data) do
table.insert(ids, spell.id)
end
end
return ids
end
function Spells.getSpellProfileByWords(words)
for profile,data in pairs(SpellInfo) do
for k,spell in pairs(data) do

Loading…
Cancel
Save