| adam@0 | 1 local _, AskMrRobot = ... | 
| adam@0 | 2 | 
| adam@0 | 3 local primaryGemTexture = "Interface\\ItemSocketingFrame\\UI-ItemSockets"; | 
| adam@0 | 4 local engineeringGemTexture = "Interface\\ItemSocketingFrame\\UI-EngineeringSockets"; | 
| adam@0 | 5 | 
| adam@0 | 6 GEM_TYPE_INFO = { | 
| adam@0 | 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}, | 
| adam@0 | 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}, | 
| adam@0 | 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}, | 
| adam@0 | 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}, | 
| adam@0 | 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}, | 
| adam@0 | 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}, | 
| adam@0 | 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} | 
| adam@0 | 14 } | 
| adam@0 | 15 | 
| adam@0 | 16 AskMrRobot.GemIcon = AskMrRobot.inheritsFrom(AskMrRobot.ItemIcon) | 
| adam@0 | 17 | 
| adam@0 | 18 -- item icon contructor | 
| adam@0 | 19 function AskMrRobot.GemIcon:new(name, parent) | 
| adam@0 | 20 	-- create a new frame (if one isn't supplied) | 
| adam@0 | 21 	local o = AskMrRobot.ItemIcon:new(name, parent) | 
| adam@0 | 22 | 
| adam@0 | 23 	-- use the ItemIcon class | 
| adam@0 | 24 	setmetatable(o, { __index = AskMrRobot.GemIcon }) | 
| adam@0 | 25 | 
| adam@0 | 26 	-- add the overlay for the | 
| adam@0 | 27 	o.openBracket = o:CreateTexture(nil, "ARTWORK") | 
| adam@0 | 28 	o.openBracket:SetPoint("TOPLEFT") | 
| adam@0 | 29 	o.openBracket:SetPoint("BOTTOMRIGHT") | 
| adam@0 | 30 | 
| adam@0 | 31 	-- return the instance of the GemIcon | 
| adam@0 | 32 	return o | 
| adam@0 | 33 end | 
| adam@0 | 34 | 
| adam@0 | 35 function AskMrRobot.GemIcon:UpdateGemStuff() | 
| adam@0 | 36 	local info = GEM_TYPE_INFO[self.color] | 
| adam@0 | 37 | 
| adam@0 | 38 	if self.itemLink then | 
| adam@0 | 39 		-- hide the 2nd half of the empty gem icon | 
| adam@0 | 40 		self.openBracket:Hide() | 
| adam@0 | 41 | 
| adam@0 | 42 		if info then | 
| adam@0 | 43 			self:SetBackdropBorderColor(info.r, info.g, info.b) | 
| adam@0 | 44 		end | 
| adam@0 | 45 	else | 
| adam@0 | 46 		if info then | 
| adam@0 | 47 			-- set the empty gem background texture | 
| adam@0 | 48 			self.itemIcon:SetTexture(info.tex) | 
| adam@0 | 49 			self.itemIcon:SetTexCoord(info.left, info.right, info.top, info.bottom) | 
| adam@0 | 50 | 
| adam@0 | 51 			-- set the empty gem overlay | 
| adam@0 | 52 			self.openBracket:SetTexture(info.tex) | 
| adam@0 | 53 			self.openBracket:SetTexCoord(info.OBLeft, info.OBRight, info.OBTop, info.OBBottom) | 
| adam@0 | 54 			self.openBracket:Show() | 
| adam@0 | 55 | 
| adam@0 | 56 			--hide the border (the empty gem icon has a border) | 
| adam@0 | 57 			self:SetBackdropBorderColor(0,0,0,0) | 
| adam@0 | 58 | 
| adam@0 | 59 			-- set the empty gem background texture | 
| adam@0 | 60 			self.itemIcon:SetTexture(info.tex) | 
| adam@0 | 61 			self.itemIcon:SetTexCoord(info.left, info.right, info.top, info.bottom) | 
| adam@0 | 62 | 
| adam@0 | 63 			-- set the empty gem overlay | 
| adam@0 | 64 			self.openBracket:SetTexture(info.tex) | 
| adam@0 | 65 			self.openBracket:SetTexCoord(info.OBLeft, info.OBRight, info.OBTop, info.OBBottom) | 
| adam@0 | 66 			self.openBracket:Show() | 
| adam@0 | 67 		else | 
| adam@0 | 68 			self.openBracket:Hide() | 
| adam@0 | 69 		end | 
| adam@0 | 70 | 
| adam@0 | 71 		self:SetBackdropBorderColor(0,0,0,0) | 
| adam@0 | 72 	end | 
| adam@0 | 73 | 
| adam@0 | 74 end | 
| adam@0 | 75 | 
| adam@0 | 76 function AskMrRobot.GemIcon:SetItemLink(link) | 
| adam@0 | 77 	AskMrRobot.ItemIcon.SetItemLink(self, link) | 
| adam@0 | 78 	self:UpdateGemStuff() | 
| adam@0 | 79 end | 
| adam@0 | 80 | 
| adam@0 | 81 function AskMrRobot.GemIcon:SetGemColor(color) | 
| adam@0 | 82 	self.color = color | 
| adam@0 | 83 	self:UpdateGemStuff() | 
| adam@0 | 84 end |