changeset 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 e6292f1a0cf3
children 89663c9dd772
files CHANGELOG.txt Core.lua Modules/Crafting.lua Modules/Utils.lua
diffstat 4 files changed, 40 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG.txt	Thu Aug 19 23:22:53 2010 -0700
+++ b/CHANGELOG.txt	Thu Aug 19 23:26:54 2010 -0700
@@ -3,6 +3,7 @@
 - Ticket 30 (related to #23) - ItemAuditor is back to counting items in the mailbox, but will subtract items purchased from the AH or COD mail from its item counts.
 - 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.
 - Added a new Crafting Rules module to allow the user to set up custom rules based on item names.
+- Converted the crafting threshold option to allow input instead of a drop down.
 
 2010-08-14  Asa Ayers  <Asa.Ayers@Gmail.com>
 
--- a/Core.lua	Thu Aug 19 23:22:53 2010 -0700
+++ b/Core.lua	Thu Aug 19 23:26:54 2010 -0700
@@ -46,7 +46,7 @@
 	char = {
 		ah = 1,
 		use_quick_auctions = false,
-		crafting_threshold = 1,
+		profitable_threshold = 10000,
 		auction_threshold = 0.15,
 		qa_extra = 0,
 		output_chat_frame = nil,
@@ -85,6 +85,19 @@
 	
 	LibStub("AceConsole-3.0"):RegisterChatCommand('rl', ReloadUI)
 
+	if self.db.char.crafting_threshold then
+		local threshold = self.db.char.crafting_threshold
+		if threshold == 1 then
+			self.db.char.profitable_threshold = 5000
+		elseif threshold == 2 then
+			self.db.char.profitable_threshold = 10000
+		elseif threshold == 3 then
+			self.db.char.profitable_threshold = 50000
+		end
+	
+		self.db.char.crafting_threshold = nil
+	end
+
 	--@debug@
 		-- ItemAuditor_DebugFrame:Show()
 		-- self:CreateFrame('tab_crafting')
--- a/Modules/Crafting.lua	Thu Aug 19 23:22:53 2010 -0700
+++ b/Modules/Crafting.lua	Thu Aug 19 23:26:54 2010 -0700
@@ -42,33 +42,14 @@
 	error('Unable to determine queue destination.')
 end
 
--- TODO: Convert this to a text field.
-local craftingThresholds = {5000, 10000, 50000}
-local craftingThresholdsDisplay = {}
-
-for key, value in pairs(craftingThresholds) do
-	craftingThresholdsDisplay[key] = ItemAuditor:FormatMoney(value, '', true)
-	-- craftingThresholdsDisplay[key] = value
-end
-
 function ItemAuditor:GetCraftingThreshold()
-	local key = ItemAuditor.db.char.crafting_threshold
-	return craftingThresholds[key]
+	return self.db.char.profitable_threshold
 end
 
 ItemAuditor.Options.args.crafting_options = {
 	name = "Crafting",
 	type = 'group',
 	args = {
-		crafting_threshold = {
-			type = "select",
-			name = "Crafting Threshold",
-			desc = "Don't create items that will make less than this amount of profit",
-			values = craftingThresholdsDisplay,
-			get = function() return ItemAuditor.db.char.crafting_threshold end,
-			set = function(info, value) ItemAuditor.db.char.crafting_threshold = value end,
-			order = 0,
-		},
 		queue_destination = {
 			type = "select",
 			name = "Queue Destination",
@@ -83,7 +64,6 @@
 			name="Crafting Deciders",
 			order = 10,
 		},
-		
 	},
 }
 
@@ -372,7 +352,29 @@
 	return -1, 'Not Profitable'
 end
 
-Crafting.RegisterCraftingDecider('Is Profitable', isProfitable)
+local isProfitableOptions = {
+	profitable_threshold = {
+		type = "input",
+		name = "Crafting Threshold",
+		desc = "Don't create items that will make less than this amount of profit",
+		get = function() return
+			Utils.FormatMoney(ItemAuditor:GetCraftingThreshold(), '', true)
+		end,
+		validate = function(info, value)
+			if not Utils.validateMoney(value) then
+				return "Invalid money format"
+			end
+			return true
+		end,
+		set = function(info, value)
+			ItemAuditor.db.char.profitable_threshold = Utils.parseMoney(value)
+		end,
+		usage = "###g ##s ##c",
+		order = 0,
+	},
+}
+
+Crafting.RegisterCraftingDecider('Is Profitable', isProfitable, isProfitableOptions)
 
 
 
--- a/Modules/Utils.lua	Thu Aug 19 23:22:53 2010 -0700
+++ b/Modules/Utils.lua	Thu Aug 19 23:26:54 2010 -0700
@@ -4,6 +4,7 @@
 function Utils.FormatMoney(copper, color, textOnly)
 	color = color or "|cFFFFFFFF"
 	local prefix = ""
+	copper = copper or 0
 	if copper < 0 then
 		prefix = "-"
 		copper = abs(copper)