comparison Modules/Tooltip.lua @ 3:bbcf81868171

Code cleanup.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Sat, 22 May 2010 11:34:19 -0700
parents
children 0271e781b154
comparison
equal deleted inserted replaced
2:e9a1646beaa4 3:bbcf81868171
1 local addonName, addonTable = ...;
2 local addon = _G[addonName]
3
4 local utils = addonTable.utils
5
6 local function ShowTipWithPricing(tip, link, num)
7 if (link == nil) then
8 return;
9 end
10
11 local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, _, _, _, _, itemVendorPrice = GetItemInfo (link);
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?")
13
14 local investedTotal, investedPerItem, count = ItemAuditor:GetItemCost(itemName)
15
16 local AHCut = 0.05
17 local keep = 1 - AHCut
18
19 if investedTotal > 0 then
20 tip:AddDoubleLine("\124cffffffffIA: Total Invested", utils:FormatMoney(investedTotal));
21 tip:AddDoubleLine("\124cffffffffIA: Invested/Item (" .. count .. ")", utils:FormatMoney(ceil(investedPerItem)));
22 tip:AddDoubleLine("\124cffffffffIA: Minimum faction AH Price: ", utils:FormatMoney(ceil(investedPerItem/keep)))
23 tip:Show()
24 end
25 end
26
27 hooksecurefunc (GameTooltip, "SetBagItem",
28 function(tip, bag, slot)
29 local _, num = GetContainerItemInfo(bag, slot);
30 ShowTipWithPricing (tip, GetContainerItemLink(bag, slot), num);
31 end
32 );
33
34 hooksecurefunc (GameTooltip, "SetAuctionItem",
35 function (tip, type, index)
36 ShowTipWithPricing (tip, GetAuctionItemLink(type, index));
37 end
38 );
39
40 hooksecurefunc (GameTooltip, "SetAuctionSellItem",
41 function (tip)
42 local name, _, count = GetAuctionSellItemInfo();
43 local __, link = GetItemInfo(name);
44 ShowTipWithPricing (tip, link, num);
45 end
46 );
47
48
49 hooksecurefunc (GameTooltip, "SetLootItem",
50 function (tip, slot)
51 if LootSlotIsItem(slot) then
52 local link, _, num = GetLootSlotLink(slot);
53 ShowTipWithPricing (tip, link, num);
54 end
55 end
56 );
57
58 hooksecurefunc (GameTooltip, "SetLootRollItem",
59 function (tip, slot)
60 local _, _, num = GetLootRollItemInfo(slot);
61 ShowTipWithPricing (tip, GetLootRollItemLink(slot), num);
62 end
63 );
64
65
66 hooksecurefunc (GameTooltip, "SetInventoryItem",
67 function (tip, unit, slot)
68 ShowTipWithPricing (tip, GetInventoryItemLink(unit, slot), GetInventoryItemCount(unit, slot));
69 end
70 );
71
72 hooksecurefunc (GameTooltip, "SetGuildBankItem",
73 function (tip, tab, slot)
74 local _, num = GetGuildBankItemInfo(tab, slot);
75 ShowTipWithPricing (tip, GetGuildBankItemLink(tab, slot), num);
76 end
77 );
78
79 hooksecurefunc (GameTooltip, "SetTradeSkillItem",
80 function (tip, skill, id)
81 local link = GetTradeSkillItemLink(skill);
82 local num = GetTradeSkillNumMade(skill);
83 if id then
84 link = GetTradeSkillReagentItemLink(skill, id);
85 num = select (3, GetTradeSkillReagentInfo(skill, id));
86 end
87
88 ShowTipWithPricing (tip, link, num);
89 end
90 );
91
92 hooksecurefunc (GameTooltip, "SetTradePlayerItem",
93 function (tip, id)
94 local _, _, num = GetTradePlayerItemInfo(id);
95 ShowTipWithPricing (tip, GetTradePlayerItemLink(id), num);
96 end
97 );
98
99 hooksecurefunc (GameTooltip, "SetTradeTargetItem",
100 function (tip, id)
101 local _, _, num = GetTradeTargetItemInfo(id);
102 ShowTipWithPricing (tip, GetTradeTargetItemLink(id), num);
103 end
104 );
105
106 hooksecurefunc (GameTooltip, "SetQuestItem",
107 function (tip, type, index)
108 local _, _, num = GetQuestItemInfo(type, index);
109 ShowTipWithPricing (tip, GetQuestItemLink(type, index), num);
110 end
111 );
112
113 hooksecurefunc (GameTooltip, "SetQuestLogItem",
114 function (tip, type, index)
115 local num, _;
116 if type == "choice" then
117 _, _, num = GetQuestLogChoiceInfo(index);
118 else
119 _, _, num = GetQuestLogRewardInfo(index)
120 end
121
122 ShowTipWithPricing (tip, GetQuestLogItemLink(type, index), num);
123 end
124 );
125
126 hooksecurefunc (GameTooltip, "SetInboxItem",
127 function (tip, index, attachIndex)
128 local _, _, num = GetInboxItem(index, attachIndex);
129 ShowTipWithPricing (tip, GetInboxItemLink(index, attachIndex), num);
130 end
131 );
132
133 hooksecurefunc (GameTooltip, "SetSendMailItem",
134 function (tip, id)
135 local name, _, num = GetSendMailItem(id)
136 local name, link = GetItemInfo(name);
137 ShowTipWithPricing (tip, link, num);
138 end
139 );
140
141 hooksecurefunc (GameTooltip, "SetHyperlink",
142 function (tip, itemstring, num)
143 local name, link = GetItemInfo (itemstring);
144 ShowTipWithPricing (tip, link, num);
145 end
146 );
147
148 hooksecurefunc (ItemRefTooltip, "SetHyperlink",
149 function (tip, itemstring)
150 local name, link = GetItemInfo (itemstring);
151 ShowTipWithPricing (tip, link);
152 end
153 );