# HG changeset patch # User Asa Ayers # Date 1280100853 25200 # Node ID 069f39f62104d0a2866c7c4614ee24c30ee606c4 # Parent 4ec321eb0dfe7702745b7d787c10b74f066663f8 Fixed the crafting interface to remove items as you create them and to disable the process button if there is nothing to craft. diff -r 4ec321eb0dfe -r 069f39f62104 Modules/Crafting.lua --- a/Modules/Crafting.lua Sun Jul 25 15:51:13 2010 -0700 +++ b/Modules/Crafting.lua Sun Jul 25 16:34:13 2010 -0700 @@ -62,6 +62,7 @@ local craftingContent = false local craftingTable = false +local btnProcess = false local function ShowCrafting(container) if craftingContent == false then local window = container.frame @@ -100,21 +101,28 @@ btnProcess:SetSize(100, 25) btnProcess:SetPoint("BOTTOMRIGHT", craftingContent, 0, 0) btnProcess:RegisterForClicks("LeftButtonUp"); - btnProcess:SetScript("OnClick", function (self, button, down) - local data = ItemAuditor:GetCraftingRow(1) - ItemAuditor:Print('Crafting %sx%s', data.link, data.queue) - DoTradeSkill(data.tradeSkillIndex, data.queue) - end) - btnProcess:SetScript("OnEnter", function() + local function UpdateProcessTooltip(btn) local data = ItemAuditor:GetCraftingRow(1) if data then GameTooltip:SetOwner(this, "ANCHOR_CURSOR") GameTooltip:SetText(format('Create %sx%s', data.link, data.queue)) GameTooltip:Show() end + end + btnProcess:SetScript("OnClick", function (self, button, down) + local data = ItemAuditor:GetCraftingRow(1) + if data then + ItemAuditor:Print('Crafting %sx%s', data.link, data.queue) + DoTradeSkill(data.tradeSkillIndex, data.queue) + data.queue = 0 + ItemAuditor:RefreshCraftingTable() + UpdateProcessTooltip() + end end) + btnProcess:SetScript("OnEnter", UpdateProcessTooltip) + btnProcess:SetScript("OnLeave", function() GameTooltip:Hide() end) @@ -281,6 +289,11 @@ end end table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end) + craftingTable:SetFilter(tableFilter) + self:RefreshCraftingTable() +end + +function ItemAuditor:RefreshCraftingTable() for key, data in pairs(realData) do tableData[key] = { data.name, @@ -291,9 +304,13 @@ data.profit*data.queue, } end + craftingTable:SetData(tableData, true) - craftingTable:SetData(tableData, true) - craftingTable:SetFilter(tableFilter) + if self:GetCraftingRow(1) then + btnProcess:Enable() + else + btnProcess:Disable() + end end function ItemAuditor:GetCraftingRow(row)