Mercurial > wow > inventory
diff Widgets.lua @ 74:8d11fc88ecab
Default summary width is now 700 pixels (up from 650).
Changed the item data table into a class which is now also used at the custom widgets.
author | Zerotorescue |
---|---|
date | Fri, 24 Dec 2010 21:55:11 +0100 |
parents | 6216b754350d |
children |
line wrap: on
line diff
--- a/Widgets.lua Fri Dec 24 16:10:20 2010 +0100 +++ b/Widgets.lua Fri Dec 24 21:55:11 2010 +0100 @@ -55,11 +55,11 @@ -- Set our own events, since we disabled the normal event-names, we'll call them our custom versions self:SetCallback("CustomOnEnter", function(this) - local itemId = this:GetUserData("itemId"); + local itemData = this:GetUserData("ItemData"); - if itemId then + if itemData then GameTooltip:SetOwner(this.frame, "ANCHOR_TOPRIGHT"); - GameTooltip:SetHyperlink(("item:%d"):format(itemId)); + GameTooltip:SetHyperlink(("item:%d"):format(itemData.id)); GameTooltip:Show(); end end); @@ -73,14 +73,14 @@ end local func = this:GetUserData("exec"); - local itemId = this:GetUserData("itemId"); + local itemData = this:GetUserData("ItemData"); if func then -- If this is a config option we will need the group id local path = this:GetUserData("path"); local groupId = (path and path[2]) or nil; - func(groupId, itemId, ...); + func(groupId, itemData, ...); end end); @@ -93,27 +93,11 @@ -- Remember the original SetText as this might get overwritten by the config-widget widget.originalSetText = widget.SetText; - widget.SetItemId = function(self, itemId) - self:SetUserData("itemId", itemId); + widget.SetItem = function(self, item) + self:SetUserData("ItemData", item); -- Put the icon in front of it - self:SetImage(GetItemIcon(itemId)); - -- Standardize the size - self:SetImageSize(16, 16); - - -- Make readable font - self:SetFontObject(GameFontHighlight); - - -- We don't want to set the itemId as text, but rather the item link, so get that. - local itemLink = select(2, GetItemInfo(itemId)) or ("Unknown (#%d)"):format(itemId); - - 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)); + self:SetImage(item.icon); -- Standardize the size self:SetImageSize(16, 16); @@ -132,7 +116,7 @@ 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); + local itemLink = item.link or ("Unknown (#%d)"):format(item.id); self:originalSetText(itemLink); end; @@ -166,7 +150,9 @@ -- Forward that itemId to the ItemLinkButton widget.SetText = function(self, value, ...) if value and tonumber(value) then - self:SetItemId(tonumber(value)); + local newItemData = addon.ItemData:New(tonumber(value)); + + self:SetItem(newItemData); end end;