comparison ui/EnchantLinkText.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 e77e01abce98
comparison
equal deleted inserted replaced
-1:000000000000 0:ec731d2fe6ba
1 local _, AskMrRobot = ...
2
3 AskMrRobot.EnchantLinkText = AskMrRobot.inheritsFrom(AskMrRobot.ItemTooltipFrame)
4
5 function AskMrRobot.EnchantLinkText:new(name, parent)
6 local o = AskMrRobot.ItemTooltipFrame:new(name, parent)
7
8 -- use the ItemLinkText class
9 setmetatable(o, { __index = AskMrRobot.EnchantLinkText })
10
11 -- the item text
12 o.itemText = AskMrRobot.FontString:new(o, nil, "ARTWORK", "GameFontWhite")
13 o.itemText:SetPoint("TOPLEFT")
14 o.itemText:SetPoint("BOTTOMRIGHT")
15 o.itemText:SetJustifyH("LEFT")
16
17 return o
18 end
19
20 function AskMrRobot.EnchantLinkText:SetEnchantId(enchantId)
21 self.itemName = nil
22 if enchantId and enchantId ~= 0 then
23 local spellId = AskMrRobot.getEnchantSpellId(enchantId)
24 local link = nil
25 if spellId then
26 link = 'enchant:' .. spellId
27 end
28 self:SetItemLink(link)
29 if self.useSpellName then
30 local spellName = spellId and select(1, GetSpellInfo(spellId))
31 self.itemText:SetText(spellName)
32 self.itemName = spellName
33 else
34 self.itemName = AskMrRobot.getEnchantName(enchantId)
35 self.itemText:SetText(self.itemName)
36 end
37 else
38 self:SetItemLink(nil)
39 self.itemText:SetText('')
40 end
41 end
42
43 function AskMrRobot.EnchantLinkText:SetFontSize(fontSize)
44 self.itemText:SetFontSize(fontSize)
45 end
46
47 function AskMrRobot.EnchantLinkText:UseSpellName()
48 self.useSpellName = true
49 end
50
51 AskMrRobot.EnchantLinkIconAndText = AskMrRobot.inheritsFrom(AskMrRobot.EnchantLinkText)
52
53 function AskMrRobot.EnchantLinkIconAndText:new(name, parent)
54 local o = AskMrRobot.EnchantLinkText:new(name, parent)
55
56 -- use the EnchantLinkIconAndText class
57 setmetatable(o, { __index = AskMrRobot.EnchantLinkIconAndText })
58
59 o.iconFrame = AskMrRobot.Frame:new(nil, o)
60 o.iconFrame:SetPoint("TOPLEFT", 0, 5)
61 o.iconFrame:SetWidth(24)
62 o.iconFrame:SetHeight(24)
63
64 o.icon = o.iconFrame:CreateTexture(nil, "BACKGROUND")
65 o.icon:SetPoint("TOPLEFT")
66 o.icon:SetPoint("BOTTOMRIGHT")
67
68 o.itemText:SetPoint("TOPLEFT", o.iconFrame, "TOPRIGHT", 4, -5)
69
70 o:SetRoundBorder()
71
72 return o
73 end
74
75 function AskMrRobot.EnchantLinkIconAndText:SetRoundBorder()
76 self.iconFrame:SetBackdrop({edgeFile = "Interface\\AddOns\\AskMrRobot\\Media\\round-edge", edgeSize = 8})
77 end
78
79 function AskMrRobot.EnchantLinkIconAndText:SetSquareBorder()
80 self.iconFrame:SetBackdrop({edgeFile = "Interface\\AddOns\\AskMrRobot\\Media\\square-edge", edgeSize = 8})
81 end
82
83 function AskMrRobot.EnchantLinkIconAndText:SetEnchantId(enchantId)
84 AskMrRobot.EnchantLinkText.SetEnchantId(self, enchantId)
85 if enchantId and enchantId ~= 0 then
86 local texture = AskMrRobot.getEnchantIcon(enchantId)
87 self.icon:SetTexture('Interface/Icons/' .. texture)
88 self.iconFrame:Show()
89 else
90 self.iconFrame:Hide()
91 end
92 end
93
94 function AskMrRobot.EnchantLinkIconAndText:SetFontSize(fontSize)
95 self.itemText:SetFontSize(fontSize)
96 end