Mercurial > wow > inventory
comparison 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 |
comparison
equal
deleted
inserted
replaced
73:6216b754350d | 74:8d11fc88ecab |
---|---|
319 | 319 |
320 | 320 |
321 -- Retrieve items list | 321 -- Retrieve items list |
322 if not itemsCache[groupName] then | 322 if not itemsCache[groupName] then |
323 itemsCache[groupName] = {}; | 323 itemsCache[groupName] = {}; |
324 | 324 end |
325 -- Sort item list | 325 |
326 if #(itemsCache[groupName]) == 0 then | |
327 -- If the item cache is empty | |
326 for itemId, _ in pairs(values.items) do | 328 for itemId, _ in pairs(values.items) do |
327 local itemName, itemLink, itemRarity = GetItemInfo(itemId); | 329 local newItemData = addon.ItemData:New(itemId); |
328 | 330 |
329 tinsert(itemsCache[groupName], { | 331 -- 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 |
330 id = itemId, | 332 if priceThreshold == 0 and not alwaysGetAuctionValue then |
331 name = itemName, -- may be nil | 333 newItemData.value = -4; |
332 link = itemLink, -- may be nil | 334 end |
333 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), | 335 |
334 rarity = itemRarity, -- may be nil | 336 tinsert(itemsCache[groupName], newItemData); |
335 count = -3,--addon:GetItemCount(itemId, groupName), | 337 |
336 localCount = -3, | |
337 set = {}, | |
338 }); | |
339 CACHE_ITEMS_TOTAL = CACHE_ITEMS_TOTAL + 1; | 338 CACHE_ITEMS_TOTAL = CACHE_ITEMS_TOTAL + 1; |
340 end | 339 end |
341 end | 340 end |
342 | 341 |
343 groupTimes.init = ceil( ( GetTime() - groupStartTime ) * 1000 ); | 342 groupTimes.init = ceil( ( GetTime() - groupStartTime ) * 1000 ); |
367 else | 366 else |
368 return aRarity < bRarity; -- the comparers were reversed because we want epics first | 367 return aRarity < bRarity; -- the comparers were reversed because we want epics first |
369 end | 368 end |
370 elseif sortMethod == "current" then | 369 elseif sortMethod == "current" then |
371 if sortDirectory == "ASC" then | 370 if sortDirectory == "ASC" then |
372 return a.count < b.count; | 371 return a.globalCount < b.globalCount; |
373 else | 372 else |
374 return a.count > b.count; | 373 return a.globalCount > b.globalCount; |
375 end | 374 end |
376 elseif sortMethod == "local" then | 375 elseif sortMethod == "local" then |
377 if sortDirectory == "ASC" then | 376 if sortDirectory == "ASC" then |
378 return a.localCount < b.localCount; | 377 return a.localCount < b.localCount; |
379 else | 378 else |
395 | 394 |
396 -- Show itemslist | 395 -- Show itemslist |
397 for i, item in pairs(itemsCache[groupName]) do | 396 for i, item in pairs(itemsCache[groupName]) do |
398 -- Go through all items for this group | 397 -- Go through all items for this group |
399 | 398 |
400 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 | 399 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 |
401 -- 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 | 400 -- 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 |
402 | 401 |
403 local btnItemLink = AceGUI:Create("ItemLinkButton"); | 402 local btnItemLink = AceGUI:Create("ItemLinkButton"); |
404 btnItemLink:SetUserData("exec", function(_, itemId, _, buttonName) | 403 btnItemLink:SetUserData("exec", function(_, itemId, _, buttonName) |
405 local itemName, itemLink = GetItemInfo(itemId); | 404 local itemName, itemLink = GetItemInfo(itemId); |
428 | 427 |
429 iGroup:AddChild(lblLocal); | 428 iGroup:AddChild(lblLocal); |
430 | 429 |
431 -- Current quantity | 430 -- Current quantity |
432 local lblQuantity = AceGUI:Create("Label"); | 431 local lblQuantity = AceGUI:Create("Label"); |
433 lblQuantity:SetText(self:DisplayItemCount(item.count, minGlobalStock)); | 432 lblQuantity:SetText(self:DisplayItemCount(item.globalCount, minGlobalStock)); |
434 lblQuantity:SetRelativeWidth(.099); | 433 lblQuantity:SetRelativeWidth(.099); |
435 | 434 |
436 iGroup:AddChild(lblQuantity); | 435 iGroup:AddChild(lblQuantity); |
437 | 436 |
438 -- Value | 437 -- Value |
441 lblValue:SetRelativeWidth(.099); | 440 lblValue:SetRelativeWidth(.099); |
442 | 441 |
443 iGroup:AddChild(lblValue); | 442 iGroup:AddChild(lblValue); |
444 | 443 |
445 -- Remember references to the value and current fields so we can fill them later | 444 -- Remember references to the value and current fields so we can fill them later |
446 if item.set then | 445 item.set.value = lblValue; |
447 -- -3 means the price is unknown, queue look up | 446 item.set.globalCount = lblQuantity; |
448 if item.value == -3 then | 447 item.set.localCount = lblLocal; |
449 item.set.value = lblValue; | |
450 end | |
451 if item.count == -3 then | |
452 item.set.current = lblQuantity; | |
453 end | |
454 if item.localCount == -3 then | |
455 item.set.localCount = lblLocal; | |
456 end | |
457 | |
458 -- Don't queue if we already know everything we want to know | |
459 if item.value ~= -3 and item.count ~= -3 and item.localCount ~= -3 then | |
460 item.set = nil; | |
461 end | |
462 end | |
463 end | 448 end |
464 end | 449 end |
465 | 450 |
466 groupTimes.preparing = ceil( ( GetTime() - groupStartTime ) * 1000 ); | 451 groupTimes.preparing = ceil( ( GetTime() - groupStartTime ) * 1000 ); |
467 | 452 |
495 local minGlobalStock = addon:GetOptionByKey(groupName, "minGlobalStock"); | 480 local minGlobalStock = addon:GetOptionByKey(groupName, "minGlobalStock"); |
496 local minLocalStock = addon:GetOptionByKey(groupName, "minLocalStock"); | 481 local minLocalStock = addon:GetOptionByKey(groupName, "minLocalStock"); |
497 local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold"); | 482 local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold"); |
498 | 483 |
499 for _, item in pairs(items) do | 484 for _, item in pairs(items) do |
500 if item.set then | 485 if item.globalCount == -3 or item.localCount == -3 or item.value == -3 then |
501 if item.count == -3 then | 486 if item.globalCount == -3 then |
502 -- Only if item count was queued, update it | 487 -- Only if item count was queued, update it |
503 item.count = addon:GetItemCount(item.id, groupName); | 488 item.globalCount = addon:GetItemCount(item.id, groupName); |
504 if item.set.current and item.set.current.SetText then | 489 if item.set.globalCount and item.set.globalCount.SetText then |
505 item.set.current:SetText(self:DisplayItemCount(item.count, minGlobalStock)); | 490 item.set.globalCount:SetText(self:DisplayItemCount(item.globalCount, minGlobalStock)); |
506 end | 491 end |
507 end | 492 end |
508 | 493 |
509 if item.localCount == -3 then | 494 if item.localCount == -3 then |
510 -- Only if item count was queued, update it | 495 -- Only if item count was queued, update it |
525 if item.set.value and item.set.value.SetText then | 510 if item.set.value and item.set.value.SetText then |
526 item.set.value:SetText(self:DisplayMoney(item.value, priceThreshold)); | 511 item.set.value:SetText(self:DisplayMoney(item.value, priceThreshold)); |
527 end | 512 end |
528 end | 513 end |
529 end | 514 end |
530 | |
531 item.set = nil; | |
532 | 515 |
533 i = i + 1; | 516 i = i + 1; |
534 CACHE_ITEMS_CURRENT = CACHE_ITEMS_CURRENT + 1; | 517 CACHE_ITEMS_CURRENT = CACHE_ITEMS_CURRENT + 1; |
535 | 518 |
536 if mod.frame then | 519 if mod.frame then |