# HG changeset patch # User Asa Ayers # Date 1279269128 25200 # Node ID 34daa46b644a072998e13bb85ba0e649363d5082 # Parent 5da5d85cd714df74ef8cae04683510697ea85625 Added an interface to view how much you have invested in each item. diff -r 5da5d85cd714 -r 34daa46b644a .pkgmeta --- a/.pkgmeta Wed Jul 14 00:29:16 2010 -0700 +++ b/.pkgmeta Fri Jul 16 01:32:08 2010 -0700 @@ -29,6 +29,9 @@ Libs/AceTimer-3.0: url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceTimer-3.0 tag: latest + Libs/lib-st: + url: svn://svn.wowace.com/wow/lib-st/mainline/trunk + tag: latest required-dependencies: - Altoholic diff -r 5da5d85cd714 -r 34daa46b644a Core.lua --- a/Core.lua Wed Jul 14 00:29:16 2010 -0700 +++ b/Core.lua Fri Jul 16 01:32:08 2010 -0700 @@ -46,6 +46,7 @@ -- /run ItemAuditor.db.profile.show_debug_frame_on_startup = true if self.db.profile.show_debug_frame_on_startup then ItemAuditor_DebugFrame:Show() + self:CreateFrames() end end @@ -231,15 +232,21 @@ end - + if self.items[link] ~= nil then + if self.items[link].invested == nil or self.items[link].invested <= 0 then + self.items[link] = nil + end + end if viewOnly == true and self.items[link] == nil then return {count = 0, invested = 0} elseif viewOnly == true then + return {count = self.items[link].count, invested = self.items[link].invested} end self.items[link].count = Altoholic:GetItemCount(self:GetIDFromLink(link)) - self.items[link].invested = tonumber(self.items[link].invested) + + return self.items[link] end diff -r 5da5d85cd714 -r 34daa46b644a ItemAuditor.toc --- a/ItemAuditor.toc Wed Jul 14 00:29:16 2010 -0700 +++ b/ItemAuditor.toc Fri Jul 16 01:32:08 2010 -0700 @@ -20,3 +20,4 @@ Modules\Options.lua Modules\Debug.lua +Modules\DisplayInvested.lua diff -r 5da5d85cd714 -r 34daa46b644a Modules/DisplayInvested.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/DisplayInvested.lua Fri Jul 16 01:32:08 2010 -0700 @@ -0,0 +1,157 @@ +local addonName, addonTable = ...; +local ItemAuditor = _G[addonName] + +local AceGUI = LibStub("AceGUI-3.0") +local ScrollingTable = LibStub("ScrollingTable") + +local investedCols = { + { name= "Item", width = 200, + ['DoCellUpdate'] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) + if fShow == true then + local _, link= strsplit("|", data[realrow][column], 2) + cellFrame.text:SetText(link) + end + end, + }, + { name= "Invested Total", width = 100, align = "RIGHT", + ['DoCellUpdate'] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) + if fShow == true then + cellFrame.text:SetText(ItemAuditor:FormatMoney(data[realrow][column])) + end + end, + }, + { name= "Invested each", width = 100, align = "RIGHT", + ['DoCellUpdate'] = function(rowFrame, cellFrame, data, cols, row, realrow, column, fShow, table, ...) + if fShow == true then + cellFrame.text:SetText(ItemAuditor:FormatMoney(data[realrow][column])) + end + end, + }, + { name= "Count", width = 50, defaultsort = "asc", }, +} + +local investedTable = false +local function ShowInvested(container) + if investedTable == false then + local window = container.frame + investedTable = ScrollingTable:CreateST(investedCols, 23, nil, nil, window) + investedTable.frame:SetPoint("BOTTOMLEFT",window, 10,10) + investedTable.frame:SetPoint("TOP", window, 0, -60) + investedTable.frame:SetPoint("RIGHT", window, -10,0) + investedTable:RegisterEvents({ + ["OnEnter"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) + if realrow then + local _, link= strsplit("|", data[realrow][1], 2) + + GameTooltip:SetOwner(rowFrame, "ANCHOR_CURSOR") + GameTooltip:SetHyperlink(link) + GameTooltip:Show() + end + end, + ["OnLeave"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) + GameTooltip:Hide() + end, + ["OnClick"] = function (rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) + if column == 3 then + GameTooltip:Hide() + end + end, + }); + end + investedTable:Show() + + local width = 80 + for i, data in pairs(investedCols) do + width = width + data.width + end + if container.parent then + container.parent:SetWidth(width); + end + + + UpdateInvestedData() +end + + +local function switchTab(container, event, group) + container:ReleaseChildren() + + if investedTab then investedTab:Hide() end + + if group == "tab_invested" then + ShowInvested(container) + end +end + + + +displayFrame = false +local function CreateFrames() + if not displayFrame then + -- Create the frame container + displayFrame = AceGUI:Create("Frame") + local window = displayFrame.frame; + displayFrame:SetTitle("ItemAuditor") + displayFrame:SetStatusText("") + + displayFrame:SetLayout("Fill") + + window:SetHeight(500); + + local width = 80 + for i, data in pairs(investedCols) do + width = width + data.width + end + window:SetWidth(width); + + local tab = AceGUI:Create("TabGroup") + tab:SetLayout("Flow") + tab:SetTabs({{text="Invested", value="tab_invested"}}) + tab:SetCallback("OnGroupSelected", switchTab) + tab:SelectTab("tab_invested") + + displayFrame:AddChild(tab) + end + displayFrame:Show() +end + + + + + +function UpdateInvestedData() + if investedTable then + tableData = {} --reset + local totalInvested = 0 + + local i = 1 + local data + for link in pairs(ItemAuditor.db.factionrealm.items) do + local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link) + local itemName, link = GetItemInfo(link) + if investedTotal > 0 then + tableData[i] = { + itemName.."|"..link, + investedTotal, + investedPerItem, + count, + } + + totalInvested = totalInvested + investedTotal + + i = i + 1 + end + end + + if investedTable.frame:IsShown() then + displayFrame:SetStatusText("Total Invested: "..ItemAuditor:FormatMoney(totalInvested)) + end + + investedTable:SetData(tableData, true) + end +end + +function ItemAuditor:CreateFrames() + CreateFrames() +end + diff -r 5da5d85cd714 -r 34daa46b644a Modules/Options.lua --- a/Modules/Options.lua Wed Jul 14 00:29:16 2010 -0700 +++ b/Modules/Options.lua Fri Jul 16 01:32:08 2010 -0700 @@ -1,4 +1,4 @@ - local addonName, addonTable = ...; +local addonName, addonTable = ...; local addon = _G[addonName] local utils = addonTable.utils @@ -148,7 +148,14 @@ desc = "Shows the debug frame", func = function() ItemAuditor_DebugFrame:Show() end, guiHidden = true, - } + }, + invested = { + type = "execute", + name = "invested", + desc = "Shows what you have invested in", + func = "CreateFrames", + guiHidden = false, + }, }, } diff -r 5da5d85cd714 -r 34daa46b644a embeds.xml --- a/embeds.xml Wed Jul 14 00:29:16 2010 -0700 +++ b/embeds.xml Fri Jul 16 01:32:08 2010 -0700 @@ -9,4 +9,5 @@ +