From a905408078b50567c61c37477c4a413ba78bbede Mon Sep 17 00:00:00 2001 From: p3lim Date: Tue, 21 Dec 2010 23:31:59 +0100 Subject: [PATCH] Add support for Disenchanting --- Database.lua | 5 +++++ Molinari.lua | 20 ++++++++++++++++++-- Molinari.toc | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 Database.lua diff --git a/Database.lua b/Database.lua new file mode 100644 index 0000000..a3c7c32 --- /dev/null +++ b/Database.lua @@ -0,0 +1,5 @@ +local _, notDisenchantable = ... + +notDisenchantable = { + +} diff --git a/Molinari.lua b/Molinari.lua index 4b9e2fd..b71e57e 100644 --- a/Molinari.lua +++ b/Molinari.lua @@ -1,5 +1,8 @@  -local button = CreateFrame('Button', 'Molinari', UIParent, 'SecureActionButtonTemplate') +local addonName, notDisenchantable = ... +local armorType = GetLocale() == 'ruRU' and '' or ARMOR + +local button = CreateFrame('Button', addonName, UIParent, 'SecureActionButtonTemplate') button:SetScript('OnEvent', function(self, event, ...) self[event](self, ...) end) button:RegisterEvent('PLAYER_LOGIN') @@ -13,7 +16,7 @@ local function ScanTooltip(self, spells) end function button:PLAYER_LOGIN() - local spells = {} + local spells, disenchantable = {} if(IsSpellKnown(51005)) then spells[ITEM_MILLABLE] = {GetSpellInfo(51005), 1/2, 1, 1/2} end @@ -22,11 +25,24 @@ function button:PLAYER_LOGIN() spells[ITEM_PROSPECTABLE] = {GetSpellInfo(31252), 1, 1/3, 1/3} end + -- I wish Blizzard could treat disenchanting the same way + if(IsSpellKnown(13262)) then + disenchantable = {GetSpellInfo(13262), 1, 1, 1} + end + GameTooltip:HookScript('OnTooltipSetItem', function(self) local item, link = self:GetItem() if(item and not InCombatLockdown() and IsAltKeyDown()) then local spell, r, g, b = ScanTooltip(self, spells) + if(not spell and disenchantable and not notDisenchantable[link:match('item:(%d+):')]) then + local _, _, quality, _, _, type = GetItemInfo(item) + + if((type == armorType or type == ENCHSLOT_WEAPON) and (quality and (quality > 1 or quality < 5))) then + spell, r, g, b = unpack(disenchantable) + end + end + local bag, slot = GetMouseFocus():GetParent(), GetMouseFocus() if(spell and GetContainerItemLink(bag:GetID(), slot:GetID()) == link) then button:SetAttribute('macrotext', string.format('/cast %s\n/use %s %s', spell, slot:GetParent():GetID(), slot:GetID())) diff --git a/Molinari.toc b/Molinari.toc index 107ee96..ea1d8ee 100644 --- a/Molinari.toc +++ b/Molinari.toc @@ -4,4 +4,5 @@ ## Title: Molinari ## Notes: One-click Milling & Prospecting! +Database.lua Molinari.lua -- 1.7.9.5