annotate Modules/Tooltip.lua @ 20:ff9a698caebc

Added options for the crafting threshold and auction threshold. I also fixed the queue to use the item cost to determine if there is enough profit instead of the auction (QA) threshold which already has profit built in.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Sun, 04 Jul 2010 09:33:25 -0700
parents e62d878c716d
children d21d202f3b3d
rev   line source
Asa@3 1 local addonName, addonTable = ...;
Asa@3 2 local addon = _G[addonName]
Asa@3 3
Asa@3 4 local utils = addonTable.utils
Asa@3 5
Asa@3 6 local function ShowTipWithPricing(tip, link, num)
Asa@3 7 if (link == nil) then
Asa@3 8 return;
Asa@3 9 end
Asa@3 10
Asa@8 11 -- local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, _, _, _, _, itemVendorPrice = GetItemInfo (link);
Asa@3 12 -- local _, _, Color, Ltype, Id, Enchant, Gem1, Gem2, Gem3, Gem4, Suffix, Unique, LinkLvl, Name = string.find(link, "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*)|?h?%[?([^%[%]]*)%]?|?h?|?r?")
Asa@3 13
Asa@8 14 local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(link)
Asa@3 15
Asa@13 16 local keep = 1 - addon:GetAHCut()
Asa@12 17 local show = false
Asa@3 18
Asa@3 19 if investedTotal > 0 then
Asa@15 20 tip:AddDoubleLine("\124cffffffffIA: Total Invested", addon:FormatMoney(investedTotal));
Asa@17 21 tip:AddDoubleLine("\124cffffffffIA: Invested per Item (own: " .. count .. ")", addon:FormatMoney(ceil(investedPerItem)));
Asa@15 22 tip:AddDoubleLine("\124cffffffffIA: Minimum " .. addon:GetAHFaction() .. " AH Price: ", addon:FormatMoney(ceil(investedPerItem/keep)))
Asa@12 23 show = true
Asa@12 24
Asa@12 25 end
Asa@13 26
Asa@13 27 if addon:IsQAEnabled() then
Asa@13 28 local groupName = QAAPI:GetItemGroup(link)
Asa@13 29 if groupName then
Asa@13 30 local threshold = QAAPI:GetGroupThreshold(groupName)
Asa@15 31 tip:AddDoubleLine("\124cffffffffIA: QA Threshold: ", addon:FormatMoney(threshold))
Asa@13 32 show = true
Asa@13 33 end
Asa@12 34 end
Asa@12 35
Asa@12 36 if show then
Asa@3 37 tip:Show()
Asa@3 38 end
Asa@3 39 end
Asa@3 40
Asa@3 41 hooksecurefunc (GameTooltip, "SetBagItem",
Asa@3 42 function(tip, bag, slot)
Asa@3 43 local _, num = GetContainerItemInfo(bag, slot);
Asa@3 44 ShowTipWithPricing (tip, GetContainerItemLink(bag, slot), num);
Asa@3 45 end
Asa@3 46 );
Asa@3 47
Asa@3 48 hooksecurefunc (GameTooltip, "SetAuctionItem",
Asa@3 49 function (tip, type, index)
Asa@3 50 ShowTipWithPricing (tip, GetAuctionItemLink(type, index));
Asa@3 51 end
Asa@3 52 );
Asa@3 53
Asa@3 54 hooksecurefunc (GameTooltip, "SetAuctionSellItem",
Asa@3 55 function (tip)
Asa@3 56 local name, _, count = GetAuctionSellItemInfo();
Asa@3 57 local __, link = GetItemInfo(name);
Asa@3 58 ShowTipWithPricing (tip, link, num);
Asa@3 59 end
Asa@3 60 );
Asa@3 61
Asa@3 62
Asa@3 63 hooksecurefunc (GameTooltip, "SetLootItem",
Asa@3 64 function (tip, slot)
Asa@3 65 if LootSlotIsItem(slot) then
Asa@3 66 local link, _, num = GetLootSlotLink(slot);
Asa@3 67 ShowTipWithPricing (tip, link, num);
Asa@3 68 end
Asa@3 69 end
Asa@3 70 );
Asa@3 71
Asa@3 72 hooksecurefunc (GameTooltip, "SetLootRollItem",
Asa@3 73 function (tip, slot)
Asa@3 74 local _, _, num = GetLootRollItemInfo(slot);
Asa@3 75 ShowTipWithPricing (tip, GetLootRollItemLink(slot), num);
Asa@3 76 end
Asa@3 77 );
Asa@3 78
Asa@3 79
Asa@3 80 hooksecurefunc (GameTooltip, "SetInventoryItem",
Asa@3 81 function (tip, unit, slot)
Asa@3 82 ShowTipWithPricing (tip, GetInventoryItemLink(unit, slot), GetInventoryItemCount(unit, slot));
Asa@3 83 end
Asa@3 84 );
Asa@3 85
Asa@3 86 hooksecurefunc (GameTooltip, "SetGuildBankItem",
Asa@3 87 function (tip, tab, slot)
Asa@3 88 local _, num = GetGuildBankItemInfo(tab, slot);
Asa@3 89 ShowTipWithPricing (tip, GetGuildBankItemLink(tab, slot), num);
Asa@3 90 end
Asa@3 91 );
Asa@3 92
Asa@3 93 hooksecurefunc (GameTooltip, "SetTradeSkillItem",
Asa@3 94 function (tip, skill, id)
Asa@3 95 local link = GetTradeSkillItemLink(skill);
Asa@3 96 local num = GetTradeSkillNumMade(skill);
Asa@3 97 if id then
Asa@3 98 link = GetTradeSkillReagentItemLink(skill, id);
Asa@3 99 num = select (3, GetTradeSkillReagentInfo(skill, id));
Asa@3 100 end
Asa@3 101
Asa@3 102 ShowTipWithPricing (tip, link, num);
Asa@3 103 end
Asa@3 104 );
Asa@3 105
Asa@3 106 hooksecurefunc (GameTooltip, "SetTradePlayerItem",
Asa@3 107 function (tip, id)
Asa@3 108 local _, _, num = GetTradePlayerItemInfo(id);
Asa@3 109 ShowTipWithPricing (tip, GetTradePlayerItemLink(id), num);
Asa@3 110 end
Asa@3 111 );
Asa@3 112
Asa@3 113 hooksecurefunc (GameTooltip, "SetTradeTargetItem",
Asa@3 114 function (tip, id)
Asa@3 115 local _, _, num = GetTradeTargetItemInfo(id);
Asa@3 116 ShowTipWithPricing (tip, GetTradeTargetItemLink(id), num);
Asa@3 117 end
Asa@3 118 );
Asa@3 119
Asa@3 120 hooksecurefunc (GameTooltip, "SetQuestItem",
Asa@3 121 function (tip, type, index)
Asa@3 122 local _, _, num = GetQuestItemInfo(type, index);
Asa@3 123 ShowTipWithPricing (tip, GetQuestItemLink(type, index), num);
Asa@3 124 end
Asa@3 125 );
Asa@3 126
Asa@3 127 hooksecurefunc (GameTooltip, "SetQuestLogItem",
Asa@3 128 function (tip, type, index)
Asa@3 129 local num, _;
Asa@3 130 if type == "choice" then
Asa@3 131 _, _, num = GetQuestLogChoiceInfo(index);
Asa@3 132 else
Asa@3 133 _, _, num = GetQuestLogRewardInfo(index)
Asa@3 134 end
Asa@3 135
Asa@3 136 ShowTipWithPricing (tip, GetQuestLogItemLink(type, index), num);
Asa@3 137 end
Asa@3 138 );
Asa@3 139
Asa@3 140 hooksecurefunc (GameTooltip, "SetInboxItem",
Asa@3 141 function (tip, index, attachIndex)
Asa@3 142 local _, _, num = GetInboxItem(index, attachIndex);
Asa@3 143 ShowTipWithPricing (tip, GetInboxItemLink(index, attachIndex), num);
Asa@3 144 end
Asa@3 145 );
Asa@3 146
Asa@3 147 hooksecurefunc (GameTooltip, "SetSendMailItem",
Asa@3 148 function (tip, id)
Asa@3 149 local name, _, num = GetSendMailItem(id)
Asa@3 150 local name, link = GetItemInfo(name);
Asa@3 151 ShowTipWithPricing (tip, link, num);
Asa@3 152 end
Asa@3 153 );
Asa@3 154
Asa@3 155 hooksecurefunc (GameTooltip, "SetHyperlink",
Asa@3 156 function (tip, itemstring, num)
Asa@3 157 local name, link = GetItemInfo (itemstring);
Asa@3 158 ShowTipWithPricing (tip, link, num);
Asa@3 159 end
Asa@3 160 );
Asa@3 161
Asa@3 162 hooksecurefunc (ItemRefTooltip, "SetHyperlink",
Asa@3 163 function (tip, itemstring)
Asa@3 164 local name, link = GetItemInfo (itemstring);
Asa@3 165 ShowTipWithPricing (tip, link);
Asa@3 166 end
Asa@3 167 );