Quantcast

Query uncached items to make sure the texture is displayed

Adrian L Lange [06-17-13 - 00:30]
Query uncached items to make sure the texture is displayed
Filename
Config.lua
diff --git a/Config.lua b/Config.lua
index 841a222..481d3bc 100644
--- a/Config.lua
+++ b/Config.lua
@@ -365,12 +365,12 @@ FilterPanel:SetScript('OnShow', function(self)

 				local Texture = Button:CreateTexture(nil, 'ARTWORK')
 				Texture:SetAllPoints()
-				Texture:SetTexture(select(10, GetItemInfo(item)))

 				Button:SetScript('OnClick', FilterItemOnClick)
 				Button:SetScript('OnEnter', FilterItemOnEnter)
 				Button:SetScript('OnLeave', GameTooltip_Hide)

+				Button.Texture = Texture
 				Button.questID = quest
 				Button.itemID = item

@@ -378,6 +378,17 @@ FilterPanel:SetScript('OnShow', function(self)
 			end
 		end

+		local queryItems
+		for item, Button in pairs(filterItems) do
+			local _, _, _, _, _, _, _, _, _, textureFile = GetItemInfo(item)
+			if(textureFile) then
+				Button.Texture:SetTexture(textureFile)
+			elseif(not queryItems) then
+				self:RegisterEvent('GET_ITEM_INFO_RECEIVED')
+				queryItems = true
+			end
+		end
+
 		local index = 1
 		local width = FilterBounds:GetWidth()
 		local cols = math.floor((width > 0 and width or 591) / 36)
@@ -388,6 +399,10 @@ FilterPanel:SetScript('OnShow', function(self)

 			index = index + 1
 		end
+
+		if(not queryItems) then
+			self:UnregisterEvent('GET_ITEM_INFO_RECEIVED')
+		end
 	end

 	UpdateFilterBox()
@@ -416,6 +431,12 @@ FilterPanel:SetScript('OnShow', function(self)
 	self:SetScript('OnShow', nil)
 end)

+FilterPanel:HookScript('OnEvent', function(self, event)
+	if(event == 'GET_ITEM_INFO_RECEIVED') then
+		UpdateFilterBox()
+	end
+end)
+
 InterfaceOptions_AddCategory(Panel)
 InterfaceOptions_AddCategory(FilterPanel)