From a54e80c47548f329fe3e7552bcff775787c771a8 Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Tue, 9 May 2023 10:58:41 -0300 Subject: [PATCH] Restored "right click to close" on breakdown window --- Definitions.lua | 3 +++ boot.lua | 18 +++++++++--------- core/parser.lua | 30 ++++++++++++++++++++++++++++++ frames/window_playerbreakdown.lua | 6 ++++++ 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/Definitions.lua b/Definitions.lua index 7f7deb054..957ac6dde 100644 --- a/Definitions.lua +++ b/Definitions.lua @@ -24,6 +24,9 @@ ---@field NewTimer fun(delay: number, func: function): timer ---@field NewTicker fun(interval: number, func: function, iterations: number|nil): timer +---@class C_ChallengeMode : table +---@field GetActiveKeystoneInfo fun(): number, number[], boolean @returns keystoneLevel, affixIDs, wasActive + ---@class tablesize : {H: number, W: number} ---@class tablecoords : {L: number, R: number, T: number, B: number} diff --git a/boot.lua b/boot.lua index 906af1f24..18e4e6a5a 100644 --- a/boot.lua +++ b/boot.lua @@ -15,8 +15,8 @@ local addonName, Details222 = ... local version, build, date, tocversion = GetBuildInfo() - Details.build_counter = 10993 - Details.alpha_build_counter = 10993 --if this is higher than the regular counter, use it instead + Details.build_counter = 11000 + Details.alpha_build_counter = 11000 --if this is higher than the regular counter, use it instead Details.dont_open_news = true Details.game_version = version Details.userversion = version .. " " .. Details.build_counter @@ -1176,6 +1176,13 @@ function Details222.PlayerStats:AddStat(statName, value) Details.player_stats[statName] = (Details.player_stats[statName] or 0) + value end +---get the value of a saved stat +---@param statName string +---@return any +function Details222.PlayerStats:GetStat(statName) + return Details.player_stats[statName] +end + ---same thing as above but set the value instead of adding ---@param statName string ---@param value number @@ -1183,13 +1190,6 @@ function Details222.PlayerStats:SetStat(statName, value) Details.player_stats[statName] = value end ----get the value of a saved stat ----@param statName string ----@return any -function Details222.PlayerStats:GetStat(statName, value) - return Details.player_stats[statName] -end - ---destroy a table and remove it from the object, if the key isn't passed, the object itself is destroyed ---@param object any ---@param key string|nil diff --git a/core/parser.lua b/core/parser.lua index 33d4be2ee..c79ab6b5c 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -5411,6 +5411,36 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 if (difficultyID == 8) then _detalhes:SendEvent("COMBAT_MYTHICDUNGEON_END") end + + local okay, errorText = pcall(function() + local mapChallengeModeID, mythicLevel, time, onTime, keystoneUpgradeLevels, practiceRun, oldOverallDungeonScore, newOverallDungeonScore, IsMapRecord, IsAffixRecord, PrimaryAffix, isEligibleForScore, members = C_ChallengeMode.GetCompletionInfo() + if (mapChallengeModeID) then + local statName = "mythicdungeoncompletedDF2" + local mythicDungeonRuns = Details222.PlayerStats:GetStat(statName) + mythicDungeonRuns = mythicDungeonRuns or {} + + mythicDungeonRuns[mapChallengeModeID] = mythicDungeonRuns[mapChallengeModeID] or {} + mythicDungeonRuns[mapChallengeModeID][mythicLevel] = mythicDungeonRuns[mapChallengeModeID][mythicLevel] or {} + + local currentRun = mythicDungeonRuns[mapChallengeModeID][mythicLevel] + currentRun.completed = (currentRun.completed or 0) + 1 + currentRun.totalTime = (currentRun.totalTime or 0) + time + if (not currentRun.minTime or time < currentRun.minTime) then + currentRun.minTime = time + end + + currentRun.history = currentRun.history or {} + local day, month, year = tonumber(date("%d")), tonumber(date("%m")), tonumber(date("%Y")) + local amountDeaths = C_ChallengeMode.GetDeathCount() or 0 + tinsert(currentRun.history, {day = day, month = month, year = year, runTime = time, onTime = onTime, deaths = amountDeaths, affix = PrimaryAffix}) + + Details222.PlayerStats:SetStat("mythicdungeoncompletedDF2", mythicDungeonRuns) + end + end) + + if (not okay) then + _detalhes:Msg("something went wrong (0x7878):", errorText) + end end function _detalhes.parser_functions:PLAYER_REGEN_ENABLED(...) diff --git a/frames/window_playerbreakdown.lua b/frames/window_playerbreakdown.lua index 217659cba..ff52ad58c 100644 --- a/frames/window_playerbreakdown.lua +++ b/frames/window_playerbreakdown.lua @@ -505,6 +505,12 @@ function Details:CreateBreakdownWindow() LibWindow.RestorePosition(breakdownWindow) LibWindow.MakeDraggable(breakdownWindow) LibWindow.SavePosition(breakdownWindow) + + breakdownWindow:SetScript("OnMouseDown", function(self, button) + if (button == "RightButton") then + Details:CloseBreakdownWindow() + end + end) end end