Skip to content

Commit

Permalink
Restored "right click to close" on breakdown window
Browse files Browse the repository at this point in the history
  • Loading branch information
Tercioo committed May 9, 2023
1 parent 767135e commit a54e80c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Definitions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
18 changes: 9 additions & 9 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1176,20 +1176,20 @@ 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
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
Expand Down
30 changes: 30 additions & 0 deletions core/parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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(...)
Expand Down
6 changes: 6 additions & 0 deletions frames/window_playerbreakdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a54e80c

Please sign in to comment.