Mercurial > wow > itemauditor
comparison Modules/Crafting.lua @ 70:3930518cb8d9
Added a public API so other addon developers can register themselves as a queue destination and added a UI so users can select that destination.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Wed, 28 Jul 2010 22:19:38 -0700 |
parents | 2d65db19d3ce |
children | 8e9beb8a0330 |
comparison
equal
deleted
inserted
replaced
69:4ae431c98059 | 70:3930518cb8d9 |
---|---|
9 | 9 |
10 local realData = {} | 10 local realData = {} |
11 | 11 |
12 | 12 |
13 local queueDestinations = {} | 13 local queueDestinations = {} |
14 | 14 local displayCraftingDestinations = {} |
15 function Crafting.RegisterQueueDestination(name, destination) | 15 function Crafting.RegisterQueueDestination(name, destination) |
16 queueDestinations[name] = destination | 16 queueDestinations[name] = destination |
17 displayCraftingDestinations[name] = name | |
18 end | |
19 | |
20 function Crafting.UnRegisterQueueDestination(name) | |
21 queueDestinations[name] = nil | |
22 displayCraftingDestinations[name] = nil | |
23 end | |
24 | |
25 function Crafting.GetQueueDestination() | |
26 local dest = ItemAuditor.db.profile.queue_destination | |
27 if dest and queueDestinations[dest] then | |
28 return queueDestinations[dest], dest | |
29 end | |
30 -- If there is none selected or the selected option has | |
31 -- dissapeared, choose the first one in the list | |
32 for name, func in pairs(queueDestinations) do | |
33 if dest then | |
34 ItemAuditor:Print("%s is no longer available as a queue destination. %s is the new default", dest, name) | |
35 end | |
36 ItemAuditor.db.profile.queue_destination = name | |
37 return func, name | |
38 end | |
39 | |
40 error('Unable to determine queue destination.') | |
17 end | 41 end |
18 | 42 |
19 -- TODO: Convert this to a text field. | 43 -- TODO: Convert this to a text field. |
20 local craftingThresholds = {5000, 10000, 50000} | 44 local craftingThresholds = {5000, 10000, 50000} |
21 local craftingThresholdsDisplay = {} | 45 local craftingThresholdsDisplay = {} |
29 local key = ItemAuditor.db.char.crafting_threshold | 53 local key = ItemAuditor.db.char.crafting_threshold |
30 return craftingThresholds[key] | 54 return craftingThresholds[key] |
31 end | 55 end |
32 | 56 |
33 ItemAuditor.Options.args.crafting_options = { | 57 ItemAuditor.Options.args.crafting_options = { |
34 name = "Crafting with Skillet", | 58 name = "Crafting", |
35 desc = "/ia queue", | |
36 type = 'group', | 59 type = 'group', |
37 disabled = function() return Skillet == nil end, | |
38 args = { | 60 args = { |
39 crafting_threshold = { | 61 crafting_threshold = { |
40 type = "select", | 62 type = "select", |
41 name = "Crafting Threshold", | 63 name = "Crafting Threshold", |
42 desc = "Don't create items that will make less than this amount of profit", | 64 desc = "Don't create items that will make less than this amount of profit", |
43 values = craftingThresholdsDisplay, | 65 values = craftingThresholdsDisplay, |
44 get = function() return ItemAuditor.db.char.crafting_threshold end, | 66 get = function() return ItemAuditor.db.char.crafting_threshold end, |
45 set = function(info, value) ItemAuditor.db.char.crafting_threshold = value end, | 67 set = function(info, value) ItemAuditor.db.char.crafting_threshold = value end, |
46 order = 11, | 68 order = 11, |
47 }, | 69 }, |
70 queue_destination = { | |
71 type = "select", | |
72 name = "Queue Destination", | |
73 desc = "Select the addon who's queue you would like ItemAuditor to post to.", | |
74 values = displayCraftingDestinations, | |
75 get = function() return select(2, Crafting.GetQueueDestination()) end, | |
76 set = function(info, value) ItemAuditor.db.profile.queue_destination = value end, | |
77 order = 11, | |
78 }, | |
48 }, | 79 }, |
49 } | 80 } |
50 | 81 |
51 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) | 82 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) |
52 if fShow == true then | 83 if fShow == true then |
99 | 130 |
100 function Crafting.Export(destination) | 131 function Crafting.Export(destination) |
101 if type(destination) == 'function' then | 132 if type(destination) == 'function' then |
102 -- do nothing | 133 -- do nothing |
103 elseif destination == nil then | 134 elseif destination == nil then |
104 destination = queueDestinations['Skillet'] | 135 destination = Crafting.GetQueueDestination() |
105 elseif type(destination) == 'string' then | 136 elseif type(destination) == 'string' then |
106 destination = queueDestinations[destination] | 137 destination = queueDestinations[destination] |
107 else | 138 else |
108 error('destination must be a function or a string') | 139 error('destination must be a function or a string') |
109 end | 140 end |
186 btnProcess:SetScript("OnLeave", function() | 217 btnProcess:SetScript("OnLeave", function() |
187 GameTooltip:Hide() | 218 GameTooltip:Hide() |
188 end) | 219 end) |
189 | 220 |
190 btnSkillet = CreateFrame("Button", nil, craftingContent, "UIPanelButtonTemplate") | 221 btnSkillet = CreateFrame("Button", nil, craftingContent, "UIPanelButtonTemplate") |
191 btnSkillet:SetText("Queue in Skillet") | 222 |
223 | |
192 btnSkillet:SetSize(125, 25) | 224 btnSkillet:SetSize(125, 25) |
193 btnSkillet:SetPoint("BOTTOMRIGHT", btnProcess, 'BOTTOMLEFT', 0, 0) | 225 btnSkillet:SetPoint("BOTTOMRIGHT", btnProcess, 'BOTTOMLEFT', 0, 0) |
194 btnSkillet:RegisterForClicks("LeftButtonUp"); | 226 btnSkillet:RegisterForClicks("LeftButtonUp"); |
195 btnSkillet:SetScript("OnClick", function (self, button, down) | 227 btnSkillet:SetScript("OnClick", function (self, button, down) |
196 ExportToSkillet() | 228 Crafting.Export() |
197 end) | 229 end) |
198 | 230 |
199 end | 231 end |
232 local destination = select(2, Crafting.GetQueueDestination()) | |
233 btnSkillet:SetText("Export to "..destination) | |
234 | |
200 craftingContent:Show() | 235 craftingContent:Show() |
201 | 236 |
202 if container.parent then | 237 if container.parent then |
203 local width = 80 | 238 local width = 80 |
204 for i, data in pairs(craftingCols) do | 239 for i, data in pairs(craftingCols) do |