- Rolling back to Mercurial repository.

This commit is contained in:
Tercio
2017-09-27 17:59:04 -03:00
parent 7df507bd46
commit 7805d269e6
15 changed files with 626 additions and 170 deletions
+183 -54
View File
@@ -316,6 +316,7 @@ function _G._detalhes:Start()
newFrame:RegisterEvent ("CHALLENGE_MODE_COMPLETED")
newFrame:RegisterEvent ("ZONE_CHANGED_NEW_AREA")
newFrame:RegisterEvent ("ENCOUNTER_END")
newFrame:RegisterEvent ("START_TIMER")
--]]
--[[
@@ -338,7 +339,7 @@ function _G._detalhes:Start()
-- 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!", "MythicDungeonFinished() > starting to merge mythic segments.", "InCombatLockdown():", InCombatLockdown())
print ("Details!", "MergeSegmentsOnEnd() > starting to merge mythic segments.", "InCombatLockdown():", InCombatLockdown())
end
--> create a new combat to be the overall for the mythic run
@@ -351,11 +352,12 @@ function _G._detalhes:Start()
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 and pastCombat.is_mythic_dungeon.RunID == self.mythic_dungeon_id) then
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
@@ -366,9 +368,10 @@ function _G._detalhes:Start()
if (canAddThisSegment) then
newCombat = newCombat + pastCombat
totalTime = totalTime + pastCombat:GetCombatTime()
totalSegments = totalSegments + 1
if (newFrame.DevelopmentDebug) then
print ("MythicDungeonFinished() > adding time:", pastCombat:GetCombatTime(), pastCombat.is_boss and pastCombat.is_boss.name)
print ("MergeSegmentsOnEnd() > adding time:", pastCombat:GetCombatTime(), pastCombat.is_boss and pastCombat.is_boss.name)
end
if (endDate == "") then
@@ -386,7 +389,7 @@ function _G._detalhes:Start()
end
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonFinished() > totalTime:", totalTime, "startDate:", startDate)
print ("Details!", "MergeSegmentsOnEnd() > totalTime:", totalTime, "startDate:", startDate)
end
local zoneName, instanceType, difficultyID, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID, instanceGroupSize = GetInstanceInfo()
@@ -404,6 +407,8 @@ function _G._detalhes:Start()
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
@@ -423,14 +428,22 @@ function _G._detalhes:Start()
self:AtualizaGumpPrincipal (-1, true)
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonFinished() > finished merging segments.")
print ("Details!", "MythicDungeonFinished() > all done, check in the segments list if everything is correct, if something is weird: '/details feedback' thanks in advance!")
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+ Overall 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()
function newFrame.MergeTrashCleanup (isFromSchedule)
if (newFrame.DevelopmentDebug) then
print ("Details!", "MergeTrashCleanup() > running", newFrame.TrashMergeScheduled and #newFrame.TrashMergeScheduled)
end
@@ -506,44 +519,84 @@ function _G._detalhes:Start()
--> immediatly finishes the segment just started
self:SairDoCombate()
--o combate agora é _tabela_vigente e [1] na tabela de overall
--seria necessario passar essa tabela para [2] na overall
local segmentHistory = self:GetCombatSegments()
local bossSegment = segmentHistory [2]
if (bossSegment) then
--set the boss as the current combat
_detalhes.tabela_vigente = bossSegment
--swap tables
segmentHistory [1] = bossSegment --as the boss combat is done, it is also the first combat in the past combats table
segmentHistory [2] = newCombat --se the overall trash as the second segment on the past table (the semgnet 2 was occupy by the boss segment)
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)
--> if was scheduled, needs to reorder the segments so it will the in the correct order
if (isFromSchedule) then
local bossSegment = segmentHistory [3]
local currentTrash = segmentHistory [2]
local trashOverall = segmentHistory [1]
local bossCLID = bossSegment and bossSegment.is_mythic_dungeon and bossSegment.is_mythic_dungeon.EncounterID
local trashCLID = trashOverall and trashOverall.is_mythic_dungeon and trashOverall.is_mythic_dungeon.EncounterID
--> check if the guessed boss and guessed trash overall segments are from the same boss
if (bossCLID == trashCLID and currentTrash.is_mythic_dungeon_trash) then
--set the boss as the current combat
_detalhes.tabela_vigente = currentTrash
--swap tables
segmentHistory [1] = currentTrash
segmentHistory [2] = bossSegment
segmentHistory [3] = trashOverall
else
--> if it fails to guess which are the boss and trash, just pull the current trash segment to index 1
local currentTrash = segmentHistory [2]
if (currentTrash) then
--set the boss as the current combat
_detalhes.tabela_vigente = currentTrash
--swap tables
segmentHistory [1] = currentTrash --as the boss combat is done, it is also the first combat in the past combats table
segmentHistory [2] = newCombat --se the overall trash as the second segment on the past table (the semgnet 2 was occupy by the boss segment)
end
end
else
local bossSegment = segmentHistory [2]
if (bossSegment) then
--set the boss as the current combat
_detalhes.tabela_vigente = bossSegment
--swap tables
segmentHistory [1] = bossSegment --as the boss combat is done, it is also the first combat in the past combats table
segmentHistory [2] = newCombat --se the overall trash as the second segment on the past table (the semgnet 2 was occupy by the boss segment)
end
end
if (newFrame.DevelopmentDebug) then
print ("Details!", "MergeTrashCleanup() > finished merging trash segments.", _detalhes.tabela_vigente, _detalhes.tabela_vigente.is_boss)
end
for i = #segmentsToMerge, 1, -1 do
local segment = segmentsToMerge [i]
if (segment == _detalhes.tabela_vigente) then
_detalhes:Msg ("unhandled exception > merged trash segment is current segment > MergeTrashCleanup() is scheduled:", isFromSchedule)
end
end
--> should delete the trash segments after the merge?
if (_detalhes.mythic_plus.delete_trash_after_merge) then
local segmentHistory = self:GetCombatSegments()
for _, pastCombat in ipairs (segmentsToMerge) do
for i = #segmentHistory, 1, -1 do
local segment = segmentHistory [i]
if (segment == pastCombat) then
wipe (segment)
if (segment == pastCombat and _detalhes.tabela_vigente ~= segment) then
--> double check if the combat should be added first to overall data
if (_detalhes:CanAddCombatToOverall (segment)) then
--> actuallt is handled, but shouldn't happen, need to know which boss are triggering this
--_detalhes:Msg ("unhandled exception > attempt to erase a segment valid to overall data > MergeTrashCleanup() is scheduled:", isFromSchedule)
_detalhes.historico:adicionar_overall (segment)
end
--> remove the segment
tremove (segmentHistory, i)
break
end
end
end
wipe (segmentsToMerge)
for i = #segmentsToMerge, 1, -1 do
tremove (segmentsToMerge, i)
end
self:SendEvent ("DETAILS_DATA_SEGMENTREMOVED")
else
--> clear the segments to merge table
@@ -557,6 +610,13 @@ function _G._detalhes:Start()
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
@@ -616,20 +676,36 @@ function _G._detalhes:Start()
print ("MergeRemainingTrashAfterAllBossesDone() > elapsed time after:", mythicDungeonInfo.EndedAt - mythicDungeonInfo.StartedAt)
end
for i = #segmentsToMerge, 1, -1 do
local segment = segmentsToMerge [i]
if (segment == _detalhes.tabela_vigente) then
_detalhes:Msg ("unhandled exception > merged trash segment is current segment > MergeRemainingTrashAfterAllBossesDone()")
end
end
--> should delete the trash segments after the merge?
if (_detalhes.mythic_plus.delete_trash_after_merge) then
local segmentHistory = self:GetCombatSegments()
for _, pastCombat in ipairs (segmentsToMerge) do
for i = #segmentHistory, 1, -1 do
local segment = segmentHistory [i]
if (segment == pastCombat) then
wipe (segment)
if (segment == pastCombat and _detalhes.tabela_vigente ~= segment) then
--> double check if the combat should be added first to overall data
if (_detalhes:CanAddCombatToOverall (segment)) then
--> actuallt is handled, but shouldn't happen, need to know which boss are triggering this
--_detalhes:Msg ("unhandled exception > attempt to erase a segment valid to overall data > MergeRemainingTrashAfterAllBossesDone()")
_detalhes.historico:adicionar_overall (segment)
end
--> remove the segment
tremove (segmentHistory, i)
break
end
end
end
wipe (segmentsToMerge)
for i = #segmentsToMerge, 1, -1 do
tremove (segmentsToMerge, i)
end
self:SendEvent ("DETAILS_DATA_SEGMENTREMOVED")
else
--> clear the segments to merge table
@@ -681,7 +757,7 @@ function _G._detalhes:Start()
end
--> check if need to merge the trash for this boss
if (_detalhes.mythic_plus.merge_boss_trash) then
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
@@ -745,10 +821,13 @@ function _G._detalhes:Start()
--> 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()
function newFrame.MythicDungeonFinished (fromZoneLeft)
if (newFrame.IsDoingMythicDungeon) then
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonFinished() > the dungeon was a Mythic+ and just ended.")
@@ -758,6 +837,8 @@ function _G._detalhes:Start()
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
@@ -769,7 +850,7 @@ function _G._detalhes:Start()
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) then
if (_detalhes.mythic_plus.merge_boss_trash and not self.MythicPlus.IsRestoredState and not fromZoneLeft) then --and false
--> is the current combat not a boss fight? this means a combat was opened after the mythic run completed
if (not self.tabela_vigente.is_boss and self.tabela_vigente:GetCombatTime() > 5) then
if (newFrame.DevelopmentDebug) then
@@ -807,7 +888,7 @@ function _G._detalhes:Start()
end
end
if (#segmentsToMerge > 0) then
if (#segmentsToMerge > 0) then --and false
if (newFrame.DevelopmentDebug) then
print ("Details!", "MythicDungeonFinished() > found ", #segmentsToMerge, "segments after the last boss")
end
@@ -843,7 +924,7 @@ function _G._detalhes:Start()
end
--> merge segments
if (_detalhes.mythic_plus.make_overall_when_done) then
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")
@@ -856,6 +937,17 @@ function _G._detalhes:Start()
_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
end
end
@@ -871,6 +963,9 @@ function _G._detalhes:Start()
print ("Details!", "MythicDungeonStarted() > CHALLENGE_MODE_START triggered, setting up details!")
end
--> this counter is individual for each character
self.mythic_dungeon_id = self.mythic_dungeon_id + 1 --14 --15
local mythicLevel = C_ChallengeMode.GetActiveKeystoneInfo()
local zoneName, _, _, _, _, _, _, currentZoneID = GetInstanceInfo()
local ejID = EJ_GetCurrentInstance()
@@ -880,13 +975,13 @@ function _G._detalhes:Start()
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()
--> this counter is individual for each character
self.mythic_dungeon_id = self.mythic_dungeon_id + 1 --14 --15
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
@@ -901,6 +996,8 @@ function _G._detalhes:Start()
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
@@ -911,26 +1008,43 @@ function _G._detalhes:Start()
end
end
function newFrame.OnChallengeModeStart()
--> is this a mythic dungeon?
local _, _, difficulty, _, _, _, _, currentZoneID = GetInstanceInfo()
if (newFrame.DevelopmentDebug) then
print ("Details!", "Dungeon Dificulty:", difficulty, currentZoneID)
end
if (difficulty == 8 and newFrame.LastTimer and newFrame.LastTimer+2 > GetTime()) then
--> start the dungeon on Details!
newFrame.MythicDungeonStarted()
else
--> from zone changed
local mythicLevel = C_ChallengeMode.GetActiveKeystoneInfo()
local zoneName, _, _, _, _, _, _, currentZoneID = GetInstanceInfo()
if (not self.MythicPlus.Started and self.MythicPlus.DungeonID == currentZoneID and self.MythicPlus.Level == mythicLevel) then
self.MythicPlus.Started = true
self.MythicPlus.EndedAt = nil
_detalhes.mythic_dungeon_currentsaved.started = true
newFrame.IsDoingMythicDungeon = true
end
end
end
newFrame:SetScript ("OnEvent", function (_, event, ...)
if (event == "CHALLENGE_MODE_START") then
if (event == "START_TIMER") then
newFrame.LastTimer = GetTime()
elseif (event == "CHALLENGE_MODE_START") then
--> CHALLENGE_MODE_START does trigger every time the player enters a mythic dungeon already in progress
if (newFrame.DevelopmentDebug) then
print ("Details!", event, ...)
end
--> is this a mythic dungeon?
local _, _, difficulty, _, _, _, _, currentZoneID = GetInstanceInfo()
if (newFrame.DevelopmentDebug) then
print ("Details!", "Dungeon Dificulty:", difficulty, currentZoneID)
end
if (difficulty == 8) then
--> start the dungeon on Details!
newFrame.MythicDungeonStarted()
end
C_Timer.After (0.5, newFrame.OnChallengeModeStart)
elseif (event == "CHALLENGE_MODE_COMPLETED") then
if (newFrame.DevelopmentDebug) then
@@ -963,7 +1077,19 @@ function _G._detalhes:Start()
end
self:SairDoCombate()
end
--> just in case the combat get tagged as boss fight
self.tabela_vigente.is_boss = nil
--> tag the combat as mythic dungeon trash
local zoneName, instanceType, difficultyID, difficultyName, maxPlayers, dynamicDifficulty, isDynamic, instanceMapID, instanceGroupSize = GetInstanceInfo()
self.tabela_vigente.is_mythic_dungeon_trash = {
ZoneName = zoneName,
MapID = instanceMapID,
Level = _detalhes.MythicPlus.Level,
EJID = _detalhes.MythicPlus.ejID,
}
end
end
end
@@ -983,7 +1109,7 @@ function _G._detalhes:Start()
newFrame.BossDefeated (true)
--> finish the mythic run
newFrame.MythicDungeonFinished()
newFrame.MythicDungeonFinished (true)
end
end
@@ -1306,6 +1432,9 @@ function _G._detalhes:Start()
if (not _detalhes.schedule_chat_enter and not _detalhes.schedule_chat_leave) then
_detalhes:ScheduleTimer ("CheckChatOnZoneChange", 60)
end
--> restore mythic dungeon state
_detalhes:RestoreState_CurrentMythicDungeonRun()
--> open profiler
_detalhes:OpenProfiler()