changeset 43:60ab9a4d2de1

Replaced my edit window with a static popup. This looks and behaves better this way. This commit also includes some small cleanup on frame strata for the invested and debug windows.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Mon, 19 Jul 2010 22:46:52 -0700
parents 1ff3b83b104c
children 9a6d4e2768fd
files CHANGELOG.txt ItemAuditor.xml Modules/DisplayInvested.lua
diffstat 3 files changed, 65 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG.txt	Mon Jul 19 21:42:44 2010 -0700
+++ b/CHANGELOG.txt	Mon Jul 19 22:46:52 2010 -0700
@@ -2,6 +2,7 @@
 
 - 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.
 
 2010-07-18  Asa Ayers  <Asa.Ayers@Gmail.com>
 
--- a/ItemAuditor.xml	Mon Jul 19 21:42:44 2010 -0700
+++ b/ItemAuditor.xml	Mon Jul 19 22:46:52 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	Mon Jul 19 21:42:44 2010 -0700
+++ b/Modules/DisplayInvested.lua	Mon Jul 19 22:46:52 2010 -0700
@@ -51,61 +51,83 @@
 	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)
+	-- function(widget, event, text) SaveNewValue(link, type, text) end
 	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 +141,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 +214,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("")