vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | |
2 | -- This is a function calling array for any other addons that wish to "tap-in" to these tooltips |
||
3 | LINK_WRANGLER_CALLER = {}; |
||
4 | |||
5 | -- Credit Legorol |
||
6 | |||
7 | IRR_LINK_COLOR_OPEN = "|cff"; |
||
8 | IRR_LINK_COLORS = {}; |
||
9 | IRR_LINK_COLORS[0] = "9d9d9d"; -- grey |
||
10 | IRR_LINK_COLORS[1] = "ffffff"; -- white |
||
11 | IRR_LINK_COLORS[2] = "1eff00"; -- green |
||
12 | IRR_LINK_COLORS[3] = "0070dd"; -- blue |
||
13 | IRR_LINK_COLORS[4] = "a335ee"; -- purple |
||
14 | IRR_LINK_COLORS[5] = "ff8000"; -- gold (legendary) |
||
15 | IRR_LINK_HYPERLINK_OPEN = "|H"; |
||
16 | IRR_LINK_LINK_OPEN = "|h["; |
||
17 | IRR_LINK_LINK_CLOSE = "]|h"; |
||
18 | IRR_LINK_COLOR_CLOSE = "|r"; |
||
19 | |||
20 | IRR_MIN_HEIGHT = 132; |
||
21 | |||
22 | ------------------------------------------------------------------------------------------- |
||
23 | -- GLOBALS |
||
24 | ------------------------------------------------------------------------------------------- |
||
25 | IRR_ItemTypes = { |
||
26 | [INVTYPE_WEAPONMAINHAND] = {[1] = 16}, -- Main Hand |
||
27 | [INVTYPE_2HWEAPON] = {[1] = 16,[2] = 17}, -- Two-Hand |
||
28 | [INVTYPE_WEAPON] = {[1] = 16,[2] = 17}, -- One-Hand |
||
29 | [INVTYPE_WEAPON_OTHER] = {[1] = 16,[2] = 17}, -- One-Hand_other |
||
30 | [INVTYPE_SHIELD] = {[1] = 17}, -- Off Hand |
||
31 | [INVTYPE_WEAPONOFFHAND] = {[1] = 17}, -- Off Hand |
||
32 | [INVTYPE_HOLDABLE] = {[1] = 17}, -- Held In Off-hand |
||
33 | [INVTYPE_HEAD] = {[1] = 1}, -- Head |
||
34 | [INVTYPE_WAIST] = {[1] = 6}, -- Waist |
||
35 | [INVTYPE_SHOULDER] = {[1] = 3}, -- Shoulder |
||
36 | [INVTYPE_LEGS] = {[1] = 7}, -- Legs |
||
37 | [INVTYPE_CLOAK] = {[1] = 15}, -- Back |
||
38 | [INVTYPE_FEET] = {[1] = 8}, -- Feet |
||
39 | [INVTYPE_CHEST] = {[1] = 5}, -- Chest |
||
40 | [INVTYPE_ROBE] = {[1] = 5}, -- Chest |
||
41 | [INVTYPE_WRIST] = {[1] = 9}, -- Wrist |
||
42 | [INVTYPE_HAND] = {[1] = 10}, -- Hands |
||
43 | [INVTYPE_RANGED] = {[1] = 18}, -- Ranged |
||
44 | [INVTYPE_BODY] = {[1] = 4}, -- Shirt |
||
45 | [INVTYPE_TABARD] = {[1] = 19}, -- Tabard |
||
46 | [INVTYPE_FINGER] = {[1] = 11,[2] = 12}, -- Finger |
||
47 | [INVTYPE_FINGER_OTHER] = {[1] = 12,[2] = 12}, -- Finger_other |
||
48 | [INVTYPE_NECK] = {[1] = 2}, -- Neck |
||
49 | [INVTYPE_TRINKET] = {[1] = 13,[2] = 14}, -- Trinket |
||
50 | [INVTYPE_TRINKET_OTHER] = {[1] = 13,[2] = 14}, -- Trinket_other |
||
51 | [INVTYPE_WAND] = {[1] = 18}, -- Wand |
||
52 | [INVTYPE_GUN] = {[1] = 18}, -- Gun |
||
53 | [INVTYPE_GUNPROJECTILE] = {[1] = 0}, -- Projectile |
||
54 | [INVTYPE_BOWPROJECTILE] = {[1] = 0} -- Projectile |
||
55 | }; |
||
56 | |||
57 | IRR_SlotIDtoSlotName = { |
||
58 | [0] = AMMOSLOT, -- 0 |
||
59 | HEADSLOT, -- 1 |
||
60 | NECKSLOT, -- 2 |
||
61 | SHOULDERSLOT, -- 3 |
||
62 | SHIRTSLOT, -- 4 |
||
63 | CHESTSLOT, -- 5 |
||
64 | WAISTSLOT, -- 6 |
||
65 | LEGSSLOT, -- 7 |
||
66 | FEETSLOT, -- 8 |
||
67 | WRISTSLOT, -- 9 |
||
68 | HANDSSLOT, -- 10 |
||
69 | FINGER0SLOT, -- 11 |
||
70 | FINGER1SLOT, -- 12 |
||
71 | TRINKET0SLOT, -- 13 |
||
72 | TRINKET1SLOT, -- 14 |
||
73 | BACKSLOT, -- 15 |
||
74 | MAINHANDSLOT, -- 16 |
||
75 | SECONDARYHANDSLOT, -- 17 |
||
76 | RANGEDSLOT, -- 18 |
||
77 | TABARDSLOT, -- 19 |
||
78 | }; |
||
79 | |||
80 | |||
81 | IR_MOD_ITEMREF_WINDOWS = {}; |
||
82 | IR_MOD_CHAT_BUFFER = {}; |
||
83 | IR_MOD_CHAT_NAMES_BUFFER = {}; |
||
84 | IR_MOD_CHAT_BUFFER_MAX = 60; |
||
85 | IR_MOD_CHAT_BUFFER_INDEX = 1; |
||
86 | |||
87 | IR_MOD_AUCTIONEER_INDEX = 0; |
||
88 | IR_MOD_AUCTIONEER_POS = 0; |
||
89 | |||
90 | ------------------------------------------------------------------------------------------- |
||
91 | -- UTILITY |
||
92 | ------------------------------------------------------------------------------------------- |
||
93 | local function dout(msg) |
||
94 | if( DEFAULT_CHAT_FRAME) then |
||
95 | DEFAULT_CHAT_FRAME:AddMessage(msg,1.0,0,0); |
||
96 | end |
||
97 | end |
||
98 | |||
99 | ------------------------------------------------------------------------------------------- |
||
100 | -- ADDON SUPPORT |
||
101 | ------------------------------------------------------------------------------------------- |
||
102 | function LinkWrangler_AddonContent(func, addonName, index) |
||
103 | local frame = IR_MOD_ITEMREF_WINDOWS[index].window; |
||
104 | local link = IR_MOD_ITEMREF_WINDOWS[index].itemRefID; |
||
105 | |||
106 | if (func ~= nil) then |
||
107 | --dout(func); |
||
108 | local caller = getglobal(func); |
||
109 | |||
110 | if (caller ~= nil) then |
||
111 | caller(frame,link); |
||
112 | frame:Show(); |
||
113 | else |
||
114 | dout("Link Wrangler Error: Attempt to call appender \""..func.."\" for AddOn: \""..addonName.."\" failed."); |
||
115 | end |
||
116 | else |
||
117 | dout("Link Wrangler Error: Attempt to call appender for AddOn: \""..addonName.."\" failed."); |
||
118 | end |
||
119 | end |
||
120 | |||
121 | function IRR_DoAuctioneerFrame(index) |
||
122 | if (IsAddOnLoaded("Auctioneer") ~= nil) then |
||
123 | --dout("IRR_DoAuctioneerFrame"); |
||
124 | if (IR_MOD_ITEMREF_WINDOWS[index].minimized == nil) then |
||
125 | local frame = IR_MOD_ITEMREF_WINDOWS[index].window; |
||
126 | |||
127 | local link = IR_MOD_ITEMREF_WINDOWS[index].itemRefID; |
||
128 | |||
129 | if (frame:IsVisible()) then |
||
130 | local itemText = getglobal(IR_MOD_ITEMREF_WINDOWS[index].windowName.."TextLeft1"); |
||
131 | local name = itemText:GetText(); |
||
132 | if (name) then |
||
133 | local fabricatedLink = "|cff000000|H"..link.."|h["..name.."]|h|r"; |
||
134 | |||
135 | if (AuctionConfig.filters['embed'] == "on") then |
||
136 | frame:SetHyperlink("item:1710:0:0:0"); |
||
137 | frame:SetHyperlink(IR_MOD_ITEMREF_WINDOWS[index].itemRefID); |
||
138 | end |
||
139 | |||
140 | if (TT_Clear) then |
||
141 | TT_Clear(); |
||
142 | TT_TooltipCall(frame, name, fabricatedLink, -1, 1, 0); |
||
143 | TT_Show(frame); |
||
144 | elseif (EnhTooltip.TooltipCall) then -- requires LW version of EnhTooltip |
||
145 | EnhTooltip.ClearTooltip(); |
||
146 | EnhTooltip.TooltipCall(frame, name, fabricatedLink, -1, 1, 0); |
||
147 | end |
||
148 | |||
149 | if (IR_MOD_ITEMREF_WINDOWS[index].firstTimeAuc == 1) then |
||
150 | IR_MOD_ITEMREF_WINDOWS[index].firstTimeAuc = 0; |
||
151 | else |
||
152 | if (AuctionConfig.filters['embed'] == "on") then |
||
153 | table.foreach(LINK_WRANGLER_CALLER, function(k,v) LinkWrangler_AddonContent(v,k,index); end); |
||
154 | end |
||
155 | end |
||
156 | |||
157 | IR_MOD_AUCTIONEER_POS = EnhancedTooltip:GetLeft(); |
||
158 | IR_MOD_AUCTIONEER_INDEX = index; |
||
159 | end |
||
160 | end |
||
161 | end |
||
162 | end |
||
163 | end |
||
164 | |||
165 | |||
166 | |||
167 | ------------------------------------------------------------------------------------------- |
||
168 | -- UTILITY |
||
169 | ------------------------------------------------------------------------------------------- |
||
170 | function IRR_CompareItem(index) |
||
171 | --dout("slot: "..GetInventorySlotInfo("RangedSlot")); |
||
172 | |||
173 | local itemComp1 = getglobal("IRR_ItemCompTooltip"..index); |
||
174 | local itemComp1Name = "IRR_ItemCompTooltip"..index; |
||
175 | local itemComp2 = getglobal("IRR_ItemCompTool"..index+10); |
||
176 | local itemComp2Name = "IRR_ItemCompTool"..index+10; |
||
177 | |||
178 | if (IR_MOD_ITEMREF_WINDOWS[index].compare == 0) then |
||
179 | IR_MOD_ITEMREF_WINDOWS[index].compare = 1; |
||
180 | |||
181 | --local slotID = IRR_GetCompareItemIndex(IR_MOD_ITEMREF_WINDOWS[index].windowName); |
||
182 | local slots = IR_MOD_ITEMREF_WINDOWS[index].slots; |
||
183 | |||
184 | if (slots == nil) then |
||
185 | return; |
||
186 | end |
||
187 | |||
188 | ShowUIPanel(itemComp1); |
||
189 | itemComp1:SetOwner(UIParent, "ANCHOR_NONE"); |
||
190 | itemComp1:SetPoint("BOTTOMLEFT",IR_MOD_ITEMREF_WINDOWS[index].windowName,"TOPLEFT",0,10); |
||
191 | itemComp1:SetInventoryItem("player",slots[1]); |
||
192 | |||
193 | if (table.getn(slots) > 1) then |
||
194 | --dout("more"); |
||
195 | ShowUIPanel(itemComp2); |
||
196 | itemComp2:SetOwner(UIParent, "ANCHOR_NONE"); |
||
197 | itemComp2:SetPoint("BOTTOMLEFT","IRR_ItemCompTooltip"..index,"TOPLEFT",0,10); |
||
198 | itemComp2:SetInventoryItem("player",slots[2]); |
||
199 | end |
||
200 | else |
||
201 | IR_MOD_ITEMREF_WINDOWS[index].compare = 0; |
||
202 | HideUIPanel(itemComp1); |
||
203 | HideUIPanel(itemComp2); |
||
204 | end |
||
205 | end |
||
206 | |||
207 | |||
208 | function IRR_GetCompareItemIndex(frame) |
||
209 | --local tooltip = getglobal(frame); |
||
210 | |||
211 | for i=1,6 do |
||
212 | --dout(i); |
||
213 | local typeText = getglobal(frame.."TextLeft"..i); |
||
214 | local type = typeText:GetText(); |
||
215 | local checkType = 1; |
||
216 | if (type == nil) then |
||
217 | checkType = 0; |
||
218 | end |
||
219 | |||
220 | if (checkType == 1) then |
||
221 | --dout("type: "..type) |
||
222 | |||
223 | local retVal = IRR_ItemTypes[type]; |
||
224 | |||
225 | if (retVal ~= nil) then |
||
226 | --dout("returning") |
||
227 | return retVal; |
||
228 | end |
||
229 | --dout("not returning") |
||
230 | end |
||
231 | end |
||
232 | end |
||
233 | |||
234 | function IRR_CloseAllWindows() |
||
235 | -- Next deal with the no windows open logic |
||
236 | for i=1,table.getn(IR_MOD_ITEMREF_WINDOWS) do |
||
237 | local info = IR_MOD_ITEMREF_WINDOWS[i]; |
||
238 | |||
239 | info.state = 0; |
||
240 | info.link = 0; |
||
241 | info.compare = 0; |
||
242 | info.whisper = nil; |
||
243 | info.textlink = nil; |
||
244 | info.itemRefID = nil; |
||
245 | info.itemID = nil; |
||
246 | info.quality = nil; |
||
247 | info.name = nil; |
||
248 | info.firstTimeAuc = 1; |
||
249 | |||
250 | HideUIPanel(info.window); |
||
251 | |||
252 | local comp1 = getglobal("IRR_ItemCompTooltip"..i); |
||
253 | HideUIPanel(comp1); |
||
254 | |||
255 | local comp2 = getglobal("IRR_ItemCompTool"..i+10); |
||
256 | HideUIPanel(comp2); |
||
257 | end |
||
258 | |||
259 | GameTooltip:Hide(); |
||
260 | end |
||
261 | |||
262 | function IRR_GetWindowIndex(link) |
||
263 | -- First check if the item is already displayed |
||
264 | for i=1,table.getn(IR_MOD_ITEMREF_WINDOWS) do |
||
265 | local info = IR_MOD_ITEMREF_WINDOWS[i]; |
||
266 | |||
267 | if (info.link == link) then |
||
268 | IRR_ItemRefTooltip_OnClick(i); |
||
269 | return 0; |
||
270 | end |
||
271 | end |
||
272 | |||
273 | |||
274 | -- Next check for open windows to display item in |
||
275 | for i=1,table.getn(IR_MOD_ITEMREF_WINDOWS) do |
||
276 | local info = IR_MOD_ITEMREF_WINDOWS[i]; |
||
277 | |||
278 | if (info.state == 0) then |
||
279 | info.state = 1; |
||
280 | info.link = link; |
||
281 | return info.index; |
||
282 | end |
||
283 | end |
||
284 | |||
285 | IRR_CloseAllWindows(); |
||
286 | |||
287 | local info = IR_MOD_ITEMREF_WINDOWS[1]; |
||
288 | info.state = 1; |
||
289 | info.link = link; |
||
290 | return 1; |
||
291 | end |
||
292 | |||
293 | function IRR_GetItemTextLink(item,linkStr,index,itemName) |
||
294 | local startPos,endPos = string.find(linkStr,item,1,true); |
||
295 | local startBound = "|cff"; |
||
296 | local endBound = "|r"; |
||
297 | |||
298 | -- check for colored links first |
||
299 | local lastLinkStart; |
||
300 | local linkStart = string.find(linkStr,startBound,1,true); |
||
301 | |||
302 | local whisperButton = getglobal("ItemRefWhisperButton"..index); |
||
303 | whisperButton:SetButtonState("NORMAL"); |
||
304 | |||
305 | if (linkStart == nil) then -- link is from loot |
||
306 | -- disable the whisper button |
||
307 | whisperButton:SetButtonState("DISABLED"); |
||
308 | |||
309 | local bag,slot = IRR_FindItem(itemName, skipcount); |
||
310 | |||
311 | if (bag and slot) then |
||
312 | link = GetContainerItemLink(bag, slot); |
||
313 | return link; |
||
314 | else |
||
315 | return nil; |
||
316 | end |
||
317 | end |
||
318 | |||
319 | --dout("linkstart: "..linkStart); |
||
320 | while (linkStart ~= nil) and (linkStart < startPos) do |
||
321 | lastLinkStart = linkStart; |
||
322 | linkStart = string.find(linkStr,startBound,(lastLinkStart+1),true); |
||
323 | end |
||
324 | |||
325 | linkStart = lastLinkStart; |
||
326 | |||
327 | local linkEnd = string.find(linkStr,endBound,endPos,true); |
||
328 | |||
329 | if (linkEnd == nil) then |
||
330 | return; |
||
331 | end |
||
332 | |||
333 | linkEnd = linkEnd + 1; |
||
334 | |||
335 | local link = strsub(linkStr, linkStart, linkEnd); |
||
336 | --dout(link); |
||
337 | |||
338 | --IRR_DecryptLink("mine: "..link); |
||
339 | |||
340 | return link; |
||
341 | |||
342 | end |
||
343 | |||
344 | |||
345 | function IRR_SetWhisperPlayerAndLink(index,frame) |
||
346 | --local itemText = getglobal(frame.."TextLeft1"); |
||
347 | local itemName = IR_MOD_ITEMREF_WINDOWS[index].name; |
||
348 | |||
349 | local item = "["..itemName.."]"; |
||
350 | |||
351 | --if (item == nil) then |
||
352 | --dout("nil returning"); |
||
353 | -- return; |
||
354 | --end |
||
355 | --dout("item: "..item); |
||
356 | |||
357 | -- |
||
358 | local foundIndex = 0; |
||
359 | for i=1,table.getn(IR_MOD_CHAT_BUFFER) do |
||
360 | local startPos,endPos = string.find(IR_MOD_CHAT_BUFFER[i],item,1,true); |
||
361 | |||
362 | --dout("chatbuf: "..IR_MOD_CHAT_BUFFER[i]); |
||
363 | if (startPos ~= nil) then |
||
364 | foundIndex = i; |
||
365 | --dout("found"); |
||
366 | end |
||
367 | end |
||
368 | |||
369 | local whisperButton = getglobal("ItemRefWhisperButton"..index); |
||
370 | whisperButton:SetButtonState("DISABLED"); |
||
371 | if (foundIndex > 0) then |
||
372 | local member = IR_MOD_CHAT_NAMES_BUFFER[foundIndex]; |
||
373 | |||
374 | if (string.len(member) > 0) then |
||
375 | IR_MOD_ITEMREF_WINDOWS[index].whisper = member; |
||
376 | whisperButton:SetButtonState("NORMAL"); |
||
377 | else |
||
378 | whisperButton:SetButtonState("DISABLED"); |
||
379 | IR_MOD_ITEMREF_WINDOWS[index].whisper = ""; |
||
380 | end |
||
381 | |||
382 | end |
||
383 | |||
384 | -- New link |
||
385 | local textLink = IRR_LINK_COLOR_OPEN; |
||
386 | textLink = textLink..IRR_LINK_COLORS[IR_MOD_ITEMREF_WINDOWS[index].quality]; |
||
387 | textLink = textLink..IRR_LINK_HYPERLINK_OPEN; |
||
388 | textLink = textLink..IR_MOD_ITEMREF_WINDOWS[index].itemRefID; |
||
389 | textLink = textLink..IRR_LINK_LINK_OPEN; |
||
390 | textLink = textLink..IR_MOD_ITEMREF_WINDOWS[index].name; |
||
391 | textLink = textLink..IRR_LINK_LINK_CLOSE; |
||
392 | textLink = textLink..IRR_LINK_COLOR_CLOSE; |
||
393 | |||
394 | IR_MOD_ITEMREF_WINDOWS[index].textlink = textLink; |
||
395 | |||
396 | --IRR_DecryptLink(linkStr); |
||
397 | --IRR_DecryptLink(textLink); |
||
398 | --dout("quality: "..iiRarity); |
||
399 | --ITEM_QUALITY_COLORS |
||
400 | end |
||
401 | |||
402 | function IRR_DecryptLink(link) |
||
403 | local dString = ""; |
||
404 | |||
405 | for i=1,string.len(link) do |
||
406 | dString = dString.."-"..string.char(string.byte(link,i)); |
||
407 | end |
||
408 | |||
409 | dout(dString); |
||
410 | end |
||
411 | |||
412 | |||
413 | function IRR_DoWhisperPlayer(index) |
||
414 | local member = IR_MOD_ITEMREF_WINDOWS[index].whisper; |
||
415 | |||
416 | if (member ~= nil) then |
||
417 | if ( not ChatFrameEditBox:IsVisible() ) then |
||
418 | ChatFrame_OpenChat("/w "..member.." "); |
||
419 | else |
||
420 | ChatFrameEditBox:SetText("/w "..member.." "); |
||
421 | end |
||
422 | end |
||
423 | end |
||
424 | |||
425 | function IRR_DoRelinkItem(index) |
||
426 | local link = IR_MOD_ITEMREF_WINDOWS[index].textlink; |
||
427 | --IRR_DecryptLink("chat edit: "..link); |
||
428 | |||
429 | if (link ~= nil) then |
||
430 | if ( not ChatFrameEditBox:IsVisible() ) then |
||
431 | ChatFrame_OpenChat(link); |
||
432 | else |
||
433 | ChatFrameEditBox:SetText(ChatFrameEditBox:GetText()..link); |
||
434 | end |
||
435 | end |
||
436 | end |
||
437 | |||
438 | function IRR_DoRelinkCompItem(index,compWindow) |
||
439 | local link = IR_MOD_ITEMREF_WINDOWS[index].compareLinks[compWindow]; |
||
440 | --IRR_DecryptLink("chat edit: "..link); |
||
441 | |||
442 | if (link ~= nil) then |
||
443 | if ( not ChatFrameEditBox:IsVisible() ) then |
||
444 | ChatFrame_OpenChat(link); |
||
445 | else |
||
446 | ChatFrameEditBox:SetText(ChatFrameEditBox:GetText()..link); |
||
447 | end |
||
448 | end |
||
449 | end |
||
450 | |||
451 | function IRR_DoDressingRoom(index) |
||
452 | --dout(IR_MOD_ITEMREF_WINDOWS[index].itemID); |
||
453 | --dout(IR_MOD_ITEMREF_WINDOWS[index].itemRefID); |
||
454 | --dout("dress up"); |
||
455 | --ShowUIPanel(DressUpFrame); |
||
456 | --DressUpModel:Dress(); |
||
457 | --DressUpModel:TryOn(IR_MOD_ITEMREF_WINDOWS[index].itemID); |
||
458 | |||
459 | DressUpItemLink(IR_MOD_ITEMREF_WINDOWS[index].itemRefID); |
||
460 | |||
461 | end |
||
462 | |||
463 | function IRR_GetItemID(link) |
||
464 | return string.sub(link,6,string.find(link,":",6)-1); |
||
465 | end |
||
466 | |||
467 | function IRR_FindItem(name, skipcount) |
||
468 | skipcount = skipcount or 0; |
||
469 | |||
470 | for i=NUM_BAG_FRAMES,0,-1 do |
||
471 | for j=GetContainerNumSlots(i),1,-1 do |
||
472 | if (IRR_GetItemName(i,j) == name) then |
||
473 | if skipcount == 0 then |
||
474 | return i,j; |
||
475 | end |
||
476 | skipcount = skipcount - 1; |
||
477 | end |
||
478 | end |
||
479 | end |
||
480 | end |
||
481 | |||
482 | function IRR_GetItemName(bag, slot) |
||
483 | local linktext = nil; |
||
484 | |||
485 | linktext = GetContainerItemLink(bag, slot); |
||
486 | |||
487 | if linktext then |
||
488 | local _,_,name = string.find(linktext, "^.*%[(.*)%].*$"); |
||
489 | return name; |
||
490 | else |
||
491 | return ""; |
||
492 | end |
||
493 | end |
||
494 | |||
495 | function IRR_DoEllipses(text,maxWidth) |
||
496 | local s = text:GetText(); |
||
497 | s = string.sub(s,1,string.len(s)-7); |
||
498 | |||
499 | return s.."..."; |
||
500 | end |
||
501 | |||
502 | function IRR_ClearAllFields(index) |
||
503 | for i=2,30 do |
||
504 | local text1 = getglobal(IR_MOD_ITEMREF_WINDOWS[index].windowName.."TextLeft"..i); |
||
505 | local text2 = getglobal(IR_MOD_ITEMREF_WINDOWS[index].windowName.."TextRight"..i); |
||
506 | |||
507 | text1:SetText(""); |
||
508 | text2:SetText(""); |
||
509 | end |
||
510 | end |
||
511 | |||
512 | function IRR_DoMinimize(index) |
||
513 | if (IR_MOD_ITEMREF_WINDOWS[index].minimized ~= nil) then |
||
514 | --dout("restore"); |
||
515 | IR_MOD_ITEMREF_WINDOWS[index].minimized = nil; |
||
516 | |||
517 | for i=2,30 do |
||
518 | local text1 = getglobal(IR_MOD_ITEMREF_WINDOWS[index].windowName.."TextLeft"..i); |
||
519 | local text2 = getglobal(IR_MOD_ITEMREF_WINDOWS[index].windowName.."TextRight"..i); |
||
520 | |||
521 | local text1Str = text1:GetText(); |
||
522 | --local text2Str = text2:GetText(); |
||
523 | |||
524 | if (IR_MOD_ITEMREF_WINDOWS[index].fontStringStatus1[i] == 1) then |
||
525 | text1:Show(); |
||
526 | end |
||
527 | |||
528 | if (IR_MOD_ITEMREF_WINDOWS[index].fontStringStatus2[i] == 1) then |
||
529 | text2:Show(); |
||
530 | end |
||
531 | end |
||
532 | |||
533 | local compareButt = getglobal("ItemRefCompButton"..index); |
||
534 | local whisperButt = getglobal("ItemRefWhisperButton"..index); |
||
535 | local relinkButt = getglobal("ItemRefRelinkButton"..index); |
||
536 | local DRButt = getglobal("ItemRefDRButton"..index); |
||
537 | |||
538 | compareButt:Show(); |
||
539 | whisperButt:Show(); |
||
540 | relinkButt:Show(); |
||
541 | DRButt:Show(); |
||
542 | |||
543 | local text1 = getglobal(IR_MOD_ITEMREF_WINDOWS[index].windowName.."TextLeft1"); |
||
544 | text1:SetText(IR_MOD_ITEMREF_WINDOWS[index].name); |
||
545 | |||
546 | -- move min button |
||
547 | local minButton = getglobal("ItemRefMinButton"..index); |
||
548 | minButton:SetPoint("TOPRIGHT","ItemRefCloseButton"..index,"TOPRIGHT",0,-20); |
||
549 | |||
550 | if (AUCTIONEER_VERSION ~= nil or ENCHANTRIX_VERSION ~= nil) then |
||
551 | IRR_DoAuctioneerFrame(index); |
||
552 | end |
||
553 | else |
||
554 | --dout("minimize"); |
||
555 | IR_MOD_ITEMREF_WINDOWS[index].minimized = 1; |
||
556 | |||
557 | for i=2,30 do |
||
558 | local text1 = getglobal(IR_MOD_ITEMREF_WINDOWS[index].windowName.."TextLeft"..i); |
||
559 | local text2 = getglobal(IR_MOD_ITEMREF_WINDOWS[index].windowName.."TextRight"..i); |
||
560 | |||
561 | if (text1:IsVisible()) then |
||
562 | IR_MOD_ITEMREF_WINDOWS[index].fontStringStatus1[i] = 1; |
||
563 | else |
||
564 | IR_MOD_ITEMREF_WINDOWS[index].fontStringStatus1[i] = 0; |
||
565 | end |
||
566 | |||
567 | if (text2:IsVisible()) then |
||
568 | IR_MOD_ITEMREF_WINDOWS[index].fontStringStatus2[i] = 1; |
||
569 | else |
||
570 | IR_MOD_ITEMREF_WINDOWS[index].fontStringStatus2[i] = 0; |
||
571 | end |
||
572 | |||
573 | text1:Hide(); |
||
574 | text2:Hide(); |
||
575 | end |
||
576 | |||
577 | --dout("Window Width: "..IR_MOD_ITEMREF_WINDOWS[index].window:GetWidth()); |
||
578 | --local text1 = getglobal(IR_MOD_ITEMREF_WINDOWS[index].windowName.."TextLeft1"); |
||
579 | --dout("String width: "..text1:GetStringWidth()); |
||
580 | |||
581 | local windowWidth = IR_MOD_ITEMREF_WINDOWS[index].window:GetWidth() -37 - 32; |
||
582 | local text1 = getglobal(IR_MOD_ITEMREF_WINDOWS[index].windowName.."TextLeft1"); |
||
583 | local stringWidth = text1:GetStringWidth(); |
||
584 | |||
585 | if (stringWidth >= windowWidth) then |
||
586 | text1:SetText(IRR_DoEllipses(text1,windowWidth)); |
||
587 | end |
||
588 | |||
589 | -- move min button |
||
590 | local minButton = getglobal("ItemRefMinButton"..index); |
||
591 | minButton:SetPoint("TOPRIGHT","ItemRefCloseButton"..index,"TOPRIGHT",-20,0); |
||
592 | |||
593 | local compareButt = getglobal("ItemRefCompButton"..index); |
||
594 | local whisperButt = getglobal("ItemRefWhisperButton"..index); |
||
595 | local relinkButt = getglobal("ItemRefRelinkButton"..index); |
||
596 | local DRButt = getglobal("ItemRefDRButton"..index); |
||
597 | |||
598 | compareButt:Hide(); |
||
599 | whisperButt:Hide(); |
||
600 | relinkButt:Hide(); |
||
601 | DRButt:Hide(); |
||
602 | |||
603 | local compFrame1 = getglobal("IRR_ItemCompTooltip"..index); |
||
604 | local compFrame2 = getglobal("IRR_ItemCompTool"..index+10); |
||
605 | IR_MOD_ITEMREF_WINDOWS[index].compare = 0; |
||
606 | |||
607 | compFrame1:Hide(); |
||
608 | compFrame2:Hide(); |
||
609 | |||
610 | if (AUCTIONEER_VERSION ~= nil or ENCHANTRIX_VERSION ~= nil) then |
||
611 | if (TT_Clear) then |
||
612 | TT_Clear(); |
||
613 | elseif(EnhTooltip.ClearTooltip) then |
||
614 | EnhTooltip.ClearTooltip(); |
||
615 | end |
||
616 | end |
||
617 | end |
||
618 | end |
||
619 | |||
620 | ------------------------------------------------------------------------------------------- |
||
621 | -- EVENT HANDLERS |
||
622 | ------------------------------------------------------------------------------------------- |
||
623 | function IRR_OnLoad() |
||
624 | this:RegisterEvent("CHAT_MSG_GUILD"); |
||
625 | this:RegisterEvent("CHAT_MSG_PARTY"); |
||
626 | this:RegisterEvent("CHAT_MSG_CHANNEL"); |
||
627 | this:RegisterEvent("CHAT_MSG_WHISPER"); |
||
628 | this:RegisterEvent("CHAT_MSG_RAID"); |
||
629 | this:RegisterEvent("CHAT_MSG_OFFICER"); |
||
630 | this:RegisterEvent("CHAT_MSG_SAY"); |
||
631 | this:RegisterEvent("CHAT_MSG_LOOT"); |
||
632 | this:RegisterEvent("CHAT_MSG_YELL"); |
||
633 | end |
||
634 | |||
635 | function IRR_OnEvent(event,arg1,arg2) |
||
636 | IR_MOD_CHAT_BUFFER[IR_MOD_CHAT_BUFFER_INDEX] = nil; |
||
637 | IR_MOD_CHAT_BUFFER[IR_MOD_CHAT_BUFFER_INDEX] = arg1; |
||
638 | IR_MOD_CHAT_NAMES_BUFFER[IR_MOD_CHAT_BUFFER_INDEX] = nil; |
||
639 | IR_MOD_CHAT_NAMES_BUFFER[IR_MOD_CHAT_BUFFER_INDEX] = arg2; |
||
640 | |||
641 | IR_MOD_CHAT_BUFFER_INDEX = IR_MOD_CHAT_BUFFER_INDEX + 1; |
||
642 | |||
643 | if (IR_MOD_CHAT_BUFFER_INDEX > IR_MOD_CHAT_BUFFER_MAX) then |
||
644 | IR_MOD_CHAT_BUFFER_INDEX = 1; |
||
645 | end |
||
646 | |||
647 | --dout("stored: "..IR_MOD_CHAT_NAMES_BUFFER[IR_MOD_CHAT_BUFFER_INDEX-1]..": "..IR_MOD_CHAT_BUFFER[IR_MOD_CHAT_BUFFER_INDEX-1]); |
||
648 | end |
||
649 | |||
650 | |||
651 | function IRR_EscPressed() |
||
652 | dout("Escape"); |
||
653 | end |
||
654 | |||
655 | function IRR_ItemRefTooltip_OnLoad(index) |
||
656 | local windowInfo = {}; |
||
657 | |||
658 | local itemFrame = getglobal("IRR_ItemRefTooltip"..index); |
||
659 | local itemFrameName = "IRR_ItemRefTooltip"..index; |
||
660 | local compFrame = getglobal("IRR_ItemCompTooltip"..index); |
||
661 | local compFrameName = "IRR_ItemCompTooltip"..index; |
||
662 | |||
663 | windowInfo.window = itemFrame; |
||
664 | windowInfo.windowName = itemFrameName; |
||
665 | |||
666 | windowInfo.index = index; |
||
667 | windowInfo.state = 0; |
||
668 | windowInfo.link = 0; |
||
669 | windowInfo.compare = 0; |
||
670 | windowInfo.compareWindow = compFrame; |
||
671 | windowInfo.compareWindowName = compFrameName; |
||
672 | windowInfo.slots = nil; |
||
673 | windowInfo.whisper = nil; |
||
674 | windowInfo.textlink = nil; |
||
675 | windowInfo.itemRefID = nil; |
||
676 | windowInfo.itemID = nil; |
||
677 | windowInfo.quality = nil; |
||
678 | windowInfo.name = nil; |
||
679 | windowInfo.minimized = nil; |
||
680 | windowInfo.originalHeight = nil; |
||
681 | windowInfo.compareLinks = {}; |
||
682 | windowInfo.firstTimeAuc = 1; |
||
683 | windowInfo.fontStringStatus1 = {}; |
||
684 | windowInfo.fontStringStatus2 = {}; |
||
685 | |||
686 | IR_MOD_ITEMREF_WINDOWS[index] = windowInfo; |
||
687 | |||
688 | this.index = index; |
||
689 | end |
||
690 | |||
691 | |||
692 | function IRR_ItemRefTooltip_OnClick(index,isCompFrame) |
||
693 | local itemFrame; |
||
694 | local masterButton = 0; |
||
695 | |||
696 | if (IsShiftKeyDown() == 1) then |
||
697 | IRR_CloseAllWindows(); |
||
698 | else |
||
699 | if (isCompFrame == nil) then |
||
700 | itemFrame = getglobal("IRR_ItemRefTooltip"..index); |
||
701 | |||
702 | IR_MOD_ITEMREF_WINDOWS[index].state = 0; |
||
703 | IR_MOD_ITEMREF_WINDOWS[index].link = 0; |
||
704 | IR_MOD_ITEMREF_WINDOWS[index].firstTimeAuc = 1; |
||
705 | |||
706 | HideUIPanel(itemFrame); |
||
707 | masterButton = 1; |
||
708 | |||
709 | IR_MOD_ITEMREF_WINDOWS[index].minimized = nil; |
||
710 | end |
||
711 | |||
712 | if (index <= 10 or masterButton == 1) then |
||
713 | local compFrame = getglobal("IRR_ItemCompTooltip"..index); |
||
714 | IR_MOD_ITEMREF_WINDOWS[index].compare = 0; |
||
715 | HideUIPanel(compFrame); |
||
716 | end |
||
717 | |||
718 | if (masterButton == 1) then |
||
719 | index = index + 10; |
||
720 | end |
||
721 | |||
722 | if (index > 10) then |
||
723 | local compFrame = getglobal("IRR_ItemCompTool"..index); |
||
724 | HideUIPanel(compFrame); |
||
725 | |||
726 | IR_MOD_ITEMREF_WINDOWS[index-10].compare = 0; |
||
727 | end |
||
728 | |||
729 | GameTooltip:Hide(); |
||
730 | end |
||
731 | end |
||
732 | |||
733 | |||
734 | function IRR_SetWindowHeight(itemRef) |
||
735 | if (IR_MOD_ITEMREF_WINDOWS[itemRef.index].minimized ~= nil) then |
||
736 | itemRef:SetHeight(37); |
||
737 | else |
||
738 | if (IR_MOD_ITEMREF_WINDOWS[itemRef.index].originalHeight) then |
||
739 | itemRef:SetHeight(IR_MOD_ITEMREF_WINDOWS[itemRef.index].originalHeight); |
||
740 | end |
||
741 | end |
||
742 | end |
||
743 | |||
744 | function IRR_SetWindowWidth() |
||
745 | if (AUCTIONEER_VERSION ~= nil or ENCHANTRIX_VERSION ~= nil) then |
||
746 | local itemRefFrame = IR_MOD_ITEMREF_WINDOWS[IR_MOD_AUCTIONEER_INDEX].window; |
||
747 | |||
748 | local fWidth = itemRefFrame:GetWidth(); |
||
749 | local aWidth = EnhancedTooltip:GetWidth(); |
||
750 | |||
751 | if (EnhancedTooltip:GetLeft() == IR_MOD_AUCTIONEER_POS) then |
||
752 | if (fWidth > aWidth) then |
||
753 | EnhancedTooltip:SetWidth(fWidth); |
||
754 | else |
||
755 | itemRefFrame:SetWidth(aWidth); |
||
756 | end |
||
757 | end |
||
758 | end |
||
759 | end |
||
760 | |||
761 | function IRR_DoTooltipUpdate(elapse) |
||
762 | IRR_SetWindowHeight(this); |
||
763 | IRR_SetWindowWidth(); |
||
764 | end |
||
765 | |||
766 | function IRR_BetterShiftClick(link,text,button,osir) |
||
767 | local iiName,iiLink,iiRarity,_,iiType,_,_,iiEquip = GetItemInfo(link); |
||
768 | |||
769 | if (not iiRarity) then |
||
770 | --dout("Original"); |
||
771 | osir(link,text,button); |
||
772 | return; end |
||
773 | |||
774 | local textLink = IRR_LINK_COLOR_OPEN; |
||
775 | textLink = textLink..IRR_LINK_COLORS[iiRarity]; |
||
776 | textLink = textLink..IRR_LINK_HYPERLINK_OPEN; |
||
777 | textLink = textLink..link; |
||
778 | textLink = textLink..IRR_LINK_LINK_OPEN; |
||
779 | textLink = textLink..iiName; |
||
780 | textLink = textLink..IRR_LINK_LINK_CLOSE; |
||
781 | textLink = textLink..IRR_LINK_COLOR_CLOSE; |
||
782 | |||
783 | --dout("link: "..textLink); |
||
784 | |||
785 | if (textLink ~= nil) then |
||
786 | if ( not ChatFrameEditBox:IsVisible() ) then |
||
787 | ChatFrame_OpenChat(textLink); |
||
788 | else |
||
789 | ChatFrameEditBox:SetText(ChatFrameEditBox:GetText()..textLink); |
||
790 | end |
||
791 | end |
||
792 | end |
||
793 | |||
794 | function IRR_DoTooltipShow(index) |
||
795 | local itemRef = this; |
||
796 | |||
797 | --IRR_SetWindowHeight(itemRef); |
||
798 | |||
799 | local iiName,iiLink,iiRarity,_,iiType,_,_,iiEquip = GetItemInfo(IR_MOD_ITEMREF_WINDOWS[index].itemRefID); |
||
800 | IR_MOD_AUCTIONEER_INDEX = index; -- Make the tooltip index available to other mods. |
||
801 | |||
802 | IR_MOD_ITEMREF_WINDOWS[index].name = iiName; |
||
803 | IR_MOD_ITEMREF_WINDOWS[index].quality = iiRarity; |
||
804 | |||
805 | -- Set the whisper/link stuff |
||
806 | IRR_SetWhisperPlayerAndLink(index,"IRR_ItemRefTooltip"..index); |
||
807 | |||
808 | local slots = IRR_GetCompareItemIndex("IRR_ItemRefTooltip"..index); |
||
809 | |||
810 | local compButton = getglobal("ItemRefCompButton"..index); |
||
811 | local DRButton = getglobal("ItemRefDRButton"..index); |
||
812 | |||
813 | if (slots == nil) then |
||
814 | --HideUIPanel(compButton); |
||
815 | --HideUIPanel(whisperButton); |
||
816 | IR_MOD_ITEMREF_WINDOWS[index].slots = nil; |
||
817 | slots = {}; |
||
818 | --dout("NOT an equippable item..."); |
||
819 | end |
||
820 | |||
821 | local empty = 1; |
||
822 | |||
823 | for i=1,table.getn(slots) do |
||
824 | local check = GetInventoryItemLink("player", slots[i]); |
||
825 | |||
826 | if (check ~= nil) then |
||
827 | empty = 0; |
||
828 | --do break end; |
||
829 | end |
||
830 | |||
831 | --dout(check); |
||
832 | IR_MOD_ITEMREF_WINDOWS[index].compareLinks[i] = check; |
||
833 | end |
||
834 | |||
835 | if (empty == 1 or slots == nil) then |
||
836 | compButton:SetButtonState("DISABLED"); |
||
837 | if (empty == 1) then |
||
838 | --dout("No equipped item..."); |
||
839 | end |
||
840 | else |
||
841 | compButton:SetButtonState("NORMAL"); |
||
842 | IR_MOD_ITEMREF_WINDOWS[index].slots = slots; |
||
843 | end |
||
844 | |||
845 | --dout(iiType.."*"); |
||
846 | if (iiType == IRR_ARMOR or iiType == IRR_WEAPON) then |
||
847 | DRButton:SetButtonState("NORMAL"); |
||
848 | else |
||
849 | --dout("disabling DR"); |
||
850 | DRButton:SetButtonState("DISABLED"); |
||
851 | end |
||
852 | |||
853 | IR_MOD_ITEMREF_WINDOWS[index].minimized = 1; |
||
854 | IRR_DoMinimize(index); |
||
855 | |||
856 | -- Auctioneer |
||
857 | IR_MOD_ITEMREF_WINDOWS[index].firstTimeAuc = 1; |
||
858 | IRR_DoAuctioneerFrame(index); |
||
859 | |||
860 | table.foreach(LINK_WRANGLER_CALLER, function(k,v) LinkWrangler_AddonContent(v,k,index); end); |
||
861 | |||
862 | return; |
||
863 | end |
||
864 | |||
865 | function IRR_SizeChanged(index) |
||
866 | if (IR_MOD_ITEMREF_WINDOWS[index].minimized == nil) then |
||
867 | --dout("size changed"); |
||
868 | IR_MOD_ITEMREF_WINDOWS[index].originalHeight = this:GetHeight(); |
||
869 | |||
870 | if (this:GetHeight() < IRR_MIN_HEIGHT) then |
||
871 | IR_MOD_ITEMREF_WINDOWS[index].originalHeight = IRR_MIN_HEIGHT; |
||
872 | end |
||
873 | end |
||
874 | end |
||
875 | |||
876 | ------------------------------------------------------------------------------------------- |
||
877 | -- Hook functions |
||
878 | ------------------------------------------------------------------------------------------- |
||
879 | local originalSetItemRef; |
||
880 | originalSetItemRef = SetItemRef; |
||
881 | function SetItemRef(link, text, button) |
||
882 | --IRR_DecryptLink(link); |
||
883 | --dout("link: "..link) |
||
884 | |||
885 | if (IsControlKeyDown()) then |
||
886 | originalSetItemRef(link,text,button); |
||
887 | return; |
||
888 | end |
||
889 | |||
890 | if ( strsub(link, 1, 4) == "item" ) then |
||
891 | if (IsShiftKeyDown()) then |
||
892 | IRR_BetterShiftClick(link,text,button,originalSetItemRef); |
||
893 | return; end |
||
894 | |||
895 | local index = IRR_GetWindowIndex(link); |
||
896 | |||
897 | if (index == 0) then -- ignore |
||
898 | --dout("index is 0. Returning...?"); |
||
899 | return; |
||
900 | end |
||
901 | |||
902 | local itemRef = IR_MOD_ITEMREF_WINDOWS[index].window; |
||
903 | |||
904 | IR_MOD_ITEMREF_WINDOWS[index].itemRefID = link; |
||
905 | --IR_MOD_ITEMREF_WINDOWS[index].itemID = IRR_GetItemID(link); |
||
906 | |||
907 | ShowUIPanel(itemRef); |
||
908 | if ( not itemRef:IsVisible() ) then |
||
909 | itemRef:SetOwner(UIParent, "ANCHOR_PRESERVE"); |
||
910 | end |
||
911 | |||
912 | IRR_ClearAllFields(index); |
||
913 | itemRef:SetHyperlink(link); |
||
914 | |||
915 | if (ChatBox_Names) then |
||
916 | --originalSetItemRef(link,text,button); |
||
917 | end |
||
918 | else |
||
919 | -- Call original if not handled above |
||
920 | originalSetItemRef(link,text,button); |
||
921 | --dout("using original"); |
||
922 | end |
||
923 | end |