Mercurial > wow > itemauditor
comparison Modules/Crafting.lua @ 60:069f39f62104
Fixed the crafting interface to remove items as you create them and to disable the process button if there is nothing to craft.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Sun, 25 Jul 2010 16:34:13 -0700 |
parents | 4ec321eb0dfe |
children | b24dbfbe2aef |
comparison
equal
deleted
inserted
replaced
59:4ec321eb0dfe | 60:069f39f62104 |
---|---|
60 end | 60 end |
61 end | 61 end |
62 | 62 |
63 local craftingContent = false | 63 local craftingContent = false |
64 local craftingTable = false | 64 local craftingTable = false |
65 local btnProcess = false | |
65 local function ShowCrafting(container) | 66 local function ShowCrafting(container) |
66 if craftingContent == false then | 67 if craftingContent == false then |
67 local window = container.frame | 68 local window = container.frame |
68 craftingContent = CreateFrame("Frame",nil,window) | 69 craftingContent = CreateFrame("Frame",nil,window) |
69 craftingContent:SetBackdropColor(0, 0, 1, 0.5) | 70 craftingContent:SetBackdropColor(0, 0, 1, 0.5) |
98 btnProcess = CreateFrame("Button", nil, craftingContent, "UIPanelButtonTemplate") | 99 btnProcess = CreateFrame("Button", nil, craftingContent, "UIPanelButtonTemplate") |
99 btnProcess:SetText("Process") | 100 btnProcess:SetText("Process") |
100 btnProcess:SetSize(100, 25) | 101 btnProcess:SetSize(100, 25) |
101 btnProcess:SetPoint("BOTTOMRIGHT", craftingContent, 0, 0) | 102 btnProcess:SetPoint("BOTTOMRIGHT", craftingContent, 0, 0) |
102 btnProcess:RegisterForClicks("LeftButtonUp"); | 103 btnProcess:RegisterForClicks("LeftButtonUp"); |
103 btnProcess:SetScript("OnClick", function (self, button, down) | 104 |
104 local data = ItemAuditor:GetCraftingRow(1) | 105 local function UpdateProcessTooltip(btn) |
105 ItemAuditor:Print('Crafting %sx%s', data.link, data.queue) | |
106 DoTradeSkill(data.tradeSkillIndex, data.queue) | |
107 end) | |
108 | |
109 btnProcess:SetScript("OnEnter", function() | |
110 local data = ItemAuditor:GetCraftingRow(1) | 106 local data = ItemAuditor:GetCraftingRow(1) |
111 if data then | 107 if data then |
112 GameTooltip:SetOwner(this, "ANCHOR_CURSOR") | 108 GameTooltip:SetOwner(this, "ANCHOR_CURSOR") |
113 GameTooltip:SetText(format('Create %sx%s', data.link, data.queue)) | 109 GameTooltip:SetText(format('Create %sx%s', data.link, data.queue)) |
114 GameTooltip:Show() | 110 GameTooltip:Show() |
115 end | 111 end |
112 end | |
113 btnProcess:SetScript("OnClick", function (self, button, down) | |
114 local data = ItemAuditor:GetCraftingRow(1) | |
115 if data then | |
116 ItemAuditor:Print('Crafting %sx%s', data.link, data.queue) | |
117 DoTradeSkill(data.tradeSkillIndex, data.queue) | |
118 data.queue = 0 | |
119 ItemAuditor:RefreshCraftingTable() | |
120 UpdateProcessTooltip() | |
121 end | |
116 end) | 122 end) |
123 | |
124 btnProcess:SetScript("OnEnter", UpdateProcessTooltip) | |
117 | 125 |
118 btnProcess:SetScript("OnLeave", function() | 126 btnProcess:SetScript("OnLeave", function() |
119 GameTooltip:Hide() | 127 GameTooltip:Hide() |
120 end) | 128 end) |
121 | 129 |
279 realData[row] = data | 287 realData[row] = data |
280 row = row + 1 | 288 row = row + 1 |
281 end | 289 end |
282 end | 290 end |
283 table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end) | 291 table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end) |
292 craftingTable:SetFilter(tableFilter) | |
293 self:RefreshCraftingTable() | |
294 end | |
295 | |
296 function ItemAuditor:RefreshCraftingTable() | |
284 for key, data in pairs(realData) do | 297 for key, data in pairs(realData) do |
285 tableData[key] = { | 298 tableData[key] = { |
286 data.name, | 299 data.name, |
287 data.cost, | 300 data.cost, |
288 data.price, | 301 data.price, |
289 data.winner, | 302 data.winner, |
290 data.queue, | 303 data.queue, |
291 data.profit*data.queue, | 304 data.profit*data.queue, |
292 } | 305 } |
293 end | 306 end |
294 | |
295 craftingTable:SetData(tableData, true) | 307 craftingTable:SetData(tableData, true) |
296 craftingTable:SetFilter(tableFilter) | 308 |
309 if self:GetCraftingRow(1) then | |
310 btnProcess:Enable() | |
311 else | |
312 btnProcess:Disable() | |
313 end | |
297 end | 314 end |
298 | 315 |
299 function ItemAuditor:GetCraftingRow(row) | 316 function ItemAuditor:GetCraftingRow(row) |
300 if craftingTable then | 317 if craftingTable then |
301 for _, index in pairs(craftingTable.sorttable) do | 318 for _, index in pairs(craftingTable.sorttable) do |