Mercurial > wow > askmrrobot
comparison ui/GemIcon.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 local primaryGemTexture = "Interface\\ItemSocketingFrame\\UI-ItemSockets"; | |
4 local engineeringGemTexture = "Interface\\ItemSocketingFrame\\UI-EngineeringSockets"; | |
5 | |
6 GEM_TYPE_INFO = { | |
7 Yellow = {tex=primaryGemTexture, left=0, right=0.16796875, top=0.640625, bottom=0.80859375, r=0.97, g=0.82, b=0.29, OBLeft=0.7578125, OBRight=0.9921875, OBTop=0, OBBottom=0.22265625}, | |
8 Red = {tex=primaryGemTexture, left=0.1796875, right=0.34375, top=0.640625, bottom=0.80859375, r=1, g=0.47, b=0.47, OBLeft=0.7578125, OBRight=0.9921875, OBTop=0.4765625, OBBottom=0.69921875}, | |
9 Blue = {tex=primaryGemTexture,left=0.3515625, right=0.51953125, top=0.640625, bottom=0.80859375, r=0.47, g=0.67, b=1, OBLeft=0.7578125, OBRight=0.9921875, OBTop=0.23828125, OBBottom=0.4609375}, | |
10 Hydraulic = {tex=engineeringGemTexture, left=0.01562500, right=0.68750000, top=0.50000000, bottom=0.58398438, r=1, g=1, b=1, OBLeft=0.01562500, OBRight=0.93750000, OBTop=0.11132813, OBBottom=0.21679688}, | |
11 Cogwheel = {tex=engineeringGemTexture, left=0.01562500, right=0.68750000, top=0.41210938, bottom=0.49609375, r=1, g=1, b=1, OBLeft=0.01562500, OBRight=0.78125000, OBTop=0.31640625, OBBottom=0.40820313}, | |
12 Meta = {tex=primaryGemTexture, left=0.171875, right=0.3984375, top=0.40234375, bottom=0.609375, r=1, g=1, b=1, OBLeft=0.7578125, OBRight=0.9921875, OBTop=0, OBBottom=0.22265625}, | |
13 Prismatic = {tex=engineeringGemTexture, left=0.01562500, right=0.68750000, top=0.76367188, bottom=0.84765625, r=1, g=1, b=1, OBLeft=0.01562500, OBRight=0.68750000, OBTop=0.58789063, OBBottom=0.67187500} | |
14 } | |
15 | |
16 AskMrRobot.GemIcon = AskMrRobot.inheritsFrom(AskMrRobot.ItemIcon) | |
17 | |
18 -- item icon contructor | |
19 function AskMrRobot.GemIcon:new(name, parent) | |
20 -- create a new frame (if one isn't supplied) | |
21 local o = AskMrRobot.ItemIcon:new(name, parent) | |
22 | |
23 -- use the ItemIcon class | |
24 setmetatable(o, { __index = AskMrRobot.GemIcon }) | |
25 | |
26 -- add the overlay for the | |
27 o.openBracket = o:CreateTexture(nil, "ARTWORK") | |
28 o.openBracket:SetPoint("TOPLEFT") | |
29 o.openBracket:SetPoint("BOTTOMRIGHT") | |
30 | |
31 -- return the instance of the GemIcon | |
32 return o | |
33 end | |
34 | |
35 function AskMrRobot.GemIcon:UpdateGemStuff() | |
36 local info = GEM_TYPE_INFO[self.color] | |
37 | |
38 if self.itemLink then | |
39 -- hide the 2nd half of the empty gem icon | |
40 self.openBracket:Hide() | |
41 | |
42 if info then | |
43 self:SetBackdropBorderColor(info.r, info.g, info.b) | |
44 end | |
45 else | |
46 if info then | |
47 -- set the empty gem background texture | |
48 self.itemIcon:SetTexture(info.tex) | |
49 self.itemIcon:SetTexCoord(info.left, info.right, info.top, info.bottom) | |
50 | |
51 -- set the empty gem overlay | |
52 self.openBracket:SetTexture(info.tex) | |
53 self.openBracket:SetTexCoord(info.OBLeft, info.OBRight, info.OBTop, info.OBBottom) | |
54 self.openBracket:Show() | |
55 | |
56 --hide the border (the empty gem icon has a border) | |
57 self:SetBackdropBorderColor(0,0,0,0) | |
58 | |
59 -- set the empty gem background texture | |
60 self.itemIcon:SetTexture(info.tex) | |
61 self.itemIcon:SetTexCoord(info.left, info.right, info.top, info.bottom) | |
62 | |
63 -- set the empty gem overlay | |
64 self.openBracket:SetTexture(info.tex) | |
65 self.openBracket:SetTexCoord(info.OBLeft, info.OBRight, info.OBTop, info.OBBottom) | |
66 self.openBracket:Show() | |
67 else | |
68 self.openBracket:Hide() | |
69 end | |
70 | |
71 self:SetBackdropBorderColor(0,0,0,0) | |
72 end | |
73 | |
74 end | |
75 | |
76 function AskMrRobot.GemIcon:SetItemLink(link) | |
77 AskMrRobot.ItemIcon.SetItemLink(self, link) | |
78 self:UpdateGemStuff() | |
79 end | |
80 | |
81 function AskMrRobot.GemIcon:SetGemColor(color) | |
82 self.color = color | |
83 self:UpdateGemStuff() | |
84 end |