vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local dewdrop = DewdropLib:GetInstance('1.0');
2 local tablet = TabletLib:GetInstance('1.0');
3 local metrognome = Metrognome:GetInstance("1");
4 local babble = BabbleLib:GetInstance("1.0");
5  
6 GroupFu = FuBarPlugin:new({
7 name = GroupFuLocals.NAME,
8 description = GroupFuLocals.DESCRIPTION,
9 version = "1.4.7.4",
10 releaseDate = "2006-07-10",
11 aceCompatible = 103,
12 fuCompatible = 102,
13 author = "Etten",
14 email = "idbrain@gmail.com",
15 website = "http://etten.wowinterface.com",
16 category = "interface",
17 db = AceDatabase:new("GroupFuDB"),
18 defaults = {
19 RollOnClick = true,
20 ShowMLName = false,
21 OutputChannel = "PARTY",
22 OutputDetail = "SHORT",
23 ClearTimer = 30,
24 StandardRollsOnly = true,
25 ShowRollCount = false,
26 AnnounceRollCountdown = false,
27 IgnoreDuplicates = true,
28 DeleteRolls = true,
29 ShowClassLevel = false,
30 TextMode = "GROUPFU",
31 LootColorTable = {}
32 },
33 hasIcon = GroupFuLocals.DEFAULT_ICON,
34 clickableTooltip = true,
35 cannotDetachTooltip = false,
36 canHideText = true,
37 updateTime = 1.0,
38  
39 -- Localization Tags
40 loc = GroupFuLocals,
41  
42 ENDGROUPFU = true
43 });
44  
45 function GroupFu:Initialize()
46  
47 if self.data.version < self.versionNumber then
48 self.data.Colors = nil;
49 self.data.Rolls = nil;
50 self.data.RollCount = nil;
51 self.data.Threshold = nil;
52 self.data.LootType = nil;
53 end
54  
55 if not self.tmpdata then
56 self.tmpdata = {};
57 end
58  
59 end
60  
61 function GroupFu:Enable()
62 self:RegisterEvent("CHAT_MSG_SYSTEM");
63 self:RegisterEvent("PARTY_MEMBERS_CHANGED", "Update");
64 self:RegisterEvent("PARTY_LOOT_METHOD_CHANGED", "Update");
65 self:RegisterEvent("RAID_ROSTER_UPDATE", "Update");
66  
67 if not self.data.LootColorTable or table.getn(self.data.LootColorTable) == 0 then
68 for i=0,6 do
69 local r, g, b, hex = GetItemQualityColor(i);
70 self.data.LootColorTable[i] =
71 {
72 Red = r,
73 Green = g,
74 Blue = b,
75 Hex = hex,
76 Threshold = i,
77 Desc = getglobal("ITEM_QUALITY".. i .. "_DESC")
78 };
79 end
80 end
81  
82 self:ClearRolls();
83 self.tmpdata.TimeSinceLastRoll = 0;
84 metrognome:Register("MGtimer", self.CheckRollTimeout, self.updateTime, self);
85 metrognome:Start("MGtimer");
86 end
87  
88 function GroupFu:Disable()
89 self:ClearRolls();
90 metrognome:Stop("MGtimer");
91 end
92  
93 function GroupFu:MenuSettings(level, value, inTooltip)
94 if not inTooltip then
95 if level == 1 then
96  
97 dewdrop:AddLine(
98 'text', self.loc.MENU_OUTPUT,
99 'value', "MENU_OUTPUT",
100 'hasArrow', true
101 );
102  
103 dewdrop:AddLine(
104 'text', self.loc.MENU_CLEAR,
105 'value', "MENU_CLEAR",
106 'hasArrow', true
107 );
108  
109 dewdrop:AddLine(
110 'text', self.loc.MENU_DETAIL,
111 'value', "MENU_DETAIL",
112 'hasArrow', true
113 );
114  
115 dewdrop:AddLine(
116 'text', self.loc.MENU_MODE,
117 'value', "MENU_MODE",
118 'hasArrow', true
119 );
120  
121 dewdrop:AddLine(
122 'text', self.loc.MENU_PERFORMROLL,
123 'value', self.loc.MENU_PERFORMROLL,
124 'func', function() self:ToggleOption("RollOnClick") end,
125 'checked', self.data.RollOnClick
126 );
127  
128 dewdrop:AddLine(
129 'text', self.loc.MENU_STANDARDROLLSONLY,
130 'value', self.loc.MENU_STANDARDROLLSONLY,
131 'func', function() self:ToggleOption("StandardRollsOnly") end,
132 'checked', self.data.StandardRollsOnly
133 );
134  
135 dewdrop:AddLine(
136 'text', self.loc.MENU_SHOWROLLCOUNT,
137 'value', self.loc.MENU_SHOWROLLCOUNT,
138 'func', function() self:ToggleOption("ShowRollCount") end,
139 'checked', self.data.ShowRollCount
140 );
141  
142 dewdrop:AddLine(
143 'text', self.loc.MENU_IGNOREDUPES,
144 'value', self.loc.MENU_IGNOREDUPES,
145 'func', function() self:ToggleOption("IgnoreDuplicates") end,
146 'checked', self.data.IgnoreDuplicates
147 );
148  
149 dewdrop:AddLine(
150 'text', self.loc.MENU_AUTODELETE,
151 'value', self.loc.MENU_AUTODELETE,
152 'func', function() self:ToggleOption("DeleteRolls") end,
153 'checked', self.data.DeleteRolls
154 );
155  
156 dewdrop:AddLine(
157 'text', self.loc.MENU_ANNOUNCEROLLCOUNTDOWN,
158 'value', self.loc.MENU_ANNOUNCEROLLCOUNTDOWN,
159 'func', function() self:ToggleOption("AnnounceRollCountdown") end,
160 'checked', self.data.AnnounceRollCountdown
161 );
162  
163 dewdrop:AddLine(
164 'text', self.loc.MENU_SHOWCLASSLEVEL,
165 'value', self.loc.MENU_SHOWCLASSLEVEL,
166 'func', function() self:ToggleOption("ShowClassLevel") end,
167 'checked', self.data.ShowClassLevel
168 );
169  
170 dewdrop:AddLine(
171 'text', self.loc.MENU_SHOWMLNAME,
172 'value', self.loc.MENU_SHOWMLNAME,
173 'func', function() self:ToggleOption("ShowMLName") end,
174 'checked', self.data.ShowMLName
175 );
176  
177 dewdrop:AddLine(
178 'text', self.loc.MENU_GROUP,
179 'value', "MENU_GROUP",
180 'hasArrow', true
181 );
182  
183 elseif level == 2 then
184  
185 if value == "MENU_OUTPUT" then
186  
187 dewdrop:AddLine(
188 'text', self.loc.MENU_OUTPUT_AUTO,
189 'value', "AUTO",
190 'func', function() self:ToggleOutputChannel("AUTO") end,
191 'isRadio', true,
192 'checked', self:IsOutputChannel("AUTO")
193 );
194  
195 dewdrop:AddLine(
196 'text', self.loc.MENU_OUTPUT_LOCAL,
197 'value', "LOCAL",
198 'func', function() self:ToggleOutputChannel("LOCAL") end,
199 'isRadio', true,
200 'checked', self:IsOutputChannel("LOCAL")
201 );
202  
203 dewdrop:AddLine(
204 'text', self.loc.MENU_OUTPUT_SAY,
205 'value', "SAY",
206 'func', function() self:ToggleOutputChannel("SAY") end,
207 'isRadio', true,
208 'checked', self:IsOutputChannel("SAY")
209 );
210  
211 dewdrop:AddLine(
212 'text', self.loc.MENU_OUTPUT_PARTY,
213 'value', "PARTY",
214 'func', function() self:ToggleOutputChannel("PARTY") end,
215 'isRadio', true,
216 'checked', self:IsOutputChannel("PARTY")
217 );
218  
219 dewdrop:AddLine(
220 'text', self.loc.MENU_OUTPUT_RAID,
221 'value', "RAID",
222 'func', function() self:ToggleOutputChannel("RAID") end,
223 'isRadio', true,
224 'checked', self:IsOutputChannel("RAID")
225 );
226  
227 dewdrop:AddLine(
228 'text', self.loc.MENU_OUTPUT_GUILD,
229 'value', "GUILD",
230 'func', function() self:ToggleOutputChannel("GUILD") end,
231 'isRadio', true,
232 'checked', self:IsOutputChannel("GUILD")
233 );
234  
235 elseif value == "MENU_CLEAR" then
236  
237 dewdrop:AddLine(
238 'text', self.loc.MENU_CLEAR_NEVER,
239 'value', 0,
240 'func', function() self:ToggleClearTimer(0) end,
241 'isRadio', true,
242 'checked', self:IsClearTimer(0)
243 );
244  
245 dewdrop:AddLine(
246 'text', self.loc.MENU_CLEAR_15SEC,
247 'value', 15,
248 'func', function() self:ToggleClearTimer(15) end,
249 'isRadio', true,
250 'checked', self:IsClearTimer(15)
251 );
252  
253 dewdrop:AddLine(
254 'text', self.loc.MENU_CLEAR_30SEC,
255 'value', 30,
256 'func', function() self:ToggleClearTimer(30) end,
257 'isRadio', true,
258 'checked', self:IsClearTimer(30)
259 );
260  
261 dewdrop:AddLine(
262 'text', self.loc.MENU_CLEAR_45SEC,
263 'value', 45,
264 'func', function() self:ToggleClearTimer(45) end,
265 'isRadio', true,
266 'checked', self:IsClearTimer(45)
267 );
268  
269 dewdrop:AddLine(
270 'text', self.loc.MENU_CLEAR_60SEC,
271 'value', 60,
272 'func', function() self:ToggleClearTimer(60) end,
273 'isRadio', true,
274 'checked', self:IsClearTimer(60)
275 );
276  
277 elseif value == "MENU_DETAIL" then
278  
279 dewdrop:AddLine(
280 'text', self.loc.MENU_DETAIL_SHORT,
281 'value', "SHORT",
282 'func', function() self:ToggleOutputDetail("SHORT") end,
283 'isRadio', true,
284 'checked', self:IsOutputDetail("SHORT")
285 );
286  
287 dewdrop:AddLine(
288 'text', self.loc.MENU_DETAIL_LONG,
289 'value', "LONG",
290 'func', function() self:ToggleOutputDetail("LONG") end,
291 'isRadio', true,
292 'checked', self:IsOutputDetail("LONG")
293 );
294  
295 dewdrop:AddLine(
296 'text', self.loc.MENU_DETAIL_FULL,
297 'value', "FULL",
298 'func', function() self:ToggleOutputDetail("FULL") end,
299 'isRadio', true,
300 'checked', self:IsOutputDetail("FULL")
301 );
302  
303 elseif value == "MENU_MODE" then
304  
305 dewdrop:AddLine(
306 'text', self.loc.MENU_MODE_GROUPFU,
307 'value', "GROUPFU",
308 'func', function() self:ToggleTextMode("GROUPFU") end,
309 'isRadio', true,
310 'checked', self:IsTextMode("GROUPFU")
311 );
312  
313 dewdrop:AddLine(
314 'text', self.loc.MENU_MODE_ROLLSFU,
315 'value', "ROLLSFU",
316 'func', function() self:ToggleTextMode("ROLLSFU") end,
317 'isRadio', true,
318 'checked', self:IsTextMode("ROLLSFU")
319 );
320  
321 dewdrop:AddLine(
322 'text', self.loc.MENU_MODE_LOOTTYFU,
323 'value', "LOOTTYFU",
324 'func', function() self:ToggleTextMode("LOOTTYFU") end,
325 'isRadio', true,
326 'checked', self:IsTextMode("LOOTTYFU")
327 );
328  
329 elseif value == "MENU_GROUP" then
330  
331 dewdrop:AddLine(
332 'text', self.loc.MENU_GROUP_LEAVE,
333 'value', "MENU_GROUP_LEAVE",
334 'func', function() LeaveParty() end,
335 'notCheckable', true
336 );
337  
338 if IsPartyLeader() or IsRaidLeader() then
339  
340 dewdrop:AddLine(
341 'text', self.loc.MENU_GROUP_RAID,
342 'value', "MENU_GROUP_RAID",
343 'func', function() ConvertToRaid() end,
344 'notCheckable', true
345 );
346  
347 dewdrop:AddLine(
348 'text', self.loc.MENU_GROUP_LOOT,
349 'value', "MENU_GROUP_LOOT",
350 'hasArrow', true
351 );
352  
353 dewdrop:AddLine(
354 'text', self.loc.MENU_GROUP_THRESHOLD,
355 'value', "MENU_GROUP_THRESHOLD",
356 'hasArrow', true
357 );
358  
359 end
360 end
361  
362 elseif level == 3 then
363  
364 if value == "MENU_GROUP_LOOT" then
365  
366 dewdrop:AddLine(
367 'text', self.loc.TEXT_GROUP,
368 'value', "TEXT_GROUP",
369 'func', function() self:SetLootType("group") end,
370 'isRadio', true,
371 'checked', self:IsLootType("group")
372 );
373  
374 dewdrop:AddLine(
375 'text', self.loc.TEXT_FFA,
376 'value', "TEXT_FFA",
377 'func', function() self:SetLootType("freeforall") end,
378 'isRadio', true,
379 'checked', self:IsLootType("freeforall")
380 );
381  
382 dewdrop:AddLine(
383 'text', self.loc.TEXT_MASTER,
384 'value', "TEXT_MASTER",
385 'func', function() self:SetLootType("master") end,
386 'isRadio', true,
387 'checked', self:IsLootType("master")
388 );
389  
390 dewdrop:AddLine(
391 'text', self.loc.TEXT_NBG,
392 'value', "TEXT_NBG",
393 'func', function() self:SetLootType("needbeforegreed") end,
394 'isRadio', true,
395 'checked', self:IsLootType("needbeforegreed")
396 );
397  
398 dewdrop:AddLine(
399 'text', self.loc.TEXT_RR,
400 'value', "TEXT_RR",
401 'func', function() self:SetLootType("roundrobin") end,
402 'isRadio', true,
403 'checked', self:IsLootType("roundrobin")
404 );
405  
406 elseif value == "MENU_GROUP_THRESHOLD" then
407 local mnuGroupThrshldDesc, mnuGroupThrshldThrshld, mnuGroupThrshldHex
408 for j=0,6 do
409  
410 mnuGroupThrshldDesc = self.data.LootColorTable[j].Desc;
411 mnuGroupThrshldThrshld = self.data.LootColorTable[j].Threshold;
412 mnuGroupThrshldHex = self.data.LootColorTable[j].Hex;
413  
414 dewdrop:AddLine(
415 'text', format("%s%s", mnuGroupThrshldHex, mnuGroupThrshldDesc .. "(" .. mnuGroupThrshldThrshld .. ")"),
416 'func', function(val) self:SetLootThreshold(val) end,
417 'arg1', mnuGroupThrshldThrshld,
418 'isRadio', true,
419 'checked', self:IsLootThreshold(mnuGroupThrshldThrshld)
420 );
421  
422 end
423 end
424 end
425 end
426 end
427  
428 function GroupFu:UpdateData()
429 if (GetNumPartyMembers() > 0) or (GetNumRaidMembers() > 0) then
430 self.tmpdata.LootType = GetLootMethod();
431 self.tmpdata.Threshold = GetLootThreshold();
432 else
433 self.tmpdata.LootType, self.tmpdata.Threshold = nil, nil;
434 end
435  
436 local i, highRoll, rollLink;
437 highRoll = 0;
438 if(self.tmpdata.RollCount > 0) then
439  
440 for i = 1, self.tmpdata.RollCount do
441  
442 if ((self.tmpdata.Rolls[i].Roll > highRoll) and ((not self.data.StandardRollsOnly) or ((self.tmpdata.Rolls[i].Min == 1) and (self.tmpdata.Rolls[i].Max == 100)))) then
443  
444 highRoll = self.tmpdata.Rolls[i].Roll;
445 rollLink = i;
446  
447 end
448 end
449  
450 self.tmpdata.LastWinner = self.tmpdata.Rolls[rollLink].Player .. " [" .. FuBarUtils.Colorize("00FF00", highRoll) .. "]";
451  
452 if((self.tmpdata.Rolls[rollLink].Min ~= 1) or (self.tmpdata.Rolls[rollLink].Max ~= 100)) then
453  
454 self.tmpdata.LastWinner = self.tmpdata.LastWinner .. " (" .. self.tmpdata.Rolls[rollLink].Min .. "-" .. self.tmpdata.Rolls[rollLink].Max .. ")";
455  
456 end
457  
458 else
459  
460 self.tmpdata.LastWinner = nil;
461  
462 end
463 end
464  
465 function GroupFu:UpdateText()
466 if self.data.TextMode == "ROLLSFU" then
467  
468 if self.tmpdata.LastWinner ~= nil then
469  
470 if self.data.ShowRollCount then
471  
472 if GetNumRaidMembers() > 0 then
473  
474 self:SetText( string.format(self.loc.FORMAT_TEXT_ROLLCOUNT, self.tmpdata.LastWinner, self.tmpdata.RollCount, GetNumRaidMembers()) );
475  
476 elseif GetNumPartyMembers() > 0 then
477  
478 self:SetText( string.format(self.loc.FORMAT_TEXT_ROLLCOUNT, self.tmpdata.LastWinner, self.tmpdata.RollCount, GetNumPartyMembers()+1) );
479  
480 else
481  
482 self:SetText(self.tmpdata.LastWinner);
483  
484 end
485  
486 else
487  
488 self:SetText(self.tmpdata.LastWinner);
489  
490 end
491  
492 else
493  
494 self:SetText(self.loc.TEXT_NOROLLS);
495  
496 end
497  
498 elseif self.data.TextMode == "LOOTTYFU" then
499  
500 if self.tmpdata.LootType == solo then
501 self:SetText(string.format("%s%s", "|cff888888", self:GetLootTypeText()));
502 else
503 if not self.tmpdata.Threshold then
504 self:UpdateData();
505 end
506 self:SetText(string.format("%s%s", self.data.LootColorTable[self.tmpdata.Threshold].Hex, self:GetLootTypeText()));
507 end
508  
509 else
510  
511 if self.tmpdata.LastWinner ~= nil then
512  
513 if self.data.ShowRollCount then
514  
515 if GetNumRaidMembers() > 0 then
516  
517 self:SetText( string.format(self.loc.FORMAT_TEXT_ROLLCOUNT, self.tmpdata.LastWinner, self.tmpdata.RollCount, GetNumRaidMembers()) );
518  
519 elseif GetNumPartyMembers() > 0 then
520  
521 self:SetText( string.format(self.loc.FORMAT_TEXT_ROLLCOUNT, self.tmpdata.LastWinner, self.tmpdata.RollCount, GetNumPartyMembers()+1) );
522  
523 else
524  
525 self:SetText(self.tmpdata.LastWinner);
526  
527 end
528  
529 else
530  
531 self:SetText(self.tmpdata.LastWinner);
532  
533 end
534  
535 else
536  
537 if self.tmpdata.LootType == solo then
538 self:SetText(string.format("%s%s", "|cff888888", self:GetLootTypeText()));
539 else
540 if not self.tmpdata.Threshold then
541 self:UpdateData();
542 end
543 self:SetText(string.format("%s%s", self.data.LootColorTable[self.tmpdata.Threshold].Hex, self:GetLootTypeText()));
544 end
545  
546 end
547 end
548 end
549  
550 function GroupFu:UpdateTooltip()
551  
552 local cat;
553  
554 cat = tablet:AddCategory(
555 'text', self.loc.TOOLTIP_CAT_LOOTING,
556 'columns', 2
557 );
558  
559 if self.tmpdata.LootType == "group" then
560  
561 if not self.tmpdata.Threshold then
562 self:UpdateData();
563 end
564 cat:AddLine(
565 'text', self.loc.TOOLTIP_METHOD .. ":",
566 'text2', string.format("%s%s", self.data.LootColorTable[self.tmpdata.Threshold].Hex, self.loc.TEXT_GROUP)
567 );
568  
569 elseif self.tmpdata.LootType == "master" then
570  
571 if self.data.ShowMLName and self.tmpdata.MLName then
572  
573 if not self.tmpdata.Threshold then
574 self:UpdateData();
575 end
576 cat:AddLine(
577 'text', self.loc.TOOLTIP_METHOD .. ":",
578 'text2', string.format("%s%s", self.data.LootColorTable[self.tmpdata.Threshold].Hex, self.loc.TEXT_MASTER .. "(" .. self.tmpdata.MLName .. ")")
579 );
580  
581 else
582  
583 if not self.tmpdata.Threshold then
584 self:UpdateData();
585 end
586 cat:AddLine(
587 'text', self.loc.TOOLTIP_METHOD .. ":",
588 'text2', string.format("%s%s", self.data.LootColorTable[self.tmpdata.Threshold].Hex, self.loc.TEXT_MASTER)
589 );
590  
591 end
592  
593 elseif self.tmpdata.LootType == "freeforall" then
594  
595 if not self.tmpdata.Threshold then
596 self:UpdateData();
597 end
598 cat:AddLine(
599 'text', self.loc.TOOLTIP_METHOD .. ":",
600 'text2', string.format("%s%s", self.data.LootColorTable[self.tmpdata.Threshold].Hex, self.loc.TEXT_FFA)
601 );
602  
603 elseif self.tmpdata.LootType == "roundrobin" then
604  
605 if not self.tmpdata.Threshold then
606 self:UpdateData();
607 end
608 cat:AddLine(
609 'text', self.loc.TOOLTIP_METHOD .. ":",
610 'text2', string.format("%s%s", self.data.LootColorTable[self.tmpdata.Threshold].Hex, self.loc.TEXT_RR)
611 );
612  
613 elseif self.tmpdata.LootType == "needbeforegreed" then
614  
615 if not self.tmpdata.Threshold then
616 self:UpdateData();
617 end
618 cat:AddLine(
619 'text', self.loc.TOOLTIP_METHOD .. ":",
620 'text2', string.format("%s%s", self.data.LootColorTable[self.tmpdata.Threshold].Hex, self.loc.TEXT_NBG)
621 );
622  
623 else
624  
625 if not self.tmpdata.Threshold then
626 self:UpdateData();
627 end
628 cat:AddLine(
629 'text', self.loc.TOOLTIP_METHOD .. ":",
630 'text2', string.format("%s%s", "|cff888888", self.loc.TEXT_SOLO)
631 );
632  
633 end
634  
635 cat = tablet:AddCategory(
636 'text', self.loc.TOOLTIP_CAT_ROLLS,
637 'columns', 2
638 );
639  
640 if(self.tmpdata.RollCount > 0) then
641  
642 local a, b, highRoll, rollLink, tallied, color, l, r;
643  
644 if self.data.ShowRollCount then
645  
646 if GetNumRaidMembers() > 0 then
647  
648 cat:AddLine(
649 'text', string.format(self.loc.FORMAT_TOOLTIP_ROLLCOUNT, self.tmpdata.RollCount, GetNumRaidMembers() )
650 );
651  
652 elseif GetNumPartyMembers() > 0 then
653  
654 cat:AddLine(
655 'text', string.format(self.loc.FORMAT_TOOLTIP_ROLLCOUNT, self.tmpdata.RollCount, GetNumPartyMembers()+1 )
656 );
657  
658 end
659  
660 end
661  
662 tallied = {};
663 for a=1,self.tmpdata.RollCount do
664 tallied[a] = 0;
665 end
666  
667 for a=1,self.tmpdata.RollCount do
668  
669 highRoll = 0;
670 rollLink = 0;
671 for b=1,self.tmpdata.RollCount do
672  
673 if((self.data.StandardRollsOnly) and ((self.tmpdata.Rolls[b].Min ~= 1) or (self.tmpdata.Rolls[b].Max ~= 100))) then
674  
675 tallied[b] = 1;
676  
677 end
678  
679 if((self.tmpdata.Rolls[b].Roll > highRoll) and (tallied[b] == 0)) then
680  
681 highRoll = self.tmpdata.Rolls[b].Roll;
682 rollLink = b;
683  
684 end
685  
686 end
687  
688 if(rollLink ~= 0) then
689  
690 r = self.tmpdata.Rolls[rollLink].Player;
691 if(self.data.ShowClassLevel) then
692  
693 local hexcolor = babble.GetClassHexColor(self.tmpdata.Rolls[rollLink].Class);
694 r = string.format("|cff%s%s %d %s%s", hexcolor, r, self.tmpdata.Rolls[rollLink].Level, string.sub(self.tmpdata.Rolls[rollLink].Class,1,1), string.lower(string.sub(self.tmpdata.Rolls[rollLink].Class,2)));
695  
696 end
697  
698 l = self.tmpdata.Rolls[rollLink].Roll;
699 if((self.tmpdata.Rolls[rollLink].Min ~= 1) or (self.tmpdata.Rolls[rollLink].Max ~= 100)) then
700  
701 l = l .. " (" .. self.tmpdata.Rolls[rollLink].Min .. "-" .. self.tmpdata.Rolls[rollLink].Max .. ")";
702  
703 end
704  
705 cat:AddLine(
706 'text', r,
707 'text2', l
708 );
709  
710 tallied[rollLink] = 1;
711  
712 end
713 end
714  
715 else
716  
717 cat:AddLine (
718 'text', self.loc.TEXT_NOROLLS,
719 'text2', ""
720 );
721  
722 end
723  
724 if(self.data.RollOnClick) then
725  
726 tablet:SetHint(self.loc.TOOLTIP_HINT_ROLLS);
727  
728 else
729  
730 tablet:SetHint(self.loc.TOOLTIP_HINT_NOROLLS);
731  
732 end
733 end
734  
735 function GroupFu:OnClick()
736  
737 if(IsControlKeyDown()) then
738  
739 if(self.tmpdata.RollCount > 0) then
740  
741 local i, highRoll, highRoller;
742  
743 highRoll = 0;
744 highRoller = "";
745 for i = 1, self.tmpdata.RollCount do
746  
747 if ((self.tmpdata.Rolls[i].Roll > highRoll) and ((not self.data.StandardRollsOnly) or ((self.tmpdata.Rolls[i].Min == 1) and (self.tmpdata.Rolls[i].Max == 100)))) then
748  
749 highRoll = self.tmpdata.Rolls[i].Roll;
750 highRoller = self.tmpdata.Rolls[i].Player;
751  
752 end
753 end
754  
755 -- Output the winner to the specified output channel
756 self:AnnounceOutput(format(self.loc.FORMAT_ANNOUNCE_WIN, highRoller, highRoll, self.tmpdata.RollCount));
757  
758 if((self.data.OutputDetail == "LONG") or (self.data.OutputDetail == "FULL")) then
759 local a, b, rollLink, tallied, message, count;
760  
761 tallied = {};
762 count = 0;
763 message = "";
764  
765 for a=1,self.tmpdata.RollCount do
766 tallied[a] = 0;
767 end
768  
769 for a=1,self.tmpdata.RollCount do
770 highRoll = 0;
771 rollLink = 0;
772  
773 for b=1,self.tmpdata.RollCount do
774  
775 if((self.data.StandardRollsOnly) and ((self.tmpdata.Rolls[b].min ~= 1) or (self.tmpdata.Rolls[b].max ~= 100))) then
776  
777 tallied[b] = 1;
778  
779 end
780  
781 if((self.tmpdata.Rolls[b].Roll > highRoll) and (tallied[b] == 0)) then
782  
783 highRoll = self.tmpdata.Rolls[b].Roll;
784 rollLink = b;
785  
786 end
787 end
788  
789 if(rollLink ~= 0) then
790  
791 message = message .. "#" .. a .. " " .. self.tmpdata.Rolls[rollLink].Player .. " [" .. self.tmpdata.Rolls[rollLink].Roll .. "]";
792 if((self.data.OutputDetail == "FULL") and ((self.tmpdata.Rolls[rollLink].Min ~= 1) or (self.tmpdata.Rolls[rollLink].Max ~= 100))) then
793  
794 message = message .. " (" .. self.tmpdata.Rolls[rollLink].Min .. "-" .. self.tmpdata.Rolls[rollLink].Max .. ")";
795  
796 end
797 message = message .. ", ";
798 count = count + 1;
799 tallied[rollLink] = 1;
800  
801 end
802  
803 if((count == 10) or (a == self.tmpdata.RollCount)) then
804  
805 message = string.sub(message, 1, -3);
806 self:AnnounceOutput(message);
807 message = "";
808 count = 0;
809  
810 end
811 end
812 end
813  
814 if(self.data.DeleteRolls) then
815  
816 self:ClearRolls();
817  
818 end
819 end
820  
821 elseif(IsShiftKeyDown()) then
822  
823 self:ClearRolls();
824  
825 else
826  
827 if(self.data.RollOnClick) then
828  
829 RandomRoll("1", "100");
830  
831 end
832 end
833 end
834  
835 function GroupFu:CHAT_MSG_SYSTEM()
836 local player, roll, min_roll, max_roll, mlname;
837  
838 -- Trap name of master looter if it has changed
839 _, _, mlname = string.find(arg1, self.loc.SEARCH_MASTERLOOTER);
840 if mlname then
841  
842 self.tmpdata.MLName = mlname;
843 self:Update();
844  
845 end
846  
847 -- Trap rolls
848 _, _, player, roll, min_roll, max_roll = string.find(arg1, self.loc.SEARCH_ROLLS);
849 if(player) then
850  
851 if((self.data.StandardRollsOnly) and ((tonumber(min_roll) ~= 1) or (tonumber(max_roll) ~= 100))) then
852  
853 return;
854  
855 end
856  
857 if((self.tmpdata.RollCount > 0) and (self.data.IgnoreDuplicates)) then
858 local i;
859  
860 for i=1,self.tmpdata.RollCount do
861  
862 if(self.tmpdata.Rolls[i].Player == player) then
863 return;
864 end
865  
866 end
867 end
868  
869 self.tmpdata.RollCount = self.tmpdata.RollCount + 1;
870 self.tmpdata.Rolls[self.tmpdata.RollCount] = {};
871 self.tmpdata.Rolls[self.tmpdata.RollCount].Roll = tonumber(roll);
872 self.tmpdata.Rolls[self.tmpdata.RollCount].Player = player;
873 self.tmpdata.Rolls[self.tmpdata.RollCount].Min = tonumber(min_roll);
874 self.tmpdata.Rolls[self.tmpdata.RollCount].Max = tonumber(max_roll);
875  
876 if(player == UnitName("player")) then
877  
878 _, self.tmpdata.Rolls[self.tmpdata.RollCount].Class = UnitClass("player");
879 self.tmpdata.Rolls[self.tmpdata.RollCount].Level = UnitLevel("player");
880  
881 elseif(GetNumRaidMembers() > 0) then
882 local i, z;
883  
884 z = GetNumRaidMembers();
885 for i=1,z do
886  
887 if(player == UnitName("raid"..i)) then
888  
889 _, self.tmpdata.Rolls[self.tmpdata.RollCount].Class = UnitClass("raid"..i);
890 self.tmpdata.Rolls[self.tmpdata.RollCount].Level = UnitLevel("raid"..i);
891 break;
892  
893 end
894 end
895  
896 elseif(GetNumPartyMembers() > 0) then
897 local i, z;
898  
899 z = GetNumPartyMembers();
900 for i=1,z do
901  
902 if(player == UnitName("party"..i)) then
903  
904 _, self.tmpdata.Rolls[self.tmpdata.RollCount].Class = UnitClass("party"..i);
905 self.tmpdata.Rolls[self.tmpdata.RollCount].Level = UnitLevel("party"..i);
906  
907 end
908 end
909  
910 else
911  
912 self.tmpdata.Rolls[self.tmpdata.RollCount].Class = "";
913 self.tmpdata.Rolls[self.tmpdata.RollCount].Level = 0;
914  
915 end
916  
917 if (self.data.ClearTimer > 0) and not self.data.AnnounceRollCountdown then
918 self.tmpdata.TimeSinceLastRoll = 0;
919 end
920  
921 self:Update();
922  
923 end
924 end
925  
926 function GroupFu:ToggleOption(opt)
927  
928 self.data[opt] = not self.data[opt];
929 self:Update();
930 return self.data[opt];
931  
932 end
933  
934 function GroupFu:ToggleOutputChannel(channel)
935  
936 self.data.OutputChannel = channel;
937 self:Update();
938 return self.data.OutputChannel;
939  
940 end
941  
942 function GroupFu:IsOutputChannel(channel)
943  
944 if self.data.OutputChannel == channel then
945 return true;
946 else
947 return false;
948 end
949  
950 end
951  
952 function GroupFu:ToggleOutputDetail(detail)
953  
954 self.data.OutputDetail = detail;
955 self:Update();
956 return self.data.OutputDetail;
957  
958 end
959  
960 function GroupFu:IsOutputDetail(detail)
961  
962 if self.data.OutputDetail == detail then
963 return true;
964 else
965 return false;
966 end
967  
968 end
969  
970 function GroupFu:ToggleTextMode(mode)
971  
972 self.data.TextMode = mode;
973 self:Update();
974 return self.data.TextMode;
975  
976 end
977  
978 function GroupFu:IsTextMode(mode)
979  
980 if self.data.TextMode == mode then
981 return true;
982 else
983 return false;
984 end
985  
986 end
987  
988 function GroupFu:ToggleClearTimer(timeout)
989  
990 self.data.ClearTimer = timeout;
991 self:Update();
992 return self.data.ClearTimer;
993  
994 end
995  
996 function GroupFu:IsClearTimer(timeout)
997  
998 if self.data.ClearTimer == timeout then
999 return true;
1000 else
1001 return false;
1002 end
1003  
1004 end
1005  
1006 function GroupFu:ClearRolls()
1007  
1008 self.tmpdata.Rolls = {};
1009 self.tmpdata.RollCount = 0;
1010 self.tmpdata.TimeSinceLastRoll = 0;
1011 self:Update();
1012  
1013 end
1014  
1015 function GroupFu:IsLootType(loottype)
1016  
1017 if GetLootMethod() == loottype then
1018 return true;
1019 else
1020 return false;
1021 end
1022  
1023 end
1024  
1025 function GroupFu:SetLootType(loottype)
1026  
1027 if loottype == "master" then
1028 SetLootMethod(loottype,UnitName("player"),2);
1029 else
1030 SetLootMethod(loottype);
1031 end
1032  
1033 self:Update();
1034 dewdrop:Close(3);
1035  
1036 end
1037  
1038 function GroupFu:IsLootThreshold(threshold)
1039  
1040 if GetLootThreshold() == threshold then
1041 return true;
1042 else
1043 return false;
1044 end
1045  
1046 end
1047  
1048 function GroupFu:SetLootThreshold(threshold)
1049  
1050 SetLootThreshold(threshold)
1051 self:Update();
1052 dewdrop:Close(3);
1053  
1054 end
1055  
1056 function GroupFu:GetLootTypeText()
1057  
1058 if self.tmpdata.LootType == "group" then
1059  
1060 return self.loc.TEXT_GROUP;
1061  
1062 elseif self.tmpdata.LootType == "master" then
1063  
1064 if self.data.ShowMLName and self.tmpdata.MLName then
1065 return self.loc.TEXT_MASTER .. "(" .. self.tmpdata.MLName .. ")";
1066 else
1067 return self.loc.TEXT_MASTER;
1068 end
1069  
1070 elseif self.tmpdata.LootType == "freeforall" then
1071  
1072 return self.loc.TEXT_FFA;
1073  
1074 elseif self.tmpdata.LootType == "roundrobin" then
1075  
1076 return self.loc.TEXT_RR;
1077  
1078 elseif self.tmpdata.LootType == "needbeforegreed" then
1079  
1080 return self.loc.TEXT_NBG;
1081  
1082 else
1083  
1084 return self.loc.TEXT_SOLO;
1085  
1086 end
1087 end
1088  
1089 function GroupFu:CheckRollTimeout()
1090  
1091 if ((self.tmpdata.RollCount > 0) and (self.data.ClearTimer > 0)) then
1092  
1093 self.tmpdata.TimeSinceLastRoll = self.tmpdata.TimeSinceLastRoll + self.updateTime;
1094  
1095 if (self.data.AnnounceRollCountdown) then
1096  
1097 if( self.tmpdata.TimeSinceLastRoll == (self.data.ClearTimer-10) ) then
1098  
1099 self:AnnounceOutput( self.loc.TEXT_ENDING10 );
1100  
1101 elseif( self.tmpdata.TimeSinceLastRoll == (self.data.ClearTimer-5) ) then
1102  
1103 self:AnnounceOutput( self.loc.TEXT_ENDING5 );
1104  
1105 elseif( self.tmpdata.TimeSinceLastRoll == (self.data.ClearTimer-4) ) then
1106  
1107 self:AnnounceOutput( self.loc.TEXT_ENDING4 );
1108  
1109 elseif( self.tmpdata.TimeSinceLastRoll == (self.data.ClearTimer-3) ) then
1110  
1111 self:AnnounceOutput( self.loc.TEXT_ENDING3 );
1112  
1113 elseif( self.tmpdata.TimeSinceLastRoll == (self.data.ClearTimer-2) ) then
1114  
1115 self:AnnounceOutput( self.loc.TEXT_ENDING2 );
1116  
1117 elseif( self.tmpdata.TimeSinceLastRoll == (self.data.ClearTimer-1) ) then
1118  
1119 self:AnnounceOutput( self.loc.TEXT_ENDING1 );
1120  
1121 elseif( self.tmpdata.TimeSinceLastRoll == self.data.ClearTimer ) then
1122  
1123 self:AnnounceOutput( self.loc.TEXT_ENDED );
1124  
1125 if(self.tmpdata.RollCount > 0) then
1126  
1127 local i, highRoll, highRoller;
1128  
1129 highRoll = 0;
1130 highRoller = "";
1131 for i = 1, self.tmpdata.RollCount do
1132  
1133 if ((self.tmpdata.Rolls[i].Roll > highRoll) and ((not self.data.StandardRollsOnly) or ((self.tmpdata.Rolls[i].Min == 1) and (self.tmpdata.Rolls[i].Max == 100)))) then
1134  
1135 highRoll = self.tmpdata.Rolls[i].Roll;
1136 highRoller = self.tmpdata.Rolls[i].Player;
1137  
1138 end
1139 end
1140  
1141 self:AnnounceOutput(format(self.loc.FORMAT_ANNOUNCE_WIN, highRoller, highRoll, self.tmpdata.RollCount));
1142 end
1143  
1144 self:ClearRolls();
1145  
1146 end
1147  
1148 elseif( self.tmpdata.TimeSinceLastRoll == self.data.ClearTimer ) then
1149  
1150 self:ClearRolls();
1151  
1152 end
1153 end
1154  
1155 end
1156  
1157 function GroupFu:AnnounceOutput( mymessage )
1158  
1159 if( self.data.OutputChannel == "LOCAL" ) then
1160  
1161 DEFAULT_CHAT_FRAME:AddMessage(mymessage);
1162  
1163 elseif ( self.data.OutputChannel == "AUTO" ) then
1164  
1165 if ( GetNumRaidMembers() > 0 ) then
1166  
1167 SendChatMessage(mymessage, "RAID");
1168  
1169 elseif ( GetNumPartyMembers() > 0 ) then
1170  
1171 SendChatMessage(mymessage, "PARTY");
1172  
1173 else
1174  
1175 DEFAULT_CHAT_FRAME:AddMessage(mymessage);
1176  
1177 end
1178  
1179 else
1180  
1181 SendChatMessage(mymessage, self.data.OutputChannel);
1182  
1183 end
1184  
1185 end
1186  
1187 GroupFu:RegisterForLoad();