comparison Modules/Crafting.lua @ 101:53147a647e28

Converted the crafting threshold option to allow input instead of a drop down.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Thu, 19 Aug 2010 23:26:54 -0700
parents e9b903cf9b33
children 89663c9dd772
comparison
equal deleted inserted replaced
100:e6292f1a0cf3 101:53147a647e28
40 end 40 end
41 41
42 error('Unable to determine queue destination.') 42 error('Unable to determine queue destination.')
43 end 43 end
44 44
45 -- TODO: Convert this to a text field.
46 local craftingThresholds = {5000, 10000, 50000}
47 local craftingThresholdsDisplay = {}
48
49 for key, value in pairs(craftingThresholds) do
50 craftingThresholdsDisplay[key] = ItemAuditor:FormatMoney(value, '', true)
51 -- craftingThresholdsDisplay[key] = value
52 end
53
54 function ItemAuditor:GetCraftingThreshold() 45 function ItemAuditor:GetCraftingThreshold()
55 local key = ItemAuditor.db.char.crafting_threshold 46 return self.db.char.profitable_threshold
56 return craftingThresholds[key]
57 end 47 end
58 48
59 ItemAuditor.Options.args.crafting_options = { 49 ItemAuditor.Options.args.crafting_options = {
60 name = "Crafting", 50 name = "Crafting",
61 type = 'group', 51 type = 'group',
62 args = { 52 args = {
63 crafting_threshold = {
64 type = "select",
65 name = "Crafting Threshold",
66 desc = "Don't create items that will make less than this amount of profit",
67 values = craftingThresholdsDisplay,
68 get = function() return ItemAuditor.db.char.crafting_threshold end,
69 set = function(info, value) ItemAuditor.db.char.crafting_threshold = value end,
70 order = 0,
71 },
72 queue_destination = { 53 queue_destination = {
73 type = "select", 54 type = "select",
74 name = "Queue Destination", 55 name = "Queue Destination",
75 desc = "Select the addon who's queue you would like ItemAuditor to post to.", 56 desc = "Select the addon who's queue you would like ItemAuditor to post to.",
76 values = displayCraftingDestinations, 57 values = displayCraftingDestinations,
81 deciders = { 62 deciders = {
82 type="header", 63 type="header",
83 name="Crafting Deciders", 64 name="Crafting Deciders",
84 order = 10, 65 order = 10,
85 }, 66 },
86
87 }, 67 },
88 } 68 }
89 69
90 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) 70 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
91 if fShow == true then 71 if fShow == true then
370 return 1 350 return 1
371 end 351 end
372 return -1, 'Not Profitable' 352 return -1, 'Not Profitable'
373 end 353 end
374 354
375 Crafting.RegisterCraftingDecider('Is Profitable', isProfitable) 355 local isProfitableOptions = {
356 profitable_threshold = {
357 type = "input",
358 name = "Crafting Threshold",
359 desc = "Don't create items that will make less than this amount of profit",
360 get = function() return
361 Utils.FormatMoney(ItemAuditor:GetCraftingThreshold(), '', true)
362 end,
363 validate = function(info, value)
364 if not Utils.validateMoney(value) then
365 return "Invalid money format"
366 end
367 return true
368 end,
369 set = function(info, value)
370 ItemAuditor.db.char.profitable_threshold = Utils.parseMoney(value)
371 end,
372 usage = "###g ##s ##c",
373 order = 0,
374 },
375 }
376
377 Crafting.RegisterCraftingDecider('Is Profitable', isProfitable, isProfitableOptions)
376 378
377 379
378 380
379 local tableData = {} 381 local tableData = {}
380 function ItemAuditor:UpdateCraftingTable() 382 function ItemAuditor:UpdateCraftingTable()