-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainFrame.lua
3375 lines (3064 loc) · 125 KB
/
MainFrame.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Author : Matthew Enthoven (Alias: Blacksen) & Nicolau Goncalves (Alias: Excentrik)
-- Create Date : 1/04/2010 1:32:25 PM
-- Modification Date: 21/02/2014 1:48:00 PM
-- MainFrame.lua: Manages the main voting interface and host/client communication
-- 4.0 Change On
local auctionRunning = false; -- 0 if session running, 1 otherwise
local isPrivate = false; -- 0 if this session is private, 1 otherwise
local isSingle = false; -- 0 if this has single vote mode enabled, 1 otherwise
local isShowingSpec = true; -- 1 if showing mainspec/offspec, 0 otherwise
local isSelfVoting = false; -- 0 if can vote for self, 1 otherwise
local isSplitRaids = false; -- 0 if every raid has is own council, 1 otherwise
local itemRunning = nil; -- item link for the auction that's running
local isInitiator = false; -- 0 if we're NOT the initiator, 1 otherwise
local theInitiator = ""; -- Name of the initiator
local specialSlot = false; -- 1 if trinket/ring/neck, 0 otherwise
local theVote = ""; -- Helper variable for static popup (actual vote For/against/none)
local voteFor = ""; -- Who we're voting for
local suggestedBy = ""; -- Who suggested to end the session
local cmdDelim = " "; -- Helper variable in earlier iterations
local voteDelim = " "; -- Helper variable in earlier iterations
local selection = nil; -- Row we have selected
local councilList = " "; -- List of council members
local councilNum = 1; -- Number of council members
local requestedBefore = false;
local itemRemember = nil;
local awardShow = false;
local sanityCheck = 0;
local EnchantersList = {}; -- List of enchanters in the group
--local EnchantersNum = table.getn(EnchantersList); -- Number of enchanters in the group
local entryLinkWaiting = false;
local entryPings = {};
local clientEntryWaiting = false;
local clientEntryPings = {};
local MAX_ENTRIES = 30;
local MAX_VOTERS = 20;
local MAX_RAIDERS = 60;
local MAX_ENTRIES = 12;
local MIN_SIZE = 96;
local oldEntry = 0;
local dataRequest;
local dataTotal = {};
local sortMethod = "asc"
local currSortIndex = 0
local L = LootCouncilLocalization;
LootCouncil_Browser_MainDebug = false; -- Note: This is a variable for ACTIVATING all debug text. Lots of random stuff. Highly recommended to turn OFF
-- 1 = debug on (all print commands fired)
-- 0 = debuf off (no print commands)
LootCouncil_Browser.private = LootCouncil_privateVoting;
LootCouncil_Browser.single = LootCouncil_singleVote;
LootCouncil_Browser.spec = LootCouncil_displaySpec;
LootCouncil_Browser.self = LootCouncil_selfVoting;
LootCouncil_Browser.confirmEnd = LootCouncil_confirmEnding;
LootCouncil_Browser.EnchantersList = LootCouncil_convertStringList(LootCouncil_Enchanters);
LootCouncil_Browser.MLI = LootCouncil_masterLootIntegration;
LootCouncil_Browser.SplitRaids=LootCouncil_SplitRaids;
-------------- MainFrame_OnLoad --------------
-- Loads the Addon Frame
----------------------------------------------
function MainFrame_OnLoad()
-- Tell the player we are being loaded
print(format('%s: %s','LootCouncil_Lite', tostring(LootCouncil_Lite.version)));
-- Update ilvl score cache
LootCouncil_Lite.inspect:AddHook('LootCouncil_Lite', 'items', function(...) if isInitiator then LootCouncil_Lite:ProcessInspect(...);end; end);
LootCouncil_Lite:RegisterEvent("GROUP_ROSTER_UPDATE", function() LootCouncil_Lite:UpdateGroup() end);
LootCouncil_Lite:RegisterEvent("PLAYER_EQUIPMENT_CHANGED", function() LootCouncil_Lite:StartScore('player'); end);
--LootCouncil_Lite:RegisterEvent("INSPECT_READY", function(self,event,...) LootCouncil_Lite:RoughScore(self,event,LootCouncil_Lite:GUIDtoName(...)) end);
LootCouncil_Lite:AutoPurge(true);
LootCouncil_Lite:StartScore('player');
MainFrame:RegisterEvent("CHAT_MSG_OFFICER");
MainFrame:RegisterEvent("CHAT_MSG_CHANNEL");
MainFrame:RegisterEvent("CHAT_MSG_RAID");
MainFrame:RegisterEvent("CHAT_MSG_RAID_LEADER");
MainFrame:RegisterEvent("CHAT_MSG_GUILD");
MainFrame:RegisterEvent("CHAT_MSG_ADDON");
MainFrame:RegisterEvent("CHAT_MSG_WHISPER");
MainFrame:SetScript("OnEvent", MainFrame_EventHandler);
MainFrame:Hide();
CurrentCouncilLabel:SetText(LootCouncilLocalization["CURRENT_COUNCIL"]);
CurrentItemLabel:SetText(LootCouncilLocalization["CURRENT_ITEM"]);
CurrentSelectionItemLevelLabel:SetText(LootCouncilLocalization["ITEM_LEVEL"]);
CurrentSelectionLabel:SetText(LootCouncilLocalization["SELECTION"]);
VotesAgainstLabel:SetText(LootCouncilLocalization["VOTES_AGAINST"]);
VotesForLabel:SetText(LootCouncilLocalization["VOTES_FOR"]);
----------- Voting Reason Popup Box -----------
-- Loads the voting reason box
-----------------------------------------------
StaticPopupDialogs["LOOT_COUNCIL_VOTE_REASON"] = {
text = "Reason for voting %s?",
button1 = ACCEPT,
button2 = CANCEL,
hasEditBox = 1,
OnAccept = function(self)
LootCouncil_Browser.updateVotes(LootCouncil_Browser.getUnitName("player"), voteFor, theVote, self.editBox:GetText())
end,
OnShow = function(self)
self.editBox:SetFocus()
end,
EditBoxOnEnterPressed = function(self)
LootCouncil_Browser.updateVotes(LootCouncil_Browser.getUnitName("player"), voteFor, theVote, self:GetText())
self:GetParent():Hide()
end,
EditBoxOnEscapePressed = function(self)
self:GetParent():Hide()
end,
timeout=0,
whileDead = 1,
hideOnEscape = 1
}
StaticPopupDialogs["LOOT_COUNCIL_SUGGEST_ABORT"] = {
text = LootCouncilLocalization["SUGGEST_ABORT"],
button1 = "Ignore",
button2 = "Abort",
OnAccept = function(self)
suggestedBy = ""
self:Hide()
end,
OnCancel = function(self)
LootCouncil_Browser.confirmAbort()
end,
timeout=0,
whileDead = 1,
hideOnEscape = 1
}
StaticPopupDialogs["LOOT_COUNCIL_CONFIRM_ABORT"] = {
text = LootCouncilLocalization["CONFIRM_END"],
button1 = "Yes",
button2 = "No",
OnAccept = function(self)
LootCouncil_Browser.closeLootCouncilSession()
self:Hide()
end,
timeout=0,
whileDead = 1,
hideOnEscape = 1
}
StaticPopupDialogs["LOOT_COUNCIL_CONFIRM_LOOT_DECISION"] = {
text = LootCouncilLocalization["CONFIRM_AWARD"],
button1 = "Yes",
button2 = "No",
OnAccept = function(self)
LootCouncil_Browser.itemAwarded = true;
LootCouncil_Browser.giveItemAway();
end,
OnCancel = function(self)
LootCouncil_Browser.itemAwarded = false;
LootCouncil_Browser.candidateNum = nil;
LootCouncil_Browser.slotNum = nil;
end,
timeout=0,
whileDead = 1,
hideOnEscape = 1
}
----------- Create Table Entries -----------
-- Creates the Table Entries
--------------------------------------------
local entry = CreateFrame("Button", "$parentEntry1", EntryFrame, "LootCouncil_Entry"); -- Creates the first entry
entry:SetID(1); -- Sets its id
entry:SetPoint("TOPLEFT", 4, -28) --Sets its anchor
for ci = 2, MAX_ENTRIES do --Loops through to create more rows
local entry = CreateFrame("Button", "$parentEntry"..ci, EntryFrame, "LootCouncil_Entry");
entry:SetID(ci);
entry:SetPoint("TOP", "$parentEntry"..(ci-1), "BOTTOM") -- sets the anchor to the row above
end
councilList = LootCouncil_Browser.getUnitName("player");
councilNum = 1;
end
-------------- showMainFrame --------------
-- Shows the Main Frame
-------------------------------------------
function LootCouncil_Browser.showMainFrame()
MainFrame:Show()
end
-------------- resetMainFrame --------------
-- Resets the Main Frame Position
-------------------------------------------
function LootCouncil_Browser.resetMainFrame()
MainFrame:ClearAllPoints()
MainFrame:SetPoint("CENTER", UIParent, "CENTER");
end
-------------- hideMainFrame --------------
-- Hides the Main Frame
-------------------------------------------
function LootCouncil_Browser.hideMainFrame()
MainFrame:Hide()
end
--------- CloseButton_OnClick -------------
-- Closes the Main Frame
-------------------------------------------
function CloseButton_OnClick()
LootCouncil_Browser.hideMainFrame();
end
-------------- MainFrame_EventHandler --------------
-- Event Handler for the Main Frame
-- EVENTS HANDLED:
-- -- CHAT_MSG_OFFICER
-- -- CHAT_MSG_ADDON
-- -- CHAT_MSG_WHISPER
-- -- CHAT_MSG_RAID
-- -- CHAT_MSG_GUILD
----------------------------------------------------
function MainFrame_EventHandler(self, event, ...)
if event == "CHAT_MSG_OFFICER" and LootCouncil_Channel=="OFFICER" and LootCouncil_LinkOfficer == true then
local msg, sender = ...
if isInitiator == true then
LootCouncil_Browser.newEntry(sender, msg);
end
elseif event == "CHAT_MSG_CHANNEL" and LootCouncil_Channel~="OFFICER" and LootCouncil_LinkOfficer == true then
local msg, sender, language, channelString, target, flags, unknown, channelNumber, channelName = ...
if isInitiator == true and channelName== LootCouncil_Channel then
LootCouncil_Browser.newEntry(sender, msg);
end
elseif event == "CHAT_MSG_WHISPER" and LootCouncil_LinkWhisper == true then
local msg, sender = ...;
if isInitiator == true and LootCouncil_Browser.getUnitName("player")~= sender then
LootCouncil_Browser.newEntry(sender, msg);
end
elseif ((event == "CHAT_MSG_RAID" or event== "CHAT_MSG_RAID_LEADER") and LootCouncil_LinkRaid == true) then
local msg, sender = ...;
if isInitiator == true then
LootCouncil_Browser.newEntry(sender, msg);
end
elseif event == "CHAT_MSG_GUILD" and LootCouncil_LinkGuild == true then
local msg, sender = ...;
if isInitiator == true then
LootCouncil_Browser.newEntry(sender, msg);
end
elseif event == "OPEN_MASTER_LOOT_LIST" then
LootCouncil_Browser.openMasterLootList();
elseif event == "UPDATE_MASTER_LOOT_LIST" then
LootCouncil_Browser.updateMasterLootList();
elseif event == "LOOT_OPENED" then
local lootmethod, masterlooterPartyID, masterlooterRaidID = GetLootMethod();
if masterlooterRaidID then
local name, rank, subgroup = GetRaidRosterInfo(masterlooterRaidID);
if name == LootCouncil_Browser.getUnitName("player") then
awardShow = true;
LootCouncil_Browser.Update()
end
end
elseif event == "LOOT_CLOSED" then
awardShow = false;
LootCouncil_Browser.Update();
elseif event == "CHAT_MSG_ADDON" then
local prefix, msg, channel, sender = ...
if prefix == "L00TCOUNCIL" and sender ~= LootCouncil_Browser.getUnitName("player") then
local cmd, other = strsplit(cmdDelim, msg, 2)
local isSame= (LootCouncil_Browser.searchSameRaid(sender) or not(LootCouncil_SplitRaids) )
if isSame then
LootCouncil_Browser.printd("Our Command: " .. cmd);
if cmd == "start" then
if other == nil or other == "" then
print(LootCouncilLocalization["FAILED_START_NO_VALID_LINK"])
else
-- Check if initiator is in the same raid as the player
if ((not itemRunning) or sender==theInitiator) then
local name, link = GetItemInfo(other);
if name == nil then
LootCouncil_awaitingItem = true;
dataRequest = other;
sanityCheck = 0;
MainFrame:SetScript("OnUpdate", MainFrame_OnUpdate);
end
LootCouncil_Browser.heardStart(sender, other);
else
print("------------------------------------")
print(string.format(LootCouncilLocalization["START_WHILE_GOING1"], sender))
print(LootCouncilLocalization["START_WHILE_GOING2"])
print("------------------------------------")
end
end
elseif cmd == "suggestAbort" then
if suggestedBy then
StaticPopup_Hide("LOOT_COUNCIL_SUGGEST_ABORT")
StaticPopup_Show("LOOT_COUNCIL_SUGGEST_ABORT", sender)
end
elseif cmd == "abort" and sender==theInitiator then
LootCouncil_Browser.closeLootCouncilSession()
elseif cmd == "vote" then
local char, voter, vote, reason = strsplit(voteDelim, other, 4);
LootCouncil_Browser.updateVotes(voter, char, vote, reason);
elseif cmd == "end" then
LootCouncil_Browser.resetConsideration();
elseif cmd == "councilList" then
CurrentCouncilList:SetText(other)
CurrentCouncilList:Show()
CurrentCouncilLabel:Show()
elseif cmd == "echo" then
LootCouncil_Browser.processEcho(sender, other);
elseif cmd == "confirmed" then
local private, single, spec, selfVoting = strsplit(voteDelim, other, 4);
LootCouncil_Browser.processResponse(tonumber(private), tonumber(single), tonumber(spec), tonumber(selfVoting));
elseif cmd == "itemEntry" then
local name, item = strsplit(" ", other, 2);
LootCouncil_Browser.printd("PULSED ITEM");
LootCouncil_Browser.receiveItemEntry(name, item);
elseif cmd == "secondEntry" then
local name, item = strsplit(" ", other, 2);
LootCouncil_Browser.receiveSecondEntry(name, item);
elseif cmd == "data" then
LootCouncil_Browser.updatePlayerData(other);
elseif cmd == "remove" and sender==theInitiator then
LootCouncil_Browser.removePlayer(other)
elseif cmd == "spec" then
local char, spec = strsplit(" ", other, 2);
LootCouncil_Browser.updateSpec(char, spec)
elseif cmd == "ilvl" then
local char, ilvl = strsplit(" ", other, 2);
LootCouncil_Browser.updateIlvl(char, ilvl)
end
end
if cmd == "testCouncil" then -- ADDED IN VERSION 2.0. Test council ping.
GuildRoster();
for ci = 1, GetNumGuildMembers() do -- otherwise, start looping through the guild list
--local theName, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName = GetGuildRosterInfo(ci);
local theName, rank, rankIndex = LootCouncil_Browser.getCharInfo(ci);
if sender == theName then -- if we find them
if (rankIndex+1) <= (LootCouncil_minRank + 0.1) then -- check if they're above the minimum rank
SendAddonMessage("L00TCOUNCIL", "testReplyGood", "GUILD")
else
SendAddonMessage("L00TCOUNCIL", "testReplyBad", "GUILD")
end
break;
end
end
end
end
end
end
-------------- initiateLootCouncil --------------
-- Tries to initiate a new loot council session
-------------------------------------------------
function LootCouncil_Browser.initiateLootCouncil(item)
if item == nil then
print(LootCouncilLocalization["FAILED_START_NO_LINK"])
else
if auctionRunning==true and (itemRunning or LootCouncil_awaitingItem) then --If we have a consideration running, tell the user we can't start a new one
print(LootCouncilLocalization["START_WHILE_SESSION1"]);
if itemRunning then
print(string.format(LootCouncilLocalization["START_WHILE_SESSION2"], itemRunning));
else
print(LootCouncilLocalization["START_WHILE_SESSION2_NOLINK"]);
end
else
local isValid = LootCouncil_Browser.validInitiator("player");
if isValid == 0 then -- Fires when player is IN a raid but NOT a raid officer
print(LootCouncilLocalization["NOSTART_1"]);
print(LootCouncilLocalization["NOSTART_NOT_RAIDASSIST"]);
elseif isValid == 3 and LootCouncil_Browser_MainDebug==false then -- Fires when player is NOT in a raid and is NOT the guild leader
print(LootCouncilLocalization["NOSTART_1"]);
print(LootCouncilLocalization["NOSTART_NOT_GM"]);
elseif isValid == 1 or (isValid ==3 and LootCouncil_Browser_MainDebug==true) then -- Fires when player is either a raid officer or guild leader
GuildRoster();
--LootCouncil_Browser.updateEnchantersList()
LootCouncil_Browser.WhisperList = {}
LootCouncil_Browser.itemAwarded = false;
entryLinkWaiting = false;
entryPings = {};
itemRunning = item; -- Set the current item that's running
isInitiator=true; -- We're the initiator, so set that
theInitiator = LootCouncil_Browser.getUnitName("player");
--Send out the messages regarding the item
if LootCouncil_Lite_debugMode == false then
LootCouncil_SendChatMessage(LootCouncilLocalization["START_FIRED"], LootCouncil_Channel);
LootCouncil_SendChatMessage("item: "..itemRunning, LootCouncil_Channel);
else
LootCouncil_Browser.printd(LootCouncilLocalization["START_FIRED"]);
LootCouncil_Browser.printd("item: "..itemRunning);
end
local found, _, itemString = string.find(itemRunning, "^|c%x+|H(.+)|h%[.*%]");
LootCouncil_Browser.printd("prep for addon message");
SendAddonMessage("L00TCOUNCIL", "start"..cmdDelim..itemString, "GUILD");
LootCouncil_Browser.printd("post addon message");
CurrentCouncilList:SetText(councilList)
CurrentCouncilList:Show()
CurrentCouncilLabel:Show()
if GetNumLootItems() > 0 then
awardShow = true;
else
awardShow = false;
end
isPrivate = LootCouncil_Browser.private;
isSingle = LootCouncil_Browser.single;
isShowingSpec = LootCouncil_Browser.spec;
isSelfVoting = LootCouncil_Browser.self;
isSplit= LootCouncil_Browser.split;
--SyncButton:Show();
LootCouncil_Browser.showMainFrame();
councilList = LootCouncil_Browser.getUnitName("player");
councilNum = 1;
if UnitInRaid("player") and LootCouncil_Lite_debugMode == false then
LootCouncil_SendChatMessage(string.format(LootCouncilLocalization["START_MSG_PULSE1"], itemRunning), "RAID_WARNING");
LootCouncil_SendChatMessage(string.format(LootCouncilLocalization["START_MSG_PULSE2"], itemRunning,theInitiator), "RAID");
else
if LootCouncil_Lite_debugMode == false then
LootCouncil_SendChatMessage(string.format(LootCouncilLocalization["START_MSG_PULSE1"], itemRunning), "GUILD");
LootCouncil_SendChatMessage(string.format(LootCouncilLocalization["START_MSG_PULSE2"], itemRunning,theInitiator), "GUILD");
end
end
-- if XLootMaster then
-- XLootMaster.dewdrop:Refresh(1)
-- end
LootCouncil_Browser.prepareLootFrame();
end
end
end
end
-------------- validInitiator ---------------------------
-- Checks if the client or sender is able to initiate a new session
---------------------------------------------------------
function LootCouncil_Browser.validInitiator(sender)
if sender == "player" then
if UnitInRaid("player") then -- If the player is in a raid
if UnitIsGroupAssistant("player") or UnitIsGroupLeader("player") then
return 1
else
return 0
end
else
if IsGuildLeader(LootCouncil_Browser.getUnitName("player")) == true then -- If they're the guild leader
return 1; --Then return 1
else
return 3; -- Else, return 3
end
end
else
GuildRoster();
for ci = 1, GetNumGuildMembers() do
--local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName = GetGuildRosterInfo(ci);
local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName = LootCouncil_Browser.getCharInfo(ci);
--print(name)
if name == sender then
if (rankIndex+1) <= (LootCouncil_minRank + 0.1) then
return 1;
else
return 0;
end
end
end
end
end
-------------- prepareLootFrame -------------------------
-- Prepares the main frame for such
---------------------------------------------------------
function LootCouncil_Browser.prepareLootFrame()
auctionRunning=true; -- We're running an auction now, so set it to true;
local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount, thisItemEquipLoc, thisItemTexture;
if itemRunning then
sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount, thisItemEquipLoc, thisItemTexture = GetItemInfo(itemRunning); -- Get the item info
end
if thisItemTexture then
CurrentItemTexture:SetTexture(thisItemTexture); -- Set the texture of the icon box
else
CurrentItemTexture:SetTexture("Interface\InventoryItems\WoWUnknownItem01");
end
CurrentItemTexture:Show(); -- Open up the icon box
AbortButton:Show(); -- Show the Abort Button
if iLevel then
CurrentItemLvl:SetText(iLevel); -- Show the Item Level
else
CurrentItemLvl:SetText("...");
end
if sLink then
CurrentItemLink:SetText(sLink); -- Set the item link for color and such
else
CurrentItemLink:SetText(LootCouncilLocalization["LOADING"]);
end
CurrentItemLevelLabel:Show(); -- Show the Label for item level
EmptyTexture:Hide(); -- Hide the empty texture
LootCouncil_Browser.Elects = {} -- Reset all entrants
LootCouncil_Browser.Votes = {} -- Reset all votes
RemoveButton:Hide()
LootCouncil_Browser.printd(thisItemEquipLoc);
local slotNum = LootCouncil_Browser.translateToSlot(thisItemEquipLoc);
LootCouncil_Browser.printd("SLOT NUMBER: " .. slotNum);
if slotNum == 13 or slotNum == 11 or slotNum == 16 then
specialSlot = true;
else
specialSlot = false;
end
CurrentItemHover:Show()
for ci = 1, MAX_ENTRIES do
if isSingle == true then
_G["EntryFrameEntry"..ci.."AgainstButton"]:Hide()
else
_G["EntryFrameEntry"..ci.."AgainstButton"]:Show()
end
if isPrivate == true then
_G["EntryFrameEntry"..ci.."VoteHover1"]:Hide()
else
_G["EntryFrameEntry"..ci.."VoteHover1"]:Show()
end
if isShowingSpec == false then
_G["EntryFrameEntry"..ci.."Spec"]:Hide()
local frame = _G["EntryFrameEntry"..ci.."Itemlvl"]
--_G["EntryFrameEntry"..ci]:SetWidth(647)
_G["EntryFrameEntry"..ci.."VotesTotal"]:SetPoint("LEFT", frame, "RIGHT");
else
local frame = _G["EntryFrameEntry"..ci.."Spec"]
frame:Show()
--_G["EntryFrameEntry"..ci]:SetWidth(687)
_G["EntryFrameEntry"..ci.."VotesTotal"]:SetPoint("LEFT", frame, "RIGHT");
end
end
if isSingle == true then
_G["EntryFrameHeaderVotesTotal"]:SetText("Total Votes")
else
_G["EntryFrameHeaderVotesTotal"]:SetText("Total Votes (+/-)")
end
if isShowingSpec == false then
_G["EntryFrameHeaderSpec"]:Hide()
--MainFrame:SetWidth(687)
--EntryFrame:SetWidth(655)
local frame = _G["EntryFrameHeaderItemlvl"]
_G["EntryFrameHeaderVotesTotal"]:SetPoint("LEFT", frame, "RIGHT");
else
local frame = _G["EntryFrameHeaderSpec"]
frame:Show()
--MainFrame:SetWidth(722)
--EntryFrame:SetWidth(695)
_G["EntryFrameHeaderVotesTotal"]:SetPoint("LEFT", frame, "RIGHT");
end
end
-------------- heardStart ---------------------
-- Process a "start" command
-----------------------------------------------
function LootCouncil_Browser.heardStart(sender, item)
councilList = "";
councilNum = 0;
itemRemember = item;
if (LootCouncil_Browser.validInitiator(sender) == 1) then
theInitiator = sender;
isInitiator = false; -- We're NOT the initiator
local rprsName, rprsLink = GetItemInfo(item); -- Get the item link (since we just got sent the item string)
itemRunning = rprsLink;
SendAddonMessage("L00TCOUNCIL", "echo "..LootCouncil_Lite.version, "WHISPER", theInitiator);
else
print(string.format(LootCouncilLocalization["TOO_LOW_RANK"], sender));
end
end
-------------- processEcho ---------------------
-- Process an echo to add to the loot list
-----------------------------------------------
function LootCouncil_Browser.processEcho(sender, ver)
if isInitiator == true then
for ci = 1, GetNumGuildMembers() do
--local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName = GetGuildRosterInfo(ci);
local name, rank, rankIndex = LootCouncil_Browser.getCharInfo(ci);
if name == sender then
if (rankIndex+1) <= (LootCouncil_minRank + 0.1) then
table.insert(LootCouncil_Browser.WhisperList, sender)
councilList = councilList..", "..sender
councilNum = councilNum + 1
CurrentCouncilList:SetText(councilList)
LootCouncil_Browser.sendGlobalMessage("councilList "..councilList)
SendAddonMessage("L00TCOUNCIL", "confirmed "..LootCouncil_logical2string(LootCouncil_privateVoting).." "..LootCouncil_logical2string(LootCouncil_singleVote).." "..LootCouncil_logical2string(LootCouncil_displaySpec).." "..LootCouncil_logical2string(LootCouncil_selfVoting), "WHISPER", sender);
end
break;
end
end
if (not ver) or (not (string.sub(LootCouncil_Lite.version,1,3) == ver)) then
if (not ver) or tonumber(string.sub(LootCouncil_Lite.version,1,3)) > tonumber(ver) then
if LootCouncil_Lite_debugMode == false then
LootCouncil_SendChatMessage(string.format(LootCouncilLocalization["OUTDATED"], string.sub(LootCouncil_Lite.version,1,-3)), "WHISPER", nil, sender)
end
else
print(string.format(LootCouncilLocalization["OUTDATED"], ver))
end
end
end
end
-------------- processResponse-----------------
-- Processes the response to an echo to prepare
-- the Main Frame
-----------------------------------------------
function LootCouncil_Browser.processResponse(prv, sing, spec, selfVoting)
--SyncButton:Hide();
isPrivate = (prv==1);
isSingle = (sing==1);
isShowingSpec = (spec==1);
isSelfVoting = (selfVoting==1);
LootCouncil_Browser.prepareLootFrame()
MainFrame:Show()
end
-------------- resetConsideration -------------
-- Ends the Loot Council Session
-----------------------------------------------
function LootCouncil_Browser.resetConsideration()
CurrentItemTexture:SetTexture("Interface\InventoryItems\WoWUnknownItem01");
LootCouncil_awaitingItem = false;
RemoveButton:Hide()
LootCouncil_Browser.ClearSelection()
EmptyTexture:Show();
CurrentItemTexture:Hide();
itemRunning = nil;
auctionRunning = false;
LootCouncil_Browser.Elects = {}
LootCouncil_Browser.Update();
CurrentItemLevelLabel:Hide();
AbortButton:Hide();
CurrentItemLvl:SetText("");
EmptyTexture:Show();
CurrentItemLink:SetText("");
CurrentItemTexture:Hide();
CurrentCouncilList:SetText("")
CurrentCouncilList:Hide()
CurrentCouncilLabel:Hide()
CurrentItemHover:Hide()
VotesForLabel:Hide()
--SyncButton:Hide();
VotesFor:Hide()
VotesAgainstLabel:Hide()
VotesAgainst:Hide();
selection = nil;
awardShow = false;
LootCouncil_Browser.Update();
oldEntry = 0;
LootCouncil_Browser.private = LootCouncil_privateVoting;
LootCouncil_Browser.split = LootCouncil_SplitRaids;
LootCouncil_Browser.single = LootCouncil_singleVote;
LootCouncil_Browser.spec = LootCouncil_displaySpec;
LootCouncil_Browser.self = LootCouncil_selfVoting;
UIDropDownMenu_Refresh(GroupLootDropDownLCL);
entryLinkWaiting = false;
entryPings = {};
end
-------------- alreadyLinkedItem --------------
-- Checks if the user has already linked an item
-- If they have, then update it
-----------------------------------------------
function LootCouncil_Browser.alreadyLinkedItem(name, item)
LootCouncil_Browser.printd("Checking for already linked...");
local psName, psLink, piRarity, piLevel, piMinLevel, psType, psSubType, piStackCount, pthisItemEquipLoc = GetItemInfo(item); --TODO: Fired problem on multiitemlinks
if piLevel then
LootCouncil_Browser.printd("Found item off server");
for ci = 1, MAX_ENTRIES do
local entry = LootCouncil_Browser.Elects[ci];
if entry and entry[1] and entry[1] == name then
entry[2] = item.." ("..piLevel..")";
entry[3] = piLevel
entry[12] = 1;
entry[13] = psLink;
entry[14] = nil;
LootCouncil_Browser.Update()
LootCouncil_Browser.printd("ALREADY LINKED!");
return ci;
end
end
else
LootCouncil_Browser.printd("Could NOT find item");
local ret = 0;
for ci = 1, MAX_ENTRIES do
local entry = LootCouncil_Browser.Elects[ci];
if entry and entry[1] and entry[1] == name then
LootCouncil_Browser.printd("ALREADY LINKED!");
ret = ci;
local notFound = true;
for ci = 1, #clientEntryPings do
local theInfo = clientEntryPings[ci];
if theInfo and theInfo[1] and theInfo[1] == name then
theInfo[3] = item;
notFound = false;
end
end
if notFound then
clientEntryWaiting = true;
table.insert(clientEntryPings, {
name,
"=",
item
});
sanityCheck = 0;
MainFrame:SetScript("OnUpdate", MainFrame_OnUpdate);
end
break;
end
end
return ret;
end
return 0
end
---------- ShowCurrentItemTooltip -------------
-- Shows item that's under the running Tooltip
-----------------------------------------------
function LootCouncil_Browser.ShowCurrentItemTooltip()
if itemRunning then
GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR")
GameTooltip:SetHyperlink(itemRunning)
GameTooltip:Show()
end
if LootCouncil_awaitingItem then
GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR")
GameTooltip:SetText(LootCouncilLocalization["LOADING"]);
GameTooltip:Show()
end
end
---------- ShowCurrentSelectionTooltip -------------
-- Shows item that's under the running Tooltip
-----------------------------------------------
function LootCouncil_Browser.ShowCurrentSelectionTooltip()
if selection then
GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR")
GameTooltip:SetHyperlink(selection[13])
GameTooltip:Show()
end
end
---------- ShowCurrentSelectionDualTooltip -------------
-- Shows item that's under the running Tooltip
-----------------------------------------------
function LootCouncil_Browser.ShowCurrentSelectionDualTooltip()
if selection then
GameTooltip:SetOwner(MainFrame, "ANCHOR_CURSOR")
GameTooltip:SetHyperlink(selection[14])
GameTooltip:Show()
end
end
------------------ CastVote -------------------
-- Maintains the Cast Vote Buttons
-----------------------------------------------
function LootCouncil_Browser.CastVote(id, vote, click)
local entry = LootCouncil_Browser.Elects[id];
if entry and entry[9]~= vote then
if vote == "None" then
LootCouncil_Browser.updateVotes(LootCouncil_Browser.getUnitName("player"), entry[1], vote, "");
else
local voteFor = entry[1];
if click == "LeftButton" then
LootCouncil_Browser.updateVotes(LootCouncil_Browser.getUnitName("player"), voteFor, vote, "No Reason")
elseif click == "RightButton" and isPrivate == false then
StaticPopup_Show("LOOT_COUNCIL_VOTE_REASON", ""..string.upper(theVote).." "..voteFor)
end
end
end
end
------------------ newEntry -------------------
-- Adds a new entry if you're the initiator
-- This is one hell of a function
-----------------------------------------------
function LootCouncil_Browser.newEntry(name, msg) --Add a new entry to the loot table
if auctionRunning==true and itemRunning and name and msg ~= nil and isInitiator == true then -- Make sure we have an auction running
-- Check if they've linked an item
-- Check if they've linked TWO items
-- Pull the item info and check if it's valid!
local theItem = msg:find("|Hitem:"); -- See if they linked an item
LootCouncil_Browser.printd(theItem);
if theItem and theItem >= 0 then -- If they entered a valid item
local flagforwaiting = false;
local actualItemString2; -- Initialize for possibility of 2 item links
local startLoc = string.find(msg, "Hitem:") -- Make sure they linked an item
local endLoc = string.find(msg, "|", startLoc)
-- local actualItemString = string.sub(msg, startLoc, endLoc) -- Isolate the item string -- OLD AND OUTDATED
-- local actualItemString = string.match(msg, "item[%-?%d:]+")
local actualItemString = string.match(msg, "|%x+|Hitem:.-|h.-|h|r");
LootCouncil_Browser.printd(actualItemString);
-- LootCouncil_Browser.printd("item... " .. itemString2);
if (specialSlot == true) then -- If this was a trinket/weapon/rings
LootCouncil_Browser.printd("Checking for 2 items starting at index " .. endLoc);
theItem = string.find(msg, "Hitem:", endLoc) --See if they linked a second item
if theItem and theItem >= 0 then -- If they did
LootCouncil_Browser.printd("found it");
local laterString = string.sub(msg, endLoc);
-- actualItemString2 = string.sub(msg, startLoc, endLoc)
actualItemString2 = string.match(laterString, "|%x+|Hitem:.-|h.-|h|r");
end
end
local psName, psLink, piRarity, piLevel, piMinLevel, psType, psSubType, piStackCount, pthisItemEquipLoc = GetItemInfo(actualItemString); -- Get better info for item 1
local sName, sLink, iRarity, iLevel, iMinLevel, sType, sSubType, iStackCount, thisItemEquipLoc = GetItemInfo(itemRunning); --Get the current info
if actualItemString == sLink then
LootCouncil_Browser.printd("MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH MATCH ");
end
if actualItemString ~= sLink then
LootCouncil_Browser.printd(actualItemString .. " vs " .. sLink);
local psName2, psLink2, piRarity2, piLevel2, piMinLevel2, psType2, psSubType2, piStackCount2, pthisItemEquipLoc2; -- Initialize scoping for second variable.
local spec = "-";
local fullSpec = "";
if psName == nil then
-- print("ERROR!!! "..name.." linked an item that we couldn't pull the data for. Report the item to Blacksen on Curse or Wowinterface.")
-- LootCouncil_SendChatMessage("ERROR!!! "..name.." linked an item that we couldn't pull the data for. Report the item to Blacksen on Curse or Wowinterface.", "WHISPER", nil, name)
-- Abort
-- return;
--VERSION 2.1 FUNCTIONALITY:
-- So most items we're going to have to wait on.
-- Luckily, we have an OnUpdate function ready.
-- We just need to toss in the variables!
flagforwaiting = true;
end
if actualItemString2 and (specialSlot == true) then -- If they linked a second item and it was appropriate
if psName2 == nil then
-- print("ERROR!!! "..name.." linked an item that we couldn't pull the data for. Report the item to Blacksen on Curse or Wowinterface.")
-- LootCouncil_SendChatMessage("ERROR!!! "..name.." linked an item that we couldn't pull the data for. Report the item to Blacksen on Curse or Wowinterface.", "WHISPER", nil, name)
-- -- Abort
-- return;
flagforwaiting = true;
end
end
-- THIS ENTIRE NEXT PART IS DESIGNED TO GET THE PLAYER'S SPEC
-- Why is it such a hassle?
-- -- We want to take out the item links from what they said
-- -- Technically that's challenging, as we don't want to parse them incorrectly
-- -- Even worse would be if their item has the word "main" or "OFFSPEC" in it (like Maiden's Offering or something)
-- -- So, we break apart the message into 3 parts: before the itemlinks, the itemlinks, and after the itemlinks
-- -- To complicate it even more, colons and dashes won't work, so we have to take them out
-------------------------------------
-- DONE SEARCHING FOR SPEC
-------------------------------------
-------------------------------------
-- START UPDATING THE TABLES
-------------------------------------
-- This is a long if statement...
-- If this item has no equip loc (like tier tokens) OR (the two items they linked have the same equip loc )
-- AND (there either is no second item OR the second item has the same equip loc)
-- VERSION 2.1
-- All of this has been kept for legacy reasons
-- New function completely reworks this logic.
spec = "-";
if isShowingSpec == true then
spec = LootCouncil_Browser.parseSpec(msg, actualItemString, actualItemString2)
end
LootCouncil_Browser.printd(actualItemString);
if actualItemString2 then
LootCouncil_Browser.printd("BANG: " .. actualItemString2);
end
table.insert(entryPings, {
name,
spec,
actualItemString,
actualItemString2,
});
if flagforwaiting then
entryLinkWaiting = true;
LootCouncil_Browser.printd("MESSAGE BOUND: " .. msg);
sanityCheck = 0;
MainFrame:SetScript("OnUpdate", MainFrame_OnUpdate);
end
LootCouncil_Browser.addNewEntry2(#entryPings);
--Entry Pings Info
-- 1: Sender
-- 2: Spec
-- 3: ItemString1
-- 4: ItemString2
--[[
if ((thisItemEquipLoc == "") or (LootCouncil_Browser.translateToSlot(pthisItemEquipLoc) == LootCouncil_Browser.translateToSlot(thisItemEquipLoc)) and ((not pthisItemEquipLoc2) or (LootCouncil_Browser.translateToSlot(pthisItemEquipLoc2) == LootCouncil_Browser.translateToSlot(thisItemEquipLoc)))) then
local indexOfPlayer = LootCouncil_Browser.alreadyLinkedItem(name, psLink); -- Checks if they've linked an item
if indexOfPlayer > 0 then -- If they have
theEntry = LootCouncil_Browser.Elects[indexOfPlayer]; -- then get their row
theEntry[15] = spec; -- and update their spec
if pthisItemEquipLoc2 then -- If they have already linked an item, we already updated the first item, so we need to update the second
theEntry[2] = theEntry[2].."\n"..psLink2.." ("..piLevel2..")"; -- append the second item link onto the string
theEntry[3] = piLevel.." - "..piLevel2 -- Get the itemlevels set
theEntry[12] = 2; -- switch the flag for two items
theEntry[14] = psLink2; -- hold the second link
if LootCouncil_Lite_debugMode == false then -- If we're displaying messages
-- Send the player a message saying we got the update
if spec == "-" then
LootCouncil_SendChatMessage(string.format(LootCouncilLocalization["UPDATE_PROCESSED"], itemRunning), "WHISPER", nil, name);
else
LootCouncil_SendChatMessage(string.format(LootCouncilLocalization["UPDATE_PROCESSED_SPEC"], fullSpec, itemRunning), "WHISPER", nil, name);
end
LootCouncil_SendChatMessage(LootCouncilLocalization["UPDATE_PROCESSED_FEEDBACK2"]..theEntry[13].." - "..theEntry[14], "WHISPER", nil, name);
end
-- Update the clients
LootCouncil_Browser.sendGlobalMessage("itemEntry "..name.." "..actualItemString) -- Send out info to other council
LootCouncil_Browser.sendGlobalMessage("secondEntry "..name.." "..actualItemString2)
LootCouncil_Browser.sendGlobalMessage("spec "..name.." "..spec)
else -- Else they only have 1 item, so we don't need to do as much
if LootCouncil_Lite_debugMode == false then -- If we're displaying messages
-- Send the player a message saying we got the update
if spec == "-" then
LootCouncil_SendChatMessage(string.format(LootCouncilLocalization["UPDATE_PROCESSED"], itemRunning), "WHISPER", nil, name);
LootCouncil_SendChatMessage(LootCouncilLocalization["UPDATE_PROCESSED_FEEDBACK1"]..psLink, "WHISPER", nil, name);
else
LootCouncil_SendChatMessage(string.format(LootCouncilLocalization["UPDATE_PROCESSED_SPEC"], fullSpec, itemRunning), "WHISPER", nil, name);
LootCouncil_SendChatMessage(LootCouncilLocalization["UPDATE_PROCESSED_FEEDBACK1"]..psLink, "WHISPER", nil, name);
end
end
-- and Update the clients!
LootCouncil_Browser.sendGlobalMessage("itemEntry "..name.." "..actualItemString)
LootCouncil_Browser.sendGlobalMessage("spec "..name.." "..spec)
end
LootCouncil_Browser.Update(); -- Update the main graphs
if indexOfPlayer > 0 and LootCouncil_Browser.IsSelected(indexOfPlayer) then -- if they had them selected, update that too
LootCouncil_Browser.SelectEntry(indexOfPlayer)
end
else -- They haven't already linked an item, so we need to put them in the table.
if LootCouncil_Lite_debugMode == false then -- If we're sending messages
-- then let them know we got the message
if spec == "-" then
LootCouncil_SendChatMessage(string.format(LootCouncilLocalization["NEW_ENTRY"], itemRunning), "WHISPER", nil, name); -- Whisper them about their consideration
else
if spec == "M" then
fullSpec = "MAIN";
elseif spec == "OFF" then
fullSpec = "OFFSPEC";
elseif spec == "2SET" then
fullSpec = "BONUS SET (2 parts)";
elseif spec == "4SET" then
fullSpec = "BONUS SET (4 parts)";
elseif spec == "XMOG" then
fullSpec = "TRANSMOG";
elseif spec =="BIS" then