vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Auctioneer Addon for World of Warcraft(tm).
3 Version: 3.9.0.1000 (Kangaroo)
4 Revision: $Id: AucTooltip.lua 874 2006-05-21 20:36:12Z mentalpower $
5  
6 Auctioneer tooltip functions.
7 Functions to present and draw the tooltips.
8  
9 License:
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14  
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19  
20 You should have received a copy of the GNU General Public License
21 along with this program(see GPL.txt); if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ]]
24  
25 --Local function prototypes
26 local hookTooltip
27  
28  
29 function hookTooltip(funcVars, retVal, frame, name, link, quality, count)
30 EnhTooltip.DebugPrint("Displaying "..name)
31 if (not link) then EnhTooltip.DebugPrint("No link was passed to the client"); return; end
32  
33 -- nothing to do, if auctioneer is disabled
34 if (not Auctioneer.Command.GetFilter("all")) then
35 return;
36 end;
37  
38 if EnhTooltip.LinkType(link) ~= "item" then return end
39  
40 local auctKey = Auctioneer.Util.GetAuctionKey();
41  
42 -- initialize local variables
43 local itemID, randomProp, enchant, uniqID, lame = EnhTooltip.BreakLink(link);
44 local itemKey = itemID..":"..randomProp..":"..enchant;
45 local embedded = Auctioneer.Command.GetFilter('embed');
46  
47 -- OUTPUT: seperator line
48 if (embedded) then
49 if (Auctioneer.Command.GetFilter('show-embed-blankline')) then
50 EnhTooltip.AddLine(" ", nil, embedded);
51 end
52 else
53 EnhTooltip.AddLine(name, nil, embedded);
54 EnhTooltip.LineQuality(quality);
55 end
56  
57 if (Auctioneer.Command.GetFilter('show-link')) then
58 -- OUTPUT: show item link
59 EnhTooltip.AddLine("Link: " .. itemID .. ":" .. enchant .. ":" .. randomProp .. ":" .. uniqID, nil, embedded);
60 EnhTooltip.LineQuality(quality);
61 end
62  
63 local itemInfo = nil;
64  
65 -- show item info
66 if (itemID > 0) then
67 frame.eDone = 1;
68 local auctionPriceItem = Auctioneer.Core.GetAuctionPriceItem(itemKey, auctKey);
69 local aCount,minCount,minPrice,bidCount,bidPrice,buyCount,buyPrice = Auctioneer.Core.GetAuctionPrices(auctionPriceItem.data);
70  
71 -- show auction info
72 if (aCount == 0) then
73 -- OUTPUT: "Never seen at auction"
74 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoNever'), _AUCT('TextAuction')), nil, embedded);
75 EnhTooltip.LineColor(0.5, 0.8, 0.5);
76 else -- (aCount > 0)
77 -- calculate auction values
78 local avgMin = math.floor(minPrice / minCount);
79  
80 local bidPct = math.floor(bidCount / minCount * 100);
81 local avgBid = 0;
82 if (bidCount > 0) then
83 avgBid = math.floor(bidPrice / bidCount);
84 end
85  
86 local buyPct = math.floor(buyCount / minCount * 100);
87 local avgBuy = 0;
88 if (buyCount > 0) then
89 avgBuy = math.floor(buyPrice / buyCount);
90 end
91  
92 local median, medCount = Auctioneer.Statistic.GetUsableMedian(itemKey, auctKey);
93  
94 if (Auctioneer.Command.GetFilter('show-average')) then -- show item's average auction price
95 -- OUTPUT: "Seen [aCount] times at auction total"
96 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoSeen'), aCount), nil, embedded);
97 EnhTooltip.LineColor(0.5,0.8,0.1);
98 if (not Auctioneer.Command.GetFilter('show-verbose')) then -- default mode
99 -- OUTPUT: "[avgMin] min/[avgBuy] BO ([avgBid] bid)"
100 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoAverage'), EnhTooltip.GetTextGSC(avgMin), EnhTooltip.GetTextGSC(avgBuy), EnhTooltip.GetTextGSC(avgBid)), nil, embedded);
101 EnhTooltip.LineColor(0.1,0.8,0.5);
102 else -- verbose mode
103 if (count > 1) then
104 -- OUTPUT: "Averages for [count] items:"
105 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoHeadMulti'), count), nil, embedded);
106 EnhTooltip.LineColor(0.4,0.5,1.0);
107 -- OUTPUT: " Minimum ([avgMin] ea)"
108 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoMinMulti'), EnhTooltip.GetTextGSC(avgMin)), avgMin*count, embedded);
109 EnhTooltip.LineColor(0.4,0.5,0.8);
110 if (Auctioneer.Command.GetFilter('show-stats')) then -- show buyout/bidded percentages
111 -- OUTPUT: " Bidded ([bidPct]%, [avgBid] ea)"
112 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoBidMulti'), bidPct.."%, ", EnhTooltip.GetTextGSC(avgBid)), avgBid*count, embedded);
113 EnhTooltip.LineColor(0.4,0.5,0.85);
114 -- OUTPUT: " Buyout ([buyPct]%, [avgBuy] ea)"
115 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoBuyMulti'), buyPct.."%, ", EnhTooltip.GetTextGSC(avgBuy)), avgBuy*count, embedded);
116 EnhTooltip.LineColor(0.4,0.5,0.9);
117 else -- don't show buyout/bidded percentages
118 -- OUTPUT: " Bidded ([avgBid] ea)"
119 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoBidMulti'), "", EnhTooltip.GetTextGSC(avgBid)), avgBid*count, embedded);
120 EnhTooltip.LineColor(0.4,0.5,0.85);
121 -- OUTPUT: " Buyout ([avgBuy] ea)"
122 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoBuyMulti'), "", EnhTooltip.GetTextGSC(avgBuy)), avgBuy*count, embedded);
123 EnhTooltip.LineColor(0.4,0.5,0.9);
124 end
125 if (median) then
126 -- OUTPUT: " Buyout median"
127 EnhTooltip.AddLine(_AUCT('FrmtInfoBuymedian'), median * count, embedded);
128 EnhTooltip.LineColor(0.4,0.5,0.95);
129 end
130 else -- (count = 0 | 1)
131 -- OUTPUT: "Averages for this item:"
132 EnhTooltip.AddLine(_AUCT('FrmtInfoHeadOne'), nil, embedded);
133 EnhTooltip.LineColor(0.4,0.5,1.0);
134 -- OUTPUT: " Minimum bid"
135 EnhTooltip.AddLine(_AUCT('FrmtInfoMinOne'), avgMin, embedded);
136 EnhTooltip.LineColor(0.4,0.5,0.8);
137 if (Auctioneer.Command.GetFilter('show-stats')) then -- show buyout/bidded percentages
138 -- OUTPUT: " Bidded [bidPct]%"
139 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoBidOne'), " "..bidPct.."%"), avgBid, embedded);
140 EnhTooltip.LineColor(0.4,0.5,0.85);
141 -- OUTPUT: " Buyout [buyPct]%"
142 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoBuyOne'), " "..buyPct.."%"), avgBuy, embedded);
143 EnhTooltip.LineColor(0.4,0.5,0.9);
144 else -- don't show buyout/bidded percentages
145 -- OUTPUT: " Bidded [bidPct]%"
146 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoBidOne'), ""), avgBid, embedded);
147 EnhTooltip.LineColor(0.4,0.5,0.85);
148 -- OUTPUT: " Buyout [buyPct]%"
149 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoBuyOne'), ""), avgBuy, embedded);
150 EnhTooltip.LineColor(0.4,0.5,0.9);
151 end
152 if (median) then
153 -- OUTPUT: " Buyout median"
154 EnhTooltip.AddLine(_AUCT('FrmtInfoBuymedian'), median, embedded);
155 EnhTooltip.LineColor(0.4,0.5,0.95);
156 end
157 end
158 end
159  
160 if median and Auctioneer.Command.GetFilter('show-median') then -- show item's median buyout price
161 local historicalMedian, historicalMedCount = Auctioneer.Statistic.GetItemHistoricalMedianBuyout(itemKey, auctKey);
162 local snapshotMedian, snapshotMedCount = Auctioneer.Statistic.GetItemSnapshotMedianBuyout(itemKey, auctKey);
163 if historicalMedian and historicalMedCount > Auctioneer.Util.NullSafe(snapshotMedCount) then
164 -- OUTPUT: "Last [historicalMedCount], median BO (ea)"
165 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoHistmed'), historicalMedCount), historicalMedian, embedded)
166 EnhTooltip.LineColor(0.1,0.8,0.5);
167 end
168 if snapshotMedian then
169 -- OUTPUT: "Scanned [snapshotMedCount], median BO (ea)"
170 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoSnapmed'), snapshotMedCount), snapshotMedian, embedded)
171 EnhTooltip.LineColor(0.1,0.8,0.5);
172 end
173 end
174 end -- if(Auctioneer.Command.GetFilter('show-average')) - show item's average auction price
175  
176 -- seperate line for suggested auction price (for clarification, even if the values have already been shown somewhere else
177 if (Auctioneer.Command.GetFilter('show-suggest')) then -- show item's suggested auction price
178 local hsp, histCount, market, warn, nexthsp, nextwarn = Auctioneer.Statistic.GetHSP(itemKey, auctKey);
179 if hsp == 0 and buyCount > 0 then
180 hsp = math.floor(buyPrice / buyCount); -- use mean buyout if median not available
181 end
182 local discountBidPercent = tonumber(Auctioneer.Command.GetFilterVal('pct-bidmarkdown'));
183 local countFix = count
184 if countFix == 0 then
185 countFix = 1
186 end
187 local buyPrice = Auctioneer.Statistic.RoundDownTo95(Auctioneer.Util.NullSafe(hsp) * countFix);
188 local bidPrice = Auctioneer.Statistic.RoundDownTo95(Auctioneer.Statistic.SubtractPercent(buyPrice, discountBidPercent));
189 if (count > 1) then
190 -- OUTPUT: "Suggested price for your [count] stack: [bidPrice] min/[buyPrice] BO"
191 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoSgststx'), count, EnhTooltip.GetTextGSC(bidPrice, true), EnhTooltip.GetTextGSC(buyPrice, true)), nil, embedded);
192 EnhTooltip.LineColor(0.5,0.5,0.8);
193 else -- count = 0 | 1
194 -- OUTPUT: "Suggested price: [bidPrice] min/[buyPrice] BO"
195 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoSgst'), EnhTooltip.GetTextGSC(bidPrice, true), EnhTooltip.GetTextGSC(buyPrice, true)), nil, embedded);
196 EnhTooltip.LineColor(0.5,0.5,0.8);
197 end
198 EnhTooltip.AddLine(warn, nil, embedded);
199 local cHex, cRed, cGreen, cBlue = Auctioneer.Util.GetWarnColor(warn);
200 EnhTooltip.LineColor(cRed, cGreen, cBlue);
201 end
202 if (not Auctioneer.Command.GetFilter('show-verbose')) then
203 if (Auctioneer.Command.GetFilter('show-stats')) then -- show buyout/bidded percentages
204 -- OUTPUT: "[bidPct]% have bid, [buyPct]% have BO"
205 EnhTooltip.AddLine(string.format(_AUCT('FrmtInfoBidrate'), bidPct, buyPct), nil, embedded);
206 EnhTooltip.LineColor(0.1,0.5,0.8);
207 end
208 end
209 end -- (aCount > 0)
210  
211 local also = Auctioneer.Command.GetFilterVal("also");
212 if (Auctioneer.Util.IsValidAlso(also)) and (also ~= "off") then
213  
214 if (also == "opposite") then
215 also = Auctioneer.Util.GetOppositeKey();
216  
217 elseif (also == "neutral") then
218 also = Auctioneer.Util.GetNeutralKey();
219  
220 elseif (also == "home") then
221 also = Auctioneer.Util.GetHomeKey();
222 end
223  
224 if (also == auctKey) then return end;
225  
226 local auctionPriceItem = Auctioneer.Core.GetAuctionPriceItem(itemKey, also);
227 local aCount,minCount,minPrice,bidCount,bidPrice,buyCount,buyPrice = Auctioneer.Core.GetAuctionPrices(auctionPriceItem.data);
228  
229 if (aCount == 0) then
230 EnhTooltip.AddLine(string.format(">> ".._AUCT('FrmtInfoNever'), also), nil, embedded);
231 EnhTooltip.LineColor(0.5,0.8,0.1);
232 else
233 -- calculate auction values
234 local avgMin = math.floor(minPrice / minCount);
235  
236 local bidPct = math.floor(bidCount / minCount * 100);
237 local avgBid = 0;
238 if (bidCount > 0) then
239 avgBid = math.floor(bidPrice / bidCount);
240 end
241  
242 local buyPct = math.floor(buyCount / minCount * 100);
243 local avgBuy = 0;
244 if (buyCount > 0) then
245 avgBuy = math.floor(buyPrice / buyCount);
246 end
247  
248 if (Auctioneer.Command.GetFilter('show-average')) then
249 EnhTooltip.AddLine(string.format(">> ".._AUCT('FrmtInfoAlsoseen'), aCount, also), nil, embedded);
250 EnhTooltip.LineColor(0.5,0.8,0.1);
251 EnhTooltip.AddLine(string.format(">> ".._AUCT('FrmtInfoAverage'), EnhTooltip.GetTextGSC(avgMin), EnhTooltip.GetTextGSC(avgBuy), EnhTooltip.GetTextGSC(avgBid)), nil, embedded);
252 EnhTooltip.LineColor(0.1,0.8,0.5);
253 end
254  
255 if (Auctioneer.Command.GetFilter('show-stats')) then
256 EnhTooltip.AddLine(string.format(">> ".._AUCT('FrmtInfoBidrate'), bidPct, buyPct), nil, embedded);
257 EnhTooltip.LineColor(0.1,0.5,0.8);
258 end
259  
260 -- seperate line for suggested auction price (for clarification, even if the values have already been shown somewhere else
261 if (Auctioneer.Command.GetFilter('show-suggest')) then -- show item's suggested auction price
262 local hsp, histCount, market, warn, nexthsp, nextwarn = Auctioneer.Statistic.GetHSP(itemKey, also);
263 if hsp == 0 and buyCount > 0 then
264 hsp = math.floor(buyPrice / buyCount); -- use mean buyout if median not available
265 end
266 local discountBidPercent = tonumber(Auctioneer.Command.GetFilterVal('pct-bidmarkdown'));
267 local countFix = count
268 if countFix == 0 then
269 countFix = 1
270 end
271 local buyPrice = Auctioneer.Statistic.RoundDownTo95(Auctioneer.Util.NullSafe(hsp) * countFix);
272 local bidPrice = Auctioneer.Statistic.RoundDownTo95(Auctioneer.Statistic.SubtractPercent(buyPrice, discountBidPercent));
273 if (count > 1) then
274 -- OUTPUT: "Suggested price for your [count] stack: [bidPrice] min/[buyPrice] BO"
275 EnhTooltip.AddLine(string.format(">> ".._AUCT('FrmtInfoSgststx'), count, EnhTooltip.GetTextGSC(bidPrice, true), EnhTooltip.GetTextGSC(buyPrice, true)), nil, embedded);
276 EnhTooltip.LineColor(0.5,0.5,0.8);
277 else -- count = 0 | 1
278 -- OUTPUT: "Suggested price: [bidPrice] min/[buyPrice] BO"
279 EnhTooltip.AddLine(string.format(">> ".._AUCT('FrmtInfoSgst'), EnhTooltip.GetTextGSC(bidPrice, true), EnhTooltip.GetTextGSC(buyPrice, true)), nil, embedded);
280 EnhTooltip.LineColor(0.5,0.5,0.8);
281 end
282 EnhTooltip.AddLine(">> "..warn, nil, embedded);
283 local cHex, cRed, cGreen, cBlue = Auctioneer.Util.GetWarnColor(warn);
284 EnhTooltip.LineColor(cRed, cGreen, cBlue);
285 end
286 end
287 end
288 end
289 end
290  
291 Auctioneer.Tooltip = {
292 HookTooltip = hookTooltip,
293 }