Mercurial > wow > itemauditor
diff Modules/Crafting.lua @ 99:e9b903cf9b33
Added a menu to allow the user to see what is to be crafted, only what you hae mats for, or view everything so you can see why something isn't to be crafted.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Thu, 19 Aug 2010 23:14:30 -0700 |
parents | 63823b6b5e28 |
children | 53147a647e28 |
line wrap: on
line diff
--- a/Modules/Crafting.lua Thu Aug 19 22:53:54 2010 -0700 +++ b/Modules/Crafting.lua Thu Aug 19 23:14:30 2010 -0700 @@ -114,12 +114,15 @@ { name= "Est Sale Each", width = 100, align = "RIGHT", ['DoCellUpdate'] = displayMoney, }, - { name= "Decided By", width = 100, align = "RIGHT", + { name= "Decided By", width = 125, align = "RIGHT", }, { name= "craft", width = 50, align = "RIGHT", }, + { name= "Have Mats", width = 60, align = "RIGHT", + + }, { name= "Total Profit", width = 100, align = "RIGHT", ['DoCellUpdate'] = displayMoney, }, @@ -160,10 +163,18 @@ end -- ItemAuditor:GetModule('Crafting').filter_queued = false -Crafting.filter_queued = true +Crafting.filter_have_mats = false +Crafting.filter_show_all = false local function tableFilter(self, row, ...) + if Crafting.filter_show_all then + return true + end + -- column 5 is how many should be crafted - if Crafting.filter_queued and row[5] <= 0 then + if Crafting.filter_have_mats and row[6] == 'n' then + return false + end + if strfind(row[4], 'VETO: .*') or row[5] == 0 then return false end return true @@ -204,7 +215,35 @@ end, }); - + local craftingView = CreateFrame("Button", nil, craftingContent, "UIPanelButtonTemplate") + craftingView:SetText("View") + craftingView:SetSize(50, 25) + craftingView:SetPoint("BOTTOMLEFT", craftingContent, 0, 0) + + local menu = { + { text = "View", isTitle = true}, + { text = "To be crafted", func = function() + Crafting.filter_have_mats = false + Crafting.filter_show_all = false + ItemAuditor:RefreshCraftingTable() + end }, + { text = "Have Mats", func = function() + Crafting.filter_have_mats = true + Crafting.filter_show_all = false + ItemAuditor:RefreshCraftingTable() + end }, + { text = "All", func = function() + Crafting.filter_have_mats = false + Crafting.filter_show_all = true + ItemAuditor:RefreshCraftingTable() + end }, + } + local menuFrame = CreateFrame("Frame", "ExampleMenuFrame", UIParent, "UIDropDownMenuTemplate") + craftingView:SetScript("OnClick", function (self, button, down) + EasyMenu(menu, menuFrame, "cursor", 0 , 0, "MENU"); + end) + + btnProcess = CreateFrame("Button", nil, craftingContent, "UIPanelButtonTemplate") btnProcess:SetText("Process") btnProcess:SetSize(100, 25) @@ -237,8 +276,7 @@ end) btnSkillet = CreateFrame("Button", nil, craftingContent, "UIPanelButtonTemplate") - - + btnSkillet:SetSize(125, 25) btnSkillet:SetPoint("BOTTOMRIGHT", btnProcess, 'BOTTOMLEFT', 0, 0) btnSkillet:RegisterForClicks("LeftButtonUp"); @@ -331,7 +369,7 @@ if data.profit > 0 and data.profit > ItemAuditor:GetCraftingThreshold() then return 1 end - return -1 + return -1, 'Not Profitable' end Crafting.RegisterCraftingDecider('Is Profitable', isProfitable) @@ -411,7 +449,13 @@ } data.winner, data.queue = Decide(data) - data.queue = data.queue - count + --[[ + If it wasn't vetoed we need to reduce the number by how many are owned + but this should not go below 0 + ]] + if data.queue > 0 then + data.queue = max(0, data.queue - count) + end -- If a tradeskill makes 5 at a time and something asks for 9, we should only -- craft twice to get 10. @@ -422,7 +466,7 @@ end end end - table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end) + table.sort(realData, function(a, b) return a.profit*max(1, a.queue) > b.profit*max(1, b.queue) end) local numOwned = {} for key, data in pairs(realData) do @@ -447,14 +491,20 @@ end function ItemAuditor:RefreshCraftingTable() + local displayMaterials for key, data in pairs(realData) do + displayMaterials = 'n' + if data.haveMaterials then + displayMaterials = 'y' + end tableData[key] = { data.name, data.cost, data.price, data.winner, - data.queue, - data.profit*data.queue, + abs(data.queue), + displayMaterials, + data.profit*abs(data.queue), } end craftingTable:SetData(tableData, true)