From c57644dfa7ac30434dbac27f463efaf5e49c6967 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 28 Nov 2009 21:45:26 +0100 Subject: [PATCH] Color backdrop by item type --- Molinari.lua | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) 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) -- 1.7.9.5