Quantcast

Removed disenchanting support

Adrian L Lange [03-01-10 - 17:09]
Removed disenchanting support
- See project "Dolemite"
Filename
Molinari.lua
Molinari.toc
diff --git a/Molinari.lua b/Molinari.lua
index 133fad5..32fa9dc 100644
--- a/Molinari.lua
+++ b/Molinari.lua
@@ -1,25 +1,23 @@
-local ARMORTYPE
-if(GetLocale() == 'ruRU') then
-	ARMORTYPE = 'Доспехи' -- DIAF Blizzard
-else
-	ARMORTYPE = ARMOR
-end
+local addon = ...

-local button = CreateFrame('Button', 'Molinari', UIParent, 'SecureActionButtonTemplate, AutoCastShineTemplate')
-button:RegisterForClicks('LeftButtonUp')
-button:SetAttribute('*type*', 'macro')
-button:Hide()
+local button = CreateFrame('Button', addon, UIParent, 'SecureActionButtonTemplate, AutoCastShineTemplate')
+local macro = '/cast %s\n/use %s %s'
+local spells = {}

-for _, spark in pairs(button.sparkles) do
-	spark:SetHeight(spark:GetHeight() * 3)
-	spark:SetWidth(spark:GetWidth() * 3)
+local function ScanTooltip(text)
+	for index = 1, GameTooltip:NumLines() do
+		local info = spells[_G['GameTooltipTextLeft'..index]:GetText()]
+		if(info) then
+			return unpack(info)
+		end
+	end
 end

-button:SetFrameStrata('DIALOG')
-button:RegisterEvent('PLAYER_LOGIN')
-button:RegisterEvent('MODIFIER_STATE_CHANGED')
-button:SetScript('OnEvent', function(self, event, ...) self[event](self, event, ...) end)
-button:SetScript('OnLeave', function(self)
+local function Clickable()
+	return not InCombatLockdown() and IsAltKeyDown()
+end
+
+local function Disperse(self)
 	if(InCombatLockdown()) then
 		self:RegisterEvent('PLAYER_REGEN_ENABLED')
 	else
@@ -27,53 +25,25 @@ button:SetScript('OnLeave', function(self)
 		self:ClearAllPoints()
 		AutoCastShine_AutoCastStop(self)
 	end
-end)
-
-local disenchanting = GetSpellInfo(13262)
-local macro = '/cast %s\n/use %s %s'
-local spells = {}
+end

 function button:MODIFIER_STATE_CHANGED(event, key)
 	if(self:IsShown() and (key == 'LALT' or key == 'RALT')) then
-		self:GetScript('OnLeave')(self)
+		Disperse(self)
 	end
 end

 function button:PLAYER_REGEN_ENABLED(event)
 	self:UnregisterEvent(event)
-	self:GetScript('OnLeave')(self)
-end
-
-local function Disenchantable(item)
-	local _, _, quality, _, _, type = GetItemInfo(item)
-	if((type == ARMORTYPE or type == ENCHSLOT_WEAPON) and quality > 1 and quality < 5) then
-		return disenchanting, 0.5, 0.5, 1
-	end
-end
-
-local function ScanTooltip()
-	for index = 1, GameTooltip:NumLines() do
-		local info = spells[_G['GameTooltipTextLeft'..index]:GetText()]
-		if(info) then
-			return unpack(info)
-		end
-	end
-end
-
-local function Clickable()
-	return not InCombatLockdown() and IsAltKeyDown()
+	Disperse(self)
 end

 GameTooltip:HookScript('OnTooltipSetItem', function(self)
 	local item = self:GetItem()
 	if(item and Clickable()) then
 		local spell, r, g, b = ScanTooltip()
-		if(not spell) then
-			spell, r, g, b = Disenchantable(item)
-		end
-
-		local bag, slot = GetMouseFocus():GetParent(), GetMouseFocus()
-		if(spell and GetContainerItemInfo(bag:GetID(), slot:GetID()) and bag ~= PaperDollFrameItemFlyoutButtons) then
+		if(spell) then
+			local bag, slot = GetMouseFocus():GetParent(), GetMouseFocus()
 			button:SetAttribute('macrotext', macro:format(spell, bag:GetID(), slot:GetID()))
 			button:SetAllPoints(slot)
 			button:Show()
@@ -90,8 +60,20 @@ function button:PLAYER_LOGIN()
 	if(IsSpellKnown(31252)) then
 		spells[ITEM_PROSPECTABLE] = {GetSpellInfo(31252), 1, 0.5, 0.5}
 	end
+end
+
+do
+	button:SetScript('OnLeave', Disperse)
+	button:SetScript('OnEvent', function(self, event, ...) self[event](self, event, ...) end)
+	button:SetFrameStrata('DIALOG')
+	button:RegisterEvent('MODIFIER_STATE_CHANGED')
+	button:RegisterEvent('PLAYER_LOGIN')
+	button:RegisterForClicks('LeftButtonUp')
+	button:SetAttribute('*type*', 'macro')
+	button:Hide()

-	if(not IsSpellKnown(13262)) then
-		Disenchantable = function() end
+	for _, sparks in pairs(button.sparkles) do
+		sparks:SetHeight(sparks:GetHeight() * 3)
+		sparks:SetWidth(sparks:GetWidth() * 3)
 	end
 end
diff --git a/Molinari.toc b/Molinari.toc
index 9f62c9e..5e9670e 100644
--- a/Molinari.toc
+++ b/Molinari.toc
@@ -2,6 +2,6 @@
 ## Author: p3lim
 ## Version: 30300.5-Beta
 ## Title: Molinari
-## Notes: One-click Milling/Prospecting/Disenchanting!
+## Notes: One-click Milling & Prospecting!

 Molinari.lua