-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCore.lua
More file actions
executable file
·759 lines (592 loc) · 21.7 KB
/
Core.lua
File metadata and controls
executable file
·759 lines (592 loc) · 21.7 KB
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
local L = LibStub("AceLocale-3.0"):GetLocale("GreatVaultStatus")
GreatVaultStatus = LibStub("AceAddon-3.0"):NewAddon("GreatVaultStatus", "AceConsole-3.0", "AceEvent-3.0", "AceTimer-3.0", "LibSink-2.0",
"AceComm-3.0", "AceSerializer-3.0");
local textures = {}
GreatVaultStatus.data = nil
textures.GreatVaultStatus = "Interface\\Addons\\GreatVaultStatus\\media\\icon.blp"
textures.alliance = "|TInterface\\FriendsFrame\\PlusManz-Alliance:18|t"
textures.horde = "|TInterface\\FriendsFrame\\PlusManz-Horde:18|t"
textures.tick = "|TInterface\\RAIDFRAME\\ReadyCheck-Ready:16|t"
textures.reward = "|TInterface\\WorldMap\\Gear_64Grey:16|t"
--Interface/Challenges/ChallengeModeTab
--textures.reward = "|TInterface\\Addons\\GreatVault\\media\\icon.blp:16|t"
local addonName = "GreatVaultStatus"
local LDB = LibStub("LibDataBroker-1.1", true)
local LDBIcon = LDB and LibStub("LibDBIcon-1.0", true)
local LibQTip = LibStub('LibQTip-1.0')
local colors = {
rare = { r = 0, g = 0.44, b = 0.87},
epic = { r = 0.63921568627451, g = 0.2078431372549, b = 0.93333333333333 },
white = { r = 1.0, g = 1.0, b = 1.0 },
yellow = { r = 1.0, g = 1.0, b = 0.2 }
}
local red = { r = 1.0, g = 0.2, b = 0.2 }
local blue = { r = 0.4, g = 0.4, b = 1.0 }
local green = { r = 0.2, g = 1.0, b = 0.2 }
local yellow = { r = 1.0, g = 1.0, b = 0.2 }
local gray = { r = 0.5, g = 0.5, b = 0.5 }
local black = { r = 0.0, g = 0.0, b = 0.0 }
local white = { r = 1.0, g = 1.0, b = 1.0 }
local epic = { r = 0.63921568627451, g = 0.2078431372549, b = 0.93333333333333 }
local frame
local COL_CHARACTER = 2
local COL_ITEMLEVEL = 3
local COL_REWARDS = 4
local COL_RAIDS = 5
local COL_MYHTICS = 8
local COL_PVP = 11
local SORT_ASC = 1
local SORT_DEC = 2
local sortColumn = COL_CHARACTER
local sortAscending = true
local showSingleRealm = true
local defaults = {
realm = {
characters = {
},
},
global = {
realms = {
},
MinimapButton = {
hide = false,
},
displayOptions = {
showHintLine = true,
showLegend = true,
showMinimapButton = true,
},
characterOptions = {
levelRestriction = true,
minimumLevel = 50,
removeInactive = true,
inactivityThreshold = 28,
include = 3,
},
bossOptions = {
hideBoss = {
},
trackLegacyBosses = false,
disableHoldidayBossTracking = false,
},
bonusRollOptions = {
trackWeeklyQuests = true,
trackedCurrencies = {
[1129] = true,
},
trackLegacyCurrencies = false,
},
},
}
local function GetTableSize(T)
local count = 0
if T then
for _ in pairs(T) do
count = count +1
end
end
return count
end
local function RealmOnClick(cell, realmName)
GreatVaultStatus.db.global.realms[realmName].collapsed = not GreatVaultStatus.db.global.realms[realmName].collapsed
GreatVaultStatus:ShowToolTip()
end
local function HeaderOnClick(cell, column)
if column == sortColumn then
sortAscending = not sortAscending
else
sortColumn = column
end
GreatVaultStatus.db.global.sortColumn = sortColumn
if sortAscending then
GreatVaultStatus.db.global.sortOrder = "Ascending"
else
GreatVaultStatus.db.global.sortOrder = "Descending"
end
GreatVaultStatus:ShowToolTip()
end
local GreatVaultStatusLauncher = LDB:NewDataObject(addonName, {
type = "data source",
text = L["Great Vault Status"],
label = "GreatVaultStatus",
tocname = "GreatVaultStatus",
--"launcher",
icon = textures.GreatVaultStatus,
OnClick = function(clickedframe, button)
--GreatVaultStatus:ShowOptions()
end,
OnEnter = function(self)
frame = self
GreatVaultStatus:ShowToolTip()
end,
})
function GreatVaultStatus:IsShowMinimapButton(info)
return not self.db.global.MinimapButton.hide
end
function GreatVaultStatus:ToggleMinimapButton(info, value)
self.db.global.MinimapButton.hide = not value
if self.db.global.MinimapButton.hide then
LDBIcon:Hide(addonName)
else
LDBIcon:Show(addonName)
end
LDBIcon:Refresh(addonName)
LDBIcon:Refresh(addonName)
end
function GreatVaultStatus:OnInitialize()
self.db = LibStub("AceDB-3.0"):New("GreatVaultStatusDB", defaults, true)
self.debug = self.db.global.debug
sortColumn = self.db.global.sortColumn or COL_CHARACTER
sortAscending = not self.db.global.sortOrder or self.db.global.sortOrder == "Ascending"
showSingleRealm = GetTableSize(self.db.global.realms) <= 1
if showSingleRealm then
COL_CHARACTER = 1
COL_ITEMLEVEL = 2
COL_REWARDS = 3
COL_RAIDS = 4
COL_MYHTICS = 7
COL_PVP = 10
end
LDBIcon:Register(addonName, GreatVaultStatusLauncher, self.db.global.MinimapButton)
--self:InitializeOptions()
LoadAddOn("Blizzard_WeeklyRewards");
end
function GreatVaultStatus:GetCharacters()
local realmInfo = self:GetRealmInfo(GetRealmName())
local characters = realmInfo.characters or {}
return characters;
end
local function GetWeeklyQuestResetTime()
local now = time()
local region = GetCurrentRegion()
local dayOffset = { 2, 1, 0, 6, 5, 4, 3 }
local regionDayOffset = {{ 2, 1, 0, 6, 5, 4, 3 }, { 4, 3, 2, 1, 0, 6, 5 }, { 3, 2, 1, 0, 6, 5, 4 }, { 4, 3, 2, 1, 0, 6, 5 }, { 4, 3, 2, 1, 0, 6, 5 } }
local nextDailyReset = GetQuestResetTime()
local utc = date("!*t", now + nextDailyReset)
local reset = regionDayOffset[region][utc.wday] * 86400 + now + nextDailyReset
return reset
end
local function HideSubTooltip()
local subTooltip = GreatVaultStatus.subTooltip
if subTooltip then
LibQTip:Release(subTooltip)
subTooltip = nil
end
GameTooltip:Hide()
GreatVaultStatus.subTooltip = subTooltip
end
local function GetActivity(activityType, index, activities)
local activities = activites[activityType]
local result
for _, activity in ipairs(activities) do
if activity.index == index then
result = activity
break
end
end
return result
end
function SortCharacters(a, b)
local result
if sortColumn == COL_CHARACTER then
if sortAscending then
result = a.name < b.name
else
result = a.name > b.name
end
elseif sortColumn == COL_ITEMLEVEL then
if sortAscending then
result = a.averageItemLevel < b.averageItemLevel
else
result = a.averageItemLevel > b.averageItemLevel
end
elseif sortColumn == COL_RAIDS then
end
return result
end
local function ShowActivities(tooltip, line, columnStart, activities, lastUpdated, leftPadding, rightPadding)
local status
local column = columnStart
local activityThisWeek = lastUpdated > GetWeeklyQuestResetTime() - 604800
table.sort(activities, function(a,b) return a.index < b.index end)
for _, activity in ipairs(activities) do
local leftPad = 3
local rightPad = 3
local difficulty
if activity.progress >= activity.threshold and activityThisWeek then
if activity.type == Enum.WeeklyRewardChestThresholdType.MythicPlus then
difficulty = L["Mythic"].." " .. activity.level
elseif activity.type == Enum.WeeklyRewardChestThresholdType.RankedPvP then
difficulty = PVPUtil.GetTierName(activity.level)
elseif activity.type == Enum.WeeklyRewardChestThresholdType.Raid then
difficulty = DifficultyUtil.GetDifficultyName(activity.level)
end
status = GREEN_FONT_COLOR_CODE .. difficulty .. FONT_COLOR_CODE_CLOSE
else
local progress = 0
if activityThisWeek then
progress = activity.progress
end
status = GRAY_FONT_COLOR_CODE .. progress .. '/' .. activity.threshold .. FONT_COLOR_CODE_CLOSE
end
if column == columnStart then
leftPad = leftPad + leftPadding
elseif column == columnStart + 2 then
rightPad = rightPad + rightPadding
end
tooltip:SetCell(line, column, status, nil, "CENTER", nil, nil, leftPad, rightPad)
if activity.progress >= activity.threshold and activityThisWeek then
tooltip:SetCellScript(line, column, "OnEnter", function(self)
local info = activity
GreatVaultStatus:ShowSubTooltip(self, info)
end)
tooltip:SetCellScript(line, column, "OnLeave", HideSubTooltip)
end
column = column + 1
end
end
local function ShowPreviewRaidReward(tooltip, activity)
local itemLevel = activity.currentItemLevel
local upgradeItemLevel = activity.upgradeItemLevel
local currentDifficultyID = activity.level
local currentDifficultyName = DifficultyUtil.GetDifficultyName(currentDifficultyID);
tooltip:AddLine(YELLOW_FONT_COLOR_CODE..string.format(WEEKLY_REWARDS_ITEM_LEVEL_RAID, itemLevel, currentDifficultyName)..FONT_COLOR_CODE_CLOSE)
tooltip:AddLine(" ")
if upgradeItemLevel then
local nextDifficultyID = DifficultyUtil.GetNextPrimaryRaidDifficultyID(currentDifficultyID);
if nextDifficultyID then
local difficultyName = DifficultyUtil.GetDifficultyName(nextDifficultyID);
tooltip:AddLine(GREEN_FONT_COLOR_CODE..string.format(WEEKLY_REWARDS_IMPROVE_ITEM_LEVEL, upgradeItemLevel)..FONT_COLOR_CODE_CLOSE)
tooltip:AddLine(string.format(WEEKLY_REWARDS_COMPLETE_RAID, difficultyName))
end
if activity.encounters then
local encounters = activity.encounters
local raidName = EJ_GetInstanceInfo(1190)
tooltip:AddLine(" ")
tooltip:AddLine(raidName.." "..L["Boss List"])
local comparison = function(entry1, entry2)
if ( entry1.bestDifficulty == entry2.bestDifficulty) then
return entry1.uiOrder < entry2.uiOrder;
else
return entry1.bestDifficulty > entry2.bestDifficulty;
end
end
table.sort(encounters, comparison);
for _, encounter in pairs(encounters) do
local boss = EJ_GetEncounterInfo(encounter.encounterID);
if encounter.bestDifficulty and encounter.bestDifficulty > 0 then
local difficultyName = DifficultyUtil.GetDifficultyName(encounter.bestDifficulty);
tooltip:AddLine(GREEN_FONT_COLOR_CODE..string.format("- %s (%s)", boss, difficultyName)..FONT_COLOR_CODE_CLOSE)
else
tooltip:AddLine(GRAY_FONT_COLOR_CODE..string.format("- %s", boss)..FONT_COLOR_CODE_CLOSE)
end
end
end
else
tooltip:AddLine(GREEN_FONT_COLOR_CODE..WEEKLY_REWARDS_MAXED_REWARD..FONT_COLOR_CODE_CLOSE)
end
end
local function ShowPreviewMythicReward(tooltip, activity)
local itemLevel = activity.currentItemLevel
local upgradeItemLevel = activity.upgradeItemLevel
tooltip:AddLine(YELLOW_FONT_COLOR_CODE..string.format(WEEKLY_REWARDS_ITEM_LEVEL_MYTHIC, itemLevel, activity.level)..FONT_COLOR_CODE_CLOSE)
tooltip:AddLine(" ")
if upgradeItemLevel then
tooltip:AddLine(GREEN_FONT_COLOR_CODE..string.format(WEEKLY_REWARDS_IMPROVE_ITEM_LEVEL, upgradeItemLevel)..FONT_COLOR_CODE_CLOSE)
if activity.threshold == 1 then
tooltip:AddLine(WEEKLY_REWARDS_COMPLETE_MYTHIC_SHORT)
else
tooltip:AddLine(string.format(WEEKLY_REWARDS_COMPLETE_MYTHIC, activity.level + 1, activity.threshold))
local runHistory = C_MythicPlus.GetRunHistory();
if #runHistory > 0 then
tooltip:AddLine(" ")
tooltip:AddLine(string.format(WEEKLY_REWARDS_MYTHIC_TOP_RUNS, activity.threshold))
local comparison = function(entry1, entry2)
if ( entry1.level == entry2.level ) then
return entry1.mapChallengeModeID < entry2.mapChallengeModeID;
else
return entry1.level > entry2.level;
end
end
table.sort(runHistory, comparison);
for i = 1, activity.threshold do
local runInfo = runHistory[i];
local name = C_ChallengeMode.GetMapUIInfo(runInfo.mapChallengeModeID);
tooltip:AddLine(string.format(WEEKLY_REWARDS_MYTHIC_RUN_INFO, runInfo.level, name))
end
end
end
else
tooltip:AddLine(GREEN_FONT_COLOR_CODE..WEEKLY_REWARDS_MAXED_REWARD..FONT_COLOR_CODE_CLOSE)
end
end
local function ShowPeviewPvPReward(tooltip, activity)
local itemLevel = activity.currentItemLevel
local upgradeItemLevel = activity.upgradeItemLevel
local tierName = PVPUtil.GetTierName(activity.level);
tooltip:AddLine(YELLOW_FONT_COLOR_CODE..string.format(WEEKLY_REWARDS_ITEM_LEVEL_PVP, itemLevel, tierName)..FONT_COLOR_CODE_CLOSE)
tooltip:AddLine(" ")
if upgradeItemLevel then
local tierID = C_PvP.GetPvpTierID(activity.level, CONQUEST_BRACKET_INDEXES[1]);
local tierInfo = C_PvP.GetPvpTierInfo(tierID);
local ascendTierInfo = C_PvP.GetPvpTierInfo(tierInfo.ascendTier);
if ascendTierInfo then
tooltip:AddLine(GREEN_FONT_COLOR_CODE..string.format(WEEKLY_REWARDS_IMPROVE_ITEM_LEVEL, upgradeItemLevel)..FONT_COLOR_CODE_CLOSE)
local ascendTierName = PVPUtil.GetTierName(ascendTierInfo.pvpTierEnum);
if ascendTierInfo.ascendRating == 0 then
tooltip:AddLine(string.format(WEEKLY_REWARDS_COMPLETE_PVP_MAX, ascendTierName, tierInfo.ascendRating))
else
tooltip:AddLine(string.format(WEEKLY_REWARDS_COMPLETE_PVP, ascendTierName, tierInfo.ascendRating, ascendTierInfo.ascendRating - 1))
end
end
else
tooltip:AddLine(GREEN_FONT_COLOR_CODE..WEEKLY_REWARDS_MAXED_REWARD..FONT_COLOR_CODE_CLOSE)
end
end
local function ShowCurrentReward(activity)
local tooltip = GreatVaultStatus.subTooltip
local itemLevel = activity.currentItemLevel
local upgradeItemLevel = activity.upgradeItemLevel
if LibQTip:IsAcquired("GreatVaultStatusSubTooltip") and tooltip then
tooltip:Clear()
else
tooltip = LibQTip:Acquire("GreatVaultStatusSubTooltip", 1, "LEFT")
GreatVaultStatus.subTooltip = tooltip
end
tooltip:ClearAllPoints()
tooltip:SetClampedToScreen(true)
tooltip:SetPoint("TOP", GreatVaultStatus.tooltip, "TOP", 30, 0)
tooltip:SetPoint("RIGHT", GreatVaultStatus.tooltip, "LEFT", -20, 0)
tooltip:AddLine(WEEKLY_REWARDS_CURRENT_REWARD)
if not itemLevel then
tooltip:AddLine(RED_FONT_COLOR_CODE..RETRIEVING_ITEM_INFO..FONT_COLOR_CODE_CLOSE)
else
if activity.type == Enum.WeeklyRewardChestThresholdType.Raid then
ShowPreviewRaidReward(tooltip, activity)
elseif activity.type == Enum.WeeklyRewardChestThresholdType.MythicPlus then
ShowPreviewMythicReward(tooltip, activity)
elseif activity.type == Enum.WeeklyRewardChestThresholdType.RankedPvP then
ShowPeviewPvPReward(tooltip,activity)
end
end
tooltip:Show()
end
function GreatVaultStatus:ShowSubTooltip(cell, info)
ShowCurrentReward(info)
end
local function HasCompletedActivities(status)
local completed = status and status.hasAvailableRewards
if not completed and status and status.activities and status.lastUpdated and (status.lastUpdated < GetWeeklyQuestResetTime() - 604800) then
for index =1, 3 do
local activities = status.activities[index] or {}
for _, activity in ipairs(activities) do
if activity.progress >= activity.threshold then
completed = true
break
end
end
end
end
return completed
end
local function ShowCharacter(tooltip, name, info)
if not info then
return
end
local factionIcon = ""
local line = tooltip:AddLine()
local activities = info.status.activities
local lastUpdated = info.status.lastUpdated
if info.faction and info.faction == "Alliance" then
factionIcon = textures.alliance
elseif info.faction and info.faction == "Horde" then
factionIcon = textures.horde
end
tooltip:SetCell(line, COL_CHARACTER, factionIcon.." "..name)
if info.averageItemLevel then
tooltip:SetCell(line, COL_ITEMLEVEL, string.format("%.1f", info.averageItemLevel), "RIGHT")
end
if activities then
ShowActivities(tooltip, line, COL_RAIDS, activities[Enum.WeeklyRewardChestThresholdType.Raid], lastUpdated, 0, 10)
ShowActivities(tooltip, line, COL_MYHTICS, activities[Enum.WeeklyRewardChestThresholdType.MythicPlus], lastUpdated, 10, 10)
ShowActivities(tooltip, line, COL_PVP, activities[Enum.WeeklyRewardChestThresholdType.RankedPvP], lastUpdated, 10, 0)
end
if HasCompletedActivities(info.status) then
tooltip:SetCell(line, COL_REWARDS, textures.reward)
end
if info.class then
local color = RAID_CLASS_COLORS[info.class]
tooltip:SetCellTextColor(line, COL_CHARACTER, color.r, color.g, color.b)
end
return line
end
local function ShowHeader(tooltip, marker, headerName)
line = tooltip:AddHeader()
tooltip:SetCell(line, COL_CHARACTER, L["Character"], nil, "LEFT", nil, nil, nil, 50)
tooltip:SetCellTextColor(line, COL_CHARACTER, yellow.r, yellow.g, yellow.b)
tooltip:SetCell(line, COL_ITEMLEVEL, L["iLevel"], nil, "RIGHT")
tooltip:SetCellTextColor(line, COL_ITEMLEVEL, yellow.r, yellow.g, yellow.b)
tooltip:SetCell(line, COL_RAIDS, L["Raids"], nil, "CENTER", 3)
tooltip:SetCellTextColor(line, COL_RAIDS, yellow.r, yellow.g, yellow.b)
tooltip:SetCell(line, COL_MYHTICS, L["Mythic Dungeons"], nil, "CENTER", 3)
tooltip:SetCellTextColor(line, COL_MYHTICS, yellow.r, yellow.g, yellow.b)
tooltip:SetCell(line, COL_PVP, L["PvP"], nil, "CENTER", 3)
tooltip:SetCellTextColor(line, COL_PVP, yellow.r, yellow.g, yellow.b)
tooltip:SetCellScript(line, COL_CHARACTER, "OnMouseUp", HeaderOnClick, COL_CHARACTER)
tooltip:SetCellScript(line, COL_ITEMLEVEL, "OnMouseUp", HeaderOnClick, COL_ITEMLEVEL)
return line
end
local function ShowRealm(tooltip, name, info)
local collapsed = info.collapsed
local characters = {}
local line = tooltip:AddHeader()
local button = "|TInterface\\Buttons\\UI-MinusButton-Up:16|t"
if collapsed then
button = "|TInterface\\Buttons\\UI-PlusButton-Up:16|t"
end
if not showSingleRealm then
tooltip:SetCell(line, 1, button)
tooltip:SetCellScript(line, 1, "OnMouseUp", RealmOnClick, name)
tooltip:SetCell(line, 2, name, nil, nil, nil, nil, nil, 50)
tooltip:SetCellTextColor(line, 2, yellow.r, yellow.g, yellow.b)
end
if not collapsed or showSingleRealm then
for key, value in pairs(info.characters) do
table.insert(characters, value);
end
table.sort(characters, SortCharacters)
for characterName, characterInfo in pairs(characters) do
line = ShowCharacter(tooltip, characterInfo.name, characterInfo)
if name == GetRealmName() and characterInfo.name == GetUnitName("Player") then
tooltip:SetLineColor(line, yellow.r, yellow.g, yellow.b, 0.2)
end
end
tooltip:AddSeparator(6,0,0,0,0)
end
end
function GreatVaultStatus:ShowToolTip()
local tooltip = GreatVaultStatus.tooltip
local columns = 13
self:SaveCharacterInfo()
if showSingleRealm then
columns = 12
end
if LibQTip:IsAcquired("GreatVaultStatusTooltip") and tooltip then
tooltip:Clear()
else
tooltip = LibQTip:Acquire("GreatVaultStatusTooltip", columns)
GreatVaultStatus.tooltip = tooltip
end
local line = tooltip:AddHeader(" ")
tooltip:SetCell(line, 1, "|T"..textures.GreatVaultStatus..":18|t "..L["Great Vault Status"], nil, "LEFT", columns)
tooltip:AddSeparator(6,0,0,0,0)
ShowHeader(tooltip, nil, nil)
for key, value in pairs(self.db.global.realms or {}) do
tooltip:AddSeparator(3,0,0,0,0)
ShowRealm(tooltip, key, value)
end
if (frame) then
tooltip:SetAutoHideDelay(0.01, frame)
tooltip:SmartAnchorTo(frame)
end
tooltip:UpdateScrolling()
tooltip:Show()
end
function GreatVaultStatus:GetRealmInfo(realmName)
if not self.db.global.realms then
self.db.global.realms = {}
end
local realmInfo = self.db.global.realms[realmName]
if not realmInfo then
realmInfo = {}
realmInfo.characters = {}
end
return realmInfo
end
local function GetActivities(activityType)
local activities = C_WeeklyRewards.GetActivities(activityType);
table.sort(activities, function(a,b) return a.index < b.index end)
for _,activity in pairs(activities) do
if activity.progress >= activity.threshold then
local encounterInfo = C_WeeklyRewards.GetActivityEncounterInfo(activityType, activity.index);
local currentLink, upgradeLink = C_WeeklyRewards.GetExampleRewardItemHyperlinks(activity.id);
if encounterInfo then
activity.encounters = encounterInfo
end
activity.currentItemLevel = GetDetailedItemLevelInfo(currentLink);
if upgradeLink then
activity.upgradeItemLevel = GetDetailedItemLevelInfo(upgradeLink);
end
end
end
return activities
end
local function UpdateStatusForCharacter(currentStatus)
local now = time()
local status = currentStatus or {}
status.lastUpdated = now
status.activities = {}
status.activities[Enum.WeeklyRewardChestThresholdType.MythicPlus] = GetActivities(Enum.WeeklyRewardChestThresholdType.MythicPlus)
status.activities[Enum.WeeklyRewardChestThresholdType.RankedPvP] = GetActivities(Enum.WeeklyRewardChestThresholdType.RankedPvP)
status.activities[Enum.WeeklyRewardChestThresholdType.Raid] = GetActivities(Enum.WeeklyRewardChestThresholdType.Raid)
status.hasAvailableRewards = C_WeeklyRewards.HasAvailableRewards();
return status
end
function GreatVaultStatus:SaveCharacterInfo(info)
if UnitLevel("player") < 60 then
return
end
local characterInfo = info or self:GetCharacterInfo()
local characterName = UnitName("player")
local realmName = GetRealmName()
local realmInfo = self:GetRealmInfo(realmName)
realmInfo.characters[characterName] = characterInfo
self.db.global.realms[realmName] = realmInfo
end
function GreatVaultStatus:GetCharacterInfo()
local name = UnitName("player")
local realmInfo = GreatVaultStatus:GetRealmInfo(GetRealmName())
local characterInfo = realmInfo.characters[name] or {}
local _, className = UnitClass("player")
characterInfo.name = name
characterInfo.lastUpdate = time()
characterInfo.class = className
characterInfo.level = UnitLevel("player")
characterInfo.averageItemLevel = GetAverageItemLevel();
characterInfo.faction = UnitFactionGroup("player")
characterInfo.status = UpdateStatusForCharacter(characterInfo.status)
return characterInfo
end
local function UpdateStatus()
GreatVaultStatus:SaveCharacterInfo()
end
function GreatVaultStatus:PLAYER_ENTERING_WORLD(event, isLogin, isReload)
if isLogin or isReload then
self:ScheduleTimer(UpdateStatus, 10)
end
end
function GreatVaultStatus:WEEKLY_REWARDS_UPDATE(event)
--self:Print(event)
self:SaveCharacterInfo()
end
function GreatVaultStatus:WEEKLY_REWARDS_ITEM_CHANGED(event)
--self:Print(event)
self:SaveCharacterInfo()
end
function GreatVaultStatus:WEEKLY_REWARDS_HIDE(event)
--self:Print(event)
self:SaveCharacterInfo()
self:ScheduleTimer(UpdateStatus, 30)
end
function GreatVaultStatus:OnEnable()
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("WEEKLY_REWARDS_UPDATE")
self:RegisterEvent("WEEKLY_REWARDS_ITEM_CHANGED")
self:RegisterEvent("WEEKLY_REWARDS_HIDE")
end
function GreatVaultStatus:OnDisable()
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
self:UnregisterEvent("WEEKLY_REWARDS_UPDATE")
self:UnregisterEvent("WEEKLY_REWARDS_ITEM_CHANGED")
self:UnregisterEvent("WEEKLY_REWARDS_HIDE")
end