comparison 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
comparison
equal deleted inserted replaced
72:7ca83ad9d67a 73:6216b754350d
107 -- We don't want to set the itemId as text, but rather the item link, so get that. 107 -- We don't want to set the itemId as text, but rather the item link, so get that.
108 local itemLink = select(2, GetItemInfo(itemId)) or ("Unknown (#%d)"):format(itemId); 108 local itemLink = select(2, GetItemInfo(itemId)) or ("Unknown (#%d)"):format(itemId);
109 109
110 self:originalSetText(itemLink); 110 self:originalSetText(itemLink);
111 end; 111 end;
112 widget.SetItem = function(self, item)
113 self:SetUserData("itemId", item.id);
114
115 -- Put the icon in front of it
116 self:SetImage(GetItemIcon(item.id));
117 -- Standardize the size
118 self:SetImageSize(16, 16);
119
120 -- Make readable font
121 self:SetFontObject(GameFontHighlight);
122
123 if not item.link then
124 -- If no item link was cached, give it another try
125
126 local itemName, itemLink, itemRarity = GetItemInfo(item.id);
127
128 -- item is a table, so passed by reference, so updatable
129 item.name = itemName;
130 item.link = itemLink;
131 item.rarity = itemRarity;
132 end
133
134 -- We don't want to set the itemId as text, but rather the item link, so get that.
135 local itemLink = item.link or ("Unknown (#%d)"):format(itemId);
136
137 self:originalSetText(itemLink);
138 end;
112 139
113 return widget; 140 return widget;
114 end 141 end
115 142
116 AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion); 143 AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion);