vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | function DuelInspect_OnLoad() |
2 | |||
3 | this:RegisterEvent("VARIABLES_LOADED"); |
||
4 | this:RegisterEvent("DUEL_REQUESTED"); |
||
5 | |||
6 | DI_STATICPOPUP_HEIGHT = ceil(getglobal("StaticPopup1"):GetHeight()); |
||
7 | |||
8 | oldStaticPopupOnHide = StaticPopup_OnHide; |
||
9 | StaticPopup_OnHide = DuelInspect_StaticPopup_OnHide; |
||
10 | |||
11 | oldStartDuelUnit = StartDuelUnit; |
||
12 | StartDuelUnit = DuelInspect_StartDuelUnit; |
||
13 | |||
14 | if ( DI_SAVE == nil ) then |
||
15 | DI_SAVE = {}; |
||
16 | DI_SAVE.ShowBuffs = true; |
||
17 | DI_SAVE.ShowResistances = true; |
||
18 | DI_SAVE.ShowItemsQuality = true; |
||
19 | DI_SAVE.ShowUsableItems = true; |
||
20 | DI_SAVE.OutboundDuels = true; |
||
21 | end |
||
22 | |||
23 | end |
||
24 | |||
25 | |||
26 | |||
27 | |||
28 | |||
29 | |||
30 | |||
31 | |||
32 | |||
33 | |||
34 | |||
35 | |||
36 | function DuelInspect_OnEvent(event) |
||
37 | |||
38 | local challengeFound = false; |
||
39 | |||
40 | if (event == "DUEL_REQUESTED") then |
||
41 | for index = 1, STATICPOPUP_NUMDIALOGS, 1 do |
||
42 | local frame = getglobal("StaticPopup"..index); |
||
43 | if ( frame:IsVisible() and frame.which == "DUEL_CHALLENGE" ) then |
||
44 | challengeFound = true; |
||
45 | break; |
||
46 | end |
||
47 | end |
||
48 | |||
49 | |||
50 | if ( challengeFound ) then |
||
51 | StaticPopup_Hide("DUEL_CHALLENGE"); |
||
52 | end |
||
53 | |||
54 | DuelInspect_UpdateStaticPopup(); |
||
55 | |||
56 | end |
||
57 | |||
58 | end |
||
59 | |||
60 | |||
61 | |||
62 | |||
63 | |||
64 | |||
65 | |||
66 | |||
67 | |||
68 | |||
69 | |||
70 | function DuelInspect_StartDuelUnit() |
||
71 | |||
72 | local duelRequested = false; |
||
73 | |||
74 | for index = 1, STATICPOPUP_NUMDIALOGS, 1 do |
||
75 | local frame = getglobal("StaticPopup"..index); |
||
76 | if ( frame:IsVisible() and frame.which == "DUEL_REQUESTED") then |
||
77 | duelRequested = true; |
||
78 | break; |
||
79 | end |
||
80 | end |
||
81 | |||
82 | if ( IsShiftKeyDown() or not DI_SAVE.OutboundDuels ) then |
||
83 | oldStartDuelUnit("target"); |
||
84 | |||
85 | elseif ( not duelRequested ) then |
||
86 | |||
87 | StaticPopupDialogs["DUEL_CHALLENGE"] = { |
||
88 | text = UnitName("target").." - "..DI_TEXT_CONFIRMDUEL, |
||
89 | button1 = DUEL, |
||
90 | button2 = TEXT(CANCEL), |
||
91 | sound = "igPlayerInvite", |
||
92 | OnAccept = function() |
||
93 | DuelInspect_TargetOpponent(); oldStartDuelUnit("target"); |
||
94 | end, |
||
95 | OnCancel = function() |
||
96 | StaticPopup_Hide("DUEL_CHALLENGE"); |
||
97 | end, |
||
98 | timeout = 0, |
||
99 | hideOnEscape = 1 |
||
100 | }; |
||
101 | |||
102 | StaticPopup_Show("DUEL_CHALLENGE", "target"); |
||
103 | |||
104 | DuelInspect_UpdateStaticPopup(); |
||
105 | DuelInspect_TargetOpponent(); |
||
106 | |||
107 | else |
||
108 | UIErrorsFrame:AddMessage(DI_TEXT_ALREADYCHALLENGED, 1.0, 0.0, 0.0, 1.0, UIERRORS_HOLD_TIME); |
||
109 | end |
||
110 | |||
111 | end |
||
112 | |||
113 | |||
114 | |||
115 | |||
116 | |||
117 | |||
118 | |||
119 | |||
120 | function DuelInspect_StaticPopup_OnHide() |
||
121 | |||
122 | local doHide = true; |
||
123 | |||
124 | for index = 1, STATICPOPUP_NUMDIALOGS, 1 do |
||
125 | local frame = getglobal("StaticPopup"..index); |
||
126 | if ( frame:IsVisible() and (frame.which == "DUEL_REQUESTED" or frame.which == "DUEL_CHALLENGE") ) then |
||
127 | doHide = false; |
||
128 | break; |
||
129 | end |
||
130 | end |
||
131 | |||
132 | for index = 1, STATICPOPUP_NUMDIALOGS, 1 do |
||
133 | frame = getglobal("StaticPopup"..index); |
||
134 | frame:SetFrameStrata("DIALOG"); |
||
135 | end |
||
136 | |||
137 | if ( doHide ) then |
||
138 | getglobal("DuelInspect_TargetButton"):Hide(); |
||
139 | getglobal("DuelInspect_ResistanceFrame"):Hide(); |
||
140 | getglobal("DuelInspect_UnitBuffFrame"):Hide(); |
||
141 | getglobal("DuelInspect_ItemQualityFrame"):Hide(); |
||
142 | getglobal("DuelInspectFrame"):Hide(); |
||
143 | getglobal("DuelInspect_OptionsFrame"):Hide(); |
||
144 | for cnt = 1, 4 do |
||
145 | getglobal("DuelInspect_UseItem"..cnt.."Frame"):Hide(); |
||
146 | end |
||
147 | end |
||
148 | |||
149 | oldStaticPopupOnHide(); |
||
150 | |||
151 | end |
||
152 | |||
153 | |||
154 | |||
155 | |||
156 | |||
157 | |||
158 | |||
159 | |||
160 | |||
161 | |||
162 | |||
163 | |||
164 | |||
165 | function DuelInspect_ShowItemTooltip(itemlink) |
||
166 | |||
167 | if (itemlink) then |
||
168 | GameTooltip:SetOwner(this, "ANCHOR_TOPRIGHT"); |
||
169 | GameTooltip:SetHyperlink(itemlink); |
||
170 | GameTooltip:Show(); |
||
171 | end |
||
172 | |||
173 | end |
||
174 | |||
175 | |||
176 | |||
177 | |||
178 | |||
179 | |||
180 | |||
181 | |||
182 | |||
183 | |||
184 | |||
185 | |||
186 | function DuelInspect_ShowBuffTooltip(buffId) |
||
187 | |||
188 | oppFound, origTarget = DuelInspect_TargetOpponent(); |
||
189 | |||
190 | if ( oppFound ) then |
||
191 | |||
192 | for index = 1, STATICPOPUP_NUMDIALOGS, 1 do |
||
193 | local frame = getglobal("StaticPopup"..index); |
||
194 | if ( frame:IsVisible() and (frame.which == "DUEL_REQUESTED" or frame.which == "DUEL_CHALLENGE") ) then |
||
195 | DuelInspect_UpdateBuffs(index); |
||
196 | getglobal("DuelInspect_Buff"..buffId.."Texture"):SetTexture(UnitBuff("target", buffId)); |
||
197 | end |
||
198 | end |
||
199 | |||
200 | GameTooltip:SetOwner(this, "ANCHOR_LEFT"); |
||
201 | GameTooltip:SetUnitBuff("target", buffId); |
||
202 | GameTooltip:Show(); |
||
203 | |||
204 | if ( origTarget ~= UnitName("target") ) then |
||
205 | TargetLastTarget(); |
||
206 | end |
||
207 | end |
||
208 | end |
||
209 | |||
210 | |||
211 | |||
212 | |||
213 | |||
214 | |||
215 | |||
216 | |||
217 | function DuelInspect_UpdateOptionsFrame(this,index) |
||
218 | |||
219 | if ( index > 1 ) then |
||
220 | getglobal("StaticPopup"..index-1):SetFrameStrata("MEDIUM"); |
||
221 | end |
||
222 | |||
223 | local newWidth = getglobal("StaticPopup"..index.."Text"):GetStringWidth(); |
||
224 | getglobal("DuelInspect_OptionsFrame"):SetWidth(ceil(newWidth)); |
||
225 | |||
226 | if ( GetMouseFocus() and GetMouseFocus():GetName() ) then |
||
227 | |||
228 | local kids = { this:GetChildren() }; |
||
229 | |||
230 | if ( string.sub(GetMouseFocus():GetName(), 0, 24 ) == this:GetName() ) then |
||
231 | |||
232 | if ( index > 1 ) then |
||
233 | if ( getglobal("StaticPopup"..(index-1).."Button1") ) then getglobal("StaticPopup"..(index-1).."Button1"):SetFrameStrata("MEDIUM"); end |
||
234 | if ( getglobal("StaticPopup"..(index-1).."Button2") ) then getglobal("StaticPopup"..(index-1).."Button2"):SetFrameStrata("MEDIUM"); end |
||
235 | end |
||
236 | |||
237 | this:SetAlpha( this:GetAlpha() + 0.04 ); |
||
238 | |||
239 | local point, relativeTo, relativePoint, xofs, yofs = this:GetPoint(); |
||
240 | |||
241 | if ( yofs <= 68 ) then |
||
242 | this:SetHeight( this:GetHeight() + 3.5 ); |
||
243 | this:SetPoint ( point, relativeTo, relativePoint, xofs, yofs + 3.5 ); |
||
244 | else |
||
245 | for _,child in ipairs(kids) do |
||
246 | child:Show(); |
||
247 | end |
||
248 | end |
||
249 | else |
||
250 | |||
251 | if ( this:GetAlpha() >= 0.3 ) then |
||
252 | this:SetAlpha( this:GetAlpha() - 0.04 ); |
||
253 | for _,child in ipairs(kids) do |
||
254 | child:Hide(); |
||
255 | end |
||
256 | else |
||
257 | if ( index > 1 ) then |
||
258 | if ( getglobal("StaticPopup"..(index-1).."Button1") ) then getglobal("StaticPopup"..(index-1).."Button1"):SetFrameStrata("DIALOG"); end |
||
259 | if ( getglobal("StaticPopup"..(index-1).."Button2") ) then getglobal("StaticPopup"..(index-1).."Button2"):SetFrameStrata("DIALOG"); end |
||
260 | end |
||
261 | end |
||
262 | |||
263 | local point, relativeTo, relativePoint, xofs, yofs = this:GetPoint(); |
||
264 | |||
265 | if ( yofs >= 23 ) then |
||
266 | this:SetHeight( this:GetHeight() - 3.5 ); |
||
267 | this:SetPoint ( point, relativeTo, relativePoint, xofs, yofs - 3.5 ); |
||
268 | end |
||
269 | end |
||
270 | |||
271 | end |
||
272 | end |
||
273 | |||
274 | |||
275 | |||
276 | |||
277 | |||
278 | |||
279 | |||
280 | |||
281 | function DuelInspect_UpdateStaticPopupSize(index) |
||
282 | |||
283 | local kids = { getglobal("StaticPopup"..index):GetChildren() }; |
||
284 | local kidsHeight = {}; |
||
285 | |||
286 | for _,child in ipairs(kids) do |
||
287 | if ( ( strfind( child:GetName(), "DuelInspect") ) and ( child:GetBottom() ) and ( child:IsVisible() ) ) then |
||
288 | table.insert ( kidsHeight, child:GetBottom() ); |
||
289 | end |
||
290 | end |
||
291 | |||
292 | table.sort(kidsHeight, function(a,b) return a<b end) |
||
293 | |||
294 | for cnt = 2, table.getn(kidsHeight) do |
||
295 | table.remove(kidsHeight, cnt); |
||
296 | end |
||
297 | |||
298 | for key,val in kidsHeight do |
||
299 | if ( val < ( getglobal("StaticPopup"..index):GetTop() - DI_STATICPOPUP_HEIGHT ) ) then |
||
300 | |||
301 | newHeight = ( getglobal("StaticPopup"..index):GetTop() - val ) + 20; |
||
302 | newStringWidth = getglobal("StaticPopup"..index.."Text"):GetStringWidth() + 5; |
||
303 | newWidth = newStringWidth + 120; |
||
304 | |||
305 | if ( DI_SAVE.ShowBuffs ) then newWidth = newWidth + 40; end |
||
306 | if ( DI_SAVE.ShowResistances ) then newWidth = newWidth + 40; end |
||
307 | |||
308 | getglobal("StaticPopup"..index.."Text"):SetWidth(ceil(newStringWidth)); |
||
309 | getglobal("StaticPopup"..index):SetWidth(ceil(newWidth)); |
||
310 | getglobal("StaticPopup"..index):SetHeight(ceil(newHeight)); |
||
311 | |||
312 | end |
||
313 | end |
||
314 | end |
||
315 | |||
316 | |||
317 | |||
318 | |||
319 | |||
320 | |||
321 | |||
322 | |||
323 | |||
324 | |||
325 | |||
326 | |||
327 | |||
328 | function DuelInspect_ScanResist(line) |
||
329 | local value, token, pos, tmpStr; |
||
330 | |||
331 | while(string.len(line) > 0) do |
||
332 | pos = string.find(line, "/", 1, true); |
||
333 | if(pos) then |
||
334 | tmpStr = string.sub(line,1,pos-1); |
||
335 | line = string.sub(line,pos+1); |
||
336 | else |
||
337 | tmpStr = line; |
||
338 | line = ""; |
||
339 | end |
||
340 | |||
341 | tmpStr = string.gsub( tmpStr, "^%s+", "" ); |
||
342 | tmpStr = string.gsub( tmpStr, "%s+$", "" ); |
||
343 | tmpStr = string.gsub( tmpStr, "%.$", "" ); |
||
344 | |||
345 | _, _, value, token = string.find(tmpStr, "^%+(%d+)%%?(.+)$"); |
||
346 | if(not value) then |
||
347 | _, _, token, value = string.find(tmpStr, "^(.+)%+(%d+)%%?$"); |
||
348 | end |
||
349 | |||
350 | |||
351 | if(token and value) then |
||
352 | token = string.gsub( token, "^%s+", "" ); |
||
353 | token = string.gsub( token, "%s+$", "" ); |
||
354 | token = string.gsub( token, "%.$", "" ); |
||
355 | return token, value; |
||
356 | end |
||
357 | end |
||
358 | return nil, nil; |
||
359 | end |
||
360 | |||
361 | |||
362 | |||
363 | |||
364 | |||
365 | |||
366 | |||
367 | |||
368 | |||
369 | |||
370 | |||
371 | |||
372 | function DuelInspect_GetDifficultyColor(level) |
||
373 | local levelDiff = level - UnitLevel("player"); |
||
374 | local color; |
||
375 | if ( levelDiff >= 5 ) then |
||
376 | color = "|cffff0000"; |
||
377 | elseif ( levelDiff >= 3 ) then |
||
378 | color = "|cffff6600"; |
||
379 | elseif ( levelDiff >= -2 ) then |
||
380 | color = "|cffffff00"; |
||
381 | elseif ( -levelDiff <= GetQuestGreenRange() ) then |
||
382 | color = "|cff00ff00"; |
||
383 | else |
||
384 | color = "|cff888888"; |
||
385 | end |
||
386 | return color; |
||
387 | end |
||
388 | |||
389 | |||
390 | |||
391 | |||
392 | |||
393 | |||
394 | |||
395 | |||
396 | |||
397 | |||
398 | |||
399 | |||
400 | |||
401 | function DuelInspect_PrepareFrames(index,initOptions) |
||
402 | |||
403 | getglobal("DuelInspect_TargetButton"):SetParent("StaticPopup"..index); |
||
404 | getglobal("DuelInspect_TargetButton"):SetPoint("LEFT", "StaticPopup"..index.."Button1", "BOTTOMRIGHT" , -64, -13); |
||
405 | getglobal("DuelInspect_TargetButton"):SetText(DI_TEXT_TARGET); |
||
406 | getglobal("DuelInspect_TargetButton"):Show(); |
||
407 | |||
408 | |||
409 | getglobal("DuelInspect_ResistanceFrame"):SetParent("StaticPopup"..index); |
||
410 | getglobal("DuelInspect_ResistanceFrame"):SetPoint("TOP", "StaticPopup"..index, "TOPRIGHT" , -31, 75); |
||
411 | if ( DI_SAVE.ShowResistances ) then |
||
412 | getglobal("DuelInspect_ResistanceFrame"):Show(); |
||
413 | end |
||
414 | |||
415 | getglobal("DuelInspect_UnitBuffFrame"):SetParent("StaticPopup"..index); |
||
416 | getglobal("DuelInspect_UnitBuffFrame"):SetPoint("TOP", "StaticPopup"..index, "TOPLEFT" , 46, 75); |
||
417 | getglobal("DuelInspect_Buff1Frame"):SetPoint("LEFT", "DuelInspect_UnitBuffFrame", "LEFT"); |
||
418 | if ( DI_SAVE.ShowBuffs ) then |
||
419 | getglobal("DuelInspect_UnitBuffFrame"):Show(); |
||
420 | end |
||
421 | |||
422 | for cnt = 1, 4 do |
||
423 | getglobal("DuelInspect_UseItem"..cnt.."Frame"):SetParent("StaticPopup"..index); |
||
424 | end |
||
425 | |||
426 | if ( DI_SAVE.ShowUsableItems ) then |
||
427 | for cnt = 1, 4 do |
||
428 | getglobal("DuelInspect_UseItem"..cnt.."Frame"):Show(); |
||
429 | end |
||
430 | end |
||
431 | |||
432 | getglobal("DuelInspect_ItemQualityFrame"):SetParent("StaticPopup"..index); |
||
433 | getglobal("DuelInspect_ItemQualityFrame"):SetPoint("TOP", "StaticPopup"..index.."Text", "BOTTOM", 0, -13); |
||
434 | |||
435 | if ( DI_SAVE.ShowItemsQuality ) then |
||
436 | getglobal("DuelInspect_ItemQualityFrame"):Show(); |
||
437 | end |
||
438 | |||
439 | |||
440 | |||
441 | if ( initOptions ) then |
||
442 | getglobal("DuelInspect_OptionsFrame"):SetHeight(39); |
||
443 | getglobal("DuelInspect_OptionsFrame"):SetWidth(275); |
||
444 | getglobal("DuelInspect_OptionsFrame"):SetAlpha(0.5); |
||
445 | getglobal("DuelInspect_OptionsFrame"):SetPoint("TOP", "StaticPopup"..index, "TOP" , 0, 21.99); |
||
446 | getglobal("DuelInspect_OptionsFrame"):Show(); |
||
447 | end |
||
448 | |||
449 | getglobal("DuelInspectFrame"):Show(); |
||
450 | |||
451 | getglobal("DuelInspect_OptionsFrame_CheckButton1"):SetChecked(DI_SAVE.ShowBuffs); |
||
452 | getglobal("DuelInspect_OptionsFrame_CheckButton2"):SetChecked(DI_SAVE.ShowResistances); |
||
453 | getglobal("DuelInspect_OptionsFrame_CheckButton3"):SetChecked(DI_SAVE.ShowItemsQuality); |
||
454 | getglobal("DuelInspect_OptionsFrame_CheckButton4"):SetChecked(DI_SAVE.ShowUsableItems); |
||
455 | getglobal("DuelInspect_OptionsFrame_CheckButton5"):SetChecked(DI_SAVE.OutboundDuels); |
||
456 | |||
457 | local point, relativeTo, relativePoint, xofs, yofs = getglobal("StaticPopup"..index.."Button1"):GetPoint(); |
||
458 | |||
459 | if ( DI_SAVE.ShowUsableItems and getn(DI_ITEMUSES) > 0 ) then |
||
460 | getglobal("StaticPopup"..index.."Button1"):SetPoint(point, "DuelInspect_UseItem"..getn(DI_ITEMUSES).."Text", relativePoint, xofs, yofs); |
||
461 | if ( not DI_SAVE.ShowItemsQuality ) then |
||
462 | getglobal("DuelInspect_UseItem1Frame"):SetPoint("TOP", "StaticPopup"..index.."Text", "BOTTOM" , 0, -13); |
||
463 | getglobal("DuelInspect_UseItem1Text"):SetPoint("TOP", "StaticPopup"..index.."Text", "BOTTOM" , 0, -13); |
||
464 | else |
||
465 | getglobal("DuelInspect_UseItem1Frame"):SetPoint("TOP", "DuelInspect_ItemQualityFrame", "BOTTOM" , 0, -13); |
||
466 | getglobal("DuelInspect_UseItem1Text"):SetPoint("TOP", "DuelInspect_ItemQualityFrame", "BOTTOM" , 0, -13); |
||
467 | end |
||
468 | elseif ( DI_SAVE.ShowItemsQuality ) then |
||
469 | getglobal("StaticPopup"..index.."Button1"):SetPoint(point, "DuelInspect_ItemQualityFrame", relativePoint, xofs, yofs) |
||
470 | else |
||
471 | getglobal("StaticPopup"..index.."Button1"):SetPoint(point, "StaticPopup"..index.."Text", relativePoint, xofs, yofs); |
||
472 | end |
||
473 | |||
474 | |||
475 | end |
||
476 | |||
477 | |||
478 | |||
479 | |||
480 | |||
481 | |||
482 | |||
483 | |||
484 | |||
485 | |||
486 | |||
487 | |||
488 | |||
489 | function DuelInspect_TargetOpponent() |
||
490 | for index = 1, STATICPOPUP_NUMDIALOGS, 1 do |
||
491 | |||
492 | local frame = getglobal("StaticPopup"..index); |
||
493 | |||
494 | if ( frame:IsVisible() and (frame.which == "DUEL_REQUESTED" or frame.which == "DUEL_CHALLENGE") ) then |
||
495 | |||
496 | local orig_text = getglobal("StaticPopup"..index.."Text"):GetText(); |
||
497 | local textpos = string.find(orig_text, " "); |
||
498 | name = string.sub(orig_text, 0, ( textpos - 1 ) ); |
||
499 | |||
500 | |||
501 | origTarget = UnitName("target"); |
||
502 | TargetByName(name); |
||
503 | |||
504 | if ( name ~= UnitName("target") ) then |
||
505 | ClearTarget(); |
||
506 | return false, origTarget; |
||
507 | else |
||
508 | return true, origTarget; |
||
509 | end |
||
510 | end |
||
511 | end |
||
512 | end |
||
513 | |||
514 | |||
515 | |||
516 | |||
517 | |||
518 | |||
519 | |||
520 | |||
521 | |||
522 | |||
523 | |||
524 | function DuelInspect_UpdateBuffs(index) |
||
525 | i = 1; |
||
526 | while (UnitBuff("target", i, 1)) do |
||
527 | getglobal("DuelInspect_Buff"..i.."Texture"):SetTexture(UnitBuff("target", i)); |
||
528 | i = i + 1; |
||
529 | end |
||
530 | |||
531 | for cnt = i, 10 do |
||
532 | |||
533 | if (UnitBuff("target", cnt)) then |
||
534 | getglobal("DuelInspect_Buff"..cnt.."Texture"):SetTexture(UnitBuff("target", cnt)); |
||
535 | else |
||
536 | getglobal("DuelInspect_Buff"..cnt.."Texture"):SetTexture(nil); |
||
537 | end |
||
538 | end |
||
539 | end |
||
540 | |||
541 | |||
542 | |||
543 | |||
544 | |||
545 | |||
546 | |||
547 | |||
548 | |||
549 | |||
550 | |||
551 | |||
552 | function DuelInspect_UpdateStaticPopup() |
||
553 | |||
554 | for index = 1, STATICPOPUP_NUMDIALOGS, 1 do |
||
555 | local frame = getglobal("StaticPopup"..index); |
||
556 | if ( frame:IsVisible() and (frame.which == "DUEL_REQUESTED" or frame.which == "DUEL_CHALLENGE") ) then |
||
557 | |||
558 | |||
559 | DuelInspect_TargetOpponent(); |
||
560 | DuelInspect_UpdateData(index,false); |
||
561 | DuelInspect_PrepareFrames(index,true); |
||
562 | |||
563 | end |
||
564 | end |
||
565 | end |
||
566 | |||
567 | |||
568 | |||
569 | |||
570 | |||
571 | |||
572 | |||
573 | function DuelInspect_UpdateData(index,keepTarget) |
||
574 | |||
575 | local orig_text = getglobal("StaticPopup"..index.."Text"):GetText(); |
||
576 | |||
577 | if ( strfind(orig_text,"\n") ) then |
||
578 | orig_text = strsub(orig_text,0,(strfind(orig_text,"\n")-1)); |
||
579 | end |
||
580 | |||
581 | local playerClass, class = UnitClass("target"); |
||
582 | local level = UnitLevel("target"); |
||
583 | local race = UnitRace("target"); |
||
584 | local rankName, rankNumber = GetPVPRankInfo(UnitPVPRank("target"), "target"); |
||
585 | local guildName, guildRankName, guildRankIndex = GetGuildInfo("target"); |
||
586 | |||
587 | if ( not rankName ) then |
||
588 | rankName = DI_TEXT_NORANK; |
||
589 | rankNumber = ""; |
||
590 | else |
||
591 | rankNumber = rankNumber.."."; |
||
592 | end |
||
593 | |||
594 | |||
595 | if ( not guildName ) then |
||
596 | di_guildtext = "|cffffffff"..DI_TEXT_NOGUILD; |
||
597 | else |
||
598 | di_guildtext = "|cffffffff"..guildRankName.." of <"..guildName..">"; |
||
599 | end |
||
600 | |||
601 | |||
602 | DuelInspect_UpdateBuffs(index); |
||
603 | |||
604 | local quality_count = { |
||
605 | [0] = 0, |
||
606 | [1] = 0, |
||
607 | [2] = 0, |
||
608 | [3] = 0, |
||
609 | [4] = 0, |
||
610 | [5] = 0, |
||
611 | [6] = 0 }; |
||
612 | |||
613 | local DI_RESISTANCES_COUNT = { |
||
614 | ["ARCRES"] = 0, |
||
615 | ["FIRERES"] = 0, |
||
616 | ["NATRES"] = 0, |
||
617 | ["FROSTRES"] = 0, |
||
618 | ["SHADRES"] = 0 |
||
619 | }; |
||
620 | |||
621 | local DI_OTHERS_COUNT = { |
||
622 | ["ARMOR"] = 0 |
||
623 | }; |
||
624 | |||
625 | useItemLink = { |
||
626 | [1] = nil, |
||
627 | [2] = nil, |
||
628 | [3] = nil, |
||
629 | [4] = nil |
||
630 | }; |
||
631 | |||
632 | DI_ITEMUSES = {}; |
||
633 | |||
634 | for cnt = 0, 18 do |
||
635 | if ( cnt ~= 4 ) then |
||
636 | link = GetInventoryItemLink("target", cnt); |
||
637 | if ( link ) then |
||
638 | local _, _, itemCode = strfind(link, "(%d+):"); |
||
639 | local __, itemLink, quality = GetItemInfo(itemCode); |
||
640 | |||
641 | quality_count[quality] = quality_count[quality] + 1; |
||
642 | |||
643 | GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR"); |
||
644 | GameTooltip:SetHyperlink(itemLink); |
||
645 | GameTooltip:Show(); |
||
646 | |||
647 | for i=1,GameTooltip:NumLines() do |
||
648 | local itemtext = getglobal("GameTooltipTextLeft" .. i):GetText(); |
||
649 | local token, value = DuelInspect_ScanResist(itemtext); |
||
650 | |||
651 | if ( itemtext ) then |
||
652 | local strpos = strfind(itemtext, " "); |
||
653 | if ( strpos and strsub(itemtext,(strpos+1)) == DI_OTHERS["ARMOR"] ) then |
||
654 | if ( strfind(strsub(itemtext,0,strpos), '%d') ) then |
||
655 | DI_OTHERS_COUNT["ARMOR"] = DI_OTHERS_COUNT["ARMOR"] + strsub(itemtext,0,strpos); |
||
656 | end |
||
657 | elseif ( strpos and ( strsub(itemtext,0,(strpos-1)) == DI_OTHERS["USE"] ) ) then |
||
658 | table.insert ( DI_ITEMUSES, cnt ); |
||
659 | end |
||
660 | end |
||
661 | |||
662 | if ( token and value ) then |
||
663 | |||
664 | for key,val in DI_RESISTANCES do |
||
665 | if ( val == token ) then |
||
666 | DI_RESISTANCES_COUNT[key] = DI_RESISTANCES_COUNT[key] + value; |
||
667 | end |
||
668 | end |
||
669 | end |
||
670 | end |
||
671 | |||
672 | GameTooltip:Hide(); |
||
673 | |||
674 | end |
||
675 | end |
||
676 | end |
||
677 | |||
678 | |||
679 | di_quality = ""; |
||
680 | |||
681 | for key,value in quality_count do |
||
682 | if ( value > 0 ) then |
||
683 | r, g, b, hex = GetItemQualityColor(key); |
||
684 | di_quality = di_quality.."|cffffffff"..value.."x"..hex..DI_TEXT_QUALITY[key].." "; |
||
685 | end |
||
686 | end |
||
687 | |||
688 | cnt = 1; |
||
689 | |||
690 | |||
691 | |||
692 | for key,val in DI_ITEMUSES do |
||
693 | useItem = GetInventoryItemLink("target", val); |
||
694 | |||
695 | getglobal("DuelInspect_UseItem"..cnt.."Text"):SetText(DI_OTHERS["USE"]..cnt..": "..useItem); |
||
696 | |||
697 | local _, _, itemCode = strfind(useItem, "(%d+):"); |
||
698 | __, useItemLinkTmp = GetItemInfo(itemCode); |
||
699 | useItemLink[cnt] = useItemLinkTmp; |
||
700 | cnt = cnt + 1; |
||
701 | end |
||
702 | |||
703 | |||
704 | for cnt = cnt, 4 do |
||
705 | getglobal("DuelInspect_UseItem"..cnt.."Text"):SetText(""); |
||
706 | useItemLink[cnt] = nil; |
||
707 | end |
||
708 | |||
709 | |||
710 | |||
711 | for key,val in DI_RESISTANCES_COUNT do |
||
712 | if ( val > 0 ) then |
||
713 | getglobal("DuelInspect_Res_"..key.."_Text"):SetText("|cff6ef028+"..val); |
||
714 | else |
||
715 | getglobal("DuelInspect_Res_"..key.."_Text"):SetText(""); |
||
716 | end |
||
717 | end |
||
718 | |||
719 | if ( not keepTarget ) then |
||
720 | TargetLastTarget(); |
||
721 | end |
||
722 | |||
723 | getglobal("DuelInspect_ItemQualityFrameText"):SetText(di_quality); |
||
724 | |||
725 | local di_playertext = DuelInspect_GetDifficultyColor(level)..""..level.." |cffffffff"..race.." "..TEXT_CLASS_COLORS[class]..playerClass.." |cffffffff- |cffcccc00"..rankNumber.." "..rankName; |
||
726 | local new_text = orig_text.."\n\n"..di_playertext.."\n"..di_guildtext; |
||
727 | getglobal("StaticPopup"..index.."Text"):SetText(new_text); |
||
728 | |||
729 | end |
||
730 | |||
731 | |||
732 | |||
733 | |||
734 | |||
735 | |||
736 | |||
737 | |||
738 | |||
739 | |||
740 | |||
741 | |||
742 | |||
743 | |||
744 | |||
745 | |||
746 | |||
747 |