diff Widgets.lua @ 73:6216b754350d

Default size for the summary window increase to 700 pixels (from 650). Cached item name and rarity no longer have a default and will be nil if the value is unknown. Cached item name, rarity and link can now be updated when the itemlink element is build. Item element now gets the item table passed rather than just the item id. If the item link is already known, this prevent an additional GetItemInfo call.
author Zerotorescue
date Fri, 24 Dec 2010 16:10:20 +0100
parents fee06221176f
children 8d11fc88ecab
line wrap: on
line diff
--- a/Widgets.lua	Thu Dec 23 18:33:05 2010 +0100
+++ b/Widgets.lua	Fri Dec 24 16:10:20 2010 +0100
@@ -109,6 +109,33 @@
     		
     		self:originalSetText(itemLink);
 	    end;
+	    widget.SetItem = function(self, item)
+ 		   	self:SetUserData("itemId", item.id);
+ 		   	
+	   		-- Put the icon in front of it
+			self:SetImage(GetItemIcon(item.id));
+			-- Standardize the size
+			self:SetImageSize(16, 16);
+    		
+			-- Make readable font
+    		self:SetFontObject(GameFontHighlight);
+    		
+    		if not item.link then
+    			-- If no item link was cached, give it another try
+    			
+				local itemName, itemLink, itemRarity = GetItemInfo(item.id);
+    			
+				-- item is a table, so passed by reference, so updatable
+				item.name = itemName;
+				item.link = itemLink;
+				item.rarity = itemRarity;
+    		end
+    		
+    		-- We don't want to set the itemId as text, but rather the item link, so get that.
+    		local itemLink = item.link or ("Unknown (#%d)"):format(itemId);
+    		
+    		self:originalSetText(itemLink);
+	    end;
 		
 		return widget;
 	end