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