Mercurial > wow > inventory
diff Summary.lua @ 74:8d11fc88ecab
Default summary width is now 700 pixels (up from 650).
Changed the item data table into a class which is now also used at the custom widgets.
author | Zerotorescue |
---|---|
date | Fri, 24 Dec 2010 21:55:11 +0100 |
parents | 6216b754350d |
children |
line wrap: on
line diff
--- a/Summary.lua Fri Dec 24 16:10:20 2010 +0100 +++ b/Summary.lua Fri Dec 24 21:55:11 2010 +0100 @@ -321,21 +321,20 @@ -- Retrieve items list if not itemsCache[groupName] then itemsCache[groupName] = {}; - - -- Sort item list + end + + if #(itemsCache[groupName]) == 0 then + -- If the item cache is empty for itemId, _ in pairs(values.items) do - local itemName, itemLink, itemRarity = GetItemInfo(itemId); + local newItemData = addon.ItemData:New(itemId); - tinsert(itemsCache[groupName], { - id = itemId, - name = itemName, -- may be nil - link = itemLink, -- may be nil - value = ((priceThreshold == 0 and not alwaysGetAuctionValue) and -4) or -3,-- if (no price threshold is set for this item and you don't want to always get auction value), then don't look it up either --addon:GetAuctionValue(itemLink), - rarity = itemRarity, -- may be nil - count = -3,--addon:GetItemCount(itemId, groupName), - localCount = -3, - set = {}, - }); + -- if no price threshold is set for this item and you don't want to always get the auction value, then don't look it up either + if priceThreshold == 0 and not alwaysGetAuctionValue then + newItemData.value = -4; + end + + tinsert(itemsCache[groupName], newItemData); + CACHE_ITEMS_TOTAL = CACHE_ITEMS_TOTAL + 1; end end @@ -369,9 +368,9 @@ end elseif sortMethod == "current" then if sortDirectory == "ASC" then - return a.count < b.count; + return a.globalCount < b.globalCount; else - return a.count > b.count; + return a.globalCount > b.globalCount; end elseif sortMethod == "local" then if sortDirectory == "ASC" then @@ -397,7 +396,7 @@ for i, item in pairs(itemsCache[groupName]) do -- Go through all items for this group - if (( item.count / minGlobalStock ) < showWhenBelow or ( item.localCount / minLocalStock ) < showWhenBelow) and (not hideWhenBelowPriceThreshold or priceThreshold == 0 or item.value < 0 or item.value >= priceThreshold) then + if (( item.globalCount / minGlobalStock ) < showWhenBelow or ( item.localCount / minLocalStock ) < showWhenBelow) and (not hideWhenBelowPriceThreshold or priceThreshold == 0 or item.value < 0 or item.value >= priceThreshold) then -- if the option "hide when below threshold" is disabled or no price threshold is set or the value is above the price threshold or the value could not be determined, proceed local btnItemLink = AceGUI:Create("ItemLinkButton"); @@ -430,7 +429,7 @@ -- Current quantity local lblQuantity = AceGUI:Create("Label"); - lblQuantity:SetText(self:DisplayItemCount(item.count, minGlobalStock)); + lblQuantity:SetText(self:DisplayItemCount(item.globalCount, minGlobalStock)); lblQuantity:SetRelativeWidth(.099); iGroup:AddChild(lblQuantity); @@ -443,23 +442,9 @@ iGroup:AddChild(lblValue); -- Remember references to the value and current fields so we can fill them later - if item.set then - -- -3 means the price is unknown, queue look up - if item.value == -3 then - item.set.value = lblValue; - end - if item.count == -3 then - item.set.current = lblQuantity; - end - if item.localCount == -3 then - item.set.localCount = lblLocal; - end - - -- Don't queue if we already know everything we want to know - if item.value ~= -3 and item.count ~= -3 and item.localCount ~= -3 then - item.set = nil; - end - end + item.set.value = lblValue; + item.set.globalCount = lblQuantity; + item.set.localCount = lblLocal; end end @@ -497,12 +482,12 @@ local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold"); for _, item in pairs(items) do - if item.set then - if item.count == -3 then + if item.globalCount == -3 or item.localCount == -3 or item.value == -3 then + if item.globalCount == -3 then -- Only if item count was queued, update it - item.count = addon:GetItemCount(item.id, groupName); - if item.set.current and item.set.current.SetText then - item.set.current:SetText(self:DisplayItemCount(item.count, minGlobalStock)); + item.globalCount = addon:GetItemCount(item.id, groupName); + if item.set.globalCount and item.set.globalCount.SetText then + item.set.globalCount:SetText(self:DisplayItemCount(item.globalCount, minGlobalStock)); end end @@ -528,8 +513,6 @@ end end - item.set = nil; - i = i + 1; CACHE_ITEMS_CURRENT = CACHE_ITEMS_CURRENT + 1;