From 504b712acc62754faee428fb517e52d8bf8a2b3a Mon Sep 17 00:00:00 2001 From: BloodDragon2580 Date: Sat, 17 Aug 2024 23:22:58 +0200 Subject: [PATCH] 'Update' --- MythicPlusDrop/MythicPlusDrop.toc | 2 +- MythicPlusDrop/ProgressTracker.lua | 66 ++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/MythicPlusDrop/MythicPlusDrop.toc b/MythicPlusDrop/MythicPlusDrop.toc index 47ac829..3c85689 100644 --- a/MythicPlusDrop/MythicPlusDrop.toc +++ b/MythicPlusDrop/MythicPlusDrop.toc @@ -1,6 +1,6 @@ ## Interface: 110002 ## Title: |cffd6266cMythicPlusDrop|r -## Version: 8.4 +## Version: 8.5 ## Notes: Info for Mythic Dungeons ## Author: BloodDragon2580 ## SavedVariables: MythicPlusDrop_Config, MythicPlusDrop_Data diff --git a/MythicPlusDrop/ProgressTracker.lua b/MythicPlusDrop/ProgressTracker.lua index 3c28e16..6c456a4 100644 --- a/MythicPlusDrop/ProgressTracker.lua +++ b/MythicPlusDrop/ProgressTracker.lua @@ -38,6 +38,7 @@ function Mod:COMBAT_LOG_EVENT_UNFILTERED() lastDied = tonumber(npc_id) lastDiedTime = GetTime() lastDiedName = destName + ProcessLasts() end if bit.band(destFlags, COMBATLOG_OBJECT_TYPE_PLAYER) > 0 then if UnitIsFeignDeath(destName) then @@ -57,11 +58,12 @@ function Mod:SCENARIO_CRITERIA_UPDATE() for criteriaIndex = 1, numCriteria do local criteriaInfo = C_ScenarioInfo.GetCriteriaInfo(criteriaIndex) if criteriaInfo and criteriaInfo.isWeightedProgress then - local quantityString = criteriaInfo.description - local currentQuantity = criteriaInfo.quantity + local quantityString = criteriaInfo.quantityString + local currentQuantity = quantityString and tonumber( quantityString:match("%d+") ) if lastQuantity and currentQuantity < criteriaInfo.totalQuantity and currentQuantity > lastQuantity then lastAmount = currentQuantity - lastQuantity lastAmountTime = GetTime() + ProcessLasts() end lastQuantity = currentQuantity break @@ -76,7 +78,8 @@ local function StartTime() for criteriaIndex = 1, numCriteria do local criteriaInfo = C_ScenarioInfo.GetCriteriaInfo(criteriaIndex) if criteriaInfo and criteriaInfo.isWeightedProgress then - lastQuantity = criteriaInfo.quantity + local quantityString = criteriaInfo.quantityString + lastQuantity = quantityString and tonumber( quantityString:match("%d+") ) break end end @@ -181,31 +184,78 @@ function Mod:GeneratePreset() return ret end +function Mod:PLAYER_ENTERING_WORLD(...) CheckTime(GetWorldElapsedTimers()) end function Mod:WORLD_STATE_TIMER_START(...) local timerID = ...; CheckTime(timerID) end function Mod:WORLD_STATE_TIMER_STOP(...) local timerID = ...; StopTime(timerID) end function Mod:CHALLENGE_MODE_START(...) CheckTime(GetWorldElapsedTimers()) end function Mod:CHALLENGE_MODE_RESET(...) wipe(Mod.playerDeaths) end local function ProgressBar_SetValue(self, percent) + + local scenarioType = select(10, C_Scenario.GetInfo()) + + if scenarioType ~= LE_SCENARIO_TYPE_CHALLENGE_MODE then return end + + local numCriteria = select(3, C_Scenario.GetStepInfo()) + local criteriaInfo + local cInfo + + for criteriaIndex = 1, numCriteria do + cInfo = C_ScenarioInfo.GetCriteriaInfo(criteriaIndex) + if cInfo and cInfo.isWeightedProgress then + criteriaInfo = cInfo + break + end + end + + if not criteriaInfo then return end + + local totalQuantity = criteriaInfo.totalQuantity + local quantityString = criteriaInfo.quantityString + local currentQuantity = quantityString and tonumber( quantityString:match("%d+") ) + + if currentQuantity and totalQuantity then + if Addon.Config.progressFormat == 1 then + self.Bar.Label:SetFormattedText("%.2f%%", currentQuantity/totalQuantity*100) + elseif Addon.Config.progressFormat == 2 then + self.Bar.Label:SetFormattedText("%d/%d", currentQuantity, totalQuantity) + elseif Addon.Config.progressFormat == 3 then + self.Bar.Label:SetFormattedText("%.2f%% - %d/%d", currentQuantity/totalQuantity*100, currentQuantity, totalQuantity) + elseif Addon.Config.progressFormat == 4 then + self.Bar.Label:SetFormattedText("%.2f%% (%.2f%%)", currentQuantity/totalQuantity*100, (totalQuantity-currentQuantity)/totalQuantity*100) + elseif Addon.Config.progressFormat == 5 then + self.Bar.Label:SetFormattedText("%d/%d (%d)", currentQuantity, totalQuantity, totalQuantity - currentQuantity) + elseif Addon.Config.progressFormat == 6 then + self.Bar.Label:SetFormattedText("%.2f%% (%.2f%%) - %d/%d (%d)", currentQuantity/totalQuantity*100, (totalQuantity-currentQuantity)/totalQuantity*100, currentQuantity, totalQuantity, totalQuantity - currentQuantity) + end + end end -function Mod:PLAYER_ENTERING_WORLD(...) - CheckTime(GetWorldElapsedTimers()) +local progressBarFound = false + +local function findProgressBar() + + if progressBarFound then return end + local usedBars = ScenarioObjectiveTracker.usedProgressBars or {} + for _, bar in pairs(usedBars) do if bar.used then hooksecurefunc(bar, "SetValue", ProgressBar_SetValue) + progressBarFound = true break end end end +hooksecurefunc(ScenarioObjectiveTracker.ObjectivesBlock, "AddProgressBar", findProgressBar ) local function DeathCount_OnEnter(self) - local timeLost = tonumber(self.Count:GetText()) * 5 + local parent = self:GetParent() + GameTooltip:SetOwner(self, "ANCHOR_LEFT") - GameTooltip:SetText(CHALLENGE_MODE_DEATH_COUNT_TITLE:format(tonumber(self.Count:GetText())), 1, 1, 1) - GameTooltip:AddLine(CHALLENGE_MODE_DEATH_COUNT_DESCRIPTION:format(SecondsToClock(timeLost, false))) + GameTooltip:SetText(CHALLENGE_MODE_DEATH_COUNT_TITLE:format(parent.deathCount), 1, 1, 1) + GameTooltip:AddLine(CHALLENGE_MODE_DEATH_COUNT_DESCRIPTION:format(SecondsToClock(parent.timeLost, false))) GameTooltip:AddLine(" ") local list = {}