annotate Modules/Tooltip.lua @ 12:6a6296dd249f

Removed dependency on DevTools, completed chaning over the database to use links instead of names, Added integration with my version of QuickAuctions3 (I need to make this optional soon)
author Asa Ayers <Asa.Ayers@Gmail.com>
date Wed, 30 Jun 2010 22:59:37 -0700
parents c79ede3c7b82
children 8c83d5f6e306
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@10 16 local AHCut = ItemAuditor.db.factionrealm.AHCut
Asa@3 17 local keep = 1 - AHCut
Asa@12 18 local show = false
Asa@3 19
Asa@3 20 if investedTotal > 0 then
Asa@3 21 tip:AddDoubleLine("\124cffffffffIA: Total Invested", utils:FormatMoney(investedTotal));
Asa@3 22 tip:AddDoubleLine("\124cffffffffIA: Invested/Item (" .. count .. ")", utils:FormatMoney(ceil(investedPerItem)));
Asa@3 23 tip:AddDoubleLine("\124cffffffffIA: Minimum faction AH Price: ", utils:FormatMoney(ceil(investedPerItem/keep)))
Asa@12 24 show = true
Asa@12 25
Asa@12 26 end
Asa@12 27 local groupName = QAAPI:GetItemGroup(link)
Asa@12 28 if groupName then
Asa@12 29 local threshold = QAAPI:GetGroupThreshold(groupName)
Asa@12 30 tip:AddDoubleLine("\124cffffffffIA: QA Threshold: ", utils:FormatMoney(threshold))
Asa@12 31 show = true
Asa@12 32 end
Asa@12 33
Asa@12 34 if show then
Asa@3 35 tip:Show()
Asa@3 36 end
Asa@3 37 end
Asa@3 38
Asa@3 39 hooksecurefunc (GameTooltip, "SetBagItem",
Asa@3 40 function(tip, bag, slot)
Asa@3 41 local _, num = GetContainerItemInfo(bag, slot);
Asa@3 42 ShowTipWithPricing (tip, GetContainerItemLink(bag, slot), num);
Asa@3 43 end
Asa@3 44 );
Asa@3 45
Asa@3 46 hooksecurefunc (GameTooltip, "SetAuctionItem",
Asa@3 47 function (tip, type, index)
Asa@3 48 ShowTipWithPricing (tip, GetAuctionItemLink(type, index));
Asa@3 49 end
Asa@3 50 );
Asa@3 51
Asa@3 52 hooksecurefunc (GameTooltip, "SetAuctionSellItem",
Asa@3 53 function (tip)
Asa@3 54 local name, _, count = GetAuctionSellItemInfo();
Asa@3 55 local __, link = GetItemInfo(name);
Asa@3 56 ShowTipWithPricing (tip, link, num);
Asa@3 57 end
Asa@3 58 );
Asa@3 59
Asa@3 60
Asa@3 61 hooksecurefunc (GameTooltip, "SetLootItem",
Asa@3 62 function (tip, slot)
Asa@3 63 if LootSlotIsItem(slot) then
Asa@3 64 local link, _, num = GetLootSlotLink(slot);
Asa@3 65 ShowTipWithPricing (tip, link, num);
Asa@3 66 end
Asa@3 67 end
Asa@3 68 );
Asa@3 69
Asa@3 70 hooksecurefunc (GameTooltip, "SetLootRollItem",
Asa@3 71 function (tip, slot)
Asa@3 72 local _, _, num = GetLootRollItemInfo(slot);
Asa@3 73 ShowTipWithPricing (tip, GetLootRollItemLink(slot), num);
Asa@3 74 end
Asa@3 75 );
Asa@3 76
Asa@3 77
Asa@3 78 hooksecurefunc (GameTooltip, "SetInventoryItem",
Asa@3 79 function (tip, unit, slot)
Asa@3 80 ShowTipWithPricing (tip, GetInventoryItemLink(unit, slot), GetInventoryItemCount(unit, slot));
Asa@3 81 end
Asa@3 82 );
Asa@3 83
Asa@3 84 hooksecurefunc (GameTooltip, "SetGuildBankItem",
Asa@3 85 function (tip, tab, slot)
Asa@3 86 local _, num = GetGuildBankItemInfo(tab, slot);
Asa@3 87 ShowTipWithPricing (tip, GetGuildBankItemLink(tab, slot), num);
Asa@3 88 end
Asa@3 89 );
Asa@3 90
Asa@3 91 hooksecurefunc (GameTooltip, "SetTradeSkillItem",
Asa@3 92 function (tip, skill, id)
Asa@3 93 local link = GetTradeSkillItemLink(skill);
Asa@3 94 local num = GetTradeSkillNumMade(skill);
Asa@3 95 if id then
Asa@3 96 link = GetTradeSkillReagentItemLink(skill, id);
Asa@3 97 num = select (3, GetTradeSkillReagentInfo(skill, id));
Asa@3 98 end
Asa@3 99
Asa@3 100 ShowTipWithPricing (tip, link, num);
Asa@3 101 end
Asa@3 102 );
Asa@3 103
Asa@3 104 hooksecurefunc (GameTooltip, "SetTradePlayerItem",
Asa@3 105 function (tip, id)
Asa@3 106 local _, _, num = GetTradePlayerItemInfo(id);
Asa@3 107 ShowTipWithPricing (tip, GetTradePlayerItemLink(id), num);
Asa@3 108 end
Asa@3 109 );
Asa@3 110
Asa@3 111 hooksecurefunc (GameTooltip, "SetTradeTargetItem",
Asa@3 112 function (tip, id)
Asa@3 113 local _, _, num = GetTradeTargetItemInfo(id);
Asa@3 114 ShowTipWithPricing (tip, GetTradeTargetItemLink(id), num);
Asa@3 115 end
Asa@3 116 );
Asa@3 117
Asa@3 118 hooksecurefunc (GameTooltip, "SetQuestItem",
Asa@3 119 function (tip, type, index)
Asa@3 120 local _, _, num = GetQuestItemInfo(type, index);
Asa@3 121 ShowTipWithPricing (tip, GetQuestItemLink(type, index), num);
Asa@3 122 end
Asa@3 123 );
Asa@3 124
Asa@3 125 hooksecurefunc (GameTooltip, "SetQuestLogItem",
Asa@3 126 function (tip, type, index)
Asa@3 127 local num, _;
Asa@3 128 if type == "choice" then
Asa@3 129 _, _, num = GetQuestLogChoiceInfo(index);
Asa@3 130 else
Asa@3 131 _, _, num = GetQuestLogRewardInfo(index)
Asa@3 132 end
Asa@3 133
Asa@3 134 ShowTipWithPricing (tip, GetQuestLogItemLink(type, index), num);
Asa@3 135 end
Asa@3 136 );
Asa@3 137
Asa@3 138 hooksecurefunc (GameTooltip, "SetInboxItem",
Asa@3 139 function (tip, index, attachIndex)
Asa@3 140 local _, _, num = GetInboxItem(index, attachIndex);
Asa@3 141 ShowTipWithPricing (tip, GetInboxItemLink(index, attachIndex), num);
Asa@3 142 end
Asa@3 143 );
Asa@3 144
Asa@3 145 hooksecurefunc (GameTooltip, "SetSendMailItem",
Asa@3 146 function (tip, id)
Asa@3 147 local name, _, num = GetSendMailItem(id)
Asa@3 148 local name, link = GetItemInfo(name);
Asa@3 149 ShowTipWithPricing (tip, link, num);
Asa@3 150 end
Asa@3 151 );
Asa@3 152
Asa@3 153 hooksecurefunc (GameTooltip, "SetHyperlink",
Asa@3 154 function (tip, itemstring, num)
Asa@3 155 local name, link = GetItemInfo (itemstring);
Asa@3 156 ShowTipWithPricing (tip, link, num);
Asa@3 157 end
Asa@3 158 );
Asa@3 159
Asa@3 160 hooksecurefunc (ItemRefTooltip, "SetHyperlink",
Asa@3 161 function (tip, itemstring)
Asa@3 162 local name, link = GetItemInfo (itemstring);
Asa@3 163 ShowTipWithPricing (tip, link);
Asa@3 164 end
Asa@3 165 );