Buffer condition/cooldown icons on module init
* This should hopefully avoid some lag with slow hdd computers
This commit is contained in:
parent
035ce26728
commit
f4f9e319d8
|
@ -6,7 +6,7 @@ local ProgressCallback = {
|
||||||
cooldownWindow = nil
|
cooldownWindow = nil
|
||||||
cooldownButton = nil
|
cooldownButton = nil
|
||||||
contentsPanel = nil
|
contentsPanel = nil
|
||||||
spellCooldownPanel = nil
|
cooldownPanel = nil
|
||||||
lastPlayer = nil
|
lastPlayer = nil
|
||||||
|
|
||||||
function init()
|
function init()
|
||||||
|
@ -23,7 +23,13 @@ function init()
|
||||||
cooldownWindow:setup()
|
cooldownWindow:setup()
|
||||||
|
|
||||||
contentsPanel = cooldownWindow:getChildById('contentsPanel')
|
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
|
if g_game.isOnline() then
|
||||||
online()
|
online()
|
||||||
|
@ -39,6 +45,24 @@ function terminate()
|
||||||
cooldownButton:destroy()
|
cooldownButton:destroy()
|
||||||
end
|
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()
|
function onMiniWindowClose()
|
||||||
cooldownButton:setOn(false)
|
cooldownButton:setOn(false)
|
||||||
end
|
end
|
||||||
|
@ -68,7 +92,7 @@ function online()
|
||||||
end
|
end
|
||||||
|
|
||||||
function refresh()
|
function refresh()
|
||||||
spellCooldownPanel:destroyChildren()
|
cooldownPanel:destroyChildren()
|
||||||
end
|
end
|
||||||
|
|
||||||
function removeCooldown(progressRect)
|
function removeCooldown(progressRect)
|
||||||
|
@ -117,24 +141,16 @@ function updateCooldown(progressRect, interval)
|
||||||
end
|
end
|
||||||
|
|
||||||
function onSpellCooldown(iconId, duration)
|
function onSpellCooldown(iconId, duration)
|
||||||
local spell, profile, spellName = Spells.getSpellByIcon(iconId)
|
local icon = loadIcon(iconId)
|
||||||
if not spellName then return end
|
|
||||||
|
|
||||||
clientIconId = Spells.getClientId(spellName)
|
|
||||||
if not clientIconId then return end
|
|
||||||
|
|
||||||
local icon = spellCooldownPanel:getChildById(spellName)
|
|
||||||
if not icon then
|
if not icon then
|
||||||
icon = g_ui.createWidget('SpellIcon', spellCooldownPanel)
|
return
|
||||||
icon:setId(spellName)
|
|
||||||
end
|
end
|
||||||
icon:setImageSource('/images/game/spells/' .. SpelllistSettings[profile].iconFile)
|
icon:setParent(cooldownPanel)
|
||||||
icon:setImageClip(Spells.getImageClip(clientIconId, profile))
|
|
||||||
|
|
||||||
local progressRect = icon:getChildById(spellName)
|
local progressRect = icon:getChildById(iconId)
|
||||||
if not progressRect then
|
if not progressRect then
|
||||||
progressRect = g_ui.createWidget('SpellProgressRect', icon)
|
progressRect = g_ui.createWidget('SpellProgressRect', icon)
|
||||||
progressRect:setId(spellName)
|
progressRect:setId(iconId)
|
||||||
progressRect.icon = icon
|
progressRect.icon = icon
|
||||||
progressRect:fill('parent')
|
progressRect:fill('parent')
|
||||||
else
|
else
|
||||||
|
|
|
@ -87,7 +87,7 @@ MiniWindow
|
||||||
!tooltip: tr('Special')
|
!tooltip: tr('Special')
|
||||||
|
|
||||||
Panel
|
Panel
|
||||||
id: spellCooldownPanel
|
id: cooldownPanel
|
||||||
layout:
|
layout:
|
||||||
type: horizontalBox
|
type: horizontalBox
|
||||||
height: 30
|
height: 30
|
||||||
|
@ -98,4 +98,3 @@ MiniWindow
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
background-color: #ffffff11
|
background-color: #ffffff11
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,11 @@ function init()
|
||||||
soulLabel = healthInfoWindow:recursiveGetChildById('soulLabel')
|
soulLabel = healthInfoWindow:recursiveGetChildById('soulLabel')
|
||||||
capLabel = healthInfoWindow:recursiveGetChildById('capLabel')
|
capLabel = healthInfoWindow:recursiveGetChildById('capLabel')
|
||||||
|
|
||||||
|
-- load condition icons
|
||||||
|
for k,v in pairs(Icons) do
|
||||||
|
loadIcon(k):destroy()
|
||||||
|
end
|
||||||
|
|
||||||
if g_game.isOnline() then
|
if g_game.isOnline() then
|
||||||
local localPlayer = g_game.getLocalPlayer()
|
local localPlayer = g_game.getLocalPlayer()
|
||||||
onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
|
onHealthChange(localPlayer, localPlayer:getHealth(), localPlayer:getMaxHealth())
|
||||||
|
@ -92,11 +97,17 @@ function toggleIcon(bitChanged)
|
||||||
if icon then
|
if icon then
|
||||||
icon:destroy()
|
icon:destroy()
|
||||||
else
|
else
|
||||||
icon = g_ui.createWidget('ConditionWidget', content)
|
icon = loadIcon(bitChanged)
|
||||||
|
icon:setParent(content)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function loadIcon(bitChanged)
|
||||||
|
local icon = g_ui.createWidget('ConditionWidget', content)
|
||||||
icon:setId(Icons[bitChanged].id)
|
icon:setId(Icons[bitChanged].id)
|
||||||
icon:setImageSource(Icons[bitChanged].path)
|
icon:setImageSource(Icons[bitChanged].path)
|
||||||
icon:setTooltip(Icons[bitChanged].tooltip)
|
icon:setTooltip(Icons[bitChanged].tooltip)
|
||||||
end
|
return icon
|
||||||
end
|
end
|
||||||
|
|
||||||
function offline()
|
function offline()
|
||||||
|
|
|
@ -361,6 +361,16 @@ function Spells.getSpellByIcon(iconId)
|
||||||
return nil
|
return nil
|
||||||
end
|
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)
|
function Spells.getSpellProfileByWords(words)
|
||||||
for profile,data in pairs(SpellInfo) do
|
for profile,data in pairs(SpellInfo) do
|
||||||
for k,spell in pairs(data) do
|
for k,spell in pairs(data) do
|
||||||
|
|
Loading…
Reference in New Issue