comparison Modules/DisplayInvested.lua @ 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 9a6d4e2768fd
children 5e981c1df761
comparison
equal deleted inserted replaced
47:aae189bf32ce 48:508110e7c8ee
32 -- Convert it all into copper 32 -- Convert it all into copper
33 return (copper or 0) + ((gold or 0) * COPPER_PER_GOLD) + ((silver or 0) * COPPER_PER_SILVER) 33 return (copper or 0) + ((gold or 0) * COPPER_PER_GOLD) + ((silver or 0) * COPPER_PER_SILVER)
34 34
35 end 35 end
36 36
37 local function SaveNewValue(link, type, text) 37 StaticPopupDialogs["ItemAuditor_NewPrice"] = {
38 if not validateMoney(text) then 38 text = "New price %s %s",
39 error("Invalid value") 39 button1 = SAVE,
40 end 40 button2 = CANCEL,
41 local investedTotal, investedPerItem, numOwned = ItemAuditor:GetItemCost(link) 41 hasEditBox = 1,
42 local newValue=parseMoney(text) 42 showAlert = 1,
43 43 OnAccept = function()
44 if type == priceTypeEach then 44 skipCODTracking = true
45 newValue = newValue * numOwned 45 end,
46 end 46 EditBoxOnEnterPressed = function()
47 47 if ( getglobal(this:GetParent():GetName().."Button1"):IsEnabled() == 1 ) then
48 ItemAuditor:SaveValue(link, newValue-investedTotal, 0) 48 getglobal(this:GetParent():GetName().."Button1"):Click()
49 -- ItemAuditor:SaveValue(link, newValue, 0) 49 end
50 50 end,
51 promptFrame:Hide() 51 EditBoxOnTextChanged = function ()
52 end 52 local parentName = this:GetParent():GetName()
53 53 local editBox = getglobal( parentName.."EditBox");
54 local value = editBox:GetText()
55 if validateMoney(value) then
56 getglobal(parentName.."Button1"):Enable();
57 else
58 getglobal(parentName.."Button1"):Disable();
59 end
60 end,
61 EditBoxOnEscapePressed = function()
62 this:GetParent():Hide();
63 ClearCursor();
64 end,
65 timeout = 0,
66 hideOnEscape = 1,
67 exclusive = true,
68 }
54 69
55 local function PromptForNewPrice(link, type) 70 local function PromptForNewPrice(link, type)
56 local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link) 71 local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link)
57 local itemName, displayLink = GetItemInfo(link) 72
58 local priceDesc = " Invested Each:" 73 local typeText = "Invested Each"
59 local price = investedPerItem 74 local price = investedPerItem
60
61 if type == priceTypeTotal then 75 if type == priceTypeTotal then
62 priceDesc = " Invested Total:" 76 typeText = "Invested Total"
63 price = investedTotal 77 price = investedTotal
64 end 78
65 79 end
66 if not promptFrame then 80
67 promptFrame = AceGUI:Create("Frame") 81 StaticPopupDialogs["ItemAuditor_NewPrice"].text = format("Update %s: %s|nThe current value is %s", typeText, link, ItemAuditor:FormatMoney(price))
68 ItemAuditor:RegisterFrame(promptFrame) 82
69 83 StaticPopupDialogs["ItemAuditor_NewPrice"].OnShow = function (self, data)
70 local window = promptFrame.frame; 84 self.editBox:SetText(ItemAuditor:FormatMoney(price, '', true))
71 local width = 345 85 end
72 local height = 115 86
73 window:SetWidth(width ) 87 StaticPopupDialogs["ItemAuditor_NewPrice"].OnAccept = function()
74 window:SetHeight(height ) 88 local name = this:GetParent():GetName().."EditBox"
75 window:SetMinResize(width, height) 89 local button = getglobal(name)
76 window:SetMaxResize(width, height) 90 local newValue = button:GetText()
77 91 newValue = parseMoney(newValue)
78 promptFrame:SetTitle("ItemAuditor") 92
79 promptFrame:SetStatusText("Status Here") 93 local investedTotal, investedPerItem, numOwned = ItemAuditor:GetItemCost(link)
80 promptFrame:SetCallback("OnClose", function(widget) AceGUI:Release(widget); promptFrame = false end) 94
81 promptFrame:SetLayout("Flow") 95 if type == priceTypeEach then
82 96 newValue = newValue * numOwned
83 promptFrame.editbox = AceGUI:Create("EditBox") 97 end
84 promptFrame.editbox:SetWidth(300) 98
85 promptFrame:AddChild(promptFrame.editbox) 99 ItemAuditor:SaveValue(link, newValue-investedTotal, 0)
86 end 100 end
87 promptFrame.editbox:SetCallback("OnEnterPressed", function(widget, event, text) SaveNewValue(link, type, text) end) 101 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 102 end
95 103
96 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) 104 local function displayMoney(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
97 if fShow == true then 105 if fShow == true then
98 local money = data[realrow][column] 106 local money = data[realrow][column]
99 if money == nil then 107 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 108 end
105 end 109 end
106 110
107 local investedCols = { 111 local investedCols = {
108 { name= "Item", width = 200, 112 { name= "Item", width = 200, defaultsort = "desc",
109 ['DoCellUpdate'] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) 113 ['DoCellUpdate'] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...)
110 if fShow == true then 114 if fShow == true then
111 local _, link= strsplit("|", data[realrow][column], 2) 115 local _, link= strsplit("|", data[realrow][column], 2)
112 cellFrame.text:SetText(link) 116 cellFrame.text:SetText(link)
113 end 117 end
117 ['DoCellUpdate'] = displayMoney, 121 ['DoCellUpdate'] = displayMoney,
118 }, 122 },
119 { name= "Invested Each", width = 100, align = "RIGHT", 123 { name= "Invested Each", width = 100, align = "RIGHT",
120 ['DoCellUpdate'] = displayMoney, 124 ['DoCellUpdate'] = displayMoney,
121 }, 125 },
122 { name= "# Owned", width = 50, align = "RIGHT", defaultsort = "asc", }, 126 { name= "# Owned", width = 50, align = "RIGHT", },
123 } 127 }
124 128
125 local investedTable = false 129 local investedTable = false
126 local function ShowInvested(container) 130 local function ShowInvested(container)
127 if investedTable == false then 131 if investedTable == false then
190 if not displayFrame then 194 if not displayFrame then
191 -- Create the frame container 195 -- Create the frame container
192 displayFrame = AceGUI:Create("Frame") 196 displayFrame = AceGUI:Create("Frame")
193 ItemAuditor:RegisterFrame(displayFrame) 197 ItemAuditor:RegisterFrame(displayFrame)
194 local window = displayFrame.frame; 198 local window = displayFrame.frame;
199 -- I have no idea why AceGUI insists on using FULLSCREEN_DIALOG by default.
200 window:SetFrameStrata("MEDIUM")
195 displayFrame:SetTitle("ItemAuditor") 201 displayFrame:SetTitle("ItemAuditor")
196 displayFrame:SetStatusText("") 202 displayFrame:SetStatusText("")
197 203
198 displayFrame:SetLayout("Fill") 204 displayFrame:SetLayout("Fill")
199 205