vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 XPerl_CheckItems = {}
2 XPerl_ItemResults = {["type"] = "item"}
3 XPerl_ResistResults = {["type"] = "res", count = 0}
4 XPerl_DurResults = {["type"] = "dur", count = 0}
5 XPerl_RegResults = {["type"] = "reg", count = 0}
6 XPerl_PlayerList = {}
7 XPerl_MsgQueue = {}
8 SelectedPlayer = nil
9 XPerl_ActiveScan = nil
10 ActiveScanItem = nil
11 ActiveScanTotals = nil
12  
13 local ITEMLISTSIZE = 12
14 local PLAYERLISTSIZE = 10
15  
16 -- XPerl_CheckOnLoad
17 function XPerl_CheckOnLoad()
18 this:RegisterEvent("CHAT_MSG_ADDON")
19 this:RegisterEvent("RAID_ROSTER_UPDATE")
20  
21 XPerl_CheckListItemsScrollBar.offset = 0
22 XPerl_CheckListPlayersScrollBar.offset = 0
23 end
24  
25 if (not XPerl_GetClassColour) then
26 XPerl_GetClassColour = function(class)
27 if (class) then
28 local color = RAID_CLASS_COLORS[class]; -- Now using the WoW class color table
29 if (color) then
30 return color
31 end
32 end
33 return {r = 0.5, g = 0.5, b = 1}
34 end
35 end
36  
37 if (not XPerlColourTable) then
38 local function MashXX(class)
39 local c = RAID_CLASS_COLORS[class]
40 XPerlColourTable[class] = string.format("|c00%02X%02X%02X", 255 * c.r, 255 * c.g, 255 * c.b)
41 end
42 XPerlColourTable = {}
43 MashXX("HUNTER")
44 MashXX("WARLOCK")
45 MashXX("PRIEST")
46 MashXX("PALADIN")
47 MashXX("MAGE")
48 MashXX("ROGUE")
49 MashXX("DRUID")
50 MashXX("SHAMAN")
51 MashXX("WARRIOR")
52 end
53  
54 if (not XPerl_ClassPos) then
55 XPerl_ClassPos = function(class)
56 if(class=="WARRIOR") then return 0, 0.25, 0, 0.25; end
57 if(class=="MAGE") then return 0.25, 0.5, 0, 0.25; end
58 if(class=="ROGUE") then return 0.5, 0.75, 0, 0.25; end
59 if(class=="DRUID") then return 0.75, 1, 0, 0.25; end
60 if(class=="HUNTER") then return 0, 0.25, 0.25, 0.5; end
61 if(class=="SHAMAN") then return 0.25, 0.5, 0.25, 0.5; end
62 if(class=="PRIEST") then return 0.5, 0.75, 0.25, 0.5; end
63 if(class=="WARLOCK") then return 0.75, 1, 0.25, 0.5; end
64 if(class=="PALADIN") then return 0, 0.25, 0.5, 0.75; end
65 return 0.25, 0.5, 0.5, 0.75 -- Returns empty next one, so blank
66 end
67 end
68  
69 -- CTRAItemMsg
70 local needUpdate
71 local function CTRAItemMsg(nick, item, count)
72  
73 local results = XPerl_ItemResults[item]
74  
75 if (not results) then
76 ChatFrame7:AddMessage("Missing results for "..item)
77 else
78 results.last = GetTime()
79 tinsert(results, {name = nick, ["count"] = tonumber(count)})
80 needUpdate = true
81 end
82 end
83  
84 local function ProcessCTRAMessage(unitName, msg)
85 --ChatFrame7:AddMessage(unitName..": "..msg)
86 if (strfind(msg, "^ITM ")) then
87 local _, _, numItems, itemName, callPerson = strfind(msg, "^ITM ([-%d]+) (.+) ([^%s]+)$")
88  
89 if (callPerson == UnitName("player")) then -- Maybe ignore this
90 CTRAItemMsg(unitName, itemName, numItems)
91 end
92  
93 elseif (strfind(msg, "^DUR ")) then
94 local _, _, currDur, maxDur, brokenItems, callPerson = strfind(msg, "^DUR (%d+) (%d+) (%d+) ([^%s]+)$")
95  
96 if (currDur and maxDur and brokenItems) then
97 currDur, maxDur, brokenItems = tonumber(currDur), tonumber(maxDur), tonumber(brokenItems)
98 XPerl_DurResults[unitName] = {dur = floor((currDur/maxDur)*100+0.5), broken = brokenItems}
99 if (callPerson == UnitName("player")) then
100 XPerl_DurResults.count = XPerl_DurResults.count + 1
101 end
102 XPerl_DurResults.last = GetTime()
103 needUpdate = true
104 end
105  
106 elseif (strfind(msg, "^RST ")) then
107 local _, _, plrName = strfind(msg, "^RST %-1 ([^%s]+)$");
108 if (not plrName) then
109 local _, _, FR, NR, FRR, SR, AR, callPerson = strfind(msg, "^RST (%d+) (%d+) (%d+) (%d+) (%d+) ([^%s]+)$")
110 if (FR) then
111 XPerl_ResistResults[unitName] = {fr = tonumber(FR), nr = tonumber(NR), frr = tonumber(FRR), sr = tonumber(SR), ar = tonumber(AR)}
112 if (callPerson == UnitName("player")) then
113 XPerl_ResistResults.count = XPerl_ResistResults.count + 1
114 end
115 XPerl_ResistResults.last = GetTime()
116 needUpdate = true
117 end
118 end
119  
120 elseif (strfind(msg, "^REA ")) then
121 local _, _, numItems, callPerson = strfind(msg, "^REA ([^%s]+) ([^%s]+)$");
122 if (numItems) then
123 XPerl_RegResults[unitName] = {count = tonumber(numItems)}
124 if (callPerson == UnitName("player")) then
125 XPerl_RegResults.count = XPerl_RegResults.count + 1
126 end
127 XPerl_RegResults.last = GetTime()
128 needUpdate = true
129 end
130 end
131 end
132  
133 -- XPerl_Check_Setup
134 function XPerl_Check_Setup()
135  
136 SlashCmdList["XPERLITEM"] = XPerl_ItemCheck
137 SLASH_XPERLITEM1 = "/xpitem"
138 SLASH_XPERLITEM2 = "/raitem"
139 SLASH_XPERLITEM3 = "/radur"
140 SLASH_XPERLITEM4 = "/raresist"
141 SLASH_XPERLITEM5 = "/raresists"
142 SLASH_XPERLITEM6 = "/rareg"
143  
144 SlashCmdList["RAITEM"] = nil
145 SLASH_RAITEM1 = nil
146 SlashCmdList["RADUR"] = nil
147 SLASH_RADUR1 = nil
148 SlashCmdList["RARST"] = nil
149 SLASH_RARST1 = nil
150 SlashCmdList["RAREG"] = nil
151 SLASH_RAREG1 = nil
152  
153 if (oRA) then -- oRA2
154 oRA:UnRegisterShorthand("raitem")
155 oRA:UnRegisterShorthand("rareg")
156 oRA:UnRegisterShorthand("radur")
157 oRA:UnRegisterShorthand("raresist")
158 elseif (oRA_Core) then -- oRA1
159 oRA_Core:UnregisterShortHand("raitem")
160 oRA_Core:UnregisterShortHand("rareg")
161 oRA_Core:UnregisterShortHand("radur")
162 oRA_Core:UnregisterShortHand("raresist")
163 end
164  
165 if (not XPerl_Admin.ResistSort) then
166 XPerl_Admin.ResistSort = "fr"
167 end
168 for k,v in ipairs(XPerl_CheckItems) do
169 v.query = nil
170 end
171  
172 XPerl_CheckTitleBarPin:SetButtonTex()
173 XPerl_CheckTitleBarLockOpen:SetButtonTex()
174  
175 XPerl_CheckListPlayersTotals:SetHighlightTexture(nil)
176 XPerl_CheckListPlayersTotals:SetScript("OnClick", nil)
177  
178 XPerl_Check_ItemsChanged()
179 XPerl_Check_UpdatePlayerList()
180 end
181  
182 -- XPerl_CheckOnEvent
183 function XPerl_CheckOnEvent()
184 if (event == "RAID_ROSTER_UPDATE") then
185 if (not UnitInRaid("player")) then
186 XPerl_ItemResults = {["type"] = "item"}
187 XPerl_ResistResults = {["type"] = "res", count = 0}
188 XPerl_DurResults = {["type"] = "dur", count = 0}
189 XPerl_RegResults = {["type"] = "reg", count = 0}
190 end
191 XPerl_Check_ValidateButtons()
192  
193 elseif (event == "CHAT_MSG_ADDON") then
194 if (arg1 == "CTRA" and arg3 == "RAID") then
195 needUpdate = nil
196 XPerl_ParseCTRA(arg4, arg2, ProcessCTRAMessage)
197  
198 if (needUpdate) then
199 XPerl_Check_UpdateItemList()
200 XPerl_Check_MakePlayerList()
201 XPerl_Check_ShowInfo()
202 end
203 end
204 elseif (event == "UNIT_INVENTORY_CHANGED" or event == "UNIT_MODEL_CHANGED") then
205 local n = UnitName(arg1)
206 if (XPerl_ActiveScan and XPerl_ActiveScan[n]) then
207 XPerl_ActiveScan[n].changed = true
208 XPerl_ActiveScan[n].offline = nil
209 XPerl_ActiveScan[n].wrongZone = nil
210 end
211 end
212 end
213  
214 -- XPerl_CheckOnUpdate
215 -- Only active after a query, and only for 10 seconds
216 local function XPerl_CheckOnUpdate()
217  
218 -- TODO Total Progress indication
219  
220 if (getn(XPerl_MsgQueue) > 0) then
221 local Time = GetTime()
222 local send
223 if (not XPerl_Check.lastMsgsent) then
224 send = true
225 elseif (Time > XPerl_Check.lastMsgsent + 1) then
226 send = true
227 end
228  
229 if (send) then
230 XPerl_Check.lastMsgsent = Time
231  
232 local count = 0
233 local msg = ""
234  
235 while (getn(XPerl_MsgQueue) > 0 and count < 4) do
236 local sub = XPerl_MsgQueue[1]
237  
238 if (strlen(msg..sub) > 220) then
239 SendAddonMessage("CTRA", msg, "RAID")
240 break
241 else
242 count = count + 1
243 tremove(XPerl_MsgQueue, 1)
244 if (msg == "") then
245 msg = sub
246 else
247 msg = msg.."#"..sub
248 end
249 end
250 end
251  
252 if (msg ~= "") then
253 SendAddonMessage("CTRA", msg, "RAID")
254 end
255 end
256  
257 elseif (ActiveScanItem) then
258 XPerl_Check_ActiveScan()
259 else
260 if (XPerl_Check.queryStart and GetTime() > XPerl_Check.queryStart + 5) then
261 XPerl_Check:SetScript("OnUpdate", nil)
262 XPerl_Check.queryStart, XPerl_Check.lastMsgsent = nil, nil
263  
264 XPerl_Check_ValidateButtons()
265 end
266 end
267 end
268  
269 -- GetVLinkName
270 local function GetVLinkName(v)
271 local linkName
272 if (strsub(v.link, 1, 1) == "|") then
273 local _
274 _, _, linkName = strfind(v.link, "%[(.+)%]")
275 else
276 linkName = v.link
277 end
278 return linkName
279 end
280  
281 -- ClearSelectedItem
282 local function ClearSelectedItem()
283 for k,v in ipairs(XPerl_CheckItems) do
284 v.selected = nil
285 end
286 end
287  
288 -- TickItemByName
289 local function TickItemByName(itemName)
290 for k,v in ipairs(XPerl_CheckItems) do
291 local name = GetVLinkName(v)
292  
293 if (name == itemName) then
294 if (not v.fixed) then
295 v.ticked = true
296 end
297 v.selected = true
298 break
299 end
300 end
301 end
302  
303 -- GotItem
304 local function GotItem(link)
305 local _,_, findItem = strfind(link, "item:(%d+):")
306 for k,v in pairs(XPerl_CheckItems) do
307 local _, _, item = strfind(v.link, "item:(%d+):")
308 if (item == findItem) then
309 return true
310 end
311 end
312 end
313  
314 -- GotItem
315 local function GotItemName(itemName)
316 for k,v in pairs(XPerl_CheckItems) do
317 local _, _, linkName = strfind(v.link, "%[(.+)%]")
318 if (linkName == itemName) then
319 return true
320 end
321 end
322 end
323  
324 -- InsertItemLink
325 local function InsertItemLink(itemLink)
326 ClearSelectedItem()
327  
328 if (strsub(itemLink, 1, 1) == "|") then
329 if (not GotItem(itemLink)) then
330 tinsert(XPerl_CheckItems, {link = itemLink, ticked = true, selected = true})
331 else
332 local _, _, linkName = strfind(itemLink, "%[(.+)%]")
333 TickItemByName(linkName)
334 end
335 else
336 if (not GotItemName(itemLink)) then
337 tinsert(XPerl_CheckItems, {link = itemLink, ticked = true, selected = true})
338 else
339 local _, _, linkName = strfind(itemLink, "%[(.+)%]")
340 TickItemByName(linkName)
341 end
342 end
343 end
344  
345 -- XPerl_Check_Expand()
346 function XPerl_Check_Expand(forced)
347 XPerl_Check:SetWidth(500)
348 XPerl_Check:SetHeight(241) --213)
349 XPerl_CheckList:Show()
350 XPerl_CheckButton:Show()
351 XPerl_Check.forcedOpen = forced
352 XPerl_CheckTitleBarLockOpen:Show()
353 end
354  
355 -- XPerl_ItemCheck
356 function XPerl_ItemCheck(itemName)
357  
358 local cmd = "/raitem"
359 if (DEFAULT_CHAT_FRAME.editBox) then
360 local command = DEFAULT_CHAT_FRAME.editBox:GetText()
361 if (strlower(strsub(command, 1, 6)) == "/radur") then
362 cmd = "/radur"
363 elseif (strlower(strsub(command, 1, 9)) == "/raresist") then
364 cmd = "/raresist"
365 elseif (strlower(strsub(command, 1, 6)) == "/rareg") then
366 cmd = "/rareg"
367 end
368 end
369  
370 XPerl_Check:Show()
371 XPerl_Check_Expand(true)
372  
373 if (cmd == "/raitem") then
374 if (not itemName or itemName == "") then
375 return
376 end
377  
378 if (strsub(itemName, 1, 1) == "|") then
379 -- TODO search for item in inventory (and LootLink) and use the link
380 end
381  
382 InsertItemLink(itemName)
383 elseif (cmd == "/radur") then
384 ClearSelectedItem()
385 TickItemByName("dur")
386  
387 elseif (cmd == "/rareg") then
388 ClearSelectedItem()
389 TickItemByName("reg")
390  
391 elseif (cmd == "/raresist") then
392 ClearSelectedItem()
393 TickItemByName("res")
394 end
395  
396 XPerl_Check_Query()
397 end
398  
399 -- XPerl_PickupContainerItem
400 local oldPickup
401 local PickupBag, PickupSlot
402 local function XPerl_PickupContainerItem(bagID, slot)
403 PickupBag, PickupSlot = bagID, slot
404 return oldPickup(bagID, slot)
405 end
406  
407 if (not oldPickup) then
408 oldPickup = PickupContainerItem
409 PickupContainerItem = XPerl_PickupContainerItem
410 end
411  
412 -- sortItems
413 -- Fixed entries at top, followed by last current queried, followed by rest. Alphabetical within this.
414 local function sortItems(i1, i2)
415  
416 local itemName1 = GetVLinkName(i1)
417 local itemName2 = GetVLinkName(i2)
418  
419 local t1, t2, f1, f2, q1, q2
420 if (i1.fixed) then f1 = "0" else f1 = "1" end
421 if (i2.fixed) then f2 = "0" else f2 = "1" end
422 if (i1.ticked) then t1 = "0" else t1 = "1" end
423 if (i2.ticked) then t2 = "0" else t2 = "1" end
424 if (i1.query) then q1 = "0" else q1 = "1" end
425 if (i2.query) then q2 = "0" else q2 = "1" end
426  
427 return f1..q1..t1..itemName1 < f2..q2..t2..itemName2
428 end
429  
430 -- ItemsChanged
431 function XPerl_Check_ItemsChanged()
432  
433 -- Validate. Make sure we have our fixed entries
434 local dur, reg, res
435 for k,v in ipairs(XPerl_CheckItems) do
436 if (v.link == "res") then
437 res = true
438 elseif (v.link == "dur") then
439 dur = true
440 elseif (v.link == "reg") then
441 reg = true
442 end
443 end
444 if (not dur) then
445 tinsert(XPerl_CheckItems, {fixed = true, link = "dur"})
446 end
447 if (not res) then
448 tinsert(XPerl_CheckItems, {fixed = true, link = "res"})
449 end
450 if (not reg) then
451 tinsert(XPerl_CheckItems, {fixed = true, link = "reg"})
452 end
453  
454 sort(XPerl_CheckItems, sortItems)
455  
456 XPerl_Check_UpdateItemList()
457 XPerl_Check_ValidateButtons()
458 end
459  
460 -- GetSelectedResults
461 local function GetSelectedItem()
462 for k,v in ipairs(XPerl_CheckItems) do
463 if (v.selected) then
464 if (v.fixed) then
465 if (v.link == "res") then
466 return XPerl_ResistResults, "res"
467 elseif (v.link == "dur") then
468 return XPerl_DurResults, "dur"
469 elseif (v.link == "reg") then
470 return XPerl_RegResults, "reg"
471 end
472 else
473 local linkName = GetVLinkName(v)
474 if (linkName) then
475 return XPerl_ItemResults[linkName], "item"
476 end
477 break
478 end
479 end
480 end
481 end
482  
483 -- GetSelectedItemLink
484 local function GetSelectedItemLink()
485 local link
486 for k,v in ipairs(XPerl_CheckItems) do
487 if (v.selected) then
488 return v.link
489 end
490 end
491 end
492  
493 -- GetCursorItem
494 local function GetCursorItemLink()
495 local id = this:GetID() + XPerl_CheckListItemsScrollBar.offset
496 local item = XPerl_CheckItems[id]
497 if (item and not item.fixed) then
498 return item.link
499 end
500 return ""
501 end
502  
503 -- SelectClickedTickItem
504 local function SelectClickedTickItem()
505  
506 local oldSelection
507 for k,v in ipairs(XPerl_CheckItems) do
508 if (v.selected) then
509 oldSelection = v
510 v.selected = nil
511 end
512 end
513  
514 local id
515 if (this:GetFrameType() == "CheckButton") then
516 id = this:GetParent():GetID()
517 else
518 id = this:GetID()
519 end
520  
521 if (id and id > 0) then
522 id = id + XPerl_CheckListItemsScrollBar.offset
523  
524 local item = XPerl_CheckItems[id]
525 if (item) then
526 item.selected = true
527 end
528  
529 if (oldSelection ~= item) then
530 XPerl_Check_StopActiveScan()
531 XPerl_ActiveScan = nil
532 ActiveScanTotals = nil
533 end
534  
535 XPerl_Check_UpdateItemList()
536 XPerl_Check_MakePlayerList()
537 XPerl_Check_ShowInfo()
538 end
539 end
540  
541 -- XPerl_Check_TickAll
542 function XPerl_Check_TickAll(all)
543 for k,v in ipairs(XPerl_CheckItems) do
544 if (not v.fixed) then
545 v.ticked = all
546 end
547 end
548 XPerl_Check_ItemsChanged()
549 end
550  
551 -- XPerl_Check_TickLastResults
552 function XPerl_Check_TickLastResults()
553 for k,v in ipairs(XPerl_CheckItems) do
554 if (not v.fixed) then
555 v.ticked = nil
556  
557 local linkName = GetVLinkName(v)
558 if (linkName) then
559 if (XPerl_ItemResults[linkName]) then
560 v.ticked = true
561 end
562 end
563 end
564 end
565  
566 XPerl_Check_ItemsChanged()
567 end
568  
569 -- XPerl_Check_OnClickItem
570 function XPerl_Check_OnClickItem(button)
571  
572 if (button == "LeftButton") then
573 if (IsShiftKeyDown()) then
574 if (ChatFrameEditBox:IsVisible()) then
575 ChatFrameEditBox:Insert(GetCursorItemLink())
576 end
577 elseif (IsControlKeyDown()) then
578 DressUpItemLink(GetCursorItemLink())
579  
580 else
581 if (CursorHasItem()) then
582 ClearCursor()
583  
584 if (PickupBag and PickupSlot) then
585 local itemLink = GetContainerItemLink(PickupBag, PickupSlot)
586  
587 if (itemLink) then
588 InsertItemLink(itemLink)
589 XPerl_Check_ItemsChanged()
590 end
591 end
592 end
593  
594 XPerl_CheckListPlayersScrollBarScrollBar:SetValue(0)
595 SetPortraitTexture(XPerl_CheckButtonPlayerPortrait, "raidx")
596 SelectedPlayer = nil
597 SelectClickedTickItem(true)
598 XPerl_Check_ValidateButtons()
599 end
600 end
601 end
602  
603 local reagentClasses = {
604 PRIEST = true,
605 MAGE = true,
606 DRUID = true,
607 WARLOCK = true,
608 PALADIN = true,
609 SHAMAN = true
610 }
611  
612 -- GetOnlineMembers
613 local function GetOnlineMembers()
614 local count = 0
615 local reagentCount = 0
616 for i = 1,GetNumRaidMembers() do
617 if (UnitIsConnected("raid"..i)) then
618 local _, class = UnitClass("raid"..i)
619  
620 if (reagentClasses[class]) then
621 reagentCount = reagentCount + 1
622 end
623  
624 if (XPerl_Roster) then
625 local stats = XPerl_Roster[UnitName("raid"..i)]
626 if (stats) then
627 if (stats.version) then
628 count = count + 1
629 end
630 end
631 else
632 count = count + 1
633 end
634 end
635 end
636 return count, reagentCount
637 end
638  
639 -- SmoothColour
640 local function SmoothColour(percentage)
641 local r, g
642 if (percentage < 0.5) then
643 g = 2*percentage
644 r = 1
645 else
646 g = 1
647 r = 2*(1 - percentage)
648 end
649 if (r < 0) then r = 0 elseif (r > 1) then r = 1 end
650 if (g < 0) then g = 0 elseif (g > 1) then g = 1 end
651 return r, g, 0
652 end
653  
654 -- SmoothBarColor
655 local function SmoothGuageColor(bar, percentage)
656 local r, g, b = SmoothColour(percentage)
657 bar:SetVertexColor(r, g, b, 0.75)
658 end
659  
660 -- XPerl_Check_UpdateItemList
661 function XPerl_Check_UpdateItemList()
662  
663 local onlineCount, reagentCount = GetOnlineMembers()
664 local index = 1
665 local i = 0
666 for k,v in ipairs(XPerl_CheckItems) do
667 if (index > ITEMLISTSIZE) then
668 break
669 end
670 if (i >= XPerl_CheckListItemsScrollBar.offset) then
671 local frame = getglobal("XPerl_CheckListItems"..index)
672 local nameFrame = getglobal("XPerl_CheckListItems"..index.."Name")
673 local countFrame = getglobal("XPerl_CheckListItems"..index.."Count")
674 local iconFrame = getglobal("XPerl_CheckListItems"..index.."Icon")
675 local gaugeFrame = getglobal("XPerl_CheckListItems"..index.."Gauge")
676 local tickFrame = getglobal("XPerl_CheckListItems"..index.."Tick")
677  
678 frame:Show()
679 if (v.selected) then
680 frame:LockHighlight()
681 else
682 frame:UnlockHighlight()
683 end
684  
685 if (v.fixed) then
686 tickFrame:Hide()
687 iconFrame:Hide()
688  
689 local div
690 if (v.link == "res") then
691 nameFrame:SetText(RESISTANCE_LABEL)
692 countFrame:SetText(XPerl_ResistResults.count)
693 div = XPerl_ResistResults.count / onlineCount
694  
695 elseif (v.link == "dur") then
696 local dur,c = string.gsub(DURABILITY_TEMPLATE, " %%d / %%d", "")
697 if (not dur or c ~= 1) then
698 dur = "Durability"
699 end
700 nameFrame:SetText(dur)
701 countFrame:SetText(XPerl_DurResults.count)
702 div = XPerl_DurResults.count / onlineCount
703  
704 elseif (v.link == "reg") then
705 local reg,c = string.gsub(SPELL_REAGENTS, ": ", "")
706 if (not reg or c ~= 1) then
707 reg = "Reagents"
708 end
709 nameFrame:SetText(reg)
710 countFrame:SetText(XPerl_RegResults.count)
711 div = XPerl_RegResults.count / reagentCount
712 end
713 nameFrame:SetTextColor(1, 1, 0.7)
714  
715 if (div > 0) then
716 if (div > 1) then div = 1 end
717 gaugeFrame:SetWidth((countFrame:GetLeft() - nameFrame:GetLeft()) * div)
718 gaugeFrame:Show()
719 SmoothGuageColor(gaugeFrame, div)
720 else
721 gaugeFrame:Hide()
722 end
723 else
724 tickFrame:Show()
725 tickFrame:SetChecked(v.ticked)
726  
727 nameFrame:SetText(v.link)
728  
729 local _,_, itemId = strfind(v.link, "item:(%d+):");
730 if (itemId) then
731 local itemName, itemString, itemQuality, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemId)
732 iconFrame:SetTexture(itemTexture)
733 iconFrame:Show()
734 else
735 iconFrame:Hide()
736 end
737  
738 local linkName = GetVLinkName(v)
739 if (linkName) then
740 local count = ""
741 local result = XPerl_ItemResults[linkName]
742 if (result) then
743 count = getn(result)
744  
745 local div = count / onlineCount
746  
747 if (v.query and div > 0) then
748 if (div > 1) then div = 1 end
749 gaugeFrame:SetWidth((countFrame:GetLeft() - nameFrame:GetLeft()) * div)
750 gaugeFrame:Show()
751 SmoothGuageColor(gaugeFrame, div)
752 else
753 gaugeFrame:Hide()
754 end
755 else
756 gaugeFrame:Hide()
757 end
758 countFrame:SetText(count)
759 else
760 gaugeFrame:Hide()
761 end
762 end
763  
764 index = index + 1
765 end
766 i = i + 1
767 end
768  
769 for i = index,ITEMLISTSIZE do
770 getglobal("XPerl_CheckListItems"..i):Hide()
771 end
772  
773 if (FauxScrollFrame_Update(XPerl_CheckListItemsScrollBar, getn(XPerl_CheckItems), ITEMLISTSIZE, 1)) then
774 XPerl_CheckListItemsScrollBar:Show()
775 else
776 XPerl_CheckListItemsScrollBar:Hide()
777 end
778 end
779  
780 -- SortPlayersByCount
781 local function SortPlayersByCount(p1, p2)
782 local c1, c2
783 if (p1.broken) then
784 if (p1.connected and not p1.noCTRA) then c1 = p1.broken + (1 - (p1.dur / 100)) else c1 = -1 end
785 if (p2.connected and not p2.noCTRA) then c2 = p2.broken + (1 - (p2.dur / 100)) else c2 = -1 end
786 else
787 if (p1.connected and not p1.noCTRA) then c1 = p1.count else c1 = -1 end
788 if (p2.connected and not p2.noCTRA) then c2 = p2.count else c2 = -1 end
789 end
790 return c1 > c2
791 end
792  
793 -- SortPlayersByName
794 local function SortPlayersByName(p1, p2)
795 return p1.name < p2.name
796 end
797  
798 -- SortPlayersByClass
799 local function SortPlayersByClass(p1, p2)
800 return p1.class..p1.name < p2.class..p2.name
801 end
802  
803 --local EquipedSortOrder = {untested = 0, notequipped = 1, equipped = 2, notinzone = 3, offline = 4}
804 local function ScanOrder(p)
805 local s = XPerl_ActiveScan[p.name]
806 if (s) then
807 if (s.notequipped) then
808 return 1
809 elseif (s.equipped and s.changed) then
810 return 2
811 elseif (s.equipped) then
812 return 3
813 elseif (s.notinzone) then
814 return 4
815 elseif (s.offline) then
816 return 5
817 end
818 end
819 return 0
820 end
821  
822 -- SortPlayersByDur
823 local function SortPlayersByDur(p1, p2)
824 if (p1.dur) then
825 local o1, o2 = 0,0
826 if (not p1.connected or p1.noCTRA) then o1 = 1000 end
827 if (not p2.connected or p2.noCTRA) then o2 = 1000 end
828 return p1.dur + o1 < p2.dur + o2
829 else
830 if (XPerl_ActiveScan) then
831 return ScanOrder(p1)..p1.class..p1.name < ScanOrder(p2)..p2.class..p2.name
832 else
833 return SortPlayersByCount(p1, p2)
834 end
835 end
836 end
837  
838 -- SortPlayersByResist
839 local function SortPlayersByResist(p1, p2)
840 local o1, o2 = 0,0
841 if (not p1.connected or p1.noCTRA) then o1 = 1000 end
842 if (not p2.connected or p2.noCTRA) then o2 = 1000 end
843 return p1[XPerl_Admin.ResistSort] - o1 > p2[XPerl_Admin.ResistSort] - o2
844 end
845  
846 -- XPerl_Check_MakePlayerList
847 function XPerl_Check_MakePlayerList()
848  
849 FauxScrollFrame_SetOffset(XPerl_CheckListPlayersScrollBar, 0)
850  
851 local function ShowResists(show)
852 if (show) then
853 XPerl_CheckListPlayersTitleFR:Show()
854 XPerl_CheckListPlayersTitleFRR:Show()
855 XPerl_CheckListPlayersTitleNR:Show()
856 XPerl_CheckListPlayersTitleSR:Show()
857 XPerl_CheckListPlayersTitleAR:Show()
858  
859 XPerl_CheckListPlayersTotalsFR:Show()
860 XPerl_CheckListPlayersTotalsFRR:Show()
861 XPerl_CheckListPlayersTotalsNR:Show()
862 XPerl_CheckListPlayersTotalsSR:Show()
863 XPerl_CheckListPlayersTotalsAR:Show()
864 else
865 XPerl_CheckListPlayersTitleFR:Hide()
866 XPerl_CheckListPlayersTitleFRR:Hide()
867 XPerl_CheckListPlayersTitleNR:Hide()
868 XPerl_CheckListPlayersTitleSR:Hide()
869 XPerl_CheckListPlayersTitleAR:Hide()
870  
871 XPerl_CheckListPlayersTotalsFR:Hide()
872 XPerl_CheckListPlayersTotalsFRR:Hide()
873 XPerl_CheckListPlayersTotalsNR:Hide()
874 XPerl_CheckListPlayersTotalsSR:Hide()
875 XPerl_CheckListPlayersTotalsAR:Hide()
876 end
877 end
878  
879 local function ShowCount(show)
880 if (show) then
881 XPerl_CheckListPlayersTitleCount:Show()
882 XPerl_CheckListPlayersTotalsCount:Show()
883 else
884 XPerl_CheckListPlayersTitleCount:Hide()
885 XPerl_CheckListPlayersTotalsCount:Hide()
886 end
887 end
888  
889 local function ShowDur(show)
890 if (show) then
891 XPerl_CheckListPlayersTitleDur:Show()
892 XPerl_CheckListPlayersTotalsNR:Show()
893 else
894 XPerl_CheckListPlayersTitleDur:Hide()
895 XPerl_CheckListPlayersTotalsNR:Hide()
896 end
897 end
898  
899 XPerl_PlayerList = {}
900  
901 local results, resType = GetSelectedItem()
902 if (results and results.last) then
903 XPerl_CheckListPlayersTitleClass:Show()
904 XPerl_CheckListPlayersTitleName:Show()
905 XPerl_CheckListPlayersTotalsName:Show()
906  
907 if (resType == "item" or resType == "reg") then
908 XPerl_CheckListPlayersTotalsName:SetText(XPERL_CHECK_TOTALS)
909 XPerl_CheckListPlayersTitleCount:SetText("#")
910  
911 ShowCount(true)
912 ShowResists(false)
913 ShowDur(XPerl_ActiveScan)
914  
915 if (XPerl_ActiveScan) then
916 XPerl_CheckListPlayersTitleDur:SetText(XPERL_CHECK_EQUIPED)
917 end
918  
919 elseif (resType == "dur") then
920 XPerl_CheckListPlayersTotalsName:SetText(XPERL_CHECK_AVERAGE)
921  
922 ShowResists(false)
923 ShowCount(true)
924 ShowDur(true)
925  
926 XPerl_CheckListPlayersTitleCount:SetText(XPERL_CHECK_BROKEN)
927 XPerl_CheckListPlayersTitleDur:SetText("%")
928  
929 elseif (resType == "res") then
930 XPerl_CheckListPlayersTotalsName:SetText(XPERL_CHECK_AVERAGE)
931  
932 ShowCount(false)
933 ShowDur(false)
934 ShowResists(true)
935 end
936  
937 for i = 1,GetNumRaidMembers() do
938 local name = UnitName("raid"..i)
939 local _, class = UnitClass("raid"..i)
940 local count = 0
941 local noCTRA
942  
943 if (XPerl_Roster) then
944 local stats = XPerl_Roster[name]
945 if (stats) then
946 if (not stats.version) then
947 noCTRA = true
948 end
949 end
950 end
951  
952 if (resType == "item") then
953 for k,v in ipairs(results) do
954 if (v.name == name) then -- type(v) == "table" and
955 count = v.count
956 if (count > 0) then
957 noCTRA = nil
958 end
959 break
960 end
961 end
962  
963 tinsert(XPerl_PlayerList, {["name"] = name, unit = "raid"..i, ["count"] = count, ["class"] = class, connected = (UnitIsConnected("raid"..i) == 1), ["noCTRA"] = noCTRA})
964  
965 elseif (resType == "reg") then
966 if (reagentClasses[class] or results[name]) then
967 local p = results[name]
968 local reg = 0
969 if (p) then
970 reg = p.count
971 if (reg > 0) then
972 noCTRA = nil
973 end
974 end
975  
976 tinsert(XPerl_PlayerList, {["name"] = name, unit = "raid"..i, ["count"] = reg, ["class"] = class, connected = (UnitIsConnected("raid"..i) == 1), ["noCTRA"] = noCTRA})
977 end
978  
979 elseif (resType == "res") then
980 local p = results[name]
981 local fr, frr, nr, sr, ar = 0, 0, 0, 0, 0
982 if (p) then
983 fr, frr, nr, sr, ar = p.fr, p.frr, p.nr, p.sr, p.ar
984 if (fr + frr + nr + sr + ar > 0) then
985 noCTRA = nil
986 end
987 end
988  
989 tinsert(XPerl_PlayerList, {["name"] = name, unit = "raid"..i, ["fr"] = fr, ["frr"] = frr, ["nr"] = nr, ["sr"] = sr, ["ar"] = ar, ["class"] = class, connected = (UnitIsConnected("raid"..i) == 1), ["noCTRA"] = noCTRA})
990  
991 elseif (resType == "dur") then
992 local p = results[name]
993 local dur, broken = 0, 0
994 if (p) then
995 dur, broken = p.dur, p.broken
996 if (dur + broken > 0) then
997 noCTRA = nil
998 end
999 end
1000  
1001 tinsert(XPerl_PlayerList, {["name"] = name, unit = "raid"..i, ["dur"] = dur, ["broken"] = broken, ["class"] = class, connected = (UnitIsConnected("raid"..i) == 1), ["noCTRA"] = noCTRA})
1002 end
1003 end
1004  
1005 if (resType == "item" or resType == "reg") then
1006 sort(XPerl_PlayerList, SortPlayersByCount)
1007 elseif (resType == "dur") then
1008 sort(XPerl_PlayerList, SortPlayersByDur)
1009 elseif (resType == "res") then
1010 sort(XPerl_PlayerList, SortPlayersByResist)
1011 end
1012 else
1013 XPerl_CheckListPlayersTitleClass:Hide()
1014 XPerl_CheckListPlayersTitleName:Hide()
1015 XPerl_CheckListPlayersTotalsName:Hide()
1016 ShowCount(false)
1017 ShowDur(false)
1018 ShowResists(false)
1019 end
1020  
1021 XPerl_Check_UpdatePlayerList()
1022 end
1023  
1024 -- XPerl_Check_UpdatePlayerList
1025 function XPerl_Check_UpdatePlayerList()
1026  
1027 local onlineCount, tFR, tFRR, tNR, tSR, tAR, tDur, tBroken, tCount = 0, 0, 0, 0, 0, 0, 0, 0, 0
1028  
1029 local results, resType = GetSelectedItem()
1030 local index = 1
1031  
1032 for i = 1,getn(XPerl_PlayerList) do
1033 -- + XPerl_CheckListPlayersScrollBar.offset, PLAYERLISTSIZE + XPerl_CheckListPlayersScrollBar.offset do
1034 local v = XPerl_PlayerList[i]
1035 if (not v) then
1036 break
1037 end
1038  
1039 if (v.fr) then
1040 tFR = tFR + v.fr
1041 tFRR = tFRR + v.frr
1042 tNR = tNR + v.nr
1043 tSR = tSR + v.sr
1044 tAR = tAR + v.ar
1045 elseif (v.dur) then
1046 tDur = tDur + v.dur
1047 tBroken = tBroken + v.broken
1048 else
1049 tCount = tCount + v.count
1050 end
1051  
1052 if (v.connected) then
1053 onlineCount = onlineCount + 1
1054 end
1055  
1056 if (i >= XPerl_CheckListPlayersScrollBar.offset + 1 and index <= PLAYERLISTSIZE) then
1057 local frame = getglobal("XPerl_CheckListPlayers"..index)
1058 local iconFrame = getglobal("XPerl_CheckListPlayers"..index.."Icon")
1059 local nameFrame = getglobal("XPerl_CheckListPlayers"..index.."Name")
1060 local countFrame = getglobal("XPerl_CheckListPlayers"..index.."Count")
1061 local resFrameFR = getglobal("XPerl_CheckListPlayers"..index.."FR")
1062 local resFrameFRR = getglobal("XPerl_CheckListPlayers"..index.."FRR")
1063 local resFrameNR = getglobal("XPerl_CheckListPlayers"..index.."NR")
1064 local resFrameSR = getglobal("XPerl_CheckListPlayers"..index.."SR")
1065 local resFrameAR = getglobal("XPerl_CheckListPlayers"..index.."AR")
1066 local resFrameEquiped = getglobal("XPerl_CheckListPlayers"..index.."Equiped")
1067  
1068 if (v.name == SelectedPlayer) then
1069 frame:LockHighlight()
1070 else
1071 frame:UnlockHighlight()
1072 end
1073  
1074 nameFrame:SetText(v.name)
1075 local color = XPerl_GetClassColour(v.class)
1076 nameFrame:SetTextColor(color.r, color.g, color.b)
1077  
1078 if (v.class) then
1079 local r, l, t, b = XPerl_ClassPos(v.class)
1080 iconFrame:SetTexCoord(r, l, t, b)
1081 iconFrame:Show()
1082 else
1083 iconFrame:Hide()
1084 end
1085  
1086 getglobal("XPerl_CheckListPlayers"..index):Show()
1087  
1088 local function ShowScanIcon()
1089 if (XPerl_ActiveScan) then
1090 local z = XPerl_ActiveScan[v.name]
1091 if (z) then
1092 resFrameEquiped:Show()
1093 if (z.equipped) then
1094 if (z.changed) then
1095 resFrameEquiped:SetTexture("Interface\\Buttons\\UI-CheckBox-Check-Disabled")
1096 else
1097 resFrameEquiped:SetTexture("Interface\\Buttons\\UI-CheckBox-Check")
1098 end
1099 resFrameEquiped:SetTexCoord(0, 1, 0, 1)
1100 elseif (z.offline) then
1101 resFrameEquiped:SetTexture("Interface\\CharacterFrame\\Disconnect-Icon")
1102 resFrameEquiped:SetTexCoord(0.2, 0.8, 0.2, 0.8)
1103 elseif (z.notequipped) then
1104 resFrameEquiped:SetTexture("Interface\\Addons\\XPerl_RaidAdmin\\Images\\XPerl_Check")
1105 if (z.changed) then
1106 resFrameEquiped:SetTexCoord(0.75, 0.875, 0.25, 0.5)
1107 else
1108 resFrameEquiped:SetTexCoord(0.625, 0.75, 0.25, 0.5)
1109 end
1110 elseif (z.notinzone) then
1111 resFrameEquiped:SetTexture("Interface\\GossipFrame\\TaxiGossipIcon")
1112 --resFrameEquiped:SetTexture("Interface\\WorldMap\\WorldMap-Icon")
1113 resFrameEquiped:SetTexCoord(0, 1, 0, 1)
1114 else
1115 resFrameEquiped:Hide()
1116 end
1117 else
1118 resFrameEquiped:Hide()
1119 end
1120 else
1121 resFrameEquiped:Hide()
1122 end
1123 end
1124  
1125 if (not v.connected or v.noCTRA) then
1126 if (not v.connected) then
1127 countFrame:SetText(XPERL_LOC_OFFLINE)
1128 else
1129 countFrame:SetText(XPERL_RAID_TOOLTIP_NOCTRA)
1130 end
1131 countFrame:SetTextColor(0.5, 0.5, 0.5)
1132 countFrame:Show()
1133  
1134 ShowScanIcon()
1135  
1136 resFrameFR:Hide()
1137 resFrameFRR:Hide()
1138 resFrameNR:Hide()
1139 resFrameSR:Hide()
1140 resFrameAR:Hide()
1141 else
1142 if (v.fr) then
1143 resFrameFR:SetText(v.fr)
1144 resFrameFRR:SetText(v.frr)
1145 resFrameNR:SetText(v.nr)
1146 resFrameNR:SetTextColor(0, 1, 0)
1147 resFrameSR:SetText(v.sr)
1148 resFrameAR:SetText(v.ar)
1149  
1150 resFrameFR:Show()
1151 resFrameFRR:Show()
1152 resFrameNR:Show()
1153 resFrameSR:Show()
1154 resFrameAR:Show()
1155 countFrame:Hide()
1156 resFrameEquiped:Hide()
1157  
1158 elseif (v.dur) then
1159 resFrameNR:SetText(v.dur)
1160 countFrame:SetText(v.broken)
1161  
1162 local r, g, b = SmoothColour(v.dur)
1163 resFrameNR:SetTextColor(r, g, b)
1164  
1165 countFrame:Show()
1166 resFrameNR:Show()
1167  
1168 if (v.broken > 0) then
1169 countFrame:SetTextColor(1, 0, 0)
1170 else
1171 countFrame:SetTextColor(0, 1, 0)
1172 end
1173  
1174 resFrameFR:Hide()
1175 resFrameFRR:Hide()
1176 resFrameSR:Hide()
1177 resFrameAR:Hide()
1178 resFrameEquiped:Hide()
1179 else
1180 countFrame:SetText(v.count)
1181 countFrame:Show()
1182  
1183 if (v.count == 0) then
1184 countFrame:SetTextColor(1, 0, 0)
1185 else
1186 countFrame:SetTextColor(0, 1, 0)
1187 end
1188  
1189 ShowScanIcon()
1190  
1191 resFrameFR:Hide()
1192 resFrameFRR:Hide()
1193 resFrameNR:Hide()
1194 resFrameSR:Hide()
1195 resFrameAR:Hide()
1196 end
1197 end
1198  
1199 index = index + 1
1200 end
1201 end
1202  
1203 for i = index,PLAYERLISTSIZE do
1204 getglobal("XPerl_CheckListPlayers"..i):Hide()
1205 end
1206  
1207 if (resType == "dur") then
1208 XPerl_CheckListPlayersTotalsNR:SetText(floor(tDur / onlineCount))
1209 XPerl_CheckListPlayersTotalsNR:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b)
1210 XPerl_CheckListPlayersTotalsCount:SetText(tBroken)
1211  
1212 local r, g, b = SmoothColour((tDur / onlineCount) / 100)
1213 XPerl_CheckListPlayersTotalsNR:SetTextColor(r, g, b)
1214  
1215 if (tBroken > 0) then
1216 XPerl_CheckListPlayersTotalsCount:SetTextColor(1, 0, 0)
1217 else
1218 XPerl_CheckListPlayersTotalsCount:SetTextColor(0, 1, 0)
1219 end
1220  
1221 elseif (resType == "res") then
1222 XPerl_CheckListPlayersTotalsFR:SetText(floor(tFR / onlineCount))
1223 XPerl_CheckListPlayersTotalsNR:SetText(floor(tNR / onlineCount))
1224 XPerl_CheckListPlayersTotalsNR:SetTextColor(0, 1, 0)
1225 XPerl_CheckListPlayersTotalsFRR:SetText(floor(tFRR / onlineCount))
1226 XPerl_CheckListPlayersTotalsSR:SetText(floor(tSR / onlineCount))
1227 XPerl_CheckListPlayersTotalsAR:SetText(floor(tAR / onlineCount))
1228 else
1229 XPerl_CheckListPlayersTotalsCount:SetText(tCount)
1230  
1231 if (tCount == 0) then
1232 XPerl_CheckListPlayersTotalsNR:SetTextColor(1, 0, 0)
1233 else
1234 XPerl_CheckListPlayersTotalsNR:SetTextColor(0, 1, 0)
1235 end
1236 end
1237  
1238 if (FauxScrollFrame_Update(XPerl_CheckListPlayersScrollBar, getn(XPerl_PlayerList), PLAYERLISTSIZE, 1)) then
1239 XPerl_CheckListPlayersScrollBar:Show()
1240 else
1241 XPerl_CheckListPlayersScrollBar:Hide()
1242 end
1243 end
1244  
1245 -- XPerl_Check_ShowInfo
1246 function XPerl_Check_ShowInfo()
1247  
1248 if (ActiveScanTotals) then
1249 if (ActiveScanTotals.missing > 0) then
1250 XPerl_CheckButtonInfo:SetText(string.format(XPERL_CHECK_SCAN_MISSING, ActiveScanTotals.missing))
1251 else
1252 XPerl_CheckButtonInfo:SetText("")
1253 end
1254 else
1255 local results = GetSelectedItem()
1256  
1257 local t
1258 if (results and results.last and results.last > 0) then
1259 t = SecondsToTime(GetTime() - results.last)
1260 else
1261 t = ""
1262 end
1263 if (t ~= "") then
1264 XPerl_CheckButtonInfo:SetText(string.format(XPERL_CHECK_LASTINFO, t))
1265 else
1266 XPerl_CheckButtonInfo:SetText("")
1267 end
1268 end
1269 end
1270  
1271 -- XPerl_Check_OnEnter
1272 function XPerl_Check_OnEnter()
1273  
1274 local f, anc
1275 if (this:GetFrameType() == "CheckButton") then
1276 f = getglobal(this:GetParent():GetName().."Name")
1277 anc = this:GetParent()
1278 else
1279 f = getglobal(this:GetName().."Name")
1280 anc = this
1281 end
1282 if (f) then
1283 local link = f:GetText()
1284 if (link and strsub(link, 1, 1) == "|") then
1285 -- Have to strip excess information for the SetHyperlink call
1286 local _,_, itemId = strfind(link, "item:(%d+):");
1287 if (itemId) then
1288 local newLink = string.format("item:%d:0:0:0", itemId)
1289  
1290 GameTooltip:SetOwner(anc, "ANCHOR_LEFT")
1291 GameTooltip:SetHyperlink(newLink)
1292 return
1293 end
1294 end
1295 end
1296  
1297 GameTooltip:SetOwner(XPerl_CheckListItems1, "ANCHOR_LEFT")
1298 GameTooltip:SetText(XPERL_CHECK_DROPITEMTIP1, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
1299 GameTooltip:AddLine(XPERL_CHECK_DROPITEMTIP2, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
1300 GameTooltip:Show()
1301 end
1302  
1303 -- XPerl_CheckMouseWheel
1304 function XPerl_CheckMouseWheel(name, dir)
1305 local frame = getglobal("XPerl_CheckList"..name.."ScrollBarScrollBar")
1306 if (dir > 0) then
1307 frame:SetValue(frame:GetValue() - 5)
1308 else
1309 frame:SetValue(frame:GetValue() + 5)
1310 end
1311 end
1312  
1313 -- XPerl_Check_OnClickStart
1314 function XPerl_Check_OnClickTick()
1315 local id = this:GetParent():GetID() + XPerl_CheckListItemsScrollBar.offset
1316 if (XPerl_CheckItems[id]) then
1317 XPerl_CheckItems[id].ticked = this:GetChecked()
1318 end
1319 XPerl_Check_ValidateButtons()
1320 end
1321  
1322 -- XPerl_Check_DeleteSelectedItems
1323 function XPerl_Check_DeleteSelectedItems()
1324  
1325 local newList = {}
1326  
1327 for k,v in ipairs(XPerl_CheckItems) do
1328 if (v.fixed or not v.ticked) then
1329 tinsert(newList, v)
1330 else
1331 local linkName = GetVLinkName(v)
1332 if (linkName) then
1333 XPerl_ItemResults[linkName] = nil
1334 end
1335 end
1336 end
1337  
1338 XPerl_CheckItems = newList
1339  
1340 XPerl_Check_ItemsChanged()
1341 end
1342  
1343 -- XPerl_Check_Query
1344 function XPerl_Check_Query()
1345  
1346 local oldResults = XPerl_ItemResults
1347 XPerl_ItemResults = {["type"] = "item"}
1348  
1349 XPerl_CheckListItemsScrollBarScrollBar:SetValue(0)
1350  
1351 tinsert(XPerl_MsgQueue, "DURC")
1352 tinsert(XPerl_MsgQueue, "RSTC")
1353 tinsert(XPerl_MsgQueue, "REAC")
1354 XPerl_ResistResults.count = 0
1355 XPerl_DurResults.count = 0
1356 XPerl_RegResults.count = 0
1357  
1358 local msg
1359 for k,v in ipairs(XPerl_CheckItems) do
1360 if (v.ticked) then
1361 v.query = true
1362 v.ticked = nil
1363  
1364 if (not v.fixed) then
1365 local linkName = GetVLinkName(v)
1366  
1367 if (linkName) then
1368 XPerl_ItemResults[linkName] = {last = 0}
1369 oldResults[linkName] = nil
1370 tinsert(XPerl_MsgQueue, "ITMC "..linkName)
1371 end
1372 end
1373 else
1374 v.query = nil
1375 end
1376 end
1377  
1378 for k,v in pairs(oldResults) do
1379 if (type(v) == "table") then
1380 if (not v.fixed) then
1381 XPerl_ItemResults[k] = v
1382 end
1383 end
1384 end
1385  
1386 XPerl_Check.queryStart = GetTime()
1387 XPerl_Check.lastMsgsent = nil
1388 XPerl_Check:SetScript("OnUpdate", XPerl_CheckOnUpdate)
1389  
1390 XPerl_Check_ItemsChanged() -- Re-sort and re-show list with ticked items at top
1391 XPerl_Check_ValidateButtons()
1392 end
1393  
1394 -- GetActiveScanItem
1395 local function GetActiveScanItem()
1396  
1397 local item = GetSelectedItemLink()
1398 local itemId
1399 if (item and strsub(item, 1, 1) == "|") then
1400 local _
1401 _,_, itemId = strfind(item, "item:(%d+):")
1402 if (not itemId) then
1403 return
1404 end
1405 else
1406 return
1407 end
1408  
1409 local itemName, itemString, itemQuality, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemId)
1410  
1411 if (not itemEquipLoc or not itemType) then
1412 return
1413 end
1414  
1415 if (not (itemType == "Armor" or itemType == "Weapon")) then
1416 return
1417 end
1418  
1419 local slots = { INVTYPE_HEAD = 1,
1420 INVTYPE_NECK = 2,
1421 INVTYPE_SHOULDER = 3,
1422 INVTYPE_BODY = 4,
1423 INVTYPE_CHEST = 5,
1424 INVTYPE_ROBE = 5,
1425 INVTYPE_WAIST = 6,
1426 INVTYPE_LEGS = 7,
1427 INVTYPE_FEET = 8,
1428 INVTYPE_WRIST = 9,
1429 INVTYPE_HAND = 10,
1430 INVTYPE_FINGER = {11, 12},
1431 INVTYPE_TRINKET = {13, 14},
1432 INVTYPE_CLOAK = 15,
1433 INVTYPE_2HWEAPON = 16,
1434 INVTYPE_WEAPONMAINHAND = 16,
1435 INVTYPE_WEAPON = {16, 17},
1436 INVTYPE_WEAPONOFFHAND = 17,
1437 INVTYPE_HOLDABLE = 17,
1438 INVTYPE_SHIELD = 17,
1439 INVTYPE_RANGED = 18,
1440 INVTYPE_RELIC = 18,
1441 INVTYPE_TABARD = 19}
1442  
1443 local slot = slots[itemEquipLoc]
1444 if (slot) then
1445 return tonumber(itemId), slot
1446 end
1447 end
1448  
1449 -- GetSelectedPlayer
1450 local function GetSelectedPlayer()
1451 if (SelectedPlayer) then
1452 for k,v in pairs(XPerl_PlayerList) do
1453 if (v.name == SelectedPlayer) then
1454 return v
1455 end
1456 end
1457 end
1458 end
1459  
1460 -- XPerl_Check_ValidateButtons
1461 function XPerl_Check_ValidateButtons()
1462  
1463 local fixedSelected, regSelected
1464 local anyTicked
1465 for k,v in ipairs(XPerl_CheckItems) do
1466 if (v.selected) then
1467 if (v.fixed) then
1468 fixedSelected = true
1469 end
1470 if (v.link == "reg") then
1471 regSelected = true
1472 end
1473 end
1474 if (not v.fixed and v.ticked) then
1475 anyTicked = true
1476 end
1477 end
1478  
1479 local results, resType = GetSelectedItem()
1480  
1481 if (anyTicked and not XPerl_Check.queryStart) then
1482 XPerl_CheckButtonDelete:Enable()
1483 else
1484 XPerl_CheckButtonDelete:Disable()
1485 end
1486  
1487 if (not XPerl_Check.queryStart and IsRaidOfficer()) then
1488 XPerl_CheckButtonQuery:Enable()
1489 else
1490 XPerl_CheckButtonQuery:Disable()
1491 end
1492  
1493 if (((results and results.last) or XPerl_ActiveScan) and UnitInRaid("player")) then
1494 XPerl_CheckButtonReport:Enable()
1495 else
1496 XPerl_CheckButtonReport:Disable()
1497 end
1498  
1499 if (results and results.last and not (fixedSelected and not regSelected) and UnitInRaid("player")) then
1500 XPerl_CheckButtonReportWith:Enable()
1501 XPerl_CheckButtonReportWithout:Enable()
1502 else
1503 XPerl_CheckButtonReportWith:Disable()
1504 XPerl_CheckButtonReportWithout:Disable()
1505 end
1506  
1507 if (ActiveScanItem) then
1508 local tex = XPerl_CheckButtonEquiped:GetNormalTexture()
1509 tex:SetTexCoord(0.75, 0.875, 0.5, 0.75)
1510 tex = XPerl_CheckButtonEquiped:GetPushedTexture()
1511 tex:SetTexCoord(0.875, 1, 0.5, 0.75)
1512  
1513 XPerl_CheckButtonEquiped.tooltipText = "XPERL_CHECK_SCANSTOP_DESC"
1514 else
1515 local tex = XPerl_CheckButtonEquiped:GetNormalTexture()
1516 tex:SetTexCoord(0.375, 0.5, 0.5, 0.75)
1517 tex = XPerl_CheckButtonEquiped:GetPushedTexture()
1518 tex:SetTexCoord(0.5, 0.625, 0.5, 0.75)
1519  
1520 XPerl_CheckButtonEquiped.tooltipText = "XPERL_CHECK_SCAN_DESC"
1521 end
1522  
1523 local myPlayer = GetSelectedPlayer()
1524 if (((results and results.last) or (XPerl_ActiveScan and XPerl_ActiveScan[SelectedPlayer])) and myPlayer and myPlayer.connected) then
1525 XPerl_CheckButtonPlayer:Enable()
1526 else
1527 XPerl_CheckButtonPlayer:Disable()
1528 end
1529  
1530 XPerl_CheckButtonEquiped:Hide()
1531 XPerl_CheckButtonEquiped:Show()
1532  
1533 if (results and not fixedSelected and GetActiveScanItem()) then
1534 XPerl_CheckButtonEquiped:Enable()
1535 else
1536 XPerl_CheckButtonEquiped:Disable()
1537 end
1538 end
1539  
1540 -- XPerl_Check_Players_Sort
1541 function XPerl_Check_Players_Sort(sortType)
1542 if (sortType == "class") then
1543 sort(XPerl_PlayerList, SortPlayersByClass)
1544 elseif (sortType == "name") then
1545 sort(XPerl_PlayerList, SortPlayersByName)
1546 elseif (sortType == "count") then
1547 sort(XPerl_PlayerList, SortPlayersByCount)
1548 elseif (sortType == "dur") then
1549 sort(XPerl_PlayerList, SortPlayersByDur)
1550 elseif (strfind("frrsrnrar", sortType)) then
1551 XPerl_Admin.ResistSort = sortType
1552 sort(XPerl_PlayerList, SortPlayersByResist)
1553 end
1554  
1555 XPerl_Check_UpdatePlayerList()
1556 end
1557  
1558 -- XPerl_Check_Report
1559 function XPerl_Check_Report(showNames)
1560  
1561 local function ReportOutput(msg)
1562 if (msg) then
1563 if (XPerlTest) then
1564 SendChatMessage("<X-Perl> "..msg, "WHISPER", nil, "Zek")
1565 else
1566 SendChatMessage("<X-Perl> "..msg, "RAID")
1567 end
1568 end
1569 end
1570  
1571 local link = GetSelectedItemLink()
1572 local msg
1573 if (link) then
1574 local myPlayer = GetSelectedPlayer()
1575  
1576 if (link == "res") then
1577 if (XPerl_ResistResults.last) then
1578 if (showNames == "player") then
1579 if (SelectedPlayer) then
1580 if (myPlayer.connected) then
1581 msg = string.format(XPERL_CHECK_REPORT_PRESISTS, SelectedPlayer, myPlayer.fr, myPlayer.nr, myPlayer.frr, myPlayer.sr, myPlayer.ar)
1582 end
1583 end
1584 else
1585 local fr, frr, nr, sr, ar, count = 0, 0, 0, 0, 0, 0
1586  
1587 for k,v in ipairs(XPerl_PlayerList) do
1588 if (v.connected) then
1589 count = count + 1
1590  
1591 fr = fr + v.fr
1592 frr = frr + v.frr
1593 nr = nr + v.nr
1594 sr = sr + v.sr
1595 ar = ar + v.ar
1596 end
1597 end
1598  
1599 fr = fr / count
1600 frr = frr / count
1601 nr = nr / count
1602 sr = sr / count
1603 ar = ar / count
1604  
1605 msg = string.format(XPERL_CHECK_REPORT_RESISTS, fr, nr, frr, sr, ar)
1606 end
1607 ReportOutput(msg)
1608 end
1609  
1610 elseif (link == "dur") then
1611 if (XPerl_DurResults.last) then
1612 if (showNames == "player") then
1613 if (SelectedPlayer) then
1614 if (myPlayer.connected) then
1615 msg = string.format(XPERL_CHECK_REPORT_PDURABILITY, SelectedPlayer, myPlayer.dur, myPlayer.broken)
1616 end
1617 end
1618 else
1619 local dur, broken, brokenPeople, count = 0, 0, 0, 0
1620  
1621 for k,v in ipairs(XPerl_PlayerList) do
1622 if (v.connected) then
1623 count = count + 1
1624 dur = dur + v.dur
1625  
1626 if (v.broken > 0) then
1627 brokenPeople = brokenPeople + 1
1628 broken = broken + v.broken
1629 end
1630 end
1631 end
1632  
1633 dur = dur / count
1634  
1635 msg = string.format(XPERL_CHECK_REPORT_DURABILITY, dur, brokenPeople, broken)
1636 end
1637 ReportOutput(msg)
1638 end
1639 else
1640 if (showNames == "player") then
1641 if (SelectedPlayer) then
1642 if (myPlayer.connected) then
1643 if (link == "reg") then
1644 if (XPerl_RegResults.last) then
1645 msg = string.format(XPERL_CHECK_REPORT_PITEM, SelectedPlayer, myPlayer.count, XPERL_REAGENTS[myPlayer.class])
1646 end
1647 else
1648 if (XPerl_ActiveScan and XPerl_ActiveScan[SelectedPlayer]) then
1649 if (XPerl_ActiveScan[SelectedPlayer].equipped) then
1650 msg = string.format(XPERL_CHECK_REPORT_PEQUIPED, SelectedPlayer, link)
1651 elseif (XPerl_ActiveScan[SelectedPlayer].notequipped) then
1652 msg = string.format(XPERL_CHECK_REPORT_PNOTEQUIPED, SelectedPlayer, link)
1653 end
1654 else
1655 msg = string.format(XPERL_CHECK_REPORT_PITEM, SelectedPlayer, myPlayer.count, link)
1656 end
1657 end
1658 ReportOutput(msg)
1659 end
1660 end
1661 else
1662 local equipable = ""
1663 if (strsub(link, 1, 1) == "|") then
1664 local _,_, itemId = strfind(link, "item:(%d+):")
1665 local itemName, itemString, itemQuality, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemId)
1666 if (itemEquipLoc and itemType) then
1667 if (itemType == "Armor" or itemType == "Weapon") then
1668 equipable = "_EQ"
1669 end
1670 end
1671 end
1672  
1673 local with = {}
1674 local without = {}
1675 local offline = {}
1676 local totalItems = 0
1677  
1678 for k,v in ipairs(XPerl_PlayerList) do
1679 if (ActiveScanTotals and ActiveScanTotals.missing == 0) then
1680 local scan = XPerl_ActiveScan[v.name]
1681 if (scan.equipped) then
1682 tinsert(with, v)
1683 elseif (scan.notequipped) then
1684 tinsert(without, v)
1685 elseif (scan.offline) then
1686 tinsert(offline, v)
1687 end
1688 else
1689 if (v.connected) then
1690 if (v.count > 0) then
1691 tinsert(with, v)
1692 totalItems = totalItems + v.count
1693 elseif (not v.noCTRA) then
1694 tinsert(without, v)
1695 end
1696 else
1697 tinsert(offline, v)
1698 end
1699 end
1700 end
1701  
1702 if (ActiveScanTotals and ActiveScanTotals.missing == 0 and ActiveScanTotals.wrongZone == 0 and ActiveScanTotals.notequipped == 0) then
1703 if (ActiveScanTotals.offline == 0) then
1704 ReportOutput(string.format(XPERL_CHECK_REPORT_ALLEQUIPED, link))
1705 else
1706 ReportOutput(string.format(XPERL_CHECK_REPORT_ALLEQUIPEDOFF, link, ActiveScanTotals.offline))
1707 end
1708 else
1709 if (showNames) then
1710 if (link == "reg") then
1711 link,c = string.gsub(SPELL_REAGENTS, ": ", "")
1712 if (not link or c ~= 1) then
1713 link = "Reagents"
1714 end
1715 end
1716  
1717 local showList
1718 local showTitle
1719 if (showNames == "with") then
1720 if (ActiveScanTotals and ActiveScanTotals.missing == 0) then
1721 showTitle = link..XPERL_CHECK_REPORT_EQUIPED
1722 else
1723 showTitle = link..getglobal("XPERL_CHECK_REPORT_WITH"..equipable)
1724 end
1725 if (getn(with) > 0) then
1726 showList = with
1727 end
1728 elseif (showNames == "without") then
1729 if (ActiveScanTotals and ActiveScanTotals.missing == 0) then
1730 showTitle = link..XPERL_CHECK_REPORT_NOTEQUIPED
1731 else
1732 showTitle = link..getglobal("XPERL_CHECK_REPORT_WITHOUT"..equipable)
1733 end
1734 if (getn(without) > 0) then
1735 showList = without
1736 end
1737 end
1738  
1739 if (showList) then
1740 msg = showTitle
1741 local msgLocal = showTitle
1742 local first = true
1743  
1744 for k,v in ipairs(showList) do
1745 local name = XPerlColourTable[v.class]..v.name.."|r"
1746  
1747 if (strlen(msg) + strlen(name) > 240) then
1748 ReportOutput(msg.."...")
1749 DEFAULT_CHAT_FRAME:AddMessage("<X-Perl> "..msgLocal)
1750 msg = " ... "..v.name
1751 msgLocal = " ... "..name
1752 else
1753 if (first) then
1754 msg = msg..v.name
1755 msgLocal = msgLocal..name
1756 first = nil
1757 else
1758 msg = msg..", "..v.name
1759 msgLocal = msgLocal..", "..name
1760 end
1761 end
1762 end
1763  
1764 if (msg) then
1765 ReportOutput(msg)
1766 end
1767 if (msgLocal) then
1768 DEFAULT_CHAT_FRAME:AddMessage("<X-Perl> "..msgLocal)
1769 end
1770 elseif (showTitle) then
1771 DEFAULT_CHAT_FRAME:AddMessage("<X-Perl> "..showTitle..NONE)
1772 end
1773 else
1774 msg = link.." "
1775  
1776 local function Out(txt, num)
1777 if (num > 0) then
1778 msg = msg..string.format(txt, num)
1779 end
1780 end
1781  
1782 if (ActiveScanTotals) then -- and ActiveScanTotals.missing == 0) then
1783 Out(XPERL_CHECK_REPORT_EQUIPEDSHORT, ActiveScanTotals.equipped)
1784 Out(XPERL_CHECK_REPORT_NOTEQUIPEDSHORT, ActiveScanTotals.notequipped)
1785 Out(XPERL_CHECK_REPORT_OFFLINE, ActiveScanTotals.offline)
1786 Out(XPERL_CHECK_REPORT_NOTSCANNED, ActiveScanTotals.missing + ActiveScanTotals.wrongZone)
1787 else
1788 Out(XPERL_CHECK_REPORT_WITHSHORT, getn(with))
1789 Out(XPERL_CHECK_REPORT_WITHOUTSHORT, getn(without))
1790 Out(" : %d "..XPERL_LOC_OFFLINE, getn(offline))
1791 end
1792  
1793 if (link ~= "reg") then
1794 Out(XPERL_CHECK_REPORT_TOTAL, totalItems)
1795 end
1796  
1797 ReportOutput(msg)
1798 end
1799 end
1800 end
1801 end
1802 end
1803 end
1804  
1805 -- XPerl_Check_PlayerOnClick
1806 function XPerl_Check_PlayerOnClick(button)
1807  
1808 local index = this:GetID() + XPerl_CheckListPlayersScrollBar.offset
1809  
1810 if (index < 1 or index > getn(XPerl_PlayerList)) then
1811 return
1812 end
1813  
1814 if (SelectedPlayer == XPerl_PlayerList[index].name) then
1815 SelectedPlayer = nil
1816 else
1817 SelectedPlayer = XPerl_PlayerList[index].name
1818 end
1819  
1820 XPerl_Check_UpdatePlayerList()
1821  
1822 if (button == "LeftButton") then
1823 TargetUnit(XPerl_PlayerList[index].unit)
1824 end
1825  
1826 SetPortraitTexture(XPerl_CheckButtonPlayerPortrait, XPerl_PlayerList[index].unit)
1827  
1828 XPerl_Check_ValidateButtons()
1829  
1830 --if (button == "RightButton") then
1831 -- ToggleDropDownMenu(1, nil, XPerl_CheckDropDown)
1832 --end
1833 end
1834  
1835 -- XPerl_Check_StopActiveScan
1836 function XPerl_Check_StopActiveScan()
1837 XPerl_Check:UnregisterEvent("UNIT_INVENTORY_CHANGED")
1838 XPerl_Check:UnregisterEvent("UNIT_MODEL_CHANGED")
1839 ActiveScanItem = nil
1840 end
1841  
1842 -- XPerl_Check_StartActiveScan
1843 function XPerl_Check_StartActiveScan()
1844  
1845 if (ActiveScanItem) then
1846 XPerl_Check_StopActiveScan()
1847 else
1848 local itemId, itemSlot = GetActiveScanItem()
1849 if (itemId) then
1850 XPerl_ActiveScan = {}
1851  
1852 ActiveScanItem = {id = itemId, slot = itemSlot, missing = GetNumRaidMembers()}
1853 ActiveScanTotals = {missing = 0, equipped = 0, notequipped = 0, offline = 0, wrongZone = 0}
1854  
1855 XPerl_Check:SetScript("OnUpdate", XPerl_CheckOnUpdate)
1856 XPerl_Check:RegisterEvent("UNIT_INVENTORY_CHANGED")
1857 XPerl_Check:RegisterEvent("UNIT_MODEL_CHANGED")
1858  
1859 XPerl_CheckListPlayersTitleDur:SetText(XPERL_CHECK_EQUIPED)
1860 XPerl_CheckListPlayersTitleDur:Show()
1861 end
1862 end
1863  
1864 XPerl_Check_ValidateButtons()
1865 end
1866  
1867 -- XPerl_Check_ActiveScan
1868 function XPerl_Check_ActiveScan()
1869  
1870 local function CheckSlot(unit, slot)
1871 local link = GetInventoryItemLink(unit, slot)
1872 local eq
1873 local name = UnitName(unit)
1874  
1875 if (link) then
1876 local _,_, itemId = strfind(link, "item:(%d+):")
1877 if (itemId) then
1878 itemId = tonumber(itemId)
1879  
1880 if (itemId == ActiveScanItem.id) then
1881 if (not XPerl_ActiveScan[name]) then
1882 XPerl_ActiveScan[name] = {}
1883 end
1884  
1885 XPerl_ActiveScan[name].notequipped = nil
1886 XPerl_ActiveScan[name].equipped = 1
1887 return true
1888 end
1889 end
1890 end
1891  
1892 if (not XPerl_ActiveScan[name]) then
1893 XPerl_ActiveScan[name] = {}
1894 end
1895 XPerl_ActiveScan[name].equipped = nil
1896 XPerl_ActiveScan[name].notequipped = 1
1897 end
1898  
1899 local myZone = GetRealZoneText()
1900  
1901 local any
1902 local update
1903 ActiveScanTotals = {missing = 0, equipped = 0, notequipped = 0, offline = 0, wrongZone = 0}
1904 for i = 1,GetNumRaidMembers() do
1905 local name, rank, subgroup, level, _, class, zone, online, isDead = GetRaidRosterInfo(i)
1906 local unit = "raid"..i
1907 local new
1908 local myScan = XPerl_ActiveScan[name]
1909  
1910 if (not myScan or myScan.changed) then
1911 if (myScan) then
1912 myScan.changed = nil
1913 end
1914 any = true
1915 if (CheckInteractDistance(unit, 1)) then -- Checks to see if in inspect range
1916 local eq
1917 if (type(ActiveScanItem.slot) == "table") then
1918 for k,v in ActiveScanItem.slot do
1919 if (CheckSlot(unit, v)) then
1920 eq = true
1921 break
1922 end
1923 end
1924 else
1925 eq = CheckSlot(unit, ActiveScanItem.slot)
1926 end
1927  
1928 if (eq) then
1929 ActiveScanTotals.equipped = ActiveScanTotals.equipped + 1
1930 else
1931 ActiveScanTotals.notequipped = ActiveScanTotals.notequipped + 1
1932 end
1933 update = true
1934  
1935 elseif (not UnitIsConnected(unit)) then
1936 if (not XPerl_ActiveScan[name]) then
1937 XPerl_ActiveScan[name] = {}
1938 end
1939  
1940 XPerl_ActiveScan[name].offline = 1
1941 ActiveScanTotals.offline = ActiveScanTotals.offline + 1
1942 update = true
1943  
1944 elseif (zone ~= myZone) then
1945 if (not XPerl_ActiveScan[name]) then
1946 XPerl_ActiveScan[name] = {}
1947 end
1948  
1949 XPerl_ActiveScan[name].notinzone = 1
1950 ActiveScanTotals.wrongZone = ActiveScanTotals.wrongZone + 1
1951 update = true
1952  
1953 else
1954 ActiveScanTotals.missing = ActiveScanTotals.missing + 1
1955 end
1956 else
1957 ActiveScanTotals.missing = ActiveScanTotals.missing + (myScan.missing or 0)
1958 ActiveScanTotals.equipped = ActiveScanTotals.equipped + (myScan.equipped or 0)
1959 ActiveScanTotals.notequipped = ActiveScanTotals.notequipped + (myScan.notequipped or 0)
1960 ActiveScanTotals.offline = ActiveScanTotals.offline + (myScan.offline or 0)
1961 ActiveScanTotals.wrongZone = ActiveScanTotals.wrongZone + (myScan.notinzone or 0)
1962 end
1963 end
1964  
1965 XPerl_Check_ShowInfo()
1966  
1967 if (update) then
1968 sort(XPerl_PlayerList, SortPlayersByDur) -- It's actually by equipped, that's sorted out in sort func
1969 XPerl_Check_UpdatePlayerList()
1970 XPerl_Check_ValidateButtons()
1971 end
1972  
1973 --if (not any) then
1974 -- ActiveScanItem = nil
1975 -- XPerl_Check_ValidateButtons()
1976 --end
1977 end
1978  
1979 --[[
1980  
1981 -- XPerl_Check_PlayerDropDown_OnLoad
1982 function XPerl_Check_PlayerDropDown_OnLoad()
1983 this.playerCheckDropDown = true;
1984 UIDropDownMenu_Initialize(this, XPerl_Check_PlayerDropDown_Initialize, "MENU");
1985 UIDropDownMenu_SetAnchor(0, 0, this, "TOPLEFT", this:GetName(), "CENTER")
1986 end
1987  
1988 -- XPerl_Check_PlayerDropDown_Initialize
1989 function XPerl_Check_PlayerDropDown_Initialize()
1990 if ( not UIDROPDOWNMENU_OPEN_MENU or not getglobal(UIDROPDOWNMENU_OPEN_MENU).playerCheckDropDown ) then
1991 return;
1992 end
1993  
1994 --local selectedUnit = XPerl_PlayerList[SelectedPlayer]
1995 local info
1996  
1997 -- Show buffs or debuffs they are exclusive for now
1998 info = {}
1999 info.text = "Target"
2000 info.func = function()
2001 TargetUnit(selectedUnit)
2002 end
2003 UIDropDownMenu_AddButton(info)
2004  
2005 info = {}
2006 info.text = "Has Equiped Item"
2007 info.func = function()
2008 XPerl_CheckPlayerEquiped(selectedUnit)
2009 end;
2010 UIDropDownMenu_AddButton(info)
2011 end
2012  
2013 ]]