Quantcast

Color backdrop by item type

unknown [11-28-09 - 20:45]
Color backdrop by item type
Filename
Molinari.lua
diff --git a/Molinari.lua b/Molinari.lua
index 607579b..9f056f8 100644
--- a/Molinari.lua
+++ b/Molinari.lua
@@ -3,7 +3,7 @@ button:RegisterForClicks('LeftButtonUp')
 button:SetAttribute('*type*', 'macro')

 button:SetBackdrop({bgFile = [=[Interface\ChatFrame\ChatFrameBackground]=]})
-button:SetBackdropColor(1, 0.5, 0.5, 0.4)
+button:SetBackdropColor(0, 0, 0, 0.4)

 button:RegisterEvent('MODIFIER_STATE_CHANGED')
 button:SetScript('OnEvent', function(self, event, ...) self[event](self, event, ...) end)
@@ -18,8 +18,8 @@ end)
 local macro = '/cast %s\n/use %s %s'

 local spells = {
-	[ITEM_MILLABLE] = GetSpellInfo(51005),
-	[ITEM_PROSPECTABLE] = GetSpellInfo(31252),
+	[ITEM_MILLABLE] = {GetSpellInfo(51005), 0.5, 1, 0.5},
+	[ITEM_PROSPECTABLE] = {GetSpellInfo(31252), 1, 0.5, 0.5},
 }

 function button:MODIFIER_STATE_CHANGED(event, key)
@@ -30,32 +30,40 @@ end

 function button:PLAYER_REGEN_ENABLED(event)
 	self:UnregisterEvent(event)
-	self:Hide()
+	self:GetScript('OnLeave')(self)
 end

 local function Disenchantable(item)
 	local _, _, quality, _, _, type = GetItemInfo(item)
-	return (type == ARMOR or type == ENCHSLOT_WEAPON) and quality > 1 and quality < 5 and GetSpellInfo(13262)
+	if ((type == ARMOR or type == ENCHSLOT_WEAPON) and quality > 1 and quality < 5) then
+		return GetSpellInfo(13262), 0.5, 0.5, 1
+	end
 end

 local function ScanTooltip()
-	local spell = nil
 	for index = 1, GameTooltip:NumLines() do
-		spell = spells[_G['GameTooltipTextLeft'..index]:GetText()]
+		local info = spells[_G['GameTooltipTextLeft'..index]:GetText()]
+		if(info) then
+			return unpack(info)
+		end
 	end
-	return spell
 end

 GameTooltip:HookScript('OnTooltipSetItem', function(self)
 	local item = self:GetItem()
 	if(item and IsAltKeyDown() and not InCombatLockdown()) then
-		local spell = ScanTooltip() or Disenchantable(item)
+		local spell, r, g, b = ScanTooltip()
+		if(not spell) then
+			spell, r, g, b = Disenchantable(item)
+		end
+
 		if(spell) then
 			local slot = GetMouseFocus()
 			button:SetAttribute('macrotext', macro:format(spell, slot:GetParent():GetID(), slot:GetID()))
 			button:SetAllPoints(slot)
 			button:SetParent(slot)
 			button:Show()
+			button:SetBackdropColor(r, g, b, 0.4)
 		end
 	end
 end)