changeset 48:508110e7c8ee

Merged my fix for the changelog
author Asa Ayers <Asa.Ayers@Gmail.com>
date Tue, 20 Jul 2010 00:20:15 -0700
parents aae189bf32ce (current diff) a66f6fc57cfb (diff)
children 84bfb5469189
files CHANGELOG.txt
diffstat 6 files changed, 100 insertions(+), 63 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Jul 20 00:18:10 2010 -0700
+++ b/.hgtags	Tue Jul 20 00:20:15 2010 -0700
@@ -1,2 +1,3 @@
 554b30908b33c90caa09fc0f554e2ec1d2a45270 v0.1
 aaa716c93fb2478d38b268710466c54cd56e1332 v0.1.1
+5273038322d7a0884d2d256534daceec8957dc02 release
--- a/CHANGELOG.txt	Tue Jul 20 00:18:10 2010 -0700
+++ b/CHANGELOG.txt	Tue Jul 20 00:20:15 2010 -0700
@@ -1,6 +1,10 @@
 2010-07-20  Asa Ayers  <Asa.Ayers@Gmail.com>
 
 - Implemented COD mail (Ticket #1) and updated the way postage was counted so that if you mail multiple items at once, they will all have the postage counted. I also removed the 30c for postage from how QA thresholds are calculated now that they will be counted every time.
+- Added a dialog to allow the user to send COD mail without a tracking number.
+- Replaced my edit window with a static popup. This looks and behaves better this way.
+- Fixed a couple nil related bugs
+- Fixed the way prices were being calculated as items were being created/destroyed/converted/crafted
 
 2010-07-18  Asa Ayers  <Asa.Ayers@Gmail.com>
 
--- a/Core.lua	Tue Jul 20 00:18:10 2010 -0700
+++ b/Core.lua	Tue Jul 20 00:20:15 2010 -0700
@@ -220,10 +220,11 @@
 			local trackID
 			if outboundSubject ~= nil then
 				self:Debug(outboundSubject)
-				trackID = tonumber(select(3, outboundSubject:find('[[]IA: (%d*)[]]')))
+				trackID = select(3, outboundSubject:find('[[]IA: (%d*)[]]'))
 				
-				self:Debug('COD ID: %s', trackID)
 				if trackID ~= nil then
+					trackID = tonumber(trackID)
+					self:Debug('COD ID: %s', trackID)
 					local cod = self.db.factionrealm.outbound_cod[trackID]
 					if cod == nil then
 						skipMail[mailSignature] = true
@@ -308,6 +309,10 @@
 	
 	if self.items[link] ~= nil then
 		self.items[link].count =  Altoholic:GetItemCount(self:GetIDFromLink(link))
+		
+		if self.items[link].invested == nil then
+			self.items[link].invested = 0
+		end
 	end
 	
 	if viewOnly == true and self.items[link] == nil then
@@ -432,7 +437,7 @@
 			count = count - countModifier
 		end
 		if count > 0 then 
-			return ceil(item.invested), ceil(item.invested/item.count), count
+			return ceil(item.invested), ceil(item.invested/count), count
 		end
 		
 	end
--- a/ItemAuditor.xml	Tue Jul 20 00:18:10 2010 -0700
+++ b/ItemAuditor.xml	Tue Jul 20 00:20:15 2010 -0700
@@ -1,7 +1,7 @@
 <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
 	../UI.xsd">
 	
-	<Frame name="ItemAuditor_DebugFrame" toplevel="true" movable="true" parent="UIParent" enableMouse="true" resizable="false" frameStrata="MEDIUM"  hidden="true">
+	<Frame name="ItemAuditor_DebugFrame" toplevel="true" movable="true" parent="UIParent" enableMouse="true" resizable="false" frameStrata="LOW"  hidden="true">
 		<Size x="640" y="512"/>
 		<Anchors>
 			<Anchor point="CENTER"/>
--- a/Modules/DisplayInvested.lua	Tue Jul 20 00:18:10 2010 -0700
+++ b/Modules/DisplayInvested.lua	Tue Jul 20 00:20:15 2010 -0700
@@ -34,78 +34,82 @@
 	
 end
 
-local function SaveNewValue(link, type, text)
-	if not validateMoney(text) then
-		error("Invalid value")
-	end
-	local investedTotal, investedPerItem, numOwned = ItemAuditor:GetItemCost(link)
-	local newValue=parseMoney(text)
-	
-	if type == priceTypeEach then
-		newValue = newValue * numOwned
-	end
-	
-	ItemAuditor:SaveValue(link, newValue-investedTotal, 0)
-	-- ItemAuditor:SaveValue(link, newValue, 0)
-	
-	promptFrame:Hide()
-end
-
+StaticPopupDialogs["ItemAuditor_NewPrice"] = {
+	text = "New price %s %s",
+	button1 = SAVE,
+	button2 = CANCEL,
+	hasEditBox = 1,
+	showAlert = 1,
+	OnAccept = function()
+		skipCODTracking = true
+	end,
+	EditBoxOnEnterPressed = function()
+		if ( getglobal(this:GetParent():GetName().."Button1"):IsEnabled() == 1 ) then
+			getglobal(this:GetParent():GetName().."Button1"):Click()
+		end
+	end,
+	EditBoxOnTextChanged = function ()
+		local parentName = this:GetParent():GetName()
+		local editBox = getglobal( parentName.."EditBox");
+		local value = editBox:GetText()
+		if validateMoney(value) then
+			getglobal(parentName.."Button1"):Enable();
+		else
+			getglobal(parentName.."Button1"):Disable();
+		end
+	end,
+	EditBoxOnEscapePressed = function()
+		this:GetParent():Hide();
+		ClearCursor();
+	end,
+	timeout = 0,
+	hideOnEscape = 1,
+	exclusive = true,
+}
 
 local function PromptForNewPrice(link, type)
 	local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link)
-	local itemName, displayLink = GetItemInfo(link)
-	local priceDesc = " Invested Each:"
+
+	local typeText = "Invested Each"
 	local price = investedPerItem
+	if type == priceTypeTotal then
+		typeText = "Invested Total"
+		price = investedTotal
+
+	end
 	
-	if type == priceTypeTotal then
-		priceDesc = " Invested Total:"
-		price = investedTotal
+	StaticPopupDialogs["ItemAuditor_NewPrice"].text = format("Update %s: %s|nThe current value is %s", typeText, link, ItemAuditor:FormatMoney(price))
+	
+	StaticPopupDialogs["ItemAuditor_NewPrice"].OnShow = function (self, data)
+		self.editBox:SetText(ItemAuditor:FormatMoney(price, '', true))
 	end
-
-	if not promptFrame then
-		promptFrame = AceGUI:Create("Frame")
-		ItemAuditor:RegisterFrame(promptFrame)
-
-		local window = promptFrame.frame;
-		local width = 345
-		local height = 115
-		window:SetWidth(width )
-		window:SetHeight(height )
-		window:SetMinResize(width, height)
-		window:SetMaxResize(width, height)
+	
+	StaticPopupDialogs["ItemAuditor_NewPrice"].OnAccept = function()
+		local name = this:GetParent():GetName().."EditBox"
+		local button = getglobal(name)
+		local newValue = button:GetText()
+		newValue = parseMoney(newValue)
 		
-		promptFrame:SetTitle("ItemAuditor")
-		promptFrame:SetStatusText("Status Here")
-		promptFrame:SetCallback("OnClose", function(widget) AceGUI:Release(widget); promptFrame = false end)
-		promptFrame:SetLayout("Flow")
-
-		promptFrame.editbox = AceGUI:Create("EditBox")
-		promptFrame.editbox:SetWidth(300)
-		promptFrame:AddChild(promptFrame.editbox)
+		local investedTotal, investedPerItem, numOwned = ItemAuditor:GetItemCost(link)
+		
+		if type == priceTypeEach then
+			newValue = newValue * numOwned
+		end
+		
+		ItemAuditor:SaveValue(link, newValue-investedTotal, 0)
 	end
-	promptFrame.editbox:SetCallback("OnEnterPressed", function(widget, event, text) SaveNewValue(link, type, text) end)
-	promptFrame:SetStatusText("Current Price: "..ItemAuditor:FormatMoney(price))
-	promptFrame.editbox:SetLabel(displayLink..priceDesc)
-	promptFrame.editbox:SetText(ItemAuditor:FormatMoney(price, "", true))
-	
-	promptFrame:Show()
-	editBox = promptFrame.editbox
+	StaticPopup_Show ("ItemAuditor_NewPrice", link, 'two');
 end
 
 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
 	if fShow == true then
 		local money = data[realrow][column]
-		if money == nil then
-			cellFrame.text:SetText("None")
-		else
-			cellFrame.text:SetText(ItemAuditor:FormatMoney(data[realrow][column]))
-		end
+		cellFrame.text:SetText(ItemAuditor:FormatMoney(data[realrow][column]))
 	end
 end
 
 local investedCols = {
-	{ name= "Item", width = 200, 
+	{ name= "Item", width = 200, defaultsort = "desc",
 		['DoCellUpdate'] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
 			if fShow == true then
 				local _, link= strsplit("|", data[realrow][column], 2)
@@ -119,7 +123,7 @@
 	{ name= "Invested Each", width = 100, align = "RIGHT", 
 		['DoCellUpdate'] = displayMoney,
 	},
-	{ name= "# Owned", width = 50, align = "RIGHT", defaultsort = "asc", },
+	{ name= "# Owned", width = 50, align = "RIGHT", },
 }
 
 local investedTable = false
@@ -192,6 +196,8 @@
 		displayFrame = AceGUI:Create("Frame")
 		ItemAuditor:RegisterFrame(displayFrame)
 		local window = displayFrame.frame;
+		-- I have no idea why AceGUI insists on using FULLSCREEN_DIALOG by default.
+		window:SetFrameStrata("MEDIUM")
 		displayFrame:SetTitle("ItemAuditor")
 		displayFrame:SetStatusText("")
 
--- a/Modules/Events.lua	Tue Jul 20 00:18:10 2010 -0700
+++ b/Modules/Events.lua	Tue Jul 20 00:20:15 2010 -0700
@@ -50,6 +50,19 @@
 
 local attachedItems = {}
 local Orig_SendMail = SendMail
+local skipCODTracking = false
+
+StaticPopupDialogs["ItemAuditor_Send_COD_without_tracking_number"] = {
+	text = "ItemAuditor cannot track COD mail with multiple item types attached. Do you want to send this mail without tracking?",
+	button1 = "Yes",
+	button2 = "No",
+	OnAccept = function()
+		skipCODTracking = true
+	end,
+	timeout = 0,
+	whileDead = true,
+	hideOnEscape = true,
+}
 
 function SendMail(recipient, subject, body, ...)
 	local self = ItemAuditor
@@ -80,11 +93,18 @@
 		data.price = pricePerStack * data.stacks
 	end
 	
-	if self.mailOutbox.COD > 0 then
+	if self.mailOutbox.COD > 0 and skipCODTracking then
+		
+	elseif self.mailOutbox.COD > 0 then
 		if self:tcount(attachedItems) > 1 then
-			self:Print("ERROR: ItemAuditor can't track COD mail with more than one item type.")
 			self:GenerateBlankOutbox()
-			-- I need to make a prompt so the user can send the mail without interference
+			local vararg = ...
+			StaticPopupDialogs["ItemAuditor_Send_COD_without_tracking_number"].OnAccept = function()
+				skipCODTracking = true
+				SendMail(recipient, subject, body, vararg)
+				skipCODTracking = false
+			end
+			StaticPopup_Show ("ItemAuditor_Send_COD_without_tracking_number");
 			return
 		end
 		self:Debug("COD mail")
@@ -106,6 +126,7 @@
 end
 
 function addon:MAIL_SUCCESS(event)
+	skipCODTracking = false
 	for link, data in pairs(attachedItems) do
 		self:SaveValue(link, data.price, data.count)
 	end