adam@0: local _, AskMrRobot = ... adam@0: adam@0: local primaryGemTexture = "Interface\\ItemSocketingFrame\\UI-ItemSockets"; adam@0: local engineeringGemTexture = "Interface\\ItemSocketingFrame\\UI-EngineeringSockets"; adam@0: adam@0: GEM_TYPE_INFO = { adam@0: 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: 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: 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: 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: 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: 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: 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: } adam@0: adam@0: AskMrRobot.GemIcon = AskMrRobot.inheritsFrom(AskMrRobot.ItemIcon) adam@0: adam@0: -- item icon contructor adam@0: function AskMrRobot.GemIcon:new(name, parent) adam@0: -- create a new frame (if one isn't supplied) adam@0: local o = AskMrRobot.ItemIcon:new(name, parent) adam@0: adam@0: -- use the ItemIcon class adam@0: setmetatable(o, { __index = AskMrRobot.GemIcon }) adam@0: adam@0: -- add the overlay for the adam@0: o.openBracket = o:CreateTexture(nil, "ARTWORK") adam@0: o.openBracket:SetPoint("TOPLEFT") adam@0: o.openBracket:SetPoint("BOTTOMRIGHT") adam@0: adam@0: -- return the instance of the GemIcon adam@0: return o adam@0: end adam@0: adam@0: function AskMrRobot.GemIcon:UpdateGemStuff() adam@0: local info = GEM_TYPE_INFO[self.color] adam@0: adam@0: if self.itemLink then adam@0: -- hide the 2nd half of the empty gem icon adam@0: self.openBracket:Hide() adam@0: adam@0: if info then adam@0: self:SetBackdropBorderColor(info.r, info.g, info.b) adam@0: end adam@0: else adam@0: if info then adam@0: -- set the empty gem background texture adam@0: self.itemIcon:SetTexture(info.tex) adam@0: self.itemIcon:SetTexCoord(info.left, info.right, info.top, info.bottom) adam@0: adam@0: -- set the empty gem overlay adam@0: self.openBracket:SetTexture(info.tex) adam@0: self.openBracket:SetTexCoord(info.OBLeft, info.OBRight, info.OBTop, info.OBBottom) adam@0: self.openBracket:Show() adam@0: adam@0: --hide the border (the empty gem icon has a border) adam@0: self:SetBackdropBorderColor(0,0,0,0) adam@0: adam@0: -- set the empty gem background texture adam@0: self.itemIcon:SetTexture(info.tex) adam@0: self.itemIcon:SetTexCoord(info.left, info.right, info.top, info.bottom) adam@0: adam@0: -- set the empty gem overlay adam@0: self.openBracket:SetTexture(info.tex) adam@0: self.openBracket:SetTexCoord(info.OBLeft, info.OBRight, info.OBTop, info.OBBottom) adam@0: self.openBracket:Show() adam@0: else adam@0: self.openBracket:Hide() adam@0: end adam@0: adam@0: self:SetBackdropBorderColor(0,0,0,0) adam@0: end adam@0: adam@0: end adam@0: adam@0: function AskMrRobot.GemIcon:SetItemLink(link) adam@0: AskMrRobot.ItemIcon.SetItemLink(self, link) adam@0: self:UpdateGemStuff() adam@0: end adam@0: adam@0: function AskMrRobot.GemIcon:SetGemColor(color) adam@0: self.color = color adam@0: self:UpdateGemStuff() adam@0: end