annotate Summary.lua @ 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 1a815139e4c3
children c4d0e5d47e10
rev   line source
Zerotorescue@0 1 local addon = LibStub("AceAddon-3.0"):GetAddon("Inventory");
Zerotorescue@1 2 local mod = addon:NewModule("Summary", "AceEvent-3.0", "AceTimer-3.0");
Zerotorescue@0 3
Zerotorescue@0 4 local AceGUI = LibStub("AceGUI-3.0");
Zerotorescue@0 5
Zerotorescue@0 6 function mod:OnEnable()
Zerotorescue@0 7 self:RegisterWidgets();
Zerotorescue@0 8
Zerotorescue@1 9 -- Register our own slash commands
Zerotorescue@1 10 addon:RegisterSlash(function()
Zerotorescue@1 11 mod:BuildMain();
Zerotorescue@1 12 mod:Build();
Zerotorescue@1 13 end, "s", "sum", "summary");
Zerotorescue@0 14 end
Zerotorescue@0 15
Zerotorescue@0 16 function mod:RegisterWidgets()
Zerotorescue@0 17 -- Register InlineGroupWithButton-widget
Zerotorescue@0 18 -- This widget adds a button next to the header of an inline group
Zerotorescue@0 19 -- SetPoint doesn't seem usable within AceGUI.
Zerotorescue@0 20
Zerotorescue@0 21 local widgetType = "InlineGroupWithButton";
Zerotorescue@0 22 local widgetVersion = 1;
Zerotorescue@0 23
Zerotorescue@0 24 local function Constructor()
Zerotorescue@0 25 local widget = AceGUI:Create("InlineGroup");
Zerotorescue@0 26 widget.type = widgetType;
Zerotorescue@0 27
Zerotorescue@0 28 widget.MakeButton = function(self, buttonSettings)
Zerotorescue@0 29 if type(buttonSettings) == "table" then
Zerotorescue@0 30 local button = CreateFrame("Button", nil, self.frame, "UIPanelButtonTemplate");
Zerotorescue@0 31 button:SetText(buttonSettings.name);
Zerotorescue@0 32 button:SetHeight(22);
Zerotorescue@0 33 button:SetWidth(120);
Zerotorescue@0 34 button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -10, 5);
Zerotorescue@0 35 button:SetScript("OnClick", buttonSettings.exec);
Zerotorescue@0 36 button.tooltipTitle = buttonSettings.name;
Zerotorescue@0 37 button.tooltip = buttonSettings.desc or "";
Zerotorescue@0 38 button:SetScript("OnEnter", function(self)
Zerotorescue@0 39 GameTooltip:SetOwner(self, "ANCHOR_NONE")
Zerotorescue@0 40 GameTooltip:SetPoint("BOTTOM", self, "TOP")
Zerotorescue@0 41 GameTooltip:SetText(self.tooltipTitle, 1, .82, 0, 1)
Zerotorescue@0 42
Zerotorescue@0 43 if type(self.tooltip) == "string" then
Zerotorescue@0 44 GameTooltip:AddLine(self.tooltip, 1, 1, 1, 1);
Zerotorescue@0 45 end
Zerotorescue@0 46
Zerotorescue@0 47 GameTooltip:Show();
Zerotorescue@0 48 end);
Zerotorescue@0 49 button:SetScript("OnLeave", function(self)
Zerotorescue@0 50 GameTooltip:Hide();
Zerotorescue@0 51 end);
Zerotorescue@0 52 else
Zerotorescue@0 53 error("settings must be a table - usage: MakeButton(table);");
Zerotorescue@0 54 end
Zerotorescue@0 55 end
Zerotorescue@0 56
Zerotorescue@0 57 return widget;
Zerotorescue@0 58 end
Zerotorescue@0 59
Zerotorescue@0 60 AceGUI:RegisterWidgetType(widgetType, Constructor, widgetVersion);
Zerotorescue@0 61 end
Zerotorescue@0 62
Zerotorescue@1 63 local itemsCache = {};
Zerotorescue@1 64 local CACHE_ITEMS_TOTAL, CACHE_ITEMS_CURRENT, CACHE_ITEMS_PER_UPDATE = 0, 0, 5;
Zerotorescue@1 65 local cacheStart;
Zerotorescue@1 66
Zerotorescue@0 67 function mod:BuildMain()
Zerotorescue@1 68 LibStub("AceConfigDialog-3.0"):Close("InventoryOptions");
Zerotorescue@0 69
Zerotorescue@1 70 -- Main Window
Zerotorescue@1 71 mod.frame = AceGUI:Create("Frame");
Zerotorescue@1 72 mod.frame:SetTitle("Inventory Summary");
Zerotorescue@1 73 mod.frame:SetLayout("Fill");
Zerotorescue@1 74 mod.frame:SetCallback("OnClose", function(widget)
Zerotorescue@7 75 mod:CancelTimer(self.tmrUpdater, true);
Zerotorescue@9 76 mod:CloseFrame();
Zerotorescue@1 77 end);
Zerotorescue@0 78
Zerotorescue@1 79 -- ScrollFrame child
Zerotorescue@1 80 mod.scrollFrame = AceGUI:Create("ScrollFrame");
Zerotorescue@1 81 mod.scrollFrame:SetLayout("Flow");
Zerotorescue@0 82
Zerotorescue@1 83 mod.frame:AddChild(mod.scrollFrame);
Zerotorescue@1 84
Zerotorescue@1 85 -- Reset items cache
Zerotorescue@1 86 table.wipe(itemsCache);
Zerotorescue@0 87 end
Zerotorescue@0 88
Zerotorescue@9 89 function mod:CloseFrame()
Zerotorescue@9 90 if mod.frame then
Zerotorescue@9 91 mod.frame:Release();
Zerotorescue@9 92 mod.frame = nil;
Zerotorescue@9 93 end
Zerotorescue@9 94 end
Zerotorescue@9 95
Zerotorescue@0 96 local sortMethod = "item";
Zerotorescue@0 97 local sortDirectory = "ASC";
Zerotorescue@0 98 local function ReSort(subject)
Zerotorescue@0 99 if sortMethod == subject then
Zerotorescue@0 100 sortDirectory = (sortDirectory == "ASC" and "DESC") or "ASC";
Zerotorescue@0 101 else
Zerotorescue@0 102 sortDirectory = "ASC";
Zerotorescue@0 103 end
Zerotorescue@0 104 sortMethod = subject;
Zerotorescue@0 105
Zerotorescue@0 106 mod:Build();
Zerotorescue@0 107 end
Zerotorescue@0 108
Zerotorescue@0 109 function mod:Build()
Zerotorescue@1 110 local start = GetTime();
Zerotorescue@1 111
Zerotorescue@0 112 mod.scrollFrame:ReleaseChildren();
Zerotorescue@0 113
Zerotorescue@1 114 -- We are going to add hunderds of widgets to this container, but don't want it to also cause hunderds of reflows, thus pause reflowing and just do it once when everything is prepared
Zerotorescue@1 115 -- This appears to be required for each container we wish to pause, so also do this for the contents
Zerotorescue@1 116 mod.scrollFrame:PauseLayout();
Zerotorescue@1 117
Zerotorescue@1 118 local playerName = UnitName("player");
Zerotorescue@1 119
Zerotorescue@1 120 -- Go through all our stored groups
Zerotorescue@0 121 for groupName, values in pairs(addon.db.global.groups) do
Zerotorescue@1 122 local trackAt = (values.trackAtCharacters or (values.trackAtCharacters == nil and addon.db.global.defaults.trackAtCharacters));
Zerotorescue@1 123
Zerotorescue@1 124 -- Does this group have any items and do we want to track it at this char?
Zerotorescue@1 125 if values.items and trackAt[playerName] then
Zerotorescue@0 126 -- Get group settings
Zerotorescue@9 127 local minimumStock = (values.minimumStock or (values.minimumStock == nil and addon.db.global.defaults.minimumStock));
Zerotorescue@1 128 local showWhenBelow = (values.summaryThresholdShow or (values.summaryThresholdShow == nil and addon.db.global.defaults.summaryThresholdShow));
Zerotorescue@1 129 local priceThreshold = (values.priceThreshold or (values.priceThreshold == nil and addon.db.global.defaults.priceThreshold));
Zerotorescue@1 130 local hideWhenBelowPriceThreshold = (values.hideFromSummaryWhenBelowPriceThreshold or (values.hideFromSummaryWhenBelowPriceThreshold == nil and addon.db.global.defaults.hideFromSummaryWhenBelowPriceThreshold));
Zerotorescue@0 131
Zerotorescue@0 132 -- Make group container
Zerotorescue@0 133 local iGroup = AceGUI:Create("InlineGroupWithButton");
Zerotorescue@1 134 iGroup:PauseLayout();
Zerotorescue@0 135 iGroup:SetTitle(groupName);
Zerotorescue@0 136 iGroup:SetFullWidth(true);
Zerotorescue@0 137 iGroup:SetLayout("Flow");
Zerotorescue@0 138 iGroup:MakeButton({
Zerotorescue@0 139 name = "Queue",
Zerotorescue@0 140 desc = "Queue all items in this group.",
Zerotorescue@0 141 exec = function()
Zerotorescue@0 142 print(groupName);
Zerotorescue@0 143 end,
Zerotorescue@0 144 });
Zerotorescue@0 145
Zerotorescue@0 146 -- Headers
Zerotorescue@1 147
Zerotorescue@0 148 -- Itemlink
Zerotorescue@0 149 local lblItem = AceGUI:Create("InteractiveLabel");
Zerotorescue@0 150 lblItem:SetText("|cfffed000Item|r");
Zerotorescue@0 151 lblItem:SetFontObject(GameFontHighlight);
Zerotorescue@0 152 lblItem:SetRelativeWidth(0.7);
Zerotorescue@0 153 lblItem:SetCallback("OnClick", function() ReSort("item"); end);
Zerotorescue@0 154
Zerotorescue@0 155 iGroup:AddChild(lblItem);
Zerotorescue@0 156
Zerotorescue@0 157 -- Current quantity
Zerotorescue@0 158 local lblQuantity = AceGUI:Create("InteractiveLabel");
Zerotorescue@0 159 lblQuantity:SetText("|cfffed000Cur.|r");
Zerotorescue@0 160 lblQuantity:SetFontObject(GameFontHighlight);
Zerotorescue@1 161 lblQuantity:SetRelativeWidth(0.099);
Zerotorescue@0 162 lblQuantity:SetCallback("OnClick", function() ReSort("current"); end);
Zerotorescue@0 163
Zerotorescue@0 164 iGroup:AddChild(lblQuantity);
Zerotorescue@0 165
Zerotorescue@0 166 -- Required stock
Zerotorescue@9 167 local lblMinimumStock = AceGUI:Create("InteractiveLabel");
Zerotorescue@9 168 lblMinimumStock:SetText("|cfffed000Req.|r");
Zerotorescue@9 169 lblMinimumStock:SetFontObject(GameFontHighlight);
Zerotorescue@9 170 lblMinimumStock:SetRelativeWidth(0.099);
Zerotorescue@9 171 lblMinimumStock:SetCallback("OnClick", function() ReSort("percentage"); end);
Zerotorescue@0 172
Zerotorescue@9 173 iGroup:AddChild(lblMinimumStock);
Zerotorescue@0 174
Zerotorescue@1 175 -- Lowest value
Zerotorescue@1 176 local lblValue = AceGUI:Create("InteractiveLabel");
Zerotorescue@1 177 lblValue:SetText("|cfffed000Value|r");
Zerotorescue@1 178 lblValue:SetFontObject(GameFontHighlight);
Zerotorescue@1 179 lblValue:SetRelativeWidth(0.099);
Zerotorescue@1 180 lblValue:SetCallback("OnClick", function() ReSort("value"); end);
Zerotorescue@1 181
Zerotorescue@1 182 iGroup:AddChild(lblValue);
Zerotorescue@1 183
Zerotorescue@1 184 if not itemsCache[groupName] then
Zerotorescue@1 185 itemsCache[groupName] = {};
Zerotorescue@0 186
Zerotorescue@1 187 -- Sort item list
Zerotorescue@1 188 for itemId in pairs(values.items) do
Zerotorescue@1 189 local itemName, itemLink, itemRarity = GetItemInfo(itemId);
Zerotorescue@1 190
Zerotorescue@1 191 table.insert(itemsCache[groupName], {
Zerotorescue@1 192 id = itemId,
Zerotorescue@1 193 name = itemName,
Zerotorescue@1 194 link = itemLink,
Zerotorescue@9 195 value = -3,--addon:GetAuctionValue(itemLink),
Zerotorescue@1 196 rarity = itemRarity,
Zerotorescue@9 197 count = -3,--addon:GetItemCount(itemId),
Zerotorescue@1 198 set = {},
Zerotorescue@1 199 });
Zerotorescue@1 200 CACHE_ITEMS_TOTAL = CACHE_ITEMS_TOTAL + 1;
Zerotorescue@1 201 end
Zerotorescue@0 202 end
Zerotorescue@0 203
Zerotorescue@1 204 table.sort(itemsCache[groupName], function(a, b)
Zerotorescue@1 205 if sortMethod == "item" and a.rarity == b.rarity then
Zerotorescue@1 206 -- Do a name-compare for items of the same rarity
Zerotorescue@1 207 -- Otherwise epics first, then junk
Zerotorescue@0 208 if sortDirectory == "ASC" then
Zerotorescue@1 209 return a.name:upper() < b.name:upper();
Zerotorescue@0 210 else
Zerotorescue@1 211 return a.name:upper() > b.name:upper();
Zerotorescue@1 212 end
Zerotorescue@1 213 elseif sortMethod == "item" then
Zerotorescue@1 214 if sortDirectory == "ASC" then
Zerotorescue@1 215 return a.rarity > b.rarity; -- the comparers were reversed because we want epics first
Zerotorescue@1 216 else
Zerotorescue@1 217 return a.rarity < b.rarity; -- the comparers were reversed because we want epics first
Zerotorescue@0 218 end
Zerotorescue@0 219 elseif sortMethod == "current" then
Zerotorescue@0 220 if sortDirectory == "ASC" then
Zerotorescue@0 221 return a.count < b.count;
Zerotorescue@0 222 else
Zerotorescue@0 223 return a.count > b.count;
Zerotorescue@0 224 end
Zerotorescue@0 225 elseif sortMethod == "percentage" then
Zerotorescue@0 226 if sortDirectory == "ASC" then
Zerotorescue@9 227 return ( a.count / lblMinimumStock ) < ( b.count / lblMinimumStock );
Zerotorescue@0 228 else
Zerotorescue@9 229 return ( a.count / lblMinimumStock ) > ( b.count / lblMinimumStock );
Zerotorescue@0 230 end
Zerotorescue@1 231 elseif sortMethod == "value" then
Zerotorescue@1 232 if sortDirectory == "ASC" then
Zerotorescue@1 233 return a.value < b.value;
Zerotorescue@1 234 else
Zerotorescue@1 235 return a.value > b.value;
Zerotorescue@1 236 end
Zerotorescue@0 237 end
Zerotorescue@0 238 end);
Zerotorescue@0 239
Zerotorescue@0 240 -- Show stuff
Zerotorescue@1 241 for i, item in pairs(itemsCache[groupName]) do
Zerotorescue@9 242 if ( item.count / minimumStock ) < showWhenBelow and not (hideWhenBelowPriceThreshold and item.value < priceThreshold) then
Zerotorescue@0 243 local btnItemLink = AceGUI:Create("ItemLinkButton");
Zerotorescue@1 244 btnItemLink:SetUserData("exec", function()
Zerotorescue@1 245 print("Win.");
Zerotorescue@1 246 end);
Zerotorescue@0 247 btnItemLink:SetRelativeWidth(0.7);
Zerotorescue@1 248 btnItemLink:SetItemId(item.id);
Zerotorescue@0 249
Zerotorescue@0 250 iGroup:AddChild(btnItemLink);
Zerotorescue@0 251
Zerotorescue@0 252 -- Current quantity
Zerotorescue@0 253 local lblQuantity = AceGUI:Create("Label");
Zerotorescue@9 254 lblQuantity:SetText(self:DisplayItemCount(item.count, minimumStock));
Zerotorescue@1 255 lblQuantity:SetRelativeWidth(0.099);
Zerotorescue@0 256
Zerotorescue@0 257 iGroup:AddChild(lblQuantity);
Zerotorescue@0 258
Zerotorescue@0 259 -- Required stock
Zerotorescue@9 260 local lblMinimumStock = AceGUI:Create("Label");
Zerotorescue@9 261 lblMinimumStock:SetText(minimumStock);
Zerotorescue@9 262 lblMinimumStock:SetRelativeWidth(0.099);
Zerotorescue@0 263
Zerotorescue@9 264 iGroup:AddChild(lblMinimumStock);
Zerotorescue@1 265
Zerotorescue@1 266 -- Value
Zerotorescue@1 267 local lblValue = AceGUI:Create("Label");
Zerotorescue@1 268 lblValue:SetText(self:DisplayMoney(item.value, priceThreshold));
Zerotorescue@1 269 lblValue:SetRelativeWidth(0.099);
Zerotorescue@1 270
Zerotorescue@1 271 iGroup:AddChild(lblValue);
Zerotorescue@1 272
Zerotorescue@1 273 -- Remember references to the value and current fields so we can fill them later
Zerotorescue@1 274 if item.set then
Zerotorescue@1 275 item.set.value = lblValue;
Zerotorescue@1 276 item.set.current = lblQuantity;
Zerotorescue@1 277 end
Zerotorescue@0 278 end
Zerotorescue@0 279 end
Zerotorescue@0 280
Zerotorescue@1 281 iGroup:ResumeLayout();
Zerotorescue@1 282 mod.scrollFrame:AddChild(iGroup); -- this can take up to .5 seconds, might need to look into again at a later time
Zerotorescue@0 283 end
Zerotorescue@0 284 end
Zerotorescue@1 285
Zerotorescue@1 286 mod.scrollFrame:ResumeLayout();
Zerotorescue@1 287 mod.scrollFrame:DoLayout();
Zerotorescue@1 288
Zerotorescue@1 289 if CACHE_ITEMS_TOTAL > 0 then
Zerotorescue@1 290 cacheStart = GetTime();
Zerotorescue@7 291 self:CancelTimer(self.tmrUpdater, true);
Zerotorescue@1 292 self.tmrUpdater = self:ScheduleRepeatingTimer("UpdateNextItem", .01); -- Once every 100 frames (or once every x frames if you have less than 100 FPS, basically, once every frame)
Zerotorescue@1 293 end
Zerotorescue@1 294 end
Zerotorescue@1 295
Zerotorescue@1 296 function mod:UpdateNextItem()
Zerotorescue@1 297 local i = 0;
Zerotorescue@1 298
Zerotorescue@1 299 for groupName, items in pairs(itemsCache) do
Zerotorescue@1 300 local minimumStock = addon:GetOptionByKey(groupName, "minimumStock");
Zerotorescue@1 301 local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold");
Zerotorescue@9 302 local groupUpdated;
Zerotorescue@1 303
Zerotorescue@1 304 for _, item in pairs(items) do
Zerotorescue@1 305 if item.set then
Zerotorescue@1 306 item.count = addon:GetItemCount(item.id);
Zerotorescue@9 307 if item.set.current and item.set.current.SetText then
Zerotorescue@9 308 item.set.current:SetText(self:DisplayItemCount(item.count, minimumStock));
Zerotorescue@1 309 end
Zerotorescue@1 310
Zerotorescue@1 311 item.value = addon:GetAuctionValue(item.link);
Zerotorescue@9 312 if item.set.value and item.set.value.SetText then
Zerotorescue@1 313 item.set.value:SetText(self:DisplayMoney(item.value, priceThreshold));
Zerotorescue@1 314 end
Zerotorescue@1 315
Zerotorescue@1 316 item.set = nil;
Zerotorescue@1 317
Zerotorescue@1 318 i = i + 1;
Zerotorescue@1 319 CACHE_ITEMS_CURRENT = CACHE_ITEMS_CURRENT + 1;
Zerotorescue@9 320 groupUpdated = true;
Zerotorescue@1 321
Zerotorescue@9 322 if mod.frame then
Zerotorescue@9 323 mod.frame:SetStatusText(("Caching auction values and item-counts... %d%% has already been processed."):format(floor(CACHE_ITEMS_CURRENT / CACHE_ITEMS_TOTAL * 100)));
Zerotorescue@9 324 end
Zerotorescue@1 325
Zerotorescue@1 326 if i >= CACHE_ITEMS_PER_UPDATE then
Zerotorescue@1 327 return;
Zerotorescue@1 328 end
Zerotorescue@1 329 end
Zerotorescue@1 330 end
Zerotorescue@9 331
Zerotorescue@9 332 if groupUpdated then
Zerotorescue@9 333 -- Rebuild list so hidden items due to too low prices get added
Zerotorescue@9 334 self:Build();
Zerotorescue@9 335 end
Zerotorescue@1 336 end
Zerotorescue@1 337
Zerotorescue@1 338 -- Reset trackers
Zerotorescue@1 339 CACHE_ITEMS_TOTAL = 0;
Zerotorescue@1 340 CACHE_ITEMS_CURRENT = 0;
Zerotorescue@1 341
Zerotorescue@1 342 -- Stop timer
Zerotorescue@1 343 self:CancelTimer(self.tmrUpdater, true);
Zerotorescue@1 344
Zerotorescue@1 345 -- Announce
Zerotorescue@1 346 mod.frame:SetStatusText("All prices and itemcounts have been cached. This process took " .. ceil(GetTime() - cacheStart) .. " seconds.");
Zerotorescue@1 347
Zerotorescue@1 348 -- Forget time
Zerotorescue@1 349 cacheStart = nil;
Zerotorescue@0 350 end
Zerotorescue@0 351
Zerotorescue@0 352 function mod:ColorCode(num, required)
Zerotorescue@0 353 local percentage = ( num / required );
Zerotorescue@0 354
Zerotorescue@0 355 if percentage >= addon.db.global.defaults.colors.green then
Zerotorescue@0 356 return ("|cff00ff00%d|r"):format(num);
Zerotorescue@0 357 elseif percentage >= addon.db.global.defaults.colors.yellow then
Zerotorescue@0 358 return ("|cffffff00%d|r"):format(num);
Zerotorescue@0 359 elseif percentage >= addon.db.global.defaults.colors.orange then
Zerotorescue@0 360 return ("|cffff9933%d|r"):format(num);
Zerotorescue@0 361 elseif percentage >= addon.db.global.defaults.colors.red then
Zerotorescue@0 362 return ("|cffff0000%d|r"):format(num);
Zerotorescue@0 363 end
Zerotorescue@0 364 end
Zerotorescue@0 365
Zerotorescue@1 366 function mod:DisplayMoney(value, priceThreshold)
Zerotorescue@7 367 if value == -1 then
Zerotorescue@7 368 return "|cff0000ffNone up|r";
Zerotorescue@7 369 elseif value == -2 then
Zerotorescue@7 370 return "|cff0000ffNo AH mod|r";
Zerotorescue@9 371 elseif value == -3 then
Zerotorescue@9 372 return "|cffffff00Unknown|r";
Zerotorescue@7 373 elseif value < priceThreshold then
Zerotorescue@1 374 return ("|cffff0000%s|r"):format(addon:ReadableMoney(value or 0, true));
Zerotorescue@1 375 else
Zerotorescue@1 376 return addon:ReadableMoney(value or 0, true);
Zerotorescue@1 377 end
Zerotorescue@1 378 end
Zerotorescue@1 379
Zerotorescue@9 380 function mod:DisplayItemCount(value, minimumStock)
Zerotorescue@9 381 if value == -3 then
Zerotorescue@9 382 return "|cffffff00Unknown|r";
Zerotorescue@9 383 else
Zerotorescue@9 384 return self:ColorCode(value, minimumStock);
Zerotorescue@9 385 end
Zerotorescue@9 386 end
Zerotorescue@9 387
Zerotorescue@0 388 function mod:NumberFormat(num)
Zerotorescue@0 389 local formatted = string.gsub(num, "(%d)(%d%d%d)$", "%1,%2", 1);
Zerotorescue@0 390
Zerotorescue@0 391 while true do
Zerotorescue@0 392 formatted, matches = string.gsub(formatted, "(%d)(%d%d%d),", "%1,%2,", 1);
Zerotorescue@0 393
Zerotorescue@0 394 if matches == 0 then
Zerotorescue@0 395 break;
Zerotorescue@0 396 end
Zerotorescue@0 397 end
Zerotorescue@0 398
Zerotorescue@0 399 return formatted;
Zerotorescue@1 400 end
Zerotorescue@1 401
Zerotorescue@1 402 --[[
Zerotorescue@1 403 No longer used, we're now caching complete item data instead of just AH values.
Zerotorescue@1 404 local AuctionValueCache = {};
Zerotorescue@1 405 function mod:GetAuctionValue(link)
Zerotorescue@1 406 local itemId = addon:GetItemId(link);
Zerotorescue@1 407
Zerotorescue@1 408 if AuctionValueCache[itemId] then
Zerotorescue@1 409 return AuctionValueCache[itemId];
Zerotorescue@1 410 else
Zerotorescue@1 411 local value = addon:GetAuctionValue(link);
Zerotorescue@1 412
Zerotorescue@1 413 AuctionValueCache[itemId] = value;
Zerotorescue@1 414
Zerotorescue@1 415 -- Reset the cache 1 minute after last updating it
Zerotorescue@1 416 self:CancelTimer(self.tmrResetCache, true);
Zerotorescue@1 417 self.tmrResetCache = self:ScheduleTimer(function()
Zerotorescue@1 418 table.wipe(AuctionValueCache);
Zerotorescue@1 419
Zerotorescue@1 420 mod.frame:SetStatusText("The auction item value cache has been reset.");
Zerotorescue@1 421 end, 60);
Zerotorescue@1 422 mod.frame:SetStatusText("");
Zerotorescue@1 423
Zerotorescue@1 424 return value;
Zerotorescue@1 425 end
Zerotorescue@1 426 end
Zerotorescue@1 427 ]]