Mercurial > wow > askmrrobot
comparison ui/ItemIcon.lua @ 0:ec731d2fe6ba
Version 1.2.12.0
author | Adam tegen <adam.tegen@gmail.com> |
---|---|
date | Tue, 20 May 2014 21:43:23 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ec731d2fe6ba |
---|---|
1 local _, AskMrRobot = ... | |
2 | |
3 -- initialize the ItemIcon class (inherit from a dummy frame) | |
4 AskMrRobot.ItemIcon = AskMrRobot.inheritsFrom(AskMrRobot.ItemTooltipFrame) | |
5 | |
6 -- item icon contructor | |
7 function AskMrRobot.ItemIcon:new(name, parent) | |
8 -- create a new frame (if one isn't supplied) | |
9 local o = AskMrRobot.ItemTooltipFrame:new(name, parent) | |
10 | |
11 -- use the ItemIcon class | |
12 setmetatable(o, { __index = AskMrRobot.ItemIcon }) | |
13 | |
14 -- the item icon | |
15 o.itemIcon = o:CreateTexture(nil, "BACKGROUND") | |
16 o.itemIcon:SetPoint("TOPLEFT") | |
17 o.itemIcon:SetPoint("BOTTOMRIGHT") | |
18 | |
19 -- return the instance of the ItemIcon | |
20 return o | |
21 end | |
22 | |
23 function AskMrRobot.ItemIcon:SetRoundBorder() | |
24 self:SetBackdrop({edgeFile = "Interface\\AddOns\\AskMrRobot\\Media\\round-edge", edgeSize = 8}) | |
25 end | |
26 | |
27 function AskMrRobot.ItemIcon:SetSquareBorder() | |
28 self:SetBackdrop({edgeFile = "Interface\\AddOns\\AskMrRobot\\Media\\square-edge", edgeSize = 8}) | |
29 end | |
30 | |
31 -- set the item icon and tooltip from the specified item link | |
32 function AskMrRobot.ItemIcon:SetItemLink(link) | |
33 AskMrRobot.ItemTooltipFrame.SetItemLink(self, link) | |
34 if link then | |
35 self.itemIcon:SetTexture(GetItemIcon(AskMrRobot.getItemIdFromLink(link))) | |
36 self.itemIcon:SetTexCoord(0, 1, 0, 1) | |
37 else | |
38 self.itemIcon:SetTexture(nil) | |
39 end | |
40 end |