-
Notifications
You must be signed in to change notification settings - Fork 0
/
CEBiSTracker.lua
793 lines (727 loc) · 25.4 KB
/
CEBiSTracker.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
cbtConfigDB = {
editRank = 1,
}
ceMinimapDB = {
hide = false,
}
playersDB = {}
local selectedPlayer = {}
local userRankIndex = -1
local overrideMinRank = false
local versionsDict = {}
local subscribers = ""
local cebistracker = LibStub("AceAddon-3.0"):NewAddon("CEBiSTracker", "AceComm-3.0", "AceEvent-3.0", "AceHook-3.0", "AceSerializer-3.0")
local AceGUI = LibStub("AceGUI-3.0")
local LD = LibStub("LibDeflate")
local LSM = LibStub("LibSharedMedia-3.0")
local DEFAULT_FONT = LSM.MediaTable.font[LSM:GetDefault('font')]
--table.removekey Function
function table.removekey(t, key)
local element = t[key]
t[key] = nil
return element
end
-- local A1, A2 = 727595, 798405 -- 5^17=D20*A1+A2
-- local D20, D40 = 1048576, 1099511627776 -- 2^20, 2^40
-- local X1, X2 = 0, 1
-- --math.randomseed(os.time())
-- function cebistracker:GetRandom()
-- local U = X2*A2
-- local V = (X1*A2 + X2*A1) % D20
-- V = (V*D20 + U) % D40
-- X1 = math.floor(V/D20)
-- X2 = V - X1*D20
-- return V/D40
-- end
function cebistracker:GetRandomInt()
return math.floor(math.random() * 10)
end
function cebistracker:GetRandomLetter()
local letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local int = math.floor(math.random() * 26)
return letters:sub(int + 1, int + 1)
end
function cebistracker:GetRandomLetterOrInt()
local int = self:GetRandomInt()
if int < 5 then
return self:GetRandomInt()
else
return self:GetRandomLetter()
end
end
function cebistracker:GetGUID()
local guid = ""
for _ = 1, 8 do
guid = guid .. self:GetRandomLetterOrInt()
end
guid = guid .. "-"
for _ = 1, 4 do
guid = guid .. self:GetRandomLetterOrInt()
end
guid = guid .. "-"
for _ = 1, 4 do
guid = guid .. self:GetRandomLetterOrInt()
end
guid = guid .. "-"
for _ = 1, 4 do
guid = guid .. self:GetRandomLetterOrInt()
end
guid = guid .. "-"
for _ = 1, 12 do
guid = guid .. self:GetRandomLetterOrInt()
end
return guid
end
--pairsByKeys Function
local function pairsByKeys(t, f)
local a = {}
for n in pairs(t) do table.insert(a, n) end
table.sort(a, f)
local i = 0 -- iterator variable
local iter = function () -- iterator function
i = i + 1
if a[i] == nil then return nil
else return a[i], t[a[i]]
end
end
return iter
end
function cebistracker:GetMyClassColor()
local color = RAID_CLASS_COLORS[UnitClass("player"):upper()]
return color.colorStr
end
--GetPlayerByName Function
function cebistracker:GetPlayerByName(name)
for _, player in pairs(playersDB) do
if player.name == name then
return player
end
end
end
function cebistracker:GetPermission()
if cbtConfigDB.editRank == 1 then
return true
elseif(userRankIndex <= cbtConfigDB.editRank - 1) then
return true
else
return false
end
end
function cebistracker:ToggleBoxes(enabled)
local permission = cebistracker:GetPermission()
for _, obj in ipairs(gearButtons) do
if not permission then
obj.checkbox:SetDisabled(true)
else
obj.checkbox:SetDisabled(not enabled)
end
end
end
--UpdatePermissions Function
function cebistracker:UpdatePermissions()
local permission = self:GetPermission()
self.editRank:SetDisabled(not permission)
self.importRaid:SetDisabled(not permission)
self.broadcast:SetDisabled(not permission)
self.ToggleBoxes(permission)
end
--Clear All Labels Function
function cebistracker:AllItemsFalse()
for _, obj in ipairs(gearButtons) do
obj.checkbox:SetValue(false)
end
end
--Select Player Function
function cebistracker:SelectPlayer(labelIndex)
local errorMessage = "Invalid index."
if not labelIndex then
return errorMessage
end
local playerLabel = self.players.playerLabels[labelIndex]
if not playerLabel then
return errorMessage
end
local player = playerLabel.player
if not player then
return errorMessage
end
self:AllItemsFalse()
self:ToggleBoxes(true)
selectedPlayer = player
--|cFFFF7D0A<Casual Encounters> BiS Tracker|r
self.gearLabel:SetText("|c" .. player.classColor.colorStr .. player.name .. "'s|r BiS Tokens")
for item, value in pairs(player.items) do
gearButtons[gearNameToIndex[item]].checkbox:SetValue(value)
end
end
function cebistracker:PopulatePlayers()
local labelIndex = 0
local playerLabels = self.players.playerLabels
local populate = function (index)
labelIndex = labelIndex + 1
local player = playersDB[index]
local label
if playerLabels[labelIndex] then
label = playerLabels[labelIndex]
label.frame:EnableMouse(true)
else
label = AceGUI:Create("InteractiveLabel")
label:SetFont(DEFAULT_FONT, 12, "")
label.label:SetTextColor(player.classColor.r, player.classColor.g, player.classColor.b, 1)
label:SetHighlight("Interface\\Buttons\\UI-Listbox-Highlight")
label:SetFullWidth(true)
label.OnClick = function()
if GetMouseButtonClicked() == "LeftButton" then
self:SelectPlayer(label.labelIndex)
elseif GetMouseButtonClicked() == "RightButton" then
self.playerDropdownMenu.clickedEntry = label.dbIndex
self.playerDropdownMenu:Show()
end
end
label:SetCallback("OnClick", label.OnClick)
self.players:AddChild(label)
table.insert(playerLabels, label)
end
label.dbIndex = index
label.labelIndex = labelIndex
label.player = player
label:SetText(player.name)
label.label:SetTextColor(player.classColor.r, player.classColor.g, player.classColor.b, 1)
end
local playerKeys = {}
for index, player in ipairs(playersDB) do
playerKeys[player.name] = index
end
for _, index in pairsByKeys(playerKeys) do
populate(index)
end
while labelIndex < #playerLabels do
labelIndex = labelIndex + 1
playerLabels[labelIndex].player = nil
playerLabels[labelIndex]:SetText(nil)
playerLabels[labelIndex].frame:EnableMouse(false)
end
self.players:DoLayout()
self:AllItemsFalse()
self:ToggleBoxes(false)
self.gearLabel:SetText("Select a player")
end
local function GetRaidPlayers()
local raidPlayers = {}
local subGroups = {}
for group = 1, 8 do
table.insert(subGroups, {})
end
for index = 1, 40 do
-- setting fileName as class, since it should be language agnostic
local name, _, subgroup, _, _, class = GetRaidRosterInfo(index)
if name then
name = strsplit("-", name)
table.insert(subGroups[subgroup], name)
raidPlayers[name] = {}
raidPlayers[name].name = name
raidPlayers[name].class = class
local color = RAID_CLASS_COLORS[class:upper()]
raidPlayers[name].classColor = {}
raidPlayers[name].classColor.r = color.r
raidPlayers[name].classColor.g = color.g
raidPlayers[name].classColor.b = color.b
raidPlayers[name].classColor.colorStr = color.colorStr
raidPlayers[name].items = {
-- head = false,
-- neck = false,
-- shoulders = false,
-- back = false,
-- chest = false,
-- wrist = false,
-- hands = false,
-- waist = false,
-- legs = false,
-- feet = false,
-- finger1 = false,
-- finger2 = false,
-- trinket1 = false,
-- trinket2 = false,
-- mainhand = false,
-- offhand = false,
-- ranged = false
}
end
end
return raidPlayers
end
function cebistracker:SendComm(message)
local messageSerialized = LD:EncodeForWoWAddonChannel(LD:CompressDeflate(self:Serialize(message)))
self:SendCommMessage("cebistracker", messageSerialized, "GUILD")
end
function cebistracker:SendCommTo(message, player)
local messageSerialized = LD:EncodeForWoWAddonChannel(LD:CompressDeflate(self:Serialize(message)))
self:SendCommMessage("cebistracker", messageSerialized, "WHISPER", player)
end
function cebistracker:Broadcast()
local message = {
key = "BROADCAST",
sender = UnitName("player"),
value = {
players = playersDB,
config = cbtConfigDB
}
}
self:SendComm(message)
end
--OnCommReceived Function
function cebistracker:OnCommReceived(prefix, message, distribution, sender)
if prefix ~= "cebistracker" or sender == UnitName("player") or not message then
return
end
local decoded = LD:DecodeForWoWAddonChannel(message)
if not decoded then
print("Could not decode addon message. Sender needs to update to the latest version of cleangroupassigns!")
return
end
local decompressed = LD:DecompressDeflate(decoded)
if not decompressed then
print("Failed to decompress addon message. Sender needs to update to the latest version of cleangroupassigns!")
return
end
local didDeserialize, message = self:Deserialize(decompressed)
if not didDeserialize then
print("Failed to deserialize sync: " .. message)
return
end
local key = message["key"]
if not key then
print("Failed to parse deserialized comm.")
return
end
if key == "BROADCAST" then
local value = message["value"]
local sender = message["sender"]
if(self.broadcastConfirm and self.broadcastConfirm:IsVisible()) then
self.broadcastConfirm:Show()
return
end
self.broadcastConfirm = AceGUI:Create("Frame")
self.broadcastConfirm:SetWidth(300)
self.broadcastConfirm:SetHeight(200)
self.broadcastConfirm:SetTitle("Accept Broadcast from " .. sender .. "?")
self.broadcastConfirm:SetCallback("OnClose", function(widget) AceGUI:Release(widget) self.broadcastConfirm = nil end)
self.broadcastConfirm:SetLayout("Flow")
self.broadcastConfirm:EnableResize(false)
local yesButton = AceGUI:Create("Button")
yesButton:SetText("Yes")
yesButton:SetWidth(100)
yesButton:SetCallback("OnClick", function()
playersDB = value.players
cbtConfigDB = value.config
overrideMinRank = true
self.editRank:SetValue(cbtConfigDB.editRank)
overrideMinRank = false
self:UpdatePermissions()
self:PopulatePlayers()
AceGUI:Release(self.broadcastConfirm)
self.broadcastConfirm = nil
local returnMessage = {
key = "BROADCAST_ACCEPTED",
sender = UnitName("player"),
senderColor = self:GetMyClassColor()
}
self:SendCommTo(returnMessage, sender)
end)
local noButton = AceGUI:Create("Button")
noButton:SetText("No")
noButton:SetWidth(100)
noButton:SetCallback("OnClick", function()
AceGUI:Release(self.broadcastConfirm)
self.broadcastConfirm = nil
end)
AceGUI:RegisterLayout("ConfirmBroadcastLayout", function()
if self.broadcastConfirm.frame:GetWidth() > 300 then
self.broadcastConfirm:SetWidth(300)
end
if self.broadcastConfirm.frame:GetHeight() > 200 then
self.broadcastConfirm:SetHeight(200)
end
yesButton:SetPoint("RIGHT", self.broadcastConfirm.frame, "CENTER", -5, 0)
noButton:SetPoint("LEFT", self.broadcastConfirm.frame, "CENTER", 5, 0)
end)
self.broadcastConfirm:AddChild(yesButton)
self.broadcastConfirm:AddChild(noButton)
self.broadcastConfirm:SetLayout("ConfirmBroadcastLayout")
self.broadcastConfirm:DoLayout()
elseif key == "ADDCHECK" then
local baseGUID = message["baseGUID"]
if cbtConfigDB.baseGUID and baseGUID ~= cbtConfigDB.baseGUID then
return
end
local value = message["value"]
local affectedPlayer = message["player"]
local found = false
for _, player in pairs(playersDB) do
if player.name == affectedPlayer then
if selectedPlayer and selectedPlayer.name == affectedPlayer then
gearButtons[gearNameToIndex[value]].checkbox:SetValue(true)
end
player.items[value] = true
found = true
break
end
end
if not found then
local returnMessage = {
key = "MISSING_PLAYER",
sender = UnitName("player"),
player = affectedPlayer
}
self:SendCommTo(returnMessage, sender)
end
elseif key == "REMOVECHECK" then
local baseGUID = message["baseGUID"]
if cbtConfigDB.baseGUID and baseGUID ~= cbtConfigDB.baseGUID then
return
end
local value = message["value"]
local affectedPlayer = message["player"]
local found = false
for _, player in pairs(playersDB) do
if player.name == affectedPlayer then
if selectedPlayer and selectedPlayer.name == affectedPlayer then
gearButtons[gearNameToIndex[value]].checkbox:SetValue(false)
end
table.removekey(player.items, value)
found = true
break
end
end
if not found then
local returnMessage = {
key = "MISSING_PLAYER",
sender = UnitName("player"),
player = affectedPlayer
}
self:SendCommTo(returnMessage, sender)
end
elseif key == "BROADCAST_ACCEPTED" then
local sender = message["sender"]
local senderColor = message["senderColor"]
print("|cFFFF7D0ACEBiSTracker:|r Broadcast accepted by |c" .. senderColor .. sender .. "|r")
elseif key == "VERSION" then
local version = GetAddOnMetadata("CEBiSTracker", "Version")
local sender = message["sender"]
local returnMessage = {
key = "VERSION_RESPONSE",
value = version,
sender = UnitName("player"),
senderColor = self:GetMyClassColor()
}
self:SendCommTo(returnMessage, sender)
elseif key == "VERSION_RESPONSE" then
local version = message["value"]
local sender = message["sender"]
local senderColor = message["senderColor"]
if versionsDict[version] then
versionsDict[version] = versionsDict[version] .. ", |c" .. senderColor .. sender .. "|r"
else
versionsDict[version] = "|c" .. senderColor .. sender .. "|r"
end
elseif key == "GUID" then
local guid = message["GUID"]
local sender = message["sender"]
if not cbtConfigDB.baseGUID or guid ~= cbtConfigDB.baseGUID then
return
end
local returnMessage = {
key = "GUID_RESPONSE",
GUID = cbtConfigDB.baseGUID,
sender = UnitName("player"),
senderColor = self:GetMyClassColor()
}
self:SendCommTo(returnMessage, sender)
elseif key == "GUID_RESPONSE" then
local guid = message["GUID"]
local sender = message["sender"]
local senderColor = message["senderColor"]
if guid ~= cbtConfigDB.baseGUID then
return
end
subscribers = subscribers .. ", |c" .. senderColor .. sender .. "|r"
elseif key == "MISSING_PLAYER" then
local sender = message["sender"]
local affectedPlayer = message["player"]
local player = self:GetPlayerByName(affectedPlayer)
local returnMessage = {
key = "PLAYER_INFO",
sender = UnitName("player"),
player = player
}
self:SendCommTo(returnMessage, sender)
elseif key == "PLAYER_INFO" then
local sender = message["sender"]
local player = message["player"]
local found = false
for _, p in pairs(playersDB) do
if p.name == player.name then
found = true
break
end
end
if not found then
table.insert(playersDB, player)
self:PopulatePlayers()
end
end
end
--GearButtonClicked
function cebistracker:GearButtonClicked(obj)
if(obj.check:IsVisible()) then
obj.check.frame:Hide()
else
obj.check.frame:Show()
end
end
function cebistracker:ImportRaid()
self:AllItemsFalse()
local raidPlayers = GetRaidPlayers()
for name, raidPlayer in pairs(raidPlayers) do
local add = true
for _, player in pairs(playersDB) do
if player.name == name then
add = false
break
end
end
if(add) then
table.insert(playersDB, raidPlayer)
end
end
self:PopulatePlayers()
end
function cebistracker:OnEnable()
self.f = AceGUI:Create("Window")
self.f:Hide()
self.f:EnableResize(false)
self.f:SetTitle("<Casual Encounters> BiS Tracker")
self.f:SetLayout("Flow")
_G["cebistrackerFrame"] = self.f.frame
table.insert(UISpecialFrames, "cebistrackerFrame")
local iconDataBroker = LibStub("LibDataBroker-1.1"):NewDataObject("cebistrackerMinimapIcon", {
type = "data source",
text = "<Casual Encounters> BiS Tracker",
label = "Casual Encounters> BiS Tracker",
icon = "Interface\\GroupFrame\\UI-Group-MasterLooter",
OnClick = function()
if self.f:IsVisible() then
self.f:Hide()
else
self.f:Show()
end
end,
OnTooltipShow = function(tooltip)
tooltip:SetText("|cFFFF7D0A<Casual Encounters> BiS Tracker|r")
tooltip:Show()
end,
})
local minimapIcon = LibStub("LibDBIcon-1.0")
minimapIcon:Register("cebistrackerMinimapIcon", iconDataBroker, ceMinimapDB)
minimapIcon:Show()
self.playerViews = AceGUI:Create("InlineGroup")
self.playerViews:SetWidth(200)
self.playerViews:SetTitle("Players")
self.playerViews:SetLayout("Fill")
self.importRaid = AceGUI:Create("Button")
self.importRaid:SetText("Import Raid")
self.importRaid:SetCallback("OnClick", function()self:ImportRaid() end)
local r, g, b = self.importRaid.text:GetTextColor()
self.importRaid.textColor = {}
self.importRaid.textColor.r = r
self.importRaid.textColor.g = g
self.importRaid.textColor.b = b
self.broadcast = AceGUI:Create("Button")
self.broadcast:SetText("Broadcast Data")
self.broadcast:SetCallback("OnClick", function()self:Broadcast() end)
local r, g, b = self.broadcast.text:GetTextColor()
self.broadcast.textColor = {}
self.broadcast.textColor.r = r
self.broadcast.textColor.g = g
self.broadcast.textColor.b = b
self.playerDropdownMenu = _G["cebistrackerDropdownMenu"]:New()
self.playerDropdownMenu:AddItem("Delete", function ()
table.remove(playersDB, self.playerDropdownMenu.clickedEntry)
self:PopulatePlayers()
end)
self.players = AceGUI:Create("ScrollFrame")
self.players:SetLayout("Flow")
self.players.playerLabels = {}
self.playerViews:AddChild(self.players)
-- self.gearViews = AceGUI:Create("InlineGroup")
-- self.gearViews:SetWidth(200)
-- self.gearViews:SetTitle("BiS Tokens")
-- self.gearViews:SetLayout("Fill")
-- self.checkboxes = AceGUI:Create("ScrollFrame")
-- self.checkboxes:SetLayout("Flow")
-- self.gearViews:AddChild(self.checkboxes)
self.gearLabel = AceGUI:Create("Label")
self.gearLabel:SetText("Select a player")
self.gearLabel:SetFont(DEFAULT_FONT, 12, "")
for _, obj in ipairs(gearButtons) do
obj.checkbox = AceGUI:Create("CheckBox")
obj.checkbox:SetLabel(obj.displayName)
obj.checkbox:SetImage(obj.icon)
obj.checkbox:SetFullWidth(true)
obj.checkbox.SetUserData(obj.checkbox, "objData", obj)
obj.checkbox:SetCallback("OnValueChanged", function(checkbox, _, value)
local obj = checkbox.userdata.objData
local messageKey = "ADDCHECK"
if value then
selectedPlayer.items[obj.name] = value
else
table.removekey(selectedPlayer.items, obj.name)
messageKey = "REMOVECHECK"
end
local permission = self:GetPermission()
if permission then
local message = {
key = messageKey,
sender = UnitName("player"),
player = selectedPlayer.name,
value = obj.name,
baseGUID = cbtConfigDB.baseGUID
}
self:SendComm(message)
end
end)
end
self.editRank = AceGUI:Create("Dropdown")
self.editRank:SetWidth(170)
self.editRank:SetLabel("Minimum Rank to Edit")
local numGuildMembers = GetNumGuildMembers()
for i = 1, numGuildMembers do
local name, _, rankIndex, _, _, _, _, _, _, _, _ = GetGuildRosterInfo(i)
if name then
name = strsplit("-", name)
if name == UnitName("player") then
userRankIndex = rankIndex + 1
break
end
end
end
local guildList = {"All Ranks"}
for i = 1, GuildControlGetNumRanks() do
table.insert(guildList, GuildControlGetRankName(i))
end
self.editRank:SetList(guildList)
if not cbtConfigDB.editRank then
cbtConfigDB.editRank = 1
end
if not cbtConfigDB.baseGUID then
cbtConfigDB.baseGUID = self:GetGUID()
end
self.editRank:SetValue(cbtConfigDB.editRank)
self.editRank:SetCallback("OnValueChanged", function(_, _, value)
if value == 1 then
cbtConfigDB.editRank = 1
elseif value - 1 < userRankIndex and not overrideMinRank then
print("You cannot set a rank higher than your own")
self.editRank:SetValue(cbtConfigDB.editRank)
else
cbtConfigDB.editRank = value
end
self:UpdatePermissions()
end)
self:UpdatePermissions()
AceGUI:RegisterLayout("MainLayout", function ()
self.playerViews:SetPoint("TOPLEFT", self.f.frame, "TOPLEFT", 10, -28)
-- self.gearViews:SetPoint("TOPLEFT", self.playerViews.frame, "TOPRIGHT", 0, 0)
self.importRaid:SetPoint("TOPLEFT", self.playerViews.frame, "BOTTOMLEFT", 0, 0)
self.editRank:SetPoint("TOPLEFT", self.importRaid.frame, "TOPRIGHT", 5, 17)
self.broadcast:SetPoint("TOPLEFT", self.importRaid.frame, "BOTTOMLEFT", 0, -5)
self.f:SetWidth(400)
self.f:SetHeight(585)
self.playerViews:SetHeight(490)
-- self.gearViews:SetHeight(520)
self.gearLabel:SetPoint("TOPLEFT", self.playerViews.frame, "TOPRIGHT", 0, -5)
for index, obj in ipairs(gearButtons) do
obj.checkbox:SetPoint("TOPLEFT", self.playerViews.frame, "TOPRIGHT", 0, 0 - (index * 24))
end
end)
self:PopulatePlayers()
self.f:AddChild(self.playerViews)
-- self.f:AddChild(self.gearViews)
self.f:AddChild(self.importRaid)
self.f:AddChild(self.editRank)
self.f:AddChild(self.broadcast)
self.f:AddChild(self.gearLabel)
for _, obj in ipairs(gearButtons) do
self.f:AddChild(obj.checkbox)
obj.checkbox:SetDisabled(true)
end
self.f:SetLayout("MainLayout")
self.f:DoLayout()
self:RegisterComm("cebistracker", "OnCommReceived")
end
-- Slash Commands Functions
local SLASH_CMD_FUNCTIONS = {
["CLEAR"] = function(args)
print("Clearing all data")
playersDB = {}
cbtConfigDB = {
editRank = 1,
baseGUID = cebistracker:GetGUID()
}
overrideMinRank = true
cebistracker.editRank:SetValue(1)
overrideMinRank = false
cebistracker:PopulatePlayers()
end,
["SHOW"] = function (args)
cebistracker.f:Show()
end,
["HIDE"] = function (args)
cebistracker.f:Hide()
end,
["VERSION"] = function (args)
versionsDict = {}
versionsDict[GetAddOnMetadata("CEBiSTracker", "Version")] = "|c" .. cebistracker:GetMyClassColor() .. UnitName("player") .. "|r"
local message = {
key = "VERSION",
sender = UnitName("player")
}
cebistracker:SendComm(message)
C_Timer.After(1, function()
print("|cFFFF7D0ACEBiSTracker|r Versions in Use:")
for version, users in pairs(versionsDict) do
print(" |cFFFF7D0A" .. version .. "|r: " .. users)
end
end)
end,
["GUID"] = function (args)
subscribers = ""
subscribers = "|c" .. cebistracker:GetMyClassColor() .. UnitName("player") .. "|r"
local message = {
key = "GUID",
sender = UnitName("player"),
GUID = cbtConfigDB.baseGUID
}
cebistracker:SendComm(message)
C_Timer.After(1, function()
print("|cFFFF7D0ACEBiSTracker|r Subscribers to |cFFFF7D0A" .. cbtConfigDB.baseGUID .. "|r:" .. subscribers)
end)
end,
["HELP"] = function (args)
print("Casual Encounter BIS Tracker Slash Commands:")
print("|cFFFF7D0A/cbt clear|r - Clears all data")
print("|cFFFF7D0A/cbt show|r - Shows the main window")
print("|cFFFF7D0A/cbt hide|r - Hides the main window")
print("|cFFFF7D0A/cbt version|r - Shows the version of CEBiSTracker in use by everyone in the raid")
print("|cFFFF7D0A/cbt guid|r - Shows the users currently subscribed to your guid")
end,
}
SLASH_CBT1 = "/cebistracker"
SLASH_CBT2 = "/cbt"
SlashCmdList["CBT"] = function(message)
local _, _, cmd, args = string.find(message:upper(), "%s?(%w+)%s?(.*)")
if not SLASH_CMD_FUNCTIONS[cmd] then
cmd = "HELP"
end
SLASH_CMD_FUNCTIONS[cmd](args)
end