forked from Tercioo/Details-Damage-Meter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.lua
1898 lines (1519 loc) · 69 KB
/
startup.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 UnitGroupRolesAssigned = DetailsFramework.UnitGroupRolesAssigned
--> check unloaded files:
if (
-- version 1.21.0
not _G._detalhes.atributo_custom.damagedoneTooltip or
not _G._detalhes.atributo_custom.healdoneTooltip
) then
local f = CreateFrame ("frame", "DetaisCorruptInstall", UIParent)
f:SetSize (370, 70)
f:SetPoint ("center", UIParent, "center", 0, 0)
f:SetPoint ("top", UIParent, "top", 0, -20)
local bg = f:CreateTexture (nil, "background")
bg:SetAllPoints (f)
bg:SetTexture ([[Interface\AddOns\Details\images\welcome]])
local image = f:CreateTexture (nil, "overlay")
image:SetTexture ([[Interface\DialogFrame\UI-Dialog-Icon-AlertNew]])
image:SetSize (32, 32)
local label = f:CreateFontString (nil, "overlay", "GameFontNormal")
label:SetText ("Restart game client in order to finish addons updates.")
label:SetWidth (300)
label:SetJustifyH ("left")
local close = CreateFrame ("button", "DetaisCorruptInstall", f, "UIPanelCloseButton")
close:SetSize (32, 32)
close:SetPoint ("topright", f, "topright", 0, 0)
image:SetPoint ("topleft", f, "topleft", 10, -20)
label:SetPoint ("left", image, "right", 4, 0)
_G._detalhes.FILEBROKEN = true
end
function _G._detalhes:InstallOkey()
if (_G._detalhes.FILEBROKEN) then
return false
end
return true
end
--> start funtion
function _G._detalhes:Start()
local Loc = LibStub ("AceLocale-3.0"):GetLocale ( "Details" )
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> row single click
--> single click row function replace
--damage, dps, damage taken, friendly fire
self.row_singleclick_overwrite [1] = {true, true, true, true, self.atributo_damage.ReportSingleFragsLine, self.atributo_damage.ReportEnemyDamageTaken, self.atributo_damage.ReportSingleVoidZoneLine, self.atributo_damage.ReportSingleDTBSLine}
--healing, hps, overheal, healing taken
self.row_singleclick_overwrite [2] = {true, true, true, true, false, self.atributo_heal.ReportSingleDamagePreventedLine}
--mana, rage, energy, runepower
self.row_singleclick_overwrite [3] = {true, true, true, true}
--cc breaks, ress, interrupts, dispells, deaths
self.row_singleclick_overwrite [4] = {true, true, true, true, self.atributo_misc.ReportSingleDeadLine, self.atributo_misc.ReportSingleCooldownLine, self.atributo_misc.ReportSingleBuffUptimeLine, self.atributo_misc.ReportSingleDebuffUptimeLine}
function self:ReplaceRowSingleClickFunction (attribute, sub_attribute, func)
assert (type (attribute) == "number" and attribute >= 1 and attribute <= 4, "ReplaceRowSingleClickFunction expects a attribute index on #1 argument.")
assert (type (sub_attribute) == "number" and sub_attribute >= 1 and sub_attribute <= 10, "ReplaceRowSingleClickFunction expects a sub attribute index on #2 argument.")
assert (type (func) == "function", "ReplaceRowSingleClickFunction expects a function on #3 argument.")
self.row_singleclick_overwrite [attribute] [sub_attribute] = func
return true
end
self.click_to_report_color = {1, 0.8, 0, 1}
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> initialize
--> build frames
--> plugin container
self:CreatePluginWindowContainer()
self:InitializeForge() --to install into the container plugin
self:InitializeRaidHistoryWindow()
self:InitializeOptionsWindow()
C_Timer.After (2, function()
self:InitializeAuraCreationWindow()
end)
self:InitializeCustomDisplayWindow()
self:InitializeAPIWindow()
self:InitializeRunCodeWindow()
self:InitializePlaterIntegrationWindow()
self:InitializeMacrosWindow()
--> bookmarks
if (self.switch.InitSwitch) then
--self.switch:InitSwitch()
end
--> custom window
self.custom = self.custom or {}
--> micro button alert
self.MicroButtonAlert = CreateFrame ("frame", "DetailsMicroButtonAlert", UIParent, "MicroButtonAlertTemplate")
self.MicroButtonAlert:Hide()
--> actor details window
self.janela_info = self.gump:CriaJanelaInfo()
self.gump:Fade (self.janela_info, 1)
--> copy and paste window
self:CreateCopyPasteWindow()
self.CreateCopyPasteWindow = nil
--> start instances
if (self:GetNumInstancesAmount() == 0) then
self:CriarInstancia()
end
self:GetLowerInstanceNumber()
--> start time machine
self.timeMachine:Ligar()
--> update abbreviation shortcut
self.atributo_damage:UpdateSelectedToKFunction()
self.atributo_heal:UpdateSelectedToKFunction()
self.atributo_energy:UpdateSelectedToKFunction()
self.atributo_misc:UpdateSelectedToKFunction()
self.atributo_custom:UpdateSelectedToKFunction()
--> start instances updater
self:CheckSwitchOnLogon()
function _detalhes:ScheduledWindowUpdate (forced)
if (not forced and _detalhes.in_combat) then
return
end
_detalhes.scheduled_window_update = nil
_detalhes:AtualizaGumpPrincipal (-1, true)
end
function _detalhes:ScheduleWindowUpdate (time, forced)
if (_detalhes.scheduled_window_update) then
_detalhes:CancelTimer (_detalhes.scheduled_window_update)
_detalhes.scheduled_window_update = nil
end
_detalhes.scheduled_window_update = _detalhes:ScheduleTimer ("ScheduledWindowUpdate", time or 1, forced)
end
self:AtualizaGumpPrincipal (-1, true)
_detalhes:RefreshUpdater()
for index = 1, #self.tabela_instancias do
local instance = self.tabela_instancias [index]
if (instance:IsAtiva()) then
self:ScheduleTimer ("RefreshBars", 1, instance)
self:ScheduleTimer ("InstanceReset", 1, instance)
self:ScheduleTimer ("InstanceRefreshRows", 1, instance)
end
end
function self:RefreshAfterStartup()
self:AtualizaGumpPrincipal (-1, true)
local lower_instance = _detalhes:GetLowerInstanceNumber()
for index = 1, #self.tabela_instancias do
local instance = self.tabela_instancias [index]
if (instance:IsAtiva()) then
--> refresh wallpaper
if (instance.wallpaper.enabled) then
instance:InstanceWallpaper (true)
else
instance:InstanceWallpaper (false)
end
--> refresh desaturated icons if is lower instance
if (index == lower_instance) then
instance:DesaturateMenu()
instance:SetAutoHideMenu (nil, nil, true)
end
end
end
--> refresh lower instance plugin icons and skin
_detalhes.ToolBar:ReorganizeIcons()
--> refresh skin for other windows
if (lower_instance) then
for i = lower_instance+1, #self.tabela_instancias do
local instance = self:GetInstance (i)
if (instance and instance.baseframe and instance.ativa) then
instance:ChangeSkin()
end
end
end
self.RefreshAfterStartup = nil
function _detalhes:CheckWallpaperAfterStartup()
if (not _detalhes.profile_loaded) then
return _detalhes:ScheduleTimer ("CheckWallpaperAfterStartup", 2)
end
for i = 1, self.instances_amount do
local instance = self:GetInstance (i)
if (instance and instance:IsEnabled()) then
if (not instance.wallpaper.enabled) then
instance:InstanceWallpaper (false)
end
instance.do_not_snap = true
self.move_janela_func (instance.baseframe, true, instance, true)
self.move_janela_func (instance.baseframe, false, instance, true)
instance.do_not_snap = false
end
end
self.CheckWallpaperAfterStartup = nil
_detalhes.profile_loaded = nil
end
_detalhes:ScheduleTimer ("CheckWallpaperAfterStartup", 5)
end
self:ScheduleTimer ("RefreshAfterStartup", 5)
--> start garbage collector
self.ultima_coleta = 0
self.intervalo_coleta = 720
--self.intervalo_coleta = 10
self.intervalo_memoria = 180
--self.intervalo_memoria = 20
self.garbagecollect = self:ScheduleRepeatingTimer ("IniciarColetaDeLixo", self.intervalo_coleta)
--desativado, algo bugou no 7.2.5
--self.memorycleanup = self:ScheduleRepeatingTimer ("CheckMemoryPeriodically", self.intervalo_memoria)
self.next_memory_check = time()+self.intervalo_memoria
--> role
self.last_assigned_role = UnitGroupRolesAssigned ("player")
--> start parser
--> load parser capture options
self:CaptureRefresh()
--> register parser events
self.listener:RegisterEvent ("PLAYER_REGEN_DISABLED")
self.listener:RegisterEvent ("PLAYER_REGEN_ENABLED")
--self.listener:RegisterEvent ("SPELL_SUMMON") --triggering error on 8.0
self.listener:RegisterEvent ("UNIT_PET")
--self.listener:RegisterEvent ("PARTY_MEMBERS_CHANGED") --triggering error on 8.0
self.listener:RegisterEvent ("GROUP_ROSTER_UPDATE")
--self.listener:RegisterEvent ("PARTY_CONVERTED_TO_RAID") --triggering error on 8.0
self.listener:RegisterEvent ("INSTANCE_ENCOUNTER_ENGAGE_UNIT")
self.listener:RegisterEvent ("ZONE_CHANGED_NEW_AREA")
self.listener:RegisterEvent ("PLAYER_ENTERING_WORLD")
self.listener:RegisterEvent ("ENCOUNTER_START")
self.listener:RegisterEvent ("ENCOUNTER_END")
self.listener:RegisterEvent ("START_TIMER")
self.listener:RegisterEvent ("UNIT_NAME_UPDATE")
self.listener:RegisterEvent ("PLAYER_ROLES_ASSIGNED")
self.listener:RegisterEvent ("ROLE_CHANGED_INFORM")
self.listener:RegisterEvent ("UNIT_FACTION")
if (not DetailsFramework.IsClassicWow()) then
self.listener:RegisterEvent ("PET_BATTLE_OPENING_START")
self.listener:RegisterEvent ("PET_BATTLE_CLOSE")
self.listener:RegisterEvent ("PLAYER_SPECIALIZATION_CHANGED")
self.listener:RegisterEvent ("PLAYER_TALENT_UPDATE")
self.listener:RegisterEvent ("CHALLENGE_MODE_START")
self.listener:RegisterEvent ("CHALLENGE_MODE_COMPLETED")
end
--test immersion stuff
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local immersionFrame = CreateFrame ("frame", "DetailsImmersionFrame", UIParent)
immersionFrame:RegisterEvent ("ZONE_CHANGED_NEW_AREA")
immersionFrame.DevelopmentDebug = true
--> check if can enabled the immersino stuff
function immersionFrame.CheckIfCanEnableImmersion()
local mapID = C_Map.GetBestMapForUnit ("player")
if (mapID) then
local mapFileName = C_Map.GetMapInfo (mapID)
mapFileName = mapFileName and mapFileName.name
if (mapFileName and mapFileName:find ("InvasionPoint")) then
self.immersion_enabled = true
if (immersionFrame.DevelopmentDebug) then
print ("Details!", "CheckIfCanEnableImmersion() > immersion enabled.")
end
else
if (self.immersion_enabled) then
if (immersionFrame.DevelopmentDebug) then
print ("Details!", "CheckIfCanEnableImmersion() > immersion disabled.")
end
self.immersion_enabled = nil
end
end
end
end
--> check events
immersionFrame:SetScript ("OnEvent", function (_, event, ...)
if (event == "ZONE_CHANGED_NEW_AREA") then
C_Timer.After (3, immersionFrame.CheckIfCanEnableImmersion)
end
end)
--test mythic + stuff
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--> data for the current mythic + dungeon
self.MythicPlus = {
RunID = 0,
}
-- ~mythic ~dungeon
local newFrame = CreateFrame ("frame", "DetailsMythicPlusFrame", UIParent)
newFrame.DevelopmentDebug = false
--disabling the mythic+ feature if the user is playing in wow classic
if (not DetailsFramework.IsClassicWow()) then
newFrame:RegisterEvent ("CHALLENGE_MODE_START")
newFrame:RegisterEvent ("CHALLENGE_MODE_COMPLETED")
newFrame:RegisterEvent ("ZONE_CHANGED_NEW_AREA")
newFrame:RegisterEvent ("ENCOUNTER_END")
newFrame:RegisterEvent ("START_TIMER")
end
--[[
all mythic segments have:
.is_mythic_dungeon_segment = true
.is_mythic_dungeon_run_id = run id from details.profile.mythic_dungeon_id
boss, 'trash overall' and 'dungeon overall' segments have:
.is_mythic_dungeon
boss segments have:
.is_boss
'trash overall' segments have:
.is_mythic_dungeon with .SegmentID = "trashoverall"
'dungeon overall' segment have:
.is_mythic_dungeon with .SegmentID = "overall"
--]]
--precisa converter um wipe em um trash segment? provavel que sim
-- at the end of a mythic run, if enable on settings, merge all the segments from the mythic run into only one
function newFrame.MergeSegmentsOnEnd()
if (newFrame.DevelopmentDebug) then
print ("Details!", "MergeSegmentsOnEnd() > starting to merge mythic segments.", "InCombatLockdown():", InCombatLockdown())
end
--> create a new combat to be the overall for the mythic run
self:EntrarEmCombate()
--> get the current combat just created and the table with all past segments
local newCombat = self:GetCurrentCombat()
local segmentHistory = self:GetCombatSegments()
local totalTime = 0
local startDate, endDate = "", ""
local lastSegment
local totalSegments = 0
--> add all boss segments from this run to this new segment
for i = 1, 25 do --> from the newer combat to the oldest
local pastCombat = segmentHistory [i]
if (pastCombat and pastCombat.is_mythic_dungeon_run_id == self.mythic_dungeon_id) then
local canAddThisSegment = true
if (_detalhes.mythic_plus.make_overall_boss_only) then
if (not pastCombat.is_boss) then
canAddThisSegment = false
end
end
if (canAddThisSegment) then
newCombat = newCombat + pastCombat
totalTime = totalTime + pastCombat:GetCombatTime()
totalSegments = totalSegments + 1
if (newFrame.DevelopmentDebug) then
print ("MergeSegmentsOnEnd() > adding time:", pastCombat:GetCombatTime(), pastCombat.is_boss and pastCombat.is_boss.name)
end
if (endDate == "") then
local _, whenEnded = pastCombat:GetDate()
endDate =whenEnded
end
lastSegment = pastCombat
end
end
end
--> get the date where the first segment started
if (lastSegment) then
startDate = lastSegment:GetDate()
end
if (newFrame.DevelopmentDebug) then
print ("Details!", "MergeSegmentsOnEnd() > totalTime:", totalTime, "startDate:", startDate)
end
local zoneName, instanceType, difficultyID, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID, instanceGroupSize = GetInstanceInfo()
--> tag the segment as mythic overall segment
newCombat.is_mythic_dungeon = {
StartedAt = self.MythicPlus.StartedAt, --the start of the run
EndedAt = self.MythicPlus.EndedAt, --the end of the run
SegmentID = "overall", --segment number within the dungeon
RunID = self.mythic_dungeon_id,
OverallSegment = true,
ZoneName = self.MythicPlus.DungeonName,
MapID = instanceMapID,
Level = self.MythicPlus.Level,
EJID = self.MythicPlus.ejID,
}
newCombat.total_segments_added = totalSegments
newCombat.is_mythic_dungeon_segment = true
newCombat.is_mythic_dungeon_run_id = self.mythic_dungeon_id
--> set the segment time and date
newCombat:SetStartTime (GetTime() - totalTime)
newCombat:SetEndTime (GetTime())
newCombat:SetDate (startDate, endDate)
--> immediatly finishes the segment just started
self:SairDoCombate()
--> update all windows
self:InstanciaCallFunction (self.gump.Fade, "in", nil, "barras")
self:InstanciaCallFunction (self.AtualizaSegmentos)
self:InstanciaCallFunction (self.AtualizaSoloMode_AfertReset)
self:InstanciaCallFunction (self.ResetaGump)
self:AtualizaGumpPrincipal (-1, true)
if (newFrame.DevelopmentDebug) then
print ("Details!", "MergeSegmentsOnEnd() > finished merging segments.")
print ("Details!", "MergeSegmentsOnEnd() > all done, check in the segments list if everything is correct, if something is weird: '/details feedback' thanks in advance!")
end
local lower_instance = self:GetLowerInstanceNumber()
if (lower_instance) then
local instance = self:GetInstance (lower_instance)
if (instance) then
local func = {function() end}
instance:InstanceAlert ("Showing Mythic+ Run Segment", {[[Interface\AddOns\Details\images\icons]], 16, 16, false, 434/512, 466/512, 243/512, 273/512}, 6, func, true)
end
end
end
--> after each boss fight, if enalbed on settings, create an extra segment with all trash segments from the boss just killed
function newFrame.MergeTrashCleanup (isFromSchedule)
if (newFrame.DevelopmentDebug) then
print ("Details!", "MergeTrashCleanup() > running", newFrame.TrashMergeScheduled and #newFrame.TrashMergeScheduled)
end
local segmentsToMerge = newFrame.TrashMergeScheduled
--> table exists and there's at least one segment
if (segmentsToMerge and segmentsToMerge[1]) then
--the first segment is the segment where all other trash segments will be added
local masterSegment = segmentsToMerge[1]
masterSegment.is_mythic_dungeon_trash = nil
--> get the current combat just created and the table with all past segments
local newCombat = masterSegment
local totalTime = newCombat:GetCombatTime()
local startDate, endDate = "", ""
local lastSegment
--> add segments
for i = 2, #segmentsToMerge do --segment #1 is the host
pastCombat = segmentsToMerge [i]
newCombat = newCombat + pastCombat
totalTime = totalTime + pastCombat:GetCombatTime()
--> tag this combat as already added to a boss trash overall
pastCombat._trashoverallalreadyadded = true
if (endDate == "") then
local _, whenEnded = pastCombat:GetDate()
endDate = whenEnded
end
lastSegment = pastCombat
end
--> get the date where the first segment started
if (lastSegment) then
startDate = lastSegment:GetDate()
end
local zoneName, instanceType, difficultyID, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID, instanceGroupSize = GetInstanceInfo()
--> tag the segment as mythic overall segment
newCombat.is_mythic_dungeon = {
StartedAt = segmentsToMerge.PreviousBossKilledAt, --start of the mythic run or when the previous boss got killed
EndedAt = segmentsToMerge.LastBossKilledAt, --the time() when encounter_end got triggered
SegmentID = "trashoverall",
RunID = self.mythic_dungeon_id,
TrashOverallSegment = true,
ZoneName = self.MythicPlus.DungeonName,
MapID = instanceMapID,
Level = self.MythicPlus.Level,
EJID = self.MythicPlus.ejID,
EncounterID = segmentsToMerge.EncounterID,
EncounterName = segmentsToMerge.EncounterName or Loc ["STRING_UNKNOW"],
}
newCombat.is_mythic_dungeon_segment = true
newCombat.is_mythic_dungeon_run_id = self.mythic_dungeon_id
--> set the segment time / using a sum of combat times, this combat time is reliable
newCombat:SetStartTime (GetTime() - totalTime)
newCombat:SetEndTime (GetTime())
--> set the segment date
newCombat:SetDate (startDate, endDate)
if (newFrame.DevelopmentDebug) then
print ("Details!", "MergeTrashCleanup() > finished merging trash segments.", _detalhes.tabela_vigente, _detalhes.tabela_vigente.is_boss)
end
--> should delete the trash segments after the merge?
if (_detalhes.mythic_plus.delete_trash_after_merge) then
local segmentHistory = self:GetCombatSegments()
for i = #segmentHistory, 1, -1 do
local segment = segmentHistory [i]
if (segment and segment._trashoverallalreadyadded) then
tremove (segmentHistory, i)
end
end
for i = #segmentsToMerge, 1, -1 do
tremove (segmentsToMerge, i)
end
self:SendEvent ("DETAILS_DATA_SEGMENTREMOVED")
else
--> clear the segments to merge table
for i = #segmentsToMerge, 1, -1 do
tremove (segmentsToMerge, i)
--> notify plugins about a segment deleted
self:SendEvent ("DETAILS_DATA_SEGMENTREMOVED")
end
--> clear encounter name and id
segmentsToMerge.EncounterID = nil
segmentsToMerge.EncounterName = nil
end
--> update all windows
self:InstanciaCallFunction (self.gump.Fade, "in", nil, "barras")
self:InstanciaCallFunction (self.AtualizaSegmentos)
self:InstanciaCallFunction (self.AtualizaSoloMode_AfertReset)
self:InstanciaCallFunction (self.ResetaGump)
self:AtualizaGumpPrincipal (-1, true)
end
end
--> this function merges trash segments after all bosses of the mythic dungeon are defeated
--> happens when the group finishes all bosses but don't complete the trash requirement
function newFrame.MergeRemainingTrashAfterAllBossesDone()
if (newFrame.DevelopmentDebug) then
print ("Details!", "MergeRemainingTrashAfterAllBossesDone() > running, #segments: ", #newFrame.TrashMergeScheduled2, "trash overall table:", newFrame.TrashMergeScheduled2_OverallCombat)
end
local segmentsToMerge = newFrame.TrashMergeScheduled2
local overallCombat = newFrame.TrashMergeScheduled2_OverallCombat
--> needs to merge, add the total combat time, set the date end to the date of the first segment
local totalTime = 0
local startDate, endDate = "", ""
local lastSegment
--> add segments
for i, pastCombat in ipairs (segmentsToMerge) do
overallCombat = overallCombat + pastCombat
if (newFrame.DevelopmentDebug) then
print ("MergeRemainingTrashAfterAllBossesDone() > segment added")
end
totalTime = totalTime + pastCombat:GetCombatTime()
--> tag this combat as already added to a boss trash overall
pastCombat._trashoverallalreadyadded = true
if (endDate == "") then --get the end date of the first index only
local _, whenEnded = pastCombat:GetDate()
endDate = whenEnded
end
lastSegment = pastCombat
end
--> set the segment time / using a sum of combat times, this combat time is reliable
local startTime = overallCombat:GetStartTime()
overallCombat:SetStartTime (startTime - totalTime)
if (newFrame.DevelopmentDebug) then
print ("MergeRemainingTrashAfterAllBossesDone() > total combat time:", totalTime)
end
--> set the segment date
local startDate = overallCombat:GetDate()
overallCombat:SetDate (startDate, endDate)
if (newFrame.DevelopmentDebug) then
print ("MergeRemainingTrashAfterAllBossesDone() > new end date:", endDate)
end
local mythicDungeonInfo = overallCombat:GetMythicDungeonInfo()
if (newFrame.DevelopmentDebug) then
print ("MergeRemainingTrashAfterAllBossesDone() > elapsed time before:", mythicDungeonInfo.EndedAt - mythicDungeonInfo.StartedAt)
end
mythicDungeonInfo.StartedAt = mythicDungeonInfo.StartedAt - (self.MythicPlus.EndedAt - self.MythicPlus.PreviousBossKilledAt)
if (newFrame.DevelopmentDebug) then
print ("MergeRemainingTrashAfterAllBossesDone() > elapsed time after:", mythicDungeonInfo.EndedAt - mythicDungeonInfo.StartedAt)
end
--> should delete the trash segments after the merge?
if (_detalhes.mythic_plus.delete_trash_after_merge) then
local removedCurrentSegment = false
local segmentHistory = self:GetCombatSegments()
for _, pastCombat in ipairs (segmentsToMerge) do
for i = #segmentHistory, 1, -1 do
local segment = segmentHistory [i]
if (segment == pastCombat) then
--> remove the segment
if (_detalhes.tabela_vigente == segment) then
removedCurrentSegment = true
end
tremove (segmentHistory, i)
break
end
end
end
for i = #segmentsToMerge, 1, -1 do
tremove (segmentsToMerge, i)
end
if (removedCurrentSegment) then
--> find another current segment
local segmentHistory = self:GetCombatSegments()
_detalhes.tabela_vigente = segmentHistory [1]
if (not _detalhes.tabela_vigente) then
--> assuming there's no segment from the dungeon run
self:EntrarEmCombate()
self:SairDoCombate()
end
--> update all windows
self:InstanciaCallFunction (self.gump.Fade, "in", nil, "barras")
self:InstanciaCallFunction (self.AtualizaSegmentos)
self:InstanciaCallFunction (self.AtualizaSoloMode_AfertReset)
self:InstanciaCallFunction (self.ResetaGump)
self:AtualizaGumpPrincipal (-1, true)
end
self:SendEvent ("DETAILS_DATA_SEGMENTREMOVED")
else
--> clear the segments to merge table
for i = #segmentsToMerge, 1, -1 do
tremove (segmentsToMerge, i)
--> notify plugins about a segment deleted
self:SendEvent ("DETAILS_DATA_SEGMENTREMOVED")
end
end
newFrame.TrashMergeScheduled2 = nil
newFrame.TrashMergeScheduled2_OverallCombat = nil
if (newFrame.DevelopmentDebug) then
print ("Details!", "MergeRemainingTrashAfterAllBossesDone() > done merging")
end
end
--this function is called right after defeat a boss inside a mythic dungeon
--it comes from details! control leave combat
function newFrame.BossDefeated (this_is_end_end, encounterID, encounterName, difficultyID, raidSize, endStatus) --hold your breath and count to ten
if (newFrame.DevelopmentDebug) then
print ("Details!", "BossDefeated() > boss defeated | SegmentID:", self.MythicPlus.SegmentID, " | mapID:", self.MythicPlus.DungeonID)
end
local zoneName, instanceType, difficultyID, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID, instanceGroupSize = GetInstanceInfo()
--> add the mythic dungeon info to the combat
_detalhes.tabela_vigente.is_mythic_dungeon = {
StartedAt = self.MythicPlus.StartedAt, --the start of the run
EndedAt = time(), --when the boss got killed
SegmentID = self.MythicPlus.SegmentID, --segment number within the dungeon
EncounterID = encounterID,
EncounterName = encounterName or Loc ["STRING_UNKNOW"],
RunID = self.mythic_dungeon_id,
ZoneName = self.MythicPlus.DungeonName,
MapID = self.MythicPlus.DungeonID,
OverallSegment = false,
Level = self.MythicPlus.Level,
EJID = self.MythicPlus.ejID,
}
--> check if need to merge the trash for this boss
if (_detalhes.mythic_plus.merge_boss_trash and not self.MythicPlus.IsRestoredState) then
--> store on an table all segments which should be merged
local segmentsToMerge = newFrame.TrashMergeScheduled or {}
--> table with all past semgnets
local segmentHistory = self:GetCombatSegments()
--> iterate among segments
for i = 1, 25 do --> from the newer combat to the oldest
local pastCombat = segmentHistory [i]
--> does the combat exists
if (pastCombat and not pastCombat._trashoverallalreadyadded and pastCombat.is_mythic_dungeon_trash) then
--> is the combat a mythic segment from this run?
local isMythicSegment, SegmentID = pastCombat:IsMythicDungeon()
if (isMythicSegment and SegmentID == self.mythic_dungeon_id and not pastCombat.is_boss) then
local mythicDungeonInfo = pastCombat:GetMythicDungeonInfo() -- .is_mythic_dungeon only boss, trash overall and run overall have it
if (not mythicDungeonInfo or not mythicDungeonInfo.TrashOverallSegment) then
--> trash segment found, schedule to merge
tinsert (segmentsToMerge, pastCombat)
end
end
end
end
--> add encounter information
segmentsToMerge.EncounterID = encounterID
segmentsToMerge.EncounterName = encounterName
segmentsToMerge.PreviousBossKilledAt = self.MythicPlus.PreviousBossKilledAt
--> reduce this boss encounter time from the trash lenght time, since the boss doesn't count towards the time spent cleaning trash
segmentsToMerge.LastBossKilledAt = time() - _detalhes.tabela_vigente:GetCombatTime()
newFrame.TrashMergeScheduled = segmentsToMerge
--there's no more script run too long
--if (not InCombatLockdown() and not UnitAffectingCombat ("player")) then
if (newFrame.DevelopmentDebug) then
print ("Details!", "BossDefeated() > not in combat, merging trash now")
end
--merge the trash clean up
newFrame.MergeTrashCleanup()
--else
-- if (newFrame.DevelopmentDebug) then
-- print ("Details!", "BossDefeated() > player in combatlockdown, scheduling trash merge")
-- end
-- _detalhes.schedule_mythicdungeon_trash_merge = true
--end
end
--> close the combat
if (this_is_end_end) then
--> player left the dungeon
if (in_combat and _detalhes.mythic_plus.always_in_combat) then
self:SairDoCombate()
end
else
--> re-enter in combat if details! is set to always be in combat during mythic plus
if (self.mythic_plus.always_in_combat) then
self:EntrarEmCombate()
end
--> increase the segment number for the mythic run
self.MythicPlus.SegmentID = self.MythicPlus.SegmentID + 1
--> register the time when the last boss has been killed (started a clean up for the next trash)
self.MythicPlus.PreviousBossKilledAt = time()
--> update the saved table inside the profile
_detalhes:UpdateState_CurrentMythicDungeonRun (true, self.MythicPlus.SegmentID, self.MythicPlus.PreviousBossKilledAt)
end
end
function newFrame.MythicDungeonFinished (fromZoneLeft)
if (newFrame.IsDoingMythicDungeon) then
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonFinished() > the dungeon was a Mythic+ and just ended.")
end
newFrame.IsDoingMythicDungeon = false
self.MythicPlus.Started = false
self.MythicPlus.EndedAt = time()-1.9
self:UpdateState_CurrentMythicDungeonRun()
--> at this point, details! should not be in combat, but if something triggered a combat start, just close the combat right away
if (self.in_combat) then
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonFinished() > was in combat, calling SairDoCombate():", InCombatLockdown())
end
self:SairDoCombate()
end
local segmentsToMerge = {}
--> check if there is trash segments after the last boss. need to merge these segments with the trash segment of the last boss
if (_detalhes.mythic_plus.merge_boss_trash and not self.MythicPlus.IsRestoredState and not fromZoneLeft) then
--> is the current combat not a boss fight?
--> this mean a combat was opened after the last boss of the dungeon was killed
if (not self.tabela_vigente.is_boss and self.tabela_vigente:GetCombatTime() > 5) then
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonFinished() > the last combat isn't a boss fight, might have trash after bosses done.")
end
--> table with all past semgnets
local segmentHistory = self:GetCombatSegments()
for i = 1, #segmentHistory do
local pastCombat = segmentHistory [i]
--> does the combat exists
if (pastCombat and not pastCombat._trashoverallalreadyadded and pastCombat:GetCombatTime() > 5) then
--> is the last boss?
if (pastCombat.is_boss) then
break
end
--> is the combat a mythic segment from this run?
local isMythicSegment, SegmentID = pastCombat:IsMythicDungeon()
if (isMythicSegment and SegmentID == self.mythic_dungeon_id and pastCombat.is_mythic_dungeon_trash) then
--> if have mythic dungeon info, cancel the loop
local mythicDungeonInfo = pastCombat:GetMythicDungeonInfo()
if (mythicDungeonInfo) then
break
end
--> merge this segment
tinsert (segmentsToMerge, pastCombat)
if (newFrame.DevelopmentDebug) then
print ("MythicDungeonFinished() > found after last boss combat")
end
end
end
end
end
end
if (#segmentsToMerge > 0) then
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonFinished() > found ", #segmentsToMerge, "segments after the last boss")
end
--> find the latest trash overall
local segmentHistory = self:GetCombatSegments()
local latestTrashOverall
for i = 1, #segmentHistory do
local pastCombat = segmentHistory [i]
if (pastCombat and pastCombat.is_mythic_dungeon and pastCombat.is_mythic_dungeon.SegmentID == "trashoverall") then
latestTrashOverall = pastCombat
break
end
end
if (latestTrashOverall) then
--> stores the segment table and the trash overall segment to use on the merge
newFrame.TrashMergeScheduled2 = segmentsToMerge
newFrame.TrashMergeScheduled2_OverallCombat = latestTrashOverall
--there's no more script ran too long
--if (not InCombatLockdown() and not UnitAffectingCombat ("player")) then
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonFinished() > not in combat, merging last pack of trash now")
end
newFrame.MergeRemainingTrashAfterAllBossesDone()
--else
-- if (newFrame.DevelopmentDebug) then
-- print ("Details!", "MythicDungeonFinished() > player in combatlockdown, scheduling the merge for last trash packs")
-- end
-- _detalhes.schedule_mythicdungeon_endtrash_merge = true
--end
end
end
--> merge segments
if (_detalhes.mythic_plus.make_overall_when_done and not self.MythicPlus.IsRestoredState and not fromZoneLeft) then
--if (not InCombatLockdown() and not UnitAffectingCombat ("player")) then
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonFinished() > not in combat, creating overall segment now")
end
newFrame.MergeSegmentsOnEnd()
--else
-- if (newFrame.DevelopmentDebug) then
-- print ("Details!", "MythicDungeonFinished() > player in combatlockdown, scheduling the creation of the overall segment")
-- end
-- _detalhes.schedule_mythicdungeon_overallrun_merge = true
--end
end
self.MythicPlus.IsRestoredState = nil
--> shutdown parser for a few seconds to avoid opening new segments after the run ends
if (not fromZoneLeft) then
self:CaptureSet (false, "damage", false, 15)
self:CaptureSet (false, "energy", false, 15)
self:CaptureSet (false, "aura", false, 15)
self:CaptureSet (false, "energy", false, 15)
self:CaptureSet (false, "spellcast", false, 15)
end
--> store data
--[=[
local expansion = tostring (select (4, GetBuildInfo())):match ("%d%d")
if (expansion and type (expansion) == "string" and string.len (expansion) == 2) then
local expansionDungeonData = _detalhes.dungeon_data [expansion]
if (not expansionDungeonData) then
expansionDungeonData = {}
_detalhes.dungeon_data [expansion] = expansionDungeonData
end
--store information about the dungeon run
--the the dungeon ID, can't be localized
--players in the group
--difficulty level
--
end
--]=]
end
end
function newFrame.MythicDungeonStarted()
--> flag as a mythic dungeon
newFrame.IsDoingMythicDungeon = true
--> this counter is individual for each character
self.mythic_dungeon_id = self.mythic_dungeon_id + 1
local mythicLevel = C_ChallengeMode.GetActiveKeystoneInfo()
local zoneName, _, _, _, _, _, _, currentZoneID = GetInstanceInfo()
local mapID = C_Map.GetBestMapForUnit ("player")
if (not mapID) then
return
end
local ejID = DetailsFramework.EncounterJournal.EJ_GetInstanceForMap (mapID)
--> setup the mythic run info
self.MythicPlus.Started = true
self.MythicPlus.DungeonName = zoneName
self.MythicPlus.DungeonID = currentZoneID
self.MythicPlus.StartedAt = time()+9.7 --> there's the countdown timer of 10 seconds
self.MythicPlus.EndedAt = nil --reset
self.MythicPlus.SegmentID = 1
self.MythicPlus.Level = mythicLevel
self.MythicPlus.ejID = ejID
self.MythicPlus.PreviousBossKilledAt = time()
self:SaveState_CurrentMythicDungeonRun (self.mythic_dungeon_id, zoneName, currentZoneID, time()+9.7, 1, mythicLevel, ejID, time())
--> start a new combat segment after 10 seconds
if (_detalhes.mythic_plus.always_in_combat) then
C_Timer.After (9.7, function()
if (newFrame.DevelopmentDebug) then
print ("Details!", "New segment for mythic dungeon created.")
end
_detalhes:EntrarEmCombate()
end)
end
local name, groupType, difficultyID, difficult = GetInstanceInfo()
if (groupType == "party" and self.overall_clear_newchallenge) then
self.historico:resetar_overall()
self:Msg ("overall data are now reset.")
if (self.debug) then
self:Msg ("(debug) timer is for a mythic+ dungeon, overall has been reseted.")
end
end
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonStarted() > State set to Mythic Dungeon, new combat starting in 10 seconds.")
end