Quantcast

Rework the click conditions, barely need any.

Adrian L Lange [12-23-09 - 01:18]
Rework the click conditions, barely need any.
Filename
Molinari.lua
diff --git a/Molinari.lua b/Molinari.lua
index 36e102e..bfda3e1 100644
--- a/Molinari.lua
+++ b/Molinari.lua
@@ -22,6 +22,7 @@ button:SetScript('OnLeave', function(self)
 	end
 end)

+local disenchanting = GetSpellInfo(13262)
 local macro = '/cast %s\n/use %s %s'
 local spells = {}

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

@@ -52,19 +53,19 @@ local function ScanTooltip()
 	end
 end

-local function Clickable()
-	return (not IsAddOnLoaded('Blizzard_AuctionUI') or (AuctionFrame and not AuctionFrame:IsShown())) and not TradeFrame:IsShown() and not BankFrame:IsShown() and not MailFrame:IsShown() and not InCombatLockdown() and IsAltKeyDown()
+local function Clickable(spell)
+	return (not IsAddOnLoaded('Blizzard_AuctionUI') or (AuctionFrame and not AuctionFrame:IsShown())) and (spell == disenchanting and not CharacterFrame:IsShown()) and not InCombatLockdown() and IsAltKeyDown()
 end

 GameTooltip:HookScript('OnTooltipSetItem', function(self)
 	local item = self:GetItem()
-	if(item and Clickable()) then
+	if(item) then
 		local spell, r, g, b = ScanTooltip()
 		if(not spell) then
 			spell, r, g, b = Disenchantable(item)
 		end

-		if(spell) then
+		if(spell and Clickable(spell)) then
 			local slot = GetMouseFocus()
 			button:SetAttribute('macrotext', macro:format(spell, slot:GetParent():GetID(), slot:GetID()))
 			button:SetAllPoints(slot)