-
Notifications
You must be signed in to change notification settings - Fork 3
/
Core.lua
3333 lines (3149 loc) · 141 KB
/
Core.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
local addonName, Groupie = ...
local locale = GetLocale()
local addon = LibStub("AceAddon-3.0"):NewAddon(Groupie, addonName, "AceEvent-3.0",
"AceConsole-3.0",
"AceTimer-3.0")
local CI = LibStub("LibClassicInspector")
local LGS = LibStub:GetLibrary("LibGearScore.1000", true)
local LDD = LibStub("LibDropDown")
--L_UIDROPDOWNMENU_SHOW_TIME = 2 -- Timeout once the cursor leaves menu
local L = LibStub('AceLocale-3.0'):GetLocale('Groupie')
local localizedClass, englishClass = UnitClass("player")
local myserver = GetRealmName()
local myname = UnitName("player")
local mylevel = UnitLevel("player")
-------------------------
--Unsupported Locale UI--
-------------------------
if not addon.tableContains(addon.validLocales, locale) then
local GroupieFrame = nil
local function BuildGroupieWindow()
local LOCALE_WINDOW_WIDTH = 400
local LOCALE_WINDOW_HEIGHT = 200
GroupieFrame = CreateFrame("Frame", "Groupie", UIParent, "PortraitFrameTemplate")
GroupieFrame:Hide()
GroupieFrame:SetFrameStrata("DIALOG")
GroupieFrame:SetWidth(LOCALE_WINDOW_WIDTH)
GroupieFrame:SetHeight(LOCALE_WINDOW_HEIGHT)
GroupieFrame:SetPoint("CENTER", UIParent)
GroupieFrame:SetMovable(true)
GroupieFrame:EnableMouse(true)
GroupieFrame:RegisterForDrag("LeftButton", "RightButton")
GroupieFrame:SetClampedToScreen(true)
GroupieFrame.text = GroupieFrame.TitleText
GroupieFrame.text:SetText(addonName)
GroupieFrame:SetScript("OnMouseDown",
function(self)
self:StartMoving()
self.isMoving = true
end)
GroupieFrame:SetScript("OnMouseUp",
function(self)
if self.isMoving then
self:StopMovingOrSizing()
self.isMoving = false
end
end)
GroupieFrame:SetScript("OnShow", function() return end)
GroupieFrame:SetFrameStrata("DIALOG")
--Icon
local icon = GroupieFrame:CreateTexture("$parentIcon", "OVERLAY", nil, -8)
icon:SetSize(60, 60)
icon:SetPoint("TOPLEFT", -5, 7)
icon:SetTexture("Interface\\AddOns\\" .. addonName .. "\\Images\\icon128.tga")
--Info Text
local msg = GroupieFrame:CreateFontString("FontString", "OVERLAY", "GameFontHighlight")
msg:SetPoint("TOPLEFT", GroupieFrame, "TOPLEFT", 16, -64)
msg:SetWidth(LOCALE_WINDOW_WIDTH - 32)
msg:SetText("Localization is Coming Soon!\n\nUnfortunately, until then Groupie is Disabled for your locale.\nIf you'd like to help with Development or Translation, you can join our Discord.")
--Edit Box for Discord Link
local editBox = CreateFrame("EditBox", "GroupieEditBox", GroupieFrame, "InputBoxTemplate")
editBox:SetPoint("TOPLEFT", GroupieFrame, "TOPLEFT", 64, -128)
editBox:SetSize(LOCALE_WINDOW_WIDTH - 128, 50)
editBox:SetAutoFocus(false)
editBox:SetText("https://discord.gg/p68QgZ8uqF")
editBox:SetScript("OnTextChanged", function()
editBox:SetText("https://discord.gg/p68QgZ8uqF")
end)
GroupieFrame:Show()
end
BuildGroupieWindow()
addon.groupieLDB = LibStub("LibDataBroker-1.1"):NewDataObject(addonName, {
type = "data source",
text = addonName,
icon = "Interface\\AddOns\\" .. addonName .. "\\Images\\icon64.tga",
OnClick = function(self, button, down)
if button == "LeftButton" then
BuildGroupieWindow()
end
end,
OnTooltipShow = function(tooltip)
tooltip:AddLine(addonName)
tooltip:AddLine("A better LFG tool for Classic WoW.", 255, 255, 255, false)
tooltip:AddLine(" ")
tooltip:AddLine("Localization Coming Soon!")
end
})
local defaults = {
global = {
}
}
addon.db = LibStub("AceDB-3.0"):New("GroupieDB", defaults)
addon.icon = LibStub("LibDBIconGroupie-1.0")
addon.icon:Register("GroupieLDB", addon.groupieLDB, addon.db.global or defaults.global)
addon.icon:Hide("GroupieLDB")
return
end
--Main UI variables
local GroupieFrame = nil
local MainTabFrame = nil
local GroupieSettingsButton = nil
local GroupieRoleDropdown = nil
local GroupieLootDropdown = nil
local GroupieLangDropdown = nil
local GroupieLevelDropdown = nil
local ShowingFontStr = nil
local CharSheetSummaryFrame = nil
local MiniMapDropdown = nil
local columnCount = 0
local LFGScrollFrame = nil
local AddButton = nil
local SetNoteButton = nil
local WINDOW_WIDTH = 960
local WINDOW_HEIGHT = 640
local WINDOW_YOFFSET = -84
local ICON_WIDTH = 32
local WINDOW_OFFSET = 133
local BUTTON_HEIGHT = 40
local BUTTON_TOTAL = math.floor((WINDOW_HEIGHT - WINDOW_OFFSET) / BUTTON_HEIGHT) + 1
local BUTTON_WIDTH = WINDOW_WIDTH - 44
local COL_CREATED = 75
local COL_TIME = 75
local COL_LEADER = 105
local COL_INSTANCE = 135
local COL_LOOT = 76
local COL_FRIENDNAME = 105
local REMOVE_BTN_WIDTH = 75
local COL_GROUPIENOTE = 150
local COL_NOTE = WINDOW_WIDTH - COL_FRIENDNAME - REMOVE_BTN_WIDTH - COL_GROUPIENOTE - 58
local DROPDOWN_WIDTH = 100
local DROPDOWN_LEFTOFFSET = 115
local DROPDOWN_PAD = 32
local APPLY_BTN_WIDTH = 64
local COL_MSG = WINDOW_WIDTH - COL_CREATED - COL_TIME - COL_LEADER - COL_INSTANCE - COL_LOOT - ICON_WIDTH -
APPLY_BTN_WIDTH - 58
local SharedMedia = LibStub("LibSharedMedia-3.0")
local gsub = gsub
local time = time
addon.groupieBoardButtons = {}
addon.filteredListings = {}
addon.filteredFriends = {}
addon.selectedListing = nil
addon.ADDON_PREFIX = "Groupie.Core"
IgnoreListButtonMixin = {}
function IgnoreListButtonMixin:OnClick()
return
end
------------------
--User Interface--
------------------
--Create a sorted index of listings
--Sort Types : -1 (default) - Time Posted
-- 0 - Time Updated
-- 1 - Leader Name
-- 2 - Instance
-- 3 - Loot Type
local function GetSortedListingIndex(sortType, sortDir)
local idx = 1
local numindex = {}
local sortType = sortType or -1
local sortDir = sortDir or false
--Build a numerical index to sort on
for author, listing in pairs(addon.db.global.listingTable) do
numindex[idx] = listing
idx = idx + 1
end
--Then sort the index
if sortType == -1 then
if sortDir then
table.sort(numindex, function(a, b) return (a.createdat or 0) > (b.createdat or 0) end)
else
table.sort(numindex, function(a, b) return (a.createdat or 0) < (b.createdat or 0) end)
end
elseif sortType == 0 then
if sortDir then
table.sort(numindex, function(a, b) return a.timestamp > b.timestamp end)
else
table.sort(numindex, function(a, b) return a.timestamp < b.timestamp end)
end
elseif sortType == 1 then
if sortDir then
table.sort(numindex, function(a, b) return a.author < b.author end)
else
table.sort(numindex, function(a, b) return a.author > b.author end)
end
elseif sortType == 2 then
if sortDir then
table.sort(numindex, function(a, b) return a.instanceName < b.instanceName end)
else
table.sort(numindex, function(a, b) return a.instanceName > b.instanceName end)
end
elseif sortType == 3 then
if sortDir then
table.sort(numindex, function(a, b) return a.lootType < b.lootType end)
else
table.sort(numindex, function(a, b) return a.lootType > b.lootType end)
end
end
return numindex
end
--Create a sorted index of friends/ignores alphabetically by name
--Sort Types : -1 (default) - name
-- 0 - Groupie Note
-- 1 - User Note
local function GetSortedFriendIndex(sortType, sortDir)
local idx = 1
local numindex = {}
sortDir = sortDir or false
--Build a numerical index to sort on
if MainTabFrame.tabType == "friend" then --Friends
--Include Friends
for source, list in pairs(addon.db.global.friends[myserver]) do
if addon.db.global.hiddenFriendLists[myserver][source] then
--Hide this character's friends
else
for name, _ in pairs(list) do
numindex[idx] = {
name = name,
groupieNote = "Friend : " .. source,
userNote = addon.db.global.friendnotes[myserver][name] or "",
isGroupieFriend = false
}
idx = idx + 1
end
end
end
--Include Groupie Friends
for name, _ in pairs(addon.db.global.groupieFriends[myserver]) do
numindex[idx] = {
name = name,
groupieNote = "Groupie Global Friend",
userNote = addon.db.global.friendnotes[myserver][name] or "",
isGroupieFriend = true
}
idx = idx + 1
end
--Include Guilds
for source, guild in pairs(addon.db.global.guilds[myserver]) do
local currentGuildName = guild["__NAME__"]
if addon.db.global.hiddenGuilds[myserver][currentGuildName] then
--Hide this guild
else
for name, _ in pairs(guild) do
if name ~= "__NAME__" then
numindex[idx] = {
name = name,
groupieNote = "Guild : " .. currentGuildName,
userNote = addon.db.global.friendnotes[myserver][name] or "",
isGroupieFriend = false
}
idx = idx + 1
end
end
end
end
elseif MainTabFrame.tabType == "ignore" then --Ignores
--Include Ignores
for source, list in pairs(addon.db.global.ignores[myserver]) do
if addon.db.global.hiddenFriendLists[myserver][source] then
--Hide this character's ignores
else
for name, _ in pairs(list) do
numindex[idx] = {
name = name,
groupieNote = "Ignore : " .. source,
userNote = addon.db.global.ignorenotes[myserver][name] or "",
isGroupieFriend = false
}
idx = idx + 1
end
end
end
--Include Groupie Ignores
for name, _ in pairs(addon.db.global.groupieIgnores[myserver]) do
numindex[idx] = {
name = name,
groupieNote = "Groupie Global Ignore",
userNote = addon.db.global.ignorenotes[myserver][name] or "",
isGroupieFriend = true
}
idx = idx + 1
end
end
--Then sort the index
if sortType == -1 then --Name
if sortDir then
table.sort(numindex, function(a, b) return (a.name or 0) > (b.name or 0) end)
else
table.sort(numindex, function(a, b) return (a.name or 0) < (b.name or 0) end)
end
elseif sortType == 0 then --Groupie Note
if sortDir then
table.sort(numindex, function(a, b) return (a.groupieNote or 0) > (b.groupieNote or 0) end)
else
table.sort(numindex, function(a, b) return (a.groupieNote or 0) < (b.groupieNote or 0) end)
end
else --User Note
if sortDir then
table.sort(numindex, function(a, b) return (a.userNote or 0) > (b.userNote or 0) end)
else
table.sort(numindex, function(a, b) return (a.userNote or 0) < (b.userNote or 0) end)
end
end
return numindex
end
--Create a numerically indexed table of listings for use in the scroller
--Tab numbers:
-- 1 - Dungeons | 2 - Heroic Dungeons | 3 - 10 Raids
-- 4 - 25 Raids | 5 - Heroic 10 Raids | 6 - Heroic 25 Raids
-- 7 - PVP | 8 - Other | 9 - All
local function filterListings()
addon.filteredListings = {}
local idx = 1
local total = 0
local sortType = MainTabFrame.sortType or -1
local now = GetServerTime()
local sortDir = MainTabFrame.sortDir or false
local sorted = GetSortedListingIndex(sortType, sortDir)
if MainTabFrame.tabType == "pvp" then --PVP
for key, listing in pairs(sorted) do
if listing.lootType ~= L["Filters"].Loot_Styles.PVP then
--Wrong tab
--Other tab shows groups with 'pvp' loot type
--most filters do not apply to this tab
elseif now - listing.timestamp > addon.db.global.minsToPreserve * 60 then
--Expired based on user settings
else
local keywordBlacklistHit = false
for k, word in pairs(addon.db.global.keywordBlacklist) do
if addon.tableContains(listing.words, word) then
keywordBlacklistHit = true
end
end
if not keywordBlacklistHit then
addon.filteredListings[idx] = listing
idx = idx + 1
end
end
total = total + 1
end
elseif MainTabFrame.tabType == "other" then --Other
for key, listing in pairs(sorted) do
if listing.lootType ~= L["Filters"].Loot_Styles.Other then
--Wrong tab
--Other tab shows groups with 'other' loot type, and 40 man raids
--Loot type filters therefore dont apply to this tab
elseif now - listing.timestamp > addon.db.global.minsToPreserve * 60 then
--Expired based on user settings
elseif addon.db.char.ignoreLFM and listing.isLFM then
--Ignoring LFM groups
elseif addon.db.char.ignoreLFG and listing.isLFG then
--Ignoring LFG groups
elseif MainTabFrame.roleType ~= nil and
not addon.tableContains(listing.rolesNeeded, MainTabFrame.roleType) then
--Doesnt match role in the dropdown
elseif MainTabFrame.lang ~= nil and MainTabFrame.lang ~= listing.language then
--Doesnt match language in the dropdown
elseif addon.db.char.hideInstances[listing.order] == true then
--Ignoring specifically hidden instances
elseif addon.db.char.ignoreSavedInstances and addon.db.global.savedInstanceInfo[listing.order] and
addon.db.global.savedInstanceInfo[listing.order][myname] and
(addon.db.global.savedInstanceInfo[listing.order][myname].resetTime > now) then
--Ignore instances the player is saved to
if addon.debugMenus then
print("FILTERED DUE TO LOCKOUT: ", listing.fullName)
end
else
local keywordBlacklistHit = false
for k, word in pairs(addon.db.global.keywordBlacklist) do
if addon.tableContains(listing.words, word) then
keywordBlacklistHit = true
end
end
if not keywordBlacklistHit then
addon.filteredListings[idx] = listing
idx = idx + 1
end
end
total = total + 1
end
elseif MainTabFrame.tabType == "all" then --All
for key, listing in pairs(sorted) do
if now - listing.timestamp > addon.db.global.minsToPreserve * 60 then
--Expired based on user settings
elseif MainTabFrame.roleType ~= nil and
not addon.tableContains(listing.rolesNeeded, MainTabFrame.roleType) then
--Doesnt match role in the dropdown
elseif MainTabFrame.lootType ~= nil and MainTabFrame.lootType ~= listing.lootType then
--Doesnt match loot type in the dropdown
elseif MainTabFrame.lang ~= nil and MainTabFrame.lang ~= listing.language then
--Doesnt match language in the dropdown
else
local keywordBlacklistHit = false
for k, word in pairs(addon.db.global.keywordBlacklist) do
if addon.tableContains(listing.words, word) then
keywordBlacklistHit = true
end
end
if not keywordBlacklistHit then
addon.filteredListings[idx] = listing
idx = idx + 1
end
end
total = total + 1
end
else --Dungeon/Raid tabs
for key, listing in pairs(sorted) do
if listing.isHeroic ~= MainTabFrame.isHeroic then
--Wrong tab
elseif listing.groupSize ~= MainTabFrame.size then
--Wrong tab
elseif listing.lootType == L["Filters"].Loot_Styles.Other or listing.lootType == L["Filters"].Loot_Styles.PVP then
--Only show these groups in 'Other' and 'PVP' tabs
elseif now - listing.timestamp > addon.db.global.minsToPreserve * 60 then
--Expired based on user settings
elseif addon.db.char.ignoreLFM and listing.isLFM then
--Ignoring LFM groups
elseif addon.db.char.ignoreLFG and listing.isLFG then
--Ignoring LFG groups
elseif MainTabFrame.roleType ~= nil and
not addon.tableContains(listing.rolesNeeded, MainTabFrame.roleType) then
--Doesnt match role in the dropdown
elseif MainTabFrame.lootType ~= nil and MainTabFrame.lootType ~= listing.lootType then
--Doesnt match loot type in the dropdown
elseif MainTabFrame.lang ~= nil and MainTabFrame.lang ~= listing.language then
--Doesnt match language in the dropdown
elseif MainTabFrame.levelFilter and listing.minLevel and
MainTabFrame.size == 5 and MainTabFrame.isHeroic == false
and listing.minLevel > (mylevel + addon.db.char.recommendedLevelRange) then
--Instance is outside of level range (ONLY for normal dungeons)
elseif MainTabFrame.levelFilter and listing.maxLevel and
MainTabFrame.size == 5 and MainTabFrame.isHeroic == false
and listing.maxLevel < mylevel then
--Instance is outside of level range (ONLY for normal dungeons)
elseif addon.db.char.hideInstances[listing.order] == true then
--Ignoring specifically hidden instances
elseif addon.db.char.ignoreSavedInstances and addon.db.global.savedInstanceInfo[listing.order] and
addon.db.global.savedInstanceInfo[listing.order][myname] and
(addon.db.global.savedInstanceInfo[listing.order][myname].resetTime > now) then
--Ignore instances the player is saved to
if addon.debugMenus then
print("FILTERED DUE TO LOCKOUT: ", listing.fullName)
end
else
--Check for blacklisted words
local keywordBlacklistHit = false
for k, word in pairs(addon.db.global.keywordBlacklist) do
if addon.tableContains(listing.words, word) then
keywordBlacklistHit = true
end
end
if not keywordBlacklistHit then
addon.filteredListings[idx] = listing
idx = idx + 1
end
end
total = total + 1
end
end
MainTabFrame.infotext:SetText(format(
"Showing %d of %d possible groups. To see more groups adjust your [Group Filters] or [Instance Filters] under Groupie > Settings."
, idx - 1, total))
if addon.debugMenus then
MainTabFrame.infotext:Show()
else
MainTabFrame.infotext:Hide()
end
end
--Create a numerically indexed table of listings for use in the scroller
--Tab numbers:
-- 10 - Friends | 11 - Ignores
local function filterFriends()
addon.filteredFriends = {}
local seen = {}
local idx = 1
local sortDir = MainTabFrame.sortDir or false
local sortType = MainTabFrame.sortType or -1
local sorted = GetSortedFriendIndex(sortType, sortDir)
for key, listing in pairs(sorted) do
--Ensure no duplicates
if not addon.tableContains(seen, listing.name) then
local ownCharFlag = false
--Dont include the player's own alts
for k, v in pairs(addon.db.global.friends) do
for k2, v2 in pairs(v) do
local shortName = k2:gsub(" %-.+", "")
if strlower(listing.name) == strlower(shortName) then
ownCharFlag = true
end
end
end
if not ownCharFlag then
addon.filteredFriends[idx] = listing
idx = idx + 1
tinsert(seen, listing.name)
end
end
end
end
--Apply filters and draw matching listings in the LFG board
local function DrawListings(self)
--Create a numerical index for use populating the table
filterListings()
FauxScrollFrame_Update(self, #addon.filteredListings, BUTTON_TOTAL, BUTTON_HEIGHT)
if addon.selectedListing then
if addon.selectedListing > #addon.filteredListings then
addon.selectedListing = nil
end
end
local offset = FauxScrollFrame_GetOffset(self)
local idx = 0
local myName = myname .. "-" .. gsub(GetRealmName(), " ", "")
for btnNum = 1, BUTTON_TOTAL do
idx = btnNum + offset
local button = addon.groupieBoardButtons[btnNum]
local listing = addon.filteredListings[idx]
if idx <= #addon.filteredListings then
if btnNum == addon.selectedListing then
button:LockHighlight()
else
button:UnlockHighlight()
end
local formattedMsg = gsub(gsub(listing.msg, "%{%w+%}", ""), "%s+", " ")
local lootColor = addon.lootTypeColors[listing.lootType]
button.listing = listing
button.created:SetText(addon.GetTimeSinceString(listing.createdat, 2))
button.time:SetText(addon.GetTimeSinceString(listing.timestamp, 2))
button.leader:SetText("|cFF" .. listing.classColor .. gsub(listing.author, "-.+", ""))
button.instance:SetText(listing.instanceName)
button.loot:SetText("|cFF" .. lootColor .. listing.lootType)
button.msg:SetText(formattedMsg)
local texture = listing.icon
if type(listing.icon) == "string" then
if listing.icon:find("Interface\\") then -- it's a full path
texture = listing.icon
else
texture = "Interface\\AddOns\\" .. addonName .. "\\Images\\InstanceIcons\\" .. listing.icon
end
end
button.icon:SetTexture(texture)
button.btn:SetScript("OnClick", function()
addon.SendPlayerInfo(listing.author, nil, nil, listing.fullName, listing.resultID)
listing.messageSent = true
listing.senderName = myname
end)
button.btn:SetScript("OnEnter", function()
local groupieMsg = addon.GetPlayerInfoMsg(listing.fullName,nil,true)
if groupieMsg and #groupieMsg > 0 then
local color = CreateColor(ChatTypeInfo["WHISPER"].r, ChatTypeInfo["WHISPER"].g, ChatTypeInfo["WHISPER"].b)
groupieMsg = color:WrapTextInColorCode(groupieMsg)
else
groupieMsg = nil
end
if groupieMsg then
GameTooltip:SetOwner(button.btn, "ANCHOR_CURSOR")
GameTooltip:SetText(L["ClickSend"],246/255,235/255,97/25, 1, false)
GameTooltip:AddLine(groupieMsg, 1, 1, 1, 1, true)
GameTooltip:Show()
end
end)
button.btn:SetScript("OnLeave", function()
if GameTooltip:IsOwned(button.btn) then
GameTooltip:Hide()
end
end)
--clear messages sent on switching characters
if listing.messageSent and myname ~= listing.senderName then
listing.messageSent = nil
listing.senderName = nil
end
--Change
if listing.messageSent then
button.btn:SetText("|TInterface\\AddOns\\" ..
addonName .. "\\Images\\load" .. tostring(MainTabFrame.animFrame + 1) .. ":10:32:0:-1|t")
else
button.btn:SetText(L["Reply"])
end
if myName == button.listing.author and not addon.debugMenus then
button.btn:Hide()
else
button.btn:Show()
end
button:SetScript("OnEnter", function()
GameTooltip:SetOwner(button, "ANCHOR_CURSOR")
GameTooltip:SetText(formattedMsg, 1, 1, 1, 1, true)
GameTooltip:Show()
end)
button:SetID(idx)
button:Show()
btnNum = btnNum + 1
else
button:Hide()
end
end
end
--Draw Friends/Ignore listings in the LFG board
local function DrawFriends(self)
--Create a numerical index for use populating the table
filterFriends()
FauxScrollFrame_Update(self, #addon.filteredFriends, BUTTON_TOTAL, BUTTON_HEIGHT)
if addon.selectedListing then
if addon.selectedListing > #addon.filteredFriends then
addon.selectedListing = nil
if SetNoteButton then
SetNoteButton:Hide()
end
else
if SetNoteButton then
SetNoteButton:Show()
end
end
else
if SetNoteButton then
SetNoteButton:Hide()
end
end
local offset = FauxScrollFrame_GetOffset(self)
local idx = 0
local myName = myname .. "-" .. gsub(GetRealmName(), " ", "")
for btnNum = 1, BUTTON_TOTAL do
idx = btnNum + offset
local button = addon.friendBoardButtons[btnNum]
local listing = addon.filteredFriends[idx]
if idx <= #addon.filteredFriends then
if btnNum == addon.selectedListing then
button:LockHighlight()
else
button:UnlockHighlight()
end
button.listing = listing
button.name:SetText(listing.name)
button.groupieNote:SetText(listing.groupieNote)
button.userNote:SetText(listing.userNote)
button.btn:SetScript("OnClick", function()
if MainTabFrame.tabType == "friend" then
addon.db.global.groupieFriends[myserver][listing.name] = nil
else
addon.db.global.groupieIgnores[myserver][listing.name] = nil
end
addon.UpdateFriends()
end)
if listing.isGroupieFriend then
button.btn:Show()
else
button.btn:Hide()
end
button:SetScript("OnEnter", function()
GameTooltip:SetOwner(button, "ANCHOR_CURSOR")
GameTooltip:SetText(listing.userNote, 1, 1, 1, 1, true)
GameTooltip:Show()
end)
button:SetID(idx)
button:Show()
btnNum = btnNum + 1
else
button:Hide()
end
end
end
--Onclick for group listings, highlights the selected listing
local function ListingOnClick(self, button, down)
if addon.selectedListing then
addon.groupieBoardButtons[addon.selectedListing]:UnlockHighlight()
end
addon.selectedListing = self.id
addon.groupieBoardButtons[addon.selectedListing]:LockHighlight()
local fullName = addon.groupieBoardButtons[addon.selectedListing].listing.author
local instance = addon.groupieBoardButtons[addon.selectedListing].listing.instanceName
local fullInstance = addon.groupieBoardButtons[addon.selectedListing].listing.fullName
local displayName = gsub(fullName, "-.+", "")
local resultID = addon.groupieBoardButtons[addon.selectedListing].listing.resultID
DrawListings(LFGScrollFrame)
--Select a listing, if shift is held, do a Who Request
if button == "LeftButton" then
if addon.debugMenus then
for k, v in pairs(addon.ignoreList) do
print(k, v)
end
end
if IsShiftKeyDown() then
DEFAULT_CHAT_FRAME.editBox:SetText("/who " .. fullName)
ChatEdit_SendText(DEFAULT_CHAT_FRAME.editBox)
end
--Open Right click Menu
elseif button == "RightButton" then
local activeSpecGroup = addon.GetActiveSpecGroup()
local maxTalentSpec, maxTalentsSpent = addon.GetSpecByGroupNum(activeSpecGroup)
local isIgnored = C_FriendList.IsIgnored(displayName)
local ignoreText = L["RightClickMenu"].Ignore
local activeRole = ""
if activeSpecGroup == 1 then
activeRole = addon.groupieRoleTable[addon.db.char.groupieSpec1Role]
else
activeRole = addon.groupieRoleTable[addon.db.char.groupieSpec2Role]
end
if isIgnored then
ignoreText = L["RightClickMenu"].StopIgnore
end
local ListingRightClick = {
{ text = displayName, isTitle = true, notCheckable = true },
{ text = L["RightClickMenu"].Invite, notCheckable = true, func = function() InviteUnit(displayName) end },
{ text = L["RightClickMenu"].Whisper, notCheckable = true, func = function()
ChatFrame_OpenChat("/w " .. fullName .. " ")
end },
{ text = ignoreText, notCheckable = true, func = function()
C_FriendList.AddOrDelIgnore(displayName)
end },
{ text = "", disabled = true, notCheckable = true },
{ text = addonName, isTitle = true, notCheckable = true },
{ text = L["RightClickMenu"].SendInfo, notClickable = true, notCheckable = true },
{ text = format(L["RightClickMenu"].Current .. " : %s (%s)", maxTalentSpec, activeRole), notCheckable = true,
leftPadding = 8,
func = function()
if instance ~= "Miscellaneous" and instance ~= L["Filters"].Loot_Styles.PVP then
addon.SendPlayerInfo(fullName, nil, nil, fullInstance, resultID)
else
addon.SendPlayerInfo(fullName)
end
end },
}
if GetLocale() == "enUS" then
tinsert(ListingRightClick, { text = L["RightClickMenu"].WCL, notCheckable = true, leftPadding = 8,
func = function()
addon.SendWCLInfo(fullName)
end })
end
local f = CreateFrame("Frame", "GroupieListingRightClick", UIParent, "UIDropDownMenuTemplate")
EasyMenu(ListingRightClick, f, "cursor", 0, 0, "MENU")
end
end
--Onclick for group listings, highlights the selected listing
local function FriendListingOnClick(self, button, down)
if addon.selectedListing then
addon.friendBoardButtons[addon.selectedListing]:UnlockHighlight()
end
addon.selectedListing = self.id
addon.friendBoardButtons[addon.selectedListing]:LockHighlight()
local name = addon.friendBoardButtons[addon.selectedListing].listing.name
DrawFriends(FriendScrollFrame)
if addon.debugMenus then
local a = {}
tinsert(a, "s")
print(addon.tableContains(a, "s"))
end
--Select a listing, if shift is held, do a Who Request
if button == "LeftButton" then
if IsShiftKeyDown() then
DEFAULT_CHAT_FRAME.editBox:SetText("/who " .. name)
ChatEdit_SendText(DEFAULT_CHAT_FRAME.editBox)
end
--Open Right click Menu
elseif button == "RightButton" then
end
end
--Create entries in the LFG board for each group listing
local function CreateFriendListingButtons()
addon.friendBoardButtons = {}
local currentListing
for listcount = 1, BUTTON_TOTAL do
addon.friendBoardButtons[listcount] = CreateFrame(
"Button",
"ListingBtn" .. tostring(listcount),
FriendScrollFrame:GetParent(),
"IgnoreListButtonTemplate2"
)
currentListing = addon.friendBoardButtons[listcount]
if listcount == 1 then
currentListing:SetPoint("TOPLEFT", FriendScrollFrame, -1, 0)
else
currentListing:SetPoint("TOP", addon.friendBoardButtons[listcount - 1], "BOTTOM", 0, 0)
end
currentListing:SetSize(BUTTON_WIDTH, BUTTON_HEIGHT)
currentListing:RegisterForClicks("LeftButtonUp", "RightButtonUp")
currentListing:SetScript("OnClick", FriendListingOnClick)
currentListing:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
--Name Column
currentListing.name:SetWidth(COL_FRIENDNAME)
--Groupie Note Column
currentListing.groupieNote = currentListing:CreateFontString("FontString", "OVERLAY", "GameFontNormal")
currentListing.groupieNote:SetPoint("LEFT", currentListing.name, "RIGHT", 0, 0)
currentListing.groupieNote:SetWidth(COL_GROUPIENOTE)
currentListing.groupieNote:SetJustifyH("LEFT")
currentListing.groupieNote:SetJustifyV("MIDDLE")
--User Note Column
currentListing.userNote = currentListing:CreateFontString("FontString", "OVERLAY", "GameFontHighlight")
currentListing.userNote:SetPoint("LEFT", currentListing.groupieNote, "RIGHT", -4, 0)
currentListing.userNote:SetWidth(COL_NOTE)
currentListing.userNote:SetJustifyH("LEFT")
currentListing.userNote:SetJustifyV("MIDDLE")
--Apply button
currentListing.btn = CreateFrame("Button", "$parentApplyBtn", currentListing, "UIPanelButtonTemplate")
currentListing.btn:SetPoint("LEFT", currentListing.userNote, "RIGHT", 4, 0)
currentListing.btn:SetWidth(REMOVE_BTN_WIDTH)
currentListing.btn:SetText("Remove")
currentListing.btn:SetScript("OnClick", function()
addon.UpdateFriends()
end)
currentListing.id = listcount
listcount = listcount + 1
--Initially hide for friend columns
currentListing:Hide()
end
DrawFriends(FriendScrollFrame)
end
--Create entries in the LFG board for each group listing
local function CreateListingButtons()
addon.groupieBoardButtons = {}
local currentListing
for listcount = 1, BUTTON_TOTAL do
addon.groupieBoardButtons[listcount] = CreateFrame(
"Button",
"ListingBtn" .. tostring(listcount),
LFGScrollFrame:GetParent(),
"IgnoreListButtonTemplate"
)
currentListing = addon.groupieBoardButtons[listcount]
if listcount == 1 then
currentListing:SetPoint("TOPLEFT", LFGScrollFrame, -1, 0)
else
currentListing:SetPoint("TOP", addon.groupieBoardButtons[listcount - 1], "BOTTOM", 0, 0)
end
currentListing:SetSize(BUTTON_WIDTH, BUTTON_HEIGHT)
currentListing:RegisterForClicks("LeftButtonUp", "RightButtonUp")
currentListing:SetScript("OnClick", ListingOnClick)
currentListing:SetScript("OnLeave", function()
GameTooltip:Hide()
end)
--Created at column
currentListing.created:SetWidth(COL_CREATED)
--Time column
currentListing.time = currentListing:CreateFontString("FontString", "OVERLAY", "GameFontNormal")
currentListing.time:SetPoint("LEFT", currentListing.created, "RIGHT", 0, 0)
currentListing.time:SetWidth(COL_TIME)
currentListing.time:SetJustifyH("LEFT")
currentListing.time:SetJustifyV("MIDDLE")
--Leader name column
currentListing.leader = currentListing:CreateFontString("FontString", "OVERLAY", "GameFontNormal")
currentListing.leader:SetPoint("LEFT", currentListing.time, "RIGHT", -4, 0)
currentListing.leader:SetWidth(COL_LEADER)
currentListing.leader:SetJustifyH("LEFT")
currentListing.leader:SetJustifyV("MIDDLE")
--Instance expansion column
currentListing.icon = currentListing:CreateTexture("$parentIcon", "OVERLAY", nil, -8)
currentListing.icon:SetSize(ICON_WIDTH, ICON_WIDTH / 2)
currentListing.icon:SetPoint("LEFT", currentListing.leader, "RIGHT", -4, 0)
currentListing.icon:SetTexture("Interface\\AddOns\\" .. addonName .. "\\Images\\InstanceIcons\\Other.tga")
--Instance name column
currentListing.instance = currentListing:CreateFontString("FontString", "OVERLAY", "GameFontHighlight")
currentListing.instance:SetPoint("LEFT", currentListing.icon, "RIGHT", 8, 0)
currentListing.instance:SetWidth(COL_INSTANCE)
currentListing.instance:SetJustifyH("LEFT")
currentListing.instance:SetJustifyV("MIDDLE")
--Loot type column
currentListing.loot = currentListing:CreateFontString("FontString", "OVERLAY", "GameFontHighlight")
currentListing.loot:SetPoint("LEFT", currentListing.instance, "RIGHT", 2, 0)
currentListing.loot:SetWidth(COL_LOOT)
currentListing.loot:SetJustifyH("LEFT")
currentListing.loot:SetJustifyV("MIDDLE")
currentListing.loot:SetTextColor(0, 173, 239)
--Posting message column
currentListing.msg = currentListing:CreateFontString("FontString", "OVERLAY", "GameFontHighlight")
currentListing.msg:SetPoint("LEFT", currentListing.loot, "RIGHT", -4, 0)
currentListing.msg:SetWidth(COL_MSG)
currentListing.msg:SetJustifyH("LEFT")
currentListing.msg:SetJustifyV("MIDDLE")
currentListing.msg:SetWordWrap(false)
--Apply button
currentListing.btn = CreateFrame("Button", "$parentApplyBtn", currentListing, "UIPanelButtonTemplate")
currentListing.btn:SetPoint("LEFT", currentListing.msg, "RIGHT", 4, 0)
currentListing.btn:SetWidth(APPLY_BTN_WIDTH)
currentListing.btn:SetText(L["Reply"])
currentListing.btn:SetScript("OnClick", function()
return
end)
currentListing.id = listcount
listcount = listcount + 1
end
DrawListings(LFGScrollFrame)
end
--Create column headers for the main tab
local function createColumn(text, width, parent, sortType, isFriendTab)
columnCount = columnCount + 1
local Header = CreateFrame("Button", parent:GetName() .. "Header" .. columnCount, parent,
"WhoFrameColumnHeaderTemplate")
Header:SetWidth(width)
_G[parent:GetName() .. "Header" .. columnCount .. "Middle"]:SetWidth(width - 9)
Header:SetText(text)
Header:SetNormalFontObject("GameFontHighlight")
Header:SetID(columnCount)
if text == L["UI_columns"].Message then
Header:Disable()
end
if columnCount == 1 or columnCount == 7 then
Header:SetPoint("TOPLEFT", parent, "TOPLEFT", 1, 22)
else
Header:SetPoint("LEFT", parent:GetName() .. "Header" .. columnCount - 1, "RIGHT", 0, 0)
end
if sortType ~= nil then
Header:SetScript("OnClick", function()
MainTabFrame.sortType = sortType
MainTabFrame.sortDir = not MainTabFrame.sortDir
if isFriendTab then
DrawFriends(FriendScrollFrame)
else
DrawListings(LFGScrollFrame)
end
end)
else
Header:SetScript("OnClick", function() return end)
end
end
--Listing update timer
local function TimerListingUpdate()
if not addon.lastUpdate then
addon.lastUpdate = GetTime()
addon.lastAnimUpdate = addon.lastUpdate
end
local now = GetTime()
--Animate the spinner texture by cycling
if (now - addon.lastAnimUpdate) > 0.4 then
addon.lastAnimUpdate = now
MainTabFrame.animFrame = (MainTabFrame.animFrame + 1) % 3
end
--Draw the listings
if (now - addon.lastUpdate) > 0.1 then
addon.lastUpdate = now
if MainTabFrame.tabType ~= "friend" and MainTabFrame.tabType ~= "ignore" then
DrawListings(LFGScrollFrame)
else