vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[-------------------------------------------------------------------------------- |
2 | ItemSyncCore Tooltip Framework |
||
3 | |||
4 | Author: Derkyle |
||
5 | Website: http://www.manaflux.com |
||
6 | -----------------------------------------------------------------------------------]] |
||
7 | |||
8 | |||
9 | local ISync_lOriginal_GameTooltip_SetOwner; |
||
10 | local ISync_lOriginal_GameTooltip_SetHyperlink; |
||
11 | local ISync_lOriginal_GameTooltip_SetInventoryItem; |
||
12 | local ISync_lOriginal_GameTooltip_SetBagItem; |
||
13 | local ISync_lOriginal_GameTooltip_SetLootItem; |
||
14 | local ISync_lOriginal_GameTooltip_SetQuestItem; |
||
15 | local ISync_lOriginal_GameTooltip_SetQuestLogItem; |
||
16 | local ISync_lOriginal_GameTooltip_SetCraftItem; |
||
17 | local ISync_lOriginal_GameTooltip_SetTradeSkillItem; |
||
18 | local ISync_lOriginal_GameTooltip_SetMerchantItem; |
||
19 | local ISync_lOriginal_GameTooltip_SetTradePlayerItem; |
||
20 | local ISync_lOriginal_GameTooltip_SetTradeTargetItem; |
||
21 | local ISync_lOriginal_GameTooltip_SetAuctionItem; |
||
22 | |||
23 | local ISync_lOriginal_GameTooltip_OnEvent; |
||
24 | local ISync_lOriginal_GameTooltip_OnHide; |
||
25 | local ISync_lOriginal_SetItemRef; |
||
26 | |||
27 | local ISync_GameTooltip_HookedMoney; |
||
28 | local ISync_GameTooltip_HookedOnShow; |
||
29 | |||
30 | --GLOBALS |
||
31 | ISYNC_ITEMCOST = 0; |
||
32 | |||
33 | local lastTooltip = { }; |
||
34 | |||
35 | --------------------------------------------------- |
||
36 | -- ISync:HookTooltip() |
||
37 | --------------------------------------------------- |
||
38 | function ISync:HookTooltip() |
||
39 | |||
40 | |||
41 | ------------------------------------------------------------------ |
||
42 | -- DO GAMETOOLTIP HOOKS |
||
43 | ------------------------------------------------------------------ |
||
44 | --GameTooltip.SetOwner |
||
45 | ISync_lOriginal_GameTooltip_SetOwner = GameTooltip.SetOwner; |
||
46 | GameTooltip.SetOwner = ISync_ToolTip_GT_SetOwner; |
||
47 | |||
48 | --GameTooltip.SetHyperlink |
||
49 | ISync_lOriginal_GameTooltip_SetHyperlink = GameTooltip.SetHyperlink; |
||
50 | GameTooltip.SetHyperlink = ISync_ToolTip_GT_SetHyperlink; |
||
51 | |||
52 | --GameTooltip.SetInventoryItem |
||
53 | ISync_lOriginal_GameTooltip_SetInventoryItem = GameTooltip.SetInventoryItem; |
||
54 | GameTooltip.SetInventoryItem = ISync_ToolTip_GT_SetInventoryItem; |
||
55 | |||
56 | --GameTooltip.SetBagItem |
||
57 | ISync_lOriginal_GameTooltip_SetBagItem = GameTooltip.SetBagItem; |
||
58 | GameTooltip.SetBagItem = ISync_ToolTip_GT_SetBagItem; |
||
59 | |||
60 | --GameTooltip.SetLootItem |
||
61 | ISync_lOriginal_GameTooltip_SetLootItem = GameTooltip.SetLootItem; |
||
62 | GameTooltip.SetLootItem = ISync_ToolTip_GT_SetLootItem; |
||
63 | |||
64 | --GameTooltip.SetQuestItem |
||
65 | ISync_lOriginal_GameTooltip_SetQuestItem = GameTooltip.SetQuestItem; |
||
66 | GameTooltip.SetQuestItem = ISync_ToolTip_GT_SetQuestItem; |
||
67 | |||
68 | --GameTooltip.SetQuestLogItem |
||
69 | ISync_lOriginal_GameTooltip_SetQuestLogItem = GameTooltip.SetQuestLogItem; |
||
70 | GameTooltip.SetQuestLogItem = ISync_ToolTip_GT_SetQuestLogItem; |
||
71 | |||
72 | --GameTooltip.SetCraftItem |
||
73 | ISync_lOriginal_GameTooltip_SetCraftItem = GameTooltip.SetCraftItem; |
||
74 | GameTooltip.SetCraftItem = ISync_ToolTip_GT_SetCraftItem; |
||
75 | |||
76 | --GameTooltip.SetTradeSkillItem |
||
77 | ISync_lOriginal_GameTooltip_SetTradeSkillItem = GameTooltip.SetTradeSkillItem; |
||
78 | GameTooltip.SetTradeSkillItem = ISync_ToolTip_GT_SetTradeSkillItem; |
||
79 | |||
80 | --GameTooltip.SetMerchantItem |
||
81 | ISync_lOriginal_GameTooltip_SetMerchantItem = GameTooltip.SetMerchantItem; |
||
82 | GameTooltip.SetMerchantItem = ISync_ToolTip_GT_SetMerchantItem; |
||
83 | |||
84 | --GameTooltip.SetTradePlayerItem |
||
85 | ISync_lOriginal_GameTooltip_SetTradePlayerItem = GameTooltip.SetTradePlayerItem; |
||
86 | GameTooltip.SetTradePlayerItem = ISync_ToolTip_GT_SetTradePlayerItem; |
||
87 | |||
88 | --GameTooltip.SetTradeTargetItem |
||
89 | ISync_lOriginal_GameTooltip_SetTradeTargetItem = GameTooltip.SetTradeTargetItem; |
||
90 | GameTooltip.SetTradeTargetItem = ISync_ToolTip_GT_SetTradeTargetItem; |
||
91 | |||
92 | --GameTooltip.SetAuctionItem |
||
93 | ISync_lOriginal_GameTooltip_SetAuctionItem = GameTooltip.SetAuctionItem; |
||
94 | GameTooltip.SetAuctionItem = ISync_ToolTip_GT_SetAuctionItem; |
||
95 | |||
96 | --Hook for GameTooltip_OnEvent Function |
||
97 | ISync_lOriginal_GameTooltip_OnEvent = GameTooltip_OnEvent; |
||
98 | GameTooltip_OnEvent = ISync_ToolTip_GT_OnEvent; |
||
99 | |||
100 | --Hook the gametooltip onhide |
||
101 | ISync_lOriginal_GameTooltip_OnHide = GameTooltip_OnHide; |
||
102 | GameTooltip_OnHide = ISync_ToolTip_GT_OnHide; |
||
103 | |||
104 | --Hook the gametooltip OnAddMoney |
||
105 | ISync_GameTooltip_HookedMoney = GameTooltip:GetScript("OnTooltipAddMoney"); |
||
106 | GameTooltip:SetScript("OnTooltipAddMoney", ISync_ToolTip_GT_AddMoney); |
||
107 | |||
108 | --Hook the gametooltip OnShow |
||
109 | ISync_GameTooltip_HookedOnShow = GameTooltip:GetScript("OnShow"); |
||
110 | GameTooltip:SetScript("OnShow", ISync_ToolTip_GT_OnShow); |
||
111 | |||
112 | ------------------------------------------------------------------ |
||
113 | ------------------------------------------------------------------ |
||
114 | |||
115 | --for items that are clicked on in chat |
||
116 | ISync_lOriginal_SetItemRef = SetItemRef; |
||
117 | SetItemRef = ISync_SetItemRef; |
||
118 | |||
119 | |||
120 | end |
||
121 | |||
122 | |||
123 | -------------------------------------------------------------------------------------------------------------------------------- |
||
124 | -------------------------------------------------------------------------------------------------------------------------------- |
||
125 | -------------------------------------------------------------------------------------------------------------------------------- |
||
126 | -------------------------------------------------------------------------------------------------------------------------------- |
||
127 | -------------------------------------------------------------------------------------------------------------------------------- |
||
128 | -------------------------------------------------------------------------------------------------------------------------------- |
||
129 | |||
130 | |||
131 | --------------------------------------------------- |
||
132 | -- ISync_ToolTip_GT_OnEvent |
||
133 | --------------------------------------------------- |
||
134 | function ISync_ToolTip_GT_OnEvent() |
||
135 | |||
136 | if event ~= "CLEAR_TOOLTIP" then |
||
137 | return ISync_lOriginal_GameTooltip_OnEvent(); |
||
138 | end |
||
139 | |||
140 | end |
||
141 | |||
142 | |||
143 | --------------------------------------------------- |
||
144 | -- ISync_ToolTip_GT_OnHide |
||
145 | --------------------------------------------------- |
||
146 | function ISync_ToolTip_GT_OnHide() |
||
147 | ISync_lOriginal_GameTooltip_OnHide(); |
||
148 | |||
149 | --don't do anything with the parsing tooltip |
||
150 | if(this:GetName() == "ISyncTooltip") then return nil; end |
||
151 | |||
152 | --make sure this is only applied to the GameTooltip |
||
153 | if(this:GetName() == "GameTooltip") then |
||
154 | |||
155 | GameTooltip.isDisplayDone = nil; |
||
156 | GameTooltip.SendtoMods = nil; |
||
157 | GameTooltip_ClearMoney(); |
||
158 | ISync_GameTooltipIcon:Hide(); |
||
159 | ISync_MoneyTooltip:Hide(); |
||
160 | end |
||
161 | |||
162 | end |
||
163 | |||
164 | |||
165 | --------------------------------------------------- |
||
166 | -- ISync_ToolTip_GT_SetOwner |
||
167 | --------------------------------------------------- |
||
168 | function ISync_ToolTip_GT_SetOwner(this, owner, anchor) |
||
169 | |||
170 | --return to original to prevent errors |
||
171 | ISync_lOriginal_GameTooltip_SetOwner(this, owner, anchor); |
||
172 | |||
173 | --we want to store this for later use (like for Auctioneer) |
||
174 | this.owner = owner; |
||
175 | this.anchor = anchor; |
||
176 | |||
177 | end |
||
178 | |||
179 | |||
180 | --------------------------------------------------- |
||
181 | -- ISync_ToolTip_GT_AddMoney |
||
182 | --------------------------------------------------- |
||
183 | function ISync_ToolTip_GT_AddMoney() |
||
184 | ISync_GameTooltip_HookedMoney(); --call the old function |
||
185 | |||
186 | if(ISYNC_LOADYES == 1 and arg1 and not InRepairMode()) then ISYNC_ITEMCOST = arg1; end |
||
187 | |||
188 | end |
||
189 | |||
190 | |||
191 | |||
192 | --------------------------------------------------- |
||
193 | -- ISync_ToolTip_GT_OnShow |
||
194 | --------------------------------------------------- |
||
195 | function ISync_ToolTip_GT_OnShow() |
||
196 | if(ISync_GameTooltip_HookedOnShow) then ISync_GameTooltip_HookedOnShow(); end |
||
197 | |||
198 | --ISync_ToolTip_GT_OnHide(); |
||
199 | end |
||
200 | |||
201 | |||
202 | -------------------------------------------------------------------------------------------------------------------------------- |
||
203 | -------------------------------------------------------------------------------------------------------------------------------- |
||
204 | -------------------------------------------------------------------------------------------------------------------------------- |
||
205 | -------------------------------------------------------------------------------------------------------------------------------- |
||
206 | -------------------------------------------------------------------------------------------------------------------------------- |
||
207 | -------------------------------------------------------------------------------------------------------------------------------- |
||
208 | |||
209 | |||
210 | --------------------------------------------------- |
||
211 | -- ISync_SetItemRef |
||
212 | --------------------------------------------------- |
||
213 | function ISync_SetItemRef( link, name, button) |
||
214 | ISync_lOriginal_SetItemRef(link, name, button); --return |
||
215 | |||
216 | --make sure we have a link to work with |
||
217 | if(not link or not name) then return nil; end |
||
218 | |||
219 | --make sure we have a tooltip to work with duh |
||
220 | if(not ItemRefTooltip) then return nil; end |
||
221 | |||
222 | --we need to weed out item links and player tooltips. |
||
223 | if( strsub(link, 1, 6) ~= "Player" ) then |
||
224 | |||
225 | if( ItemRefTooltip:IsVisible() and link) then |
||
226 | |||
227 | if (link) then |
||
228 | |||
229 | if(not DressUpFrame:IsVisible()) then |
||
230 | ISync:AddTooltipInfo(ItemRefTooltip, link, 1); |
||
231 | end |
||
232 | |||
233 | --reset it after it's been added so that we can always see it |
||
234 | ItemRefTooltip.isDisplayDone = nil; |
||
235 | end |
||
236 | |||
237 | end |
||
238 | |||
239 | end |
||
240 | |||
241 | |||
242 | end |
||
243 | |||
244 | -------------------------------------------------------------------------------------------------------------------------------- |
||
245 | -------------------------------------------------------------------------------------------------------------------------------- |
||
246 | -------------------------------------------------------------------------------------------------------------------------------- |
||
247 | -------------------------------------------------------------------------------------------------------------------------------- |
||
248 | -------------------------------------------------------------------------------------------------------------------------------- |
||
249 | -------------------------------------------------------------------------------------------------------------------------------- |
||
250 | |||
251 | |||
252 | |||
253 | --------------------------------------------------- |
||
254 | -- ISync_ToolTip_GT_SetHyperlink |
||
255 | --------------------------------------------------- |
||
256 | function ISync_ToolTip_GT_SetHyperlink(this, link) |
||
257 | |||
258 | if( link ) then |
||
259 | |||
260 | local _,_,id = string.find(link, "^.*item:([0-9]+):.*$"); |
||
261 | |||
262 | if (id) then |
||
263 | |||
264 | ISync_lOriginal_GameTooltip_SetHyperlink(this, link); |
||
265 | ISync:AddTooltipInfo(this, link, 1); |
||
266 | end |
||
267 | end |
||
268 | end |
||
269 | |||
270 | |||
271 | |||
272 | |||
273 | --------------------------------------------------- |
||
274 | -- ISync_ToolTip_GT_SetInventoryItem |
||
275 | --------------------------------------------------- |
||
276 | function ISync_ToolTip_GT_SetInventoryItem(this, unit, slot) |
||
277 | |||
278 | local sItem, sCooldown, sRepair = ISync_lOriginal_GameTooltip_SetInventoryItem(this, unit, slot); |
||
279 | |||
280 | if(not sItem) then return nil; end |
||
281 | |||
282 | local link = (unit) and GetInventoryItemLink(unit, slot) or GetContainerItemLink(BANK_CONTAINER,this:GetID()); |
||
283 | local _, qty; |
||
284 | |||
285 | if(unit) then |
||
286 | qty = GetInventoryItemCount(unit, slot); |
||
287 | else |
||
288 | _, qty = GetContainerItemInfo(BANK_CONTAINER,this:GetID()); |
||
289 | end |
||
290 | |||
291 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
292 | |||
293 | --return to original one |
||
294 | return sItem, sCooldown, sRepair; |
||
295 | |||
296 | end |
||
297 | |||
298 | |||
299 | |||
300 | --------------------------------------------------- |
||
301 | -- ISync_ToolTip_GT_SetBagItem |
||
302 | --------------------------------------------------- |
||
303 | function ISync_ToolTip_GT_SetBagItem(this, bag, slot) |
||
304 | ISync_lOriginal_GameTooltip_SetBagItem(this, bag, slot); |
||
305 | |||
306 | local link = GetContainerItemLink(bag, slot); |
||
307 | local _, qty = GetContainerItemInfo(bag, slot); |
||
308 | |||
309 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
310 | |||
311 | end |
||
312 | |||
313 | |||
314 | |||
315 | --------------------------------------------------- |
||
316 | -- ISync_ToolTip_GT_SetLootItem |
||
317 | --------------------------------------------------- |
||
318 | function ISync_ToolTip_GT_SetLootItem(this, slot) |
||
319 | ISync_lOriginal_GameTooltip_SetLootItem(this, slot); |
||
320 | |||
321 | local link = GetLootSlotLink(slot); |
||
322 | local _,_, qty = GetLootSlotInfo(slot); |
||
323 | |||
324 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
325 | |||
326 | end |
||
327 | |||
328 | |||
329 | |||
330 | --------------------------------------------------- |
||
331 | -- ISync_ToolTip_GT_SetQuestItem |
||
332 | --------------------------------------------------- |
||
333 | function ISync_ToolTip_GT_SetQuestItem(this, unit, slot) |
||
334 | ISync_lOriginal_GameTooltip_SetQuestItem(this, unit, slot); |
||
335 | |||
336 | local link = GetQuestItemLink(unit, slot); |
||
337 | local _,_, qty = GetQuestItemInfo(unit, slot); |
||
338 | |||
339 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
340 | |||
341 | end |
||
342 | |||
343 | |||
344 | |||
345 | --------------------------------------------------- |
||
346 | -- ISync_ToolTip_GT_SetQuestLogItem |
||
347 | --------------------------------------------------- |
||
348 | function ISync_ToolTip_GT_SetQuestLogItem(this, sOpt, slot) |
||
349 | ISync_lOriginal_GameTooltip_SetQuestLogItem(this, sOpt, slot); |
||
350 | |||
351 | local link = GetQuestLogItemLink(sOpt, slot); |
||
352 | local name, texture, qty, quality, usable = GetQuestLogRewardInfo(slot); |
||
353 | |||
354 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
355 | |||
356 | end |
||
357 | |||
358 | |||
359 | |||
360 | --------------------------------------------------- |
||
361 | -- ISync_ToolTip_GT_SetCraftItem |
||
362 | --------------------------------------------------- |
||
363 | function ISync_ToolTip_GT_SetCraftItem(this, skill, slot) |
||
364 | ISync_lOriginal_GameTooltip_SetCraftItem(this, skill, slot); |
||
365 | |||
366 | local link = (slot) and GetCraftReagentItemLink(skill, slot) or GetCraftItemLink(skill); |
||
367 | local _, _, qty = GetCraftReagentInfo(skill, slot); |
||
368 | |||
369 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
370 | |||
371 | end |
||
372 | |||
373 | |||
374 | |||
375 | --------------------------------------------------- |
||
376 | -- ISync_ToolTip_GT_SetTradeSkillItem |
||
377 | --------------------------------------------------- |
||
378 | function ISync_ToolTip_GT_SetTradeSkillItem(this, skill, slot) |
||
379 | ISync_lOriginal_GameTooltip_SetTradeSkillItem(this, skill, slot); |
||
380 | |||
381 | local link = (slot) and GetTradeSkillReagentItemLink(skill, slot) or GetTradeSkillItemLink(skill); |
||
382 | local _, _, qty; |
||
383 | |||
384 | if(slot) then |
||
385 | _, _, qty = GetTradeSkillReagentInfo(skill, slot); |
||
386 | else |
||
387 | qty = 1; |
||
388 | end |
||
389 | |||
390 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
391 | |||
392 | end |
||
393 | |||
394 | |||
395 | --------------------------------------------------- |
||
396 | -- ISync_ToolTip_GT_SetMerchantItem |
||
397 | --------------------------------------------------- |
||
398 | function ISync_ToolTip_GT_SetMerchantItem(this, slot) |
||
399 | ISync_lOriginal_GameTooltip_SetMerchantItem(this, slot); |
||
400 | |||
401 | local link = GetMerchantItemLink(slot); |
||
402 | local _,_,_, qty = GetMerchantItemInfo(slot); |
||
403 | |||
404 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
405 | |||
406 | end |
||
407 | |||
408 | |||
409 | --------------------------------------------------- |
||
410 | -- ISync_ToolTip_GT_SetTradePlayerItem |
||
411 | --------------------------------------------------- |
||
412 | function ISync_ToolTip_GT_SetTradePlayerItem(this, slot) |
||
413 | ISync_lOriginal_GameTooltip_SetTradePlayerItem(this, slot); |
||
414 | |||
415 | local link = GetTradePlayerItemLink(slot); |
||
416 | local _,_, qty = GetTradeTargetItemInfo(slot); |
||
417 | |||
418 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
419 | |||
420 | end |
||
421 | |||
422 | |||
423 | --------------------------------------------------- |
||
424 | -- ISync_ToolTip_GT_SetTradeTargetItem |
||
425 | --------------------------------------------------- |
||
426 | function ISync_ToolTip_GT_SetTradeTargetItem(this, slot) |
||
427 | ISync_lOriginal_GameTooltip_SetTradeTargetItem(this, slot); |
||
428 | |||
429 | local link = GetTradeTargetItemLink(slot); |
||
430 | local _,_, qty = GetTradeTargetItemInfo(slot); |
||
431 | |||
432 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
433 | end |
||
434 | |||
435 | |||
436 | |||
437 | --------------------------------------------------- |
||
438 | -- ISync_ToolTip_GT_SetAuctionItem |
||
439 | --------------------------------------------------- |
||
440 | function ISync_ToolTip_GT_SetAuctionItem(this, unit, slot) |
||
441 | ISync_lOriginal_GameTooltip_SetAuctionItem(this, unit, slot); |
||
442 | |||
443 | local link = GetAuctionItemLink(unit, slot); |
||
444 | local _,_,qty = GetAuctionItemInfo(unit, slot); |
||
445 | |||
446 | ISync:AddTooltipInfo(this, link, qty, 1); |
||
447 | end |
||
448 | |||
449 | |||
450 | -------------------------------------------------------------------------------------------------------------------------------- |
||
451 | -------------------------------------------------------------------------------------------------------------------------------- |
||
452 | -------------------------------------------------------------------------------------------------------------------------------- |
||
453 | -------------------------------------------------------------------------------------------------------------------------------- |
||
454 | -------------------------------------------------------------------------------------------------------------------------------- |
||
455 | -------------------------------------------------------------------------------------------------------------------------------- |
||
456 | |||
457 | |||
458 | --------------------------------------------------- |
||
459 | -- ISync:AddTooltipInfo |
||
460 | --------------------------------------------------- |
||
461 | function ISync:AddTooltipInfo(sTooltip, sLink, sQty, sChk) |
||
462 | |||
463 | --check |
||
464 | if(not sTooltip) then return nil; end |
||
465 | if(not sLink and not sQty) then return nil; end --if we don't have both, then ignore |
||
466 | if(tonumber(sLink) and tonumber(sLink) == 0) then return nil; end--if we have a link but it's zero then ignore |
||
467 | if(sLink and not sQty) then sQty = 1; end --if we have an item but no qty, then set qty to 1 |
||
468 | if(tonumber(sQty) and tonumber(sQty) == 0) then sQty = 1; end --fix incorrect qty |
||
469 | if(not tonumber(sQty)) then sQty = 1; end --fix stupid errors |
||
470 | if(sTooltip.isDisplayDone) then return nil; end |
||
471 | |||
472 | --we don't want the information to be placed while we are at a merchant, EXCEPT if it's the clickable links. |
||
473 | if(MerchantFrame:IsVisible() and sTooltip:GetName() ~= "ItemRefTooltip") then return nil; end |
||
474 | |||
475 | --grab the itemid we need |
||
476 | sLink = ISync:GetItemID(sLink); |
||
477 | if(not sLink) then return nil; end --exit if nothing |
||
478 | |||
479 | --grab the coreid |
||
480 | local sID = ISync:GetCoreID(sLink); |
||
481 | if(not tonumber(sID)) then return nil; end --exit if nothing |
||
482 | |||
483 | sID = tonumber(sID); --convert |
||
484 | |||
485 | |||
486 | local name_X, link_X, quality_X, minLevel_X, class_X, subclass_X, maxStack_X, equipType_X, iconTexture_X = GetItemInfo("item:"..sLink); |
||
487 | if(not name_X) then return nil; end --make sure |
||
488 | |||
489 | |||
490 | --don't show for certain things cause it's annoying |
||
491 | if(ISync:SetVar({"OPT","TOOLTIPITEMICONS"}, 1, "COMPARE") and not sChk) then--show the tooltip icon |
||
492 | |||
493 | getglobal("ISync_"..sTooltip:GetName().."IconTexture"):SetTexture(iconTexture_X); |
||
494 | |||
495 | if(sTooltip:GetName() == "ItemRefTooltip") then --move if equipcompare is installed |
||
496 | if(EquipCompare_Enabled) then |
||
497 | getglobal("ISync_"..sTooltip:GetName().."Icon"):SetPoint("TOPLEFT", "ItemRefTooltip", "TOPLEFT" , 3, 39); |
||
498 | end |
||
499 | end |
||
500 | |||
501 | getglobal("ISync_"..sTooltip:GetName().."Icon"):Show(); |
||
502 | else |
||
503 | getglobal("ISync_"..sTooltip:GetName().."Icon"):Hide(); |
||
504 | end |
||
505 | |||
506 | --to prevent continous fetching |
||
507 | if(not lastTooltip.item or lastTooltip.item ~= sID) then |
||
508 | lastTooltip.getPrice = nil; |
||
509 | lastTooltip.vendPrice = nil; |
||
510 | lastTooltip.vendQty = nil; |
||
511 | lastTooltip.getPrice = ISync:FetchDB(sID, "price"); |
||
512 | lastTooltip.vendPrice = ISync:FetchDB(sID, "vendor"); |
||
513 | lastTooltip.vendQty = ISync:FetchDB(sID, "vendorqty"); |
||
514 | lastTooltip.item = sID; |
||
515 | end |
||
516 | |||
517 | |||
518 | |||
519 | if(ISync:SetVar({"OPT","SHOWMONEYICONS"}, 1, "COMPARE")) then --show money icons |
||
520 | |||
521 | local chkAddLine = 0; |
||
522 | local getPrice = lastTooltip.getPrice; |
||
523 | local sFrameGet; |
||
524 | local priceChk = 0; |
||
525 | local vendorChk = 0; |
||
526 | |||
527 | if(sTooltip == ItemRefTooltip) then |
||
528 | sFrameGet = "ISync_MoneyTooltipItemRef"; |
||
529 | else |
||
530 | sFrameGet = "ISync_MoneyTooltip"; |
||
531 | end |
||
532 | |||
533 | --start off hidden |
||
534 | local text = getglobal(sFrameGet.."Text1"); |
||
535 | local money = getglobal(sFrameGet.."Money1"); |
||
536 | local text2 = getglobal(sFrameGet.."Text2"); |
||
537 | local money2 = getglobal(sFrameGet.."Money2"); |
||
538 | money:Hide(); |
||
539 | text:Hide(); |
||
540 | money2:Hide(); |
||
541 | text2:Hide(); |
||
542 | |||
543 | |||
544 | if(getPrice and tonumber(getPrice) and tonumber(getPrice) == -1) then --item has no value |
||
545 | |||
546 | local text = getglobal(sFrameGet.."Text1"); |
||
547 | local money = getglobal(sFrameGet.."Money1"); |
||
548 | money:Hide(); |
||
549 | text:Hide(); |
||
550 | |||
551 | if(chkAddLine == 0) then sTooltip:AddLine(" "); chkAddLine = 1; end |
||
552 | sTooltip:AddLine("|c00FFFF00"..ISYNC_NOSELLPRICE.."|r"); |
||
553 | sTooltip.isDisplayDone = 1; |
||
554 | priceChk = 0; |
||
555 | |||
556 | elseif(getPrice and tonumber(getPrice) and tonumber(getPrice) > 0) then |
||
557 | |||
558 | getPrice = tonumber(getPrice) * sQty; |
||
559 | |||
560 | --PRICE |
||
561 | if(ISync:SetVar({"OPT","PRICE"}, 1, "COMPARE")) then |
||
562 | |||
563 | if(chkAddLine == 0) then sTooltip:AddLine(" "); chkAddLine = 1; end |
||
564 | sTooltip:AddLine(" ", 0, 0, 0); |
||
565 | |||
566 | local numLines = sTooltip:NumLines(); |
||
567 | local text = getglobal(sFrameGet.."Text1"); |
||
568 | local money = getglobal(sFrameGet.."Money1"); |
||
569 | local newLine = sTooltip:GetName().."TextLeft"..numLines; |
||
570 | |||
571 | MoneyFrame_Update(sFrameGet.."Money1", getPrice); |
||
572 | text:SetText("|c00FFFF00"..ISYNC_COST.."[|r|c00BDFCC9"..sQty.."|r|c00FFFF00]: |r"); |
||
573 | text:Show(); |
||
574 | money:Show(); |
||
575 | |||
576 | --set the point at it's new location |
||
577 | text:ClearAllPoints(); |
||
578 | text:SetPoint("LEFT", newLine, "LEFT", 0, 0); |
||
579 | text:SetWidth(text:GetStringWidth()); |
||
580 | |||
581 | --fix the tooltip width if small |
||
582 | local getTextWidth = text:GetWidth(); |
||
583 | local getMoneyWidth = money:GetWidth(); |
||
584 | local getTooltipWidth= getglobal(sTooltip:GetName().."TextLeft1"):GetWidth(); |
||
585 | |||
586 | --check, expand the tooltip if we need to |
||
587 | if( (getTextWidth + getMoneyWidth) > getTooltipWidth ) then |
||
588 | |||
589 | getglobal(sTooltip:GetName().."TextLeft1"):SetWidth((getTextWidth + getMoneyWidth) + 10); |
||
590 | |||
591 | end |
||
592 | |||
593 | sTooltip.isDisplayDone = 1; |
||
594 | priceChk = 1; |
||
595 | |||
596 | end--if(ISync:SetVar({"OPT","PRICE"}, 1, "COMPARE")) then |
||
597 | |||
598 | else--don't show the first money line |
||
599 | |||
600 | local text = getglobal(sFrameGet.."Text1"); |
||
601 | local money = getglobal(sFrameGet.."Money1"); |
||
602 | money:Hide(); |
||
603 | text:Hide(); |
||
604 | |||
605 | priceChk = 0; |
||
606 | |||
607 | end--if(getPrice < 0) then |
||
608 | |||
609 | |||
610 | --VENDOR |
||
611 | if(ISync:SetVar({"OPT","VENDOR"}, 1, "COMPARE")) then |
||
612 | |||
613 | local vendPrice = lastTooltip.vendPrice; |
||
614 | local vendQty = lastTooltip.vendQty; |
||
615 | |||
616 | if(vendPrice and vendQty and tonumber(vendPrice) and tonumber(vendPrice) > 0) then |
||
617 | |||
618 | if(chkAddLine == 0) then sTooltip:AddLine(" "); chkAddLine = 1; end |
||
619 | sTooltip:AddLine(" ", 0, 0, 0); |
||
620 | |||
621 | local numLines = sTooltip:NumLines(); |
||
622 | local text = getglobal(sFrameGet.."Text2"); |
||
623 | local money = getglobal(sFrameGet.."Money2"); |
||
624 | local newLine = sTooltip:GetName().."TextLeft"..numLines; |
||
625 | |||
626 | |||
627 | MoneyFrame_Update(sFrameGet.."Money2", vendPrice); |
||
628 | text:SetText("|c00FFFF00"..ISYNC_VENDORCOST.."[|r|c00BDFCC9"..vendQty.."|r|c00FFFF00]: |r"); |
||
629 | text:Show(); |
||
630 | money:Show(); |
||
631 | |||
632 | --set the point at it's new location |
||
633 | text:ClearAllPoints(); |
||
634 | text:SetPoint("LEFT", newLine, "LEFT", 0, 0); |
||
635 | text:SetWidth(text:GetStringWidth()); |
||
636 | |||
637 | --fix the tooltip width if small |
||
638 | local getTextWidth = text:GetWidth(); |
||
639 | local getMoneyWidth = money:GetWidth(); |
||
640 | local getTooltipWidth= getglobal(sTooltip:GetName().."TextLeft1"):GetWidth(); |
||
641 | |||
642 | --check, expand the tooltip if we need to |
||
643 | if( (getTextWidth + getMoneyWidth) > getTooltipWidth ) then |
||
644 | |||
645 | getglobal(sTooltip:GetName().."TextLeft1"):SetWidth((getTextWidth + getMoneyWidth) + 10); |
||
646 | |||
647 | end |
||
648 | |||
649 | --set as done |
||
650 | sTooltip.isDisplayDone = 1; |
||
651 | vendorChk = 1; |
||
652 | |||
653 | end--if(vendPrice and vendQty) then |
||
654 | |||
655 | else |
||
656 | |||
657 | local text = getglobal(sFrameGet.."Text2"); |
||
658 | local money = getglobal(sFrameGet.."Money2"); |
||
659 | money:Hide(); |
||
660 | text:Hide(); |
||
661 | |||
662 | vendorChk = 0; |
||
663 | |||
664 | end |
||
665 | |||
666 | --show and update the frame accordingly |
||
667 | if(priceChk == 1 and vendorChk == 1) then |
||
668 | |||
669 | local getPriceWidth = getglobal(sFrameGet.."Text1"):GetWidth(); |
||
670 | local getVendorWidth = getglobal(sFrameGet.."Text2"):GetWidth(); |
||
671 | local diffWidth = 0; |
||
672 | |||
673 | --if vendor is bigger then price |
||
674 | if(getPriceWidth < getVendorWidth) then |
||
675 | getglobal(sFrameGet.."Text1"):SetWidth(getVendorWidth); |
||
676 | getglobal(sFrameGet.."Text1"):SetJustifyH("LEFT"); |
||
677 | --if price is bigger then vendor |
||
678 | elseif(getVendorWidth < getPriceWidth) then |
||
679 | getglobal(sFrameGet.."Text2"):SetWidth(getPriceWidth); |
||
680 | getglobal(sFrameGet.."Text2"):SetJustifyH("LEFT"); |
||
681 | end |
||
682 | |||
683 | end |
||
684 | |||
685 | --show the tooltipmoneyframe if we have information |
||
686 | if(priceChk == 1 or vendorChk == 1) then |
||
687 | |||
688 | if(sTooltip == ItemRefTooltip) then |
||
689 | ISync_MoneyTooltipItemRef:Show(); |
||
690 | else |
||
691 | ISync_MoneyTooltip:Show(); |
||
692 | end |
||
693 | |||
694 | else |
||
695 | ISync_MoneyTooltipItemRef:Hide(); |
||
696 | ISync_MoneyTooltip:Hide(); |
||
697 | end |
||
698 | |||
699 | --show the tooltip |
||
700 | sTooltip:Show(); |
||
701 | |||
702 | return nil; |
||
703 | |||
704 | |||
705 | ------------------------------------------------------------------------------------------------- |
||
706 | ------------------------------------------------------------------------------------------------- |
||
707 | ------------------------------------------------------------------------------------------------- |
||
708 | else--SHOW MONEY TEXT |
||
709 | |||
710 | local chkAddLine = 0; |
||
711 | local getPrice = lastTooltip.getPrice; |
||
712 | |||
713 | |||
714 | if(getPrice and tonumber(getPrice) and tonumber(getPrice) == -1 and ISync:SetVar({"OPT","PRICE"}, 1, "COMPARE")) then --item has no value |
||
715 | |||
716 | if(chkAddLine == 0) then sTooltip:AddLine(" "); chkAddLine = 1; end |
||
717 | sTooltip:AddLine("|c00FFFF00"..ISYNC_NOSELLPRICE.."|r"); |
||
718 | sTooltip.isDisplayDone = 1; |
||
719 | |||
720 | elseif(getPrice and tonumber(getPrice) and tonumber(getPrice) > 0) then |
||
721 | |||
722 | getPrice = tonumber(getPrice) * sQty; |
||
723 | local gold, silver, copper = ISync:ReturnCurrency(getPrice); |
||
724 | local currencySTR = ""; |
||
725 | |||
726 | local goldLay = ISync:SetVar({"LAYOUT","GOLD"}, "|c00FFFFFF%s|r|c00E2CD54"..ISYNC_OPTGOLD1.."|r "); |
||
727 | local silverLay = ISync:SetVar({"LAYOUT","SILVER"}, "|c00FFFFFF%s|r|c00AEAEAE"..ISYNC_OPTSILVER1.."|r "); |
||
728 | local copperLay = ISync:SetVar({"LAYOUT","COPPER"}, "|c00FFFFFF%s|r|c00D7844D"..ISYNC_OPTCOPPER1.."|r"); |
||
729 | |||
730 | --PRICE |
||
731 | if(ISync:SetVar({"OPT","PRICE"}, 1, "COMPARE")) then |
||
732 | |||
733 | if(gold and gold ~= 0) then --GOLD |
||
734 | currencySTR = string.format(goldLay, gold); |
||
735 | end |
||
736 | |||
737 | if(silver and silver ~= 0) then--SILVER |
||
738 | currencySTR = currencySTR..string.format(silverLay, silver); |
||
739 | end |
||
740 | |||
741 | if(copper and copper ~= 0) then--COPPER |
||
742 | currencySTR = currencySTR..string.format(copperLay, copper); |
||
743 | end |
||
744 | |||
745 | |||
746 | if(chkAddLine == 0) then sTooltip:AddLine(" "); chkAddLine = 1; end |
||
747 | sTooltip:AddDoubleLine("|c00FFFF00"..ISYNC_COST.."[|r|c00BDFCC9"..sQty.."|r|c00FFFF00]:|r", currencySTR,1,1,1,1,1,1); |
||
748 | sTooltip.isDisplayDone = 1; |
||
749 | |||
750 | end |
||
751 | |||
752 | |||
753 | end--if(getPrice < 0) then |
||
754 | |||
755 | |||
756 | --VENDOR |
||
757 | if(ISync:SetVar({"OPT","VENDOR"}, 1, "COMPARE")) then |
||
758 | |||
759 | local vendPrice = lastTooltip.vendPrice; |
||
760 | local vendQty = lastTooltip.vendQty; |
||
761 | |||
762 | if(vendPrice and vendQty and tonumber(vendPrice) and tonumber(vendPrice) > 0) then |
||
763 | |||
764 | vendPrice = tonumber(vendPrice); |
||
765 | vendQty = tonumber(vendQty); |
||
766 | if(vendQty < 1) then vendQty = 1; end |
||
767 | |||
768 | local gold, silver, copper = ISync:ReturnCurrency(vendPrice); |
||
769 | local currencySTR = ""; |
||
770 | |||
771 | local goldLay = ISync:SetVar({"LAYOUT","GOLD"}, "|c00FFFFFF%s|r|c00E2CD54"..ISYNC_OPTGOLD1.."|r "); |
||
772 | local silverLay = ISync:SetVar({"LAYOUT","SILVER"}, "|c00FFFFFF%s|r|c00AEAEAE"..ISYNC_OPTSILVER1.."|r "); |
||
773 | local copperLay = ISync:SetVar({"LAYOUT","COPPER"}, "|c00FFFFFF%s|r|c00D7844D"..ISYNC_OPTCOPPER1.."|r"); |
||
774 | |||
775 | |||
776 | if(gold and gold ~= 0) then --GOLD |
||
777 | currencySTR = string.format(goldLay, gold); |
||
778 | end |
||
779 | |||
780 | if(silver and silver ~= 0) then--SILVER |
||
781 | currencySTR = currencySTR..string.format(silverLay, silver); |
||
782 | end |
||
783 | |||
784 | if(copper and copper ~= 0) then--COPPER |
||
785 | currencySTR = currencySTR..string.format(copperLay, copper); |
||
786 | end |
||
787 | |||
788 | |||
789 | if(chkAddLine == 0) then sTooltip:AddLine(" "); chkAddLine = 1; end |
||
790 | sTooltip:AddDoubleLine("|c00FFFF00"..ISYNC_VENDORCOST.."[|r|c00BDFCC9"..vendQty.."|r|c00FFFF00]:|r", currencySTR,1,1,1,1,1,1); |
||
791 | sTooltip.isDisplayDone = 1; |
||
792 | |||
793 | end--if(vendPrice and vendQty) then |
||
794 | end |
||
795 | |||
796 | |||
797 | --show the tooltip |
||
798 | sTooltip:Show(); |
||
799 | |||
800 | --hide the money icons since we aren't using them |
||
801 | ISync_MoneyTooltipItemRef:Hide(); |
||
802 | ISync_MoneyTooltip:Hide(); |
||
803 | |||
804 | return nil; |
||
805 | |||
806 | end--if(ISync:SetVar({"OPT","SHOWMONEYICONS"}, 1, "COMPARE")) then |
||
807 | |||
808 | |||
809 | end |
||
810 | |||
811 | |||
812 | --------------------------------------------------- |
||
813 | -- ISync:ReturnCurrency |
||
814 | --------------------------------------------------- |
||
815 | function ISync:ReturnCurrency(sMoney) |
||
816 | |||
817 | --convert the long money value into seperate variables |
||
818 | local gold = floor(sMoney / (COPPER_PER_SILVER * SILVER_PER_GOLD)); |
||
819 | local silver = floor((sMoney - (gold * COPPER_PER_SILVER * SILVER_PER_GOLD)) / COPPER_PER_SILVER); |
||
820 | local copper = mod(sMoney, COPPER_PER_SILVER); |
||
821 | |||
822 | |||
823 | return gold, silver, copper; |
||
824 | |||
825 | end |
||
826 | |||
827 | |||
828 | |||
829 | |||
830 | -------------------------------------------------------------------------------------------------------------------------------- |
||
831 | -------------------------------------------------------------------------------------------------------------------------------- |
||
832 | -------------------------------------------------------------------------------------------------------------------------------- |
||
833 | -------------------------------------------------------------------------------------------------------------------------------- |
||
834 | -------------------------------------------------------------------------------------------------------------------------------- |
||
835 | -------------------------------------------------------------------------------------------------------------------------------- |