Buffer condition/cooldown icons on module init

* This should hopefully avoid some lag with slow hdd computers
This commit is contained in:
BeniS
2013-02-23 18:53:27 +13:00
parent 035ce26728
commit f4f9e319d8
4 changed files with 58 additions and 22 deletions

View File

@@ -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