comparison Modules/DisplayInvested.lua @ 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 e27d13095b49
children 9a6d4e2768fd
comparison
equal deleted inserted replaced
42:1ff3b83b104c 43:60ab9a4d2de1
49 -- ItemAuditor:SaveValue(link, newValue, 0) 49 -- ItemAuditor:SaveValue(link, newValue, 0)
50 50
51 promptFrame:Hide() 51 promptFrame:Hide()
52 end 52 end
53 53
54 StaticPopupDialogs["ItemAuditor_NewPrice"] = {
55 text = "New price %s %s",
56 button1 = SAVE,
57 button2 = CANCEL,
58 hasEditBox = 1,
59 showAlert = 1,
60 OnAccept = function()
61 skipCODTracking = true
62 end,
63 EditBoxOnEnterPressed = function()
64 if ( getglobal(this:GetParent():GetName().."Button1"):IsEnabled() == 1 ) then
65 getglobal(this:GetParent():GetName().."Button1"):Click()
66 end
67 end,
68 EditBoxOnTextChanged = function ()
69 local parentName = this:GetParent():GetName()
70 local editBox = getglobal( parentName.."EditBox");
71 local value = editBox:GetText()
72 if validateMoney(value) then
73 getglobal(parentName.."Button1"):Enable();
74 else
75 getglobal(parentName.."Button1"):Disable();
76 end
77 end,
78 EditBoxOnEscapePressed = function()
79 this:GetParent():Hide();
80 ClearCursor();
81 end,
82 timeout = 0,
83 hideOnEscape = 1,
84 exclusive = true,
85 }
54 86
55 local function PromptForNewPrice(link, type) 87 local function PromptForNewPrice(link, type)
88 -- function(widget, event, text) SaveNewValue(link, type, text) end
56 local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link) 89 local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link)
57 local itemName, displayLink = GetItemInfo(link) 90
58 local priceDesc = " Invested Each:" 91 local typeText = "Invested Each"
59 local price = investedPerItem 92 local price = investedPerItem
60
61 if type == priceTypeTotal then 93 if type == priceTypeTotal then
62 priceDesc = " Invested Total:" 94 typeText = "Invested Total"
63 price = investedTotal 95 price = investedTotal
64 end 96
65 97 end
66 if not promptFrame then 98
67 promptFrame = AceGUI:Create("Frame") 99 StaticPopupDialogs["ItemAuditor_NewPrice"].text = format("Update %s: %s|nThe current value is %s", typeText, link, ItemAuditor:FormatMoney(price))
68 ItemAuditor:RegisterFrame(promptFrame) 100
69 101 StaticPopupDialogs["ItemAuditor_NewPrice"].OnShow = function (self, data)
70 local window = promptFrame.frame; 102 self.editBox:SetText(ItemAuditor:FormatMoney(price, '', true))
71 local width = 345 103 end
72 local height = 115 104
73 window:SetWidth(width ) 105 StaticPopupDialogs["ItemAuditor_NewPrice"].OnAccept = function()
74 window:SetHeight(height ) 106 local name = this:GetParent():GetName().."EditBox"
75 window:SetMinResize(width, height) 107 local button = getglobal(name)
76 window:SetMaxResize(width, height) 108 local newValue = button:GetText()
77 109 newValue = parseMoney(newValue)
78 promptFrame:SetTitle("ItemAuditor") 110
79 promptFrame:SetStatusText("Status Here") 111 local investedTotal, investedPerItem, numOwned = ItemAuditor:GetItemCost(link)
80 promptFrame:SetCallback("OnClose", function(widget) AceGUI:Release(widget); promptFrame = false end) 112
81 promptFrame:SetLayout("Flow") 113 if type == priceTypeEach then
82 114 newValue = newValue * numOwned
83 promptFrame.editbox = AceGUI:Create("EditBox") 115 end
84 promptFrame.editbox:SetWidth(300) 116
85 promptFrame:AddChild(promptFrame.editbox) 117 ItemAuditor:SaveValue(link, newValue-investedTotal, 0)
86 end 118 end
87 promptFrame.editbox:SetCallback("OnEnterPressed", function(widget, event, text) SaveNewValue(link, type, text) end) 119 StaticPopup_Show ("ItemAuditor_NewPrice", link, 'two');
88 promptFrame:SetStatusText("Current Price: "..ItemAuditor:FormatMoney(price))
89 promptFrame.editbox:SetLabel(displayLink..priceDesc)
90 promptFrame.editbox:SetText(ItemAuditor:FormatMoney(price, "", true))
91
92 promptFrame:Show()
93 editBox = promptFrame.editbox
94 end 120 end
95 121
96 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) 122 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
97 if fShow == true then 123 if fShow == true then
98 local money = data[realrow][column] 124 local money = data[realrow][column]
99 if money == nil then 125 cellFrame.text:SetText(ItemAuditor:FormatMoney(data[realrow][column]))
100 cellFrame.text:SetText("None")
101 else
102 cellFrame.text:SetText(ItemAuditor:FormatMoney(data[realrow][column]))
103 end
104 end 126 end
105 end 127 end
106 128
107 local investedCols = { 129 local investedCols = {
108 { name= "Item", width = 200, 130 { name= "Item", width = 200, defaultsort = "desc",
109 ['DoCellUpdate'] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) 131 ['DoCellUpdate'] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
110 if fShow == true then 132 if fShow == true then
111 local _, link= strsplit("|", data[realrow][column], 2) 133 local _, link= strsplit("|", data[realrow][column], 2)
112 cellFrame.text:SetText(link) 134 cellFrame.text:SetText(link)
113 end 135 end
117 ['DoCellUpdate'] = displayMoney, 139 ['DoCellUpdate'] = displayMoney,
118 }, 140 },
119 { name= "Invested Each", width = 100, align = "RIGHT", 141 { name= "Invested Each", width = 100, align = "RIGHT",
120 ['DoCellUpdate'] = displayMoney, 142 ['DoCellUpdate'] = displayMoney,
121 }, 143 },
122 { name= "# Owned", width = 50, align = "RIGHT", defaultsort = "asc", }, 144 { name= "# Owned", width = 50, align = "RIGHT", },
123 } 145 }
124 146
125 local investedTable = false 147 local investedTable = false
126 local function ShowInvested(container) 148 local function ShowInvested(container)
127 if investedTable == false then 149 if investedTable == false then
190 if not displayFrame then 212 if not displayFrame then
191 -- Create the frame container 213 -- Create the frame container
192 displayFrame = AceGUI:Create("Frame") 214 displayFrame = AceGUI:Create("Frame")
193 ItemAuditor:RegisterFrame(displayFrame) 215 ItemAuditor:RegisterFrame(displayFrame)
194 local window = displayFrame.frame; 216 local window = displayFrame.frame;
217 -- I have no idea why AceGUI insists on using FULLSCREEN_DIALOG by default.
218 window:SetFrameStrata("MEDIUM")
195 displayFrame:SetTitle("ItemAuditor") 219 displayFrame:SetTitle("ItemAuditor")
196 displayFrame:SetStatusText("") 220 displayFrame:SetStatusText("")
197 221
198 displayFrame:SetLayout("Fill") 222 displayFrame:SetLayout("Fill")
199 223