Mercurial > wow > inventory
changeset 9:3bac0bdd59e2
Close the summary frame when opening the config.
Remove ?track at? data when exporting/importing a group.
Don?t add items when importing a group that are already inside a group.
author | Zerotorescue |
---|---|
date | Sun, 10 Oct 2010 04:37:21 +0200 |
parents | 1f30a9ac9027 |
children | c4d0e5d47e10 |
files | .hgignore Core.lua Summary.lua |
diffstat | 3 files changed, 85 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Fri Oct 08 17:11:05 2010 +0200 +++ b/.hgignore Sun Oct 10 04:37:21 2010 +0200 @@ -1,1 +1,2 @@ glob:Libs +glob:TODO.txt
--- a/Core.lua Fri Oct 08 17:11:05 2010 +0200 +++ b/Core.lua Sun Oct 10 04:37:21 2010 +0200 @@ -266,6 +266,13 @@ cmd = string.lower(cmd); if cmd == "c" or cmd == "config" or cmd == "conf" or cmd == "option" or cmd == "options" or cmd == "opt" or cmd == "setting" or cmd == "settings" then + -- We don't want any other windows open at this time. + for name, module in self:IterateModules() do + if module.CloseFrame then + module:CloseFrame(); + end + end + self:Show(); elseif cmd == "d" or cmd == "debug" then self.debugChannel = false; @@ -291,7 +298,7 @@ elseif slashArgs[cmd] then slashArgs[cmd](); else - print("Wrong command, available: /inventory config (or /inventory c)"); + print("Wrong command, available: /inventory config (or /iy c) and /inventory summary (or /iy s)"); end end @@ -1210,6 +1217,8 @@ -- We want to include the group name, so we copy the table then set another value local temp = CopyTable(addon.db.global.groups[groupName]); temp.name = groupName; + temp.trackAtCharacters = nil; + temp.overrideTrackAtCharacters = nil; if not AceSerializer then AceSerializer = LibStub("AceSerializer-3.0"); @@ -1438,9 +1447,9 @@ name = "Group data", desc = "Paste the group data as provided by a group export. If you are trying to import multiple groups at the same time, make sure to use newlines to seperate them.", set = function(info, value) - local temp = { string.split("\n", value or "") }; + local data = { string.split("\n", value or "") }; - for no, current in pairs(temp) do + for _, current in pairs(data) do if not AceSerializer then AceSerializer = LibStub("AceSerializer-3.0"); end @@ -1454,17 +1463,39 @@ else name = temp.name; temp.name = nil; + print(("Importing %s..."):format(name)); end local newGroupName = string.trim(string.lower(name or "")); for name in pairs(self.db.global.groups) do if string.lower(name) == newGroupName then - print(("|cffff0000A group named \"%s\" already exists.|r"):format(name)); + print(("|cffff0000Aborting: A group named \"%s\" already exists.|r"):format(name)); return; end end - + + -- Remove items that are already in another group + for value, _ in pairs(temp.items) do + local itemId = tonumber(itemid); + + if not itemId then + print(("\"%s\" is not a number."):format(value)); + temp.items[value] = nil; + elseif InGroup(itemId) then + print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, InGroup(itemId))); + temp.items[value] = nil; + else + -- Ensure the keys are numeric + temp.items[value] = nil; + temp.items[itemId] = true; + end + end + + -- Ensure this data isn't received (this would be buggy as exports from other accounts won't know what to do with this) + temp.trackAtCharacters = nil; + temp.overrideTrackAtCharacters = nil; + self.db.global.groups[name] = temp; self:FillGroupOptions();
--- a/Summary.lua Fri Oct 08 17:11:05 2010 +0200 +++ b/Summary.lua Sun Oct 10 04:37:21 2010 +0200 @@ -72,8 +72,8 @@ mod.frame:SetTitle("Inventory Summary"); mod.frame:SetLayout("Fill"); mod.frame:SetCallback("OnClose", function(widget) - AceGUI:Release(widget); mod:CancelTimer(self.tmrUpdater, true); + mod:CloseFrame(); end); -- ScrollFrame child @@ -86,6 +86,13 @@ table.wipe(itemsCache); end +function mod:CloseFrame() + if mod.frame then + mod.frame:Release(); + mod.frame = nil; + end +end + local sortMethod = "item"; local sortDirectory = "ASC"; local function ReSort(subject) @@ -117,7 +124,7 @@ -- Does this group have any items and do we want to track it at this char? if values.items and trackAt[playerName] then -- Get group settings - local stockRequired = (values.minimumStock or (values.minimumStock == nil and addon.db.global.defaults.minimumStock)); + local minimumStock = (values.minimumStock or (values.minimumStock == nil and addon.db.global.defaults.minimumStock)); local showWhenBelow = (values.summaryThresholdShow or (values.summaryThresholdShow == nil and addon.db.global.defaults.summaryThresholdShow)); local priceThreshold = (values.priceThreshold or (values.priceThreshold == nil and addon.db.global.defaults.priceThreshold)); local hideWhenBelowPriceThreshold = (values.hideFromSummaryWhenBelowPriceThreshold or (values.hideFromSummaryWhenBelowPriceThreshold == nil and addon.db.global.defaults.hideFromSummaryWhenBelowPriceThreshold)); @@ -157,13 +164,13 @@ iGroup:AddChild(lblQuantity); -- Required stock - local lblStockRequired = AceGUI:Create("InteractiveLabel"); - lblStockRequired:SetText("|cfffed000Req.|r"); - lblStockRequired:SetFontObject(GameFontHighlight); - lblStockRequired:SetRelativeWidth(0.099); - lblStockRequired:SetCallback("OnClick", function() ReSort("percentage"); end); + local lblMinimumStock = AceGUI:Create("InteractiveLabel"); + lblMinimumStock:SetText("|cfffed000Req.|r"); + lblMinimumStock:SetFontObject(GameFontHighlight); + lblMinimumStock:SetRelativeWidth(0.099); + lblMinimumStock:SetCallback("OnClick", function() ReSort("percentage"); end); - iGroup:AddChild(lblStockRequired); + iGroup:AddChild(lblMinimumStock); -- Lowest value local lblValue = AceGUI:Create("InteractiveLabel"); @@ -185,9 +192,9 @@ id = itemId, name = itemName, link = itemLink, - value = 0,--addon:GetAuctionValue(itemLink), + value = -3,--addon:GetAuctionValue(itemLink), rarity = itemRarity, - count = 0,--addon:GetItemCount(itemId), + count = -3,--addon:GetItemCount(itemId), set = {}, }); CACHE_ITEMS_TOTAL = CACHE_ITEMS_TOTAL + 1; @@ -217,9 +224,9 @@ end elseif sortMethod == "percentage" then if sortDirectory == "ASC" then - return ( a.count / stockRequired ) < ( b.count / stockRequired ); + return ( a.count / lblMinimumStock ) < ( b.count / lblMinimumStock ); else - return ( a.count / stockRequired ) > ( b.count / stockRequired ); + return ( a.count / lblMinimumStock ) > ( b.count / lblMinimumStock ); end elseif sortMethod == "value" then if sortDirectory == "ASC" then @@ -232,7 +239,7 @@ -- Show stuff for i, item in pairs(itemsCache[groupName]) do - if ( item.count / stockRequired ) < showWhenBelow and not (hideWhenBelowPriceThreshold and item.value < priceThreshold) then + if ( item.count / minimumStock ) < showWhenBelow and not (hideWhenBelowPriceThreshold and item.value < priceThreshold) then local btnItemLink = AceGUI:Create("ItemLinkButton"); btnItemLink:SetUserData("exec", function() print("Win."); @@ -244,17 +251,17 @@ -- Current quantity local lblQuantity = AceGUI:Create("Label"); - lblQuantity:SetText(self:ColorCode(item.count, stockRequired)); + lblQuantity:SetText(self:DisplayItemCount(item.count, minimumStock)); lblQuantity:SetRelativeWidth(0.099); iGroup:AddChild(lblQuantity); -- Required stock - local lblStockRequired = AceGUI:Create("Label"); - lblStockRequired:SetText(stockRequired); - lblStockRequired:SetRelativeWidth(0.099); + local lblMinimumStock = AceGUI:Create("Label"); + lblMinimumStock:SetText(minimumStock); + lblMinimumStock:SetRelativeWidth(0.099); - iGroup:AddChild(lblStockRequired); + iGroup:AddChild(lblMinimumStock); -- Value local lblValue = AceGUI:Create("Label"); @@ -292,16 +299,17 @@ for groupName, items in pairs(itemsCache) do local minimumStock = addon:GetOptionByKey(groupName, "minimumStock"); local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold"); + local groupUpdated; for _, item in pairs(items) do if item.set then item.count = addon:GetItemCount(item.id); - if item.set.current then - item.set.current:SetText(self:ColorCode(item.count, minimumStock)); + if item.set.current and item.set.current.SetText then + item.set.current:SetText(self:DisplayItemCount(item.count, minimumStock)); end item.value = addon:GetAuctionValue(item.link); - if item.set.value then + if item.set.value and item.set.value.SetText then item.set.value:SetText(self:DisplayMoney(item.value, priceThreshold)); end @@ -309,23 +317,28 @@ i = i + 1; CACHE_ITEMS_CURRENT = CACHE_ITEMS_CURRENT + 1; + groupUpdated = true; - mod.frame:SetStatusText(("Caching auction values and item-counts... %d% has already been processed."):format(floor(CACHE_ITEMS_CURRENT / CACHE_ITEMS_TOTAL * 100))); + if mod.frame then + mod.frame:SetStatusText(("Caching auction values and item-counts... %d%% has already been processed."):format(floor(CACHE_ITEMS_CURRENT / CACHE_ITEMS_TOTAL * 100))); + end if i >= CACHE_ITEMS_PER_UPDATE then return; end end end + + if groupUpdated then + -- Rebuild list so hidden items due to too low prices get added + self:Build(); + end end -- Reset trackers CACHE_ITEMS_TOTAL = 0; CACHE_ITEMS_CURRENT = 0; - -- Rebuild list so hidden items due to too low prices get added - self:Build(); - -- Stop timer self:CancelTimer(self.tmrUpdater, true); @@ -355,6 +368,8 @@ return "|cff0000ffNone up|r"; elseif value == -2 then return "|cff0000ffNo AH mod|r"; + elseif value == -3 then + return "|cffffff00Unknown|r"; elseif value < priceThreshold then return ("|cffff0000%s|r"):format(addon:ReadableMoney(value or 0, true)); else @@ -362,6 +377,14 @@ end end +function mod:DisplayItemCount(value, minimumStock) + if value == -3 then + return "|cffffff00Unknown|r"; + else + return self:ColorCode(value, minimumStock); + end +end + function mod:NumberFormat(num) local formatted = string.gsub(num, "(%d)(%d%d%d)$", "%1,%2", 1);