From 039c3072dcd74f81d73e0e804300d2a51bffb06a Mon Sep 17 00:00:00 2001 From: BeniS Date: Sat, 23 Feb 2013 19:16:42 +1300 Subject: [PATCH] Preload properly with g_textures.preload * Thanks Baxnie for advising me of this method :) --- modules/game_cooldown/cooldown.lua | 9 ++++----- modules/game_healthinfo/healthinfo.lua | 2 +- modules/gamelib/spells.lua | 11 +++++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/modules/game_cooldown/cooldown.lua b/modules/game_cooldown/cooldown.lua index 0195da2e..24efc583 100644 --- a/modules/game_cooldown/cooldown.lua +++ b/modules/game_cooldown/cooldown.lua @@ -25,10 +25,9 @@ function init() contentsPanel = cooldownWindow:getChildById('contentsPanel') cooldownPanel = contentsPanel:getChildById('cooldownPanel') - -- load cooldown icons - local iconIds = Spells.getSpellIconIds() - for k,id in pairs(iconIds) do - loadIcon(id):destroy() + -- preload cooldown images + for k,v in pairs(SpelllistSettings) do + g_textures.preload(v.iconFile) end if g_game.isOnline() then @@ -58,7 +57,7 @@ function loadIcon(iconId) icon:setId(iconId) end - icon:setImageSource('/images/game/spells/' .. SpelllistSettings[profile].iconFile) + icon:setImageSource('/images/game/spells/'..SpelllistSettings[profile].iconFile) icon:setImageClip(Spells.getImageClip(clientIconId, profile)) return icon end diff --git a/modules/game_healthinfo/healthinfo.lua b/modules/game_healthinfo/healthinfo.lua index 330b4a60..78e7e2ef 100644 --- a/modules/game_healthinfo/healthinfo.lua +++ b/modules/game_healthinfo/healthinfo.lua @@ -50,7 +50,7 @@ function init() -- load condition icons for k,v in pairs(Icons) do - loadIcon(k):destroy() + g_textures.preload(v.path) end if g_game.isOnline() then diff --git a/modules/gamelib/spells.lua b/modules/gamelib/spells.lua index 24935c4b..09c3b993 100644 --- a/modules/gamelib/spells.lua +++ b/modules/gamelib/spells.lua @@ -371,6 +371,17 @@ function Spells.getSpellIconIds() return ids end +function Spells.getSpellProfileById(id) + for profile,data in pairs(SpellInfo) do + for k,spell in pairs(data) do + if spell.id == id then + return profile + end + end + end + return nil +end + function Spells.getSpellProfileByWords(words) for profile,data in pairs(SpellInfo) do for k,spell in pairs(data) do