Added Erase Segment Options: "Remove Common Segments" and "Reset, but keep Mythic+ Overall Segments"

This commit is contained in:
Tercio Jose
2023-11-20 19:36:28 -03:00
parent 22483cb77c
commit 95ba39b389
3 changed files with 133 additions and 16 deletions
+17 -15
View File
@@ -316,25 +316,27 @@
--mythic dungeon
local isMythicDungeon = self.is_mythic_dungeon_segment
if (isMythicDungeon) then
local bIsMythicDungeonOverall = self.is_mythic_dungeon and self.is_mythic_dungeon.OverallSegment
if (bIsMythicDungeonOverall) then
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_OVERALL, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
end
local bIsMythicDungeonTrashOverall = self.is_mythic_dungeon and self.is_mythic_dungeon.TrashOverallSegment
if (bIsMythicDungeonTrashOverall) then
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASHOVERALL, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
end
local isMythicDungeonTrash = self.is_mythic_dungeon_trash
if (isMythicDungeonTrash) then
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASH, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
else
local isMythicDungeonOverall = self.is_mythic_dungeon and self.is_mythic_dungeon.OverallSegment
local isMythicDungeonTrashOverall = self.is_mythic_dungeon and self.is_mythic_dungeon.TrashOverallSegment
if (isMythicDungeonOverall) then
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_OVERALL, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
elseif (isMythicDungeonTrashOverall) then
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_TRASHOVERALL, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
end
local bossEncounter = self.is_boss
if (bossEncounter) then
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_BOSS, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
end
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_GENERIC, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
end
local bossEncounter = self.is_boss
if (bossEncounter) then
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_BOSS, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
end
return DETAILS_SEGMENTTYPE_MYTHICDUNGEON_GENERIC, DETAILS_SEGMENTTYPE_MYTHICDUNGEON
end
--arena
+91
View File
@@ -26,6 +26,10 @@ function Details:GetCurrentCombat()
return Details.tabela_vigente
end
function Details:SetCurrentCombat(combatObject)
Details.tabela_vigente = combatObject
end
function Details:GetOverallCombat()
return Details.tabela_overall
end
@@ -758,6 +762,93 @@ function segmentClass:ResetOverallData()
Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED")
end
function segmentClass:ResetDataByCombatType(combatType)
local bIsException = false
if (combatType == "m+overall") then
combatType = DETAILS_SEGMENTTYPE_MYTHICDUNGEON_OVERALL
bIsException = true
elseif (combatType == "generic") then
combatType = DETAILS_SEGMENTTYPE_GENERIC
end
--if true then return end
--destroy the overall combat object
segmentClass:ResetOverallData()
local bSegmentDestroyed = false
local segmentsTable = Details:GetCombatSegments()
---@type table<combat, boolean> store references of combat objects removed
local removedCombats = {}
if (bIsException) then --include all except the combatType
--iterate over all segments and remove those that are not of the combatType
--go to a minimum of 2 because the first segment is the current segment when the player isn't in combat
for i = #segmentsTable, 2, -1 do
---@type combat
local thisCombatObject = segmentsTable[i]
if (thisCombatObject:GetCombatType() ~= combatType) then
---@type boolean, combat|nil
local combatObjectRemoved = table.remove(segmentsTable, i)
if (combatObjectRemoved and combatObjectRemoved == thisCombatObject) then
Details:DestroyCombat(combatObjectRemoved)
bSegmentDestroyed = true
--add the combat reference to removed combats table
removedCombats[combatObjectRemoved] = true
end
end
end
else
--iterate over all segments and remove those that are equal to the combatType
for i = #segmentsTable, 2, -1 do
---@type combat
local thisCombatObject = segmentsTable[i]
if (thisCombatObject:GetCombatType() == combatType) then
---@type boolean, combat|nil
local combatObjectRemoved = table.remove(segmentsTable, i)
if (combatObjectRemoved and combatObjectRemoved == thisCombatObject) then
Details:DestroyCombat(combatObjectRemoved)
bSegmentDestroyed = true
end
end
end
end
--safe check, if no segments saved, can cleanup all data
if (#segmentsTable == 0) then
--there's no combat left in the segments table
segmentClass:ResetAllCombatData()
return
end
--check if an instance is showing a combat which was removed
for instanceId, instanceObject in Details:ListInstances() do
---@type combat
local combatObject = instanceObject:GetShowingCombat()
if (combatObject and combatObject.__destroyed) then
--update the combat the instance uses
instanceObject:SetSegmentId(DETAILS_SEGMENTID_CURRENT)
--reset the window frame
instanceObject:ResetWindow()
--refresh the window to show the new combat attributed to it
local bForceRefresh = true
instanceObject:RefreshData(bForceRefresh)
end
end
Details:InstanceCall(function(instanceObject) instanceObject:RefreshCombat() end)
--update the combat shown on all instances
Details:InstanceCallDetailsFunc(Details.AtualizaSegmentos_AfterCombat)
Details:UpdateParserGears()
if (bSegmentDestroyed) then
Details:SendEvent("DETAILS_DATA_SEGMENTREMOVED")
end
end
function segmentClass:ResetAllCombatData()
if (Details:IsInCombat()) then
Details:EndCombat()
+25 -1
View File
@@ -2209,7 +2209,7 @@ local iconFrame_OnEnter = function(self)
local previousScore = rioProfile.previousScore or 0
local currentScore = rioProfile.currentScore or 0
if (previousScore > currentScore) then
if (false and previousScore > currentScore and time() > 1700562401) then --2023.11.21 midday
GameCooltip:AddLine("M+ Score:", previousScore .. " (|cFFFFDD11" .. currentScore .. "|r)", 1, "white")
addedInfo = true
else
@@ -2257,6 +2257,20 @@ local iconFrame_OnEnter = function(self)
height = height + 19
end
if (actor.classe == "UNKNOW") then
local npcId = tonumber(actor.aID)
if (not npcId) then
npcId = Details:GetNpcIdFromGuid(actor.serial)
end
if (npcId) then
GameCooltip:AddLine("NpcID:", npcId)
GameCooltip:AddIcon([[]], 1, 1, 1, 20)
Details:AddTooltipBackgroundStatusbar()
height = height + 19
end
end
GameCooltip:SetOption("FixedHeight", height)
GameCooltip:ShowCooltip()
@@ -8990,6 +9004,16 @@ end
Details:SetTooltipMinWidth()
gameCooltip:AddLine("Remove Common Segments", nil, 1, "white", nil, Details.font_sizes.menus, Details.font_faces.menus)
gameCooltip:AddIcon([[Interface\Buttons\UI-StopButton]], 1, 1, 14, 14, 0, 1, 0, 1, "orange")
gameCooltip:AddMenu(1, function() return Details.tabela_historico:ResetDataByCombatType("generic") end)
gameCooltip:AddLine("Reset, but keep Mythic+ Overall Segments", nil, 1, "white", nil, Details.font_sizes.menus, Details.font_faces.menus)
gameCooltip:AddIcon([[Interface\Buttons\UI-StopButton]], 1, 1, 14, 14, 0, 1, 0, 1, "orange")
gameCooltip:AddMenu(1, function() return Details.tabela_historico:ResetDataByCombatType("m+overall") end)
gameCooltip:AddLine("$div", nil, 1, nil, -5, -11)
gameCooltip:AddLine(Loc["STRING_ERASE_DATA_OVERALL"], nil, 1, "white", nil, Details.font_sizes.menus, Details.font_faces.menus)
gameCooltip:AddIcon([[Interface\Buttons\UI-StopButton]], 1, 1, 14, 14, 0, 1, 0, 1, "orange")
gameCooltip:AddMenu(1, Details.tabela_historico.ResetOverallData)