added commentator stuff, general code cleanup and better formatting, some deprecated code removed

This commit is contained in:
Tercio Jose
2024-07-09 12:47:24 -03:00
committed by andrew6180
parent af3477354a
commit 00f04959cb
20 changed files with 1602 additions and 1596 deletions
+90
View File
@@ -0,0 +1,90 @@
local Details = _G.Details
local addonName, Details222 = ...
local Loc = LibStub("AceLocale-3.0"):GetLocale("Details")
---@type detailsframework
local detailsFramework = DetailsFramework
local _
--commentator functions are features to help the streamer or blizzard commentator to show information about the combat in a more visual way
--atm the moment using "/run Details.Commentator.ShowBestInShowFrame(secondsToHide, height)"
--a third party frame can be attached to the best in show frame to show information about the combat (parent: DetailsBestInShowFrame)
function Details222.LoadCommentatorFunctions()
local frameWidth = 300
local frameHeight = 400
local bestInShowFrame = CreateFrame("frame", "DetailsBestInShowFrame", UIParent, "BackdropTemplate")
bestInShowFrame:SetSize(frameWidth, frameHeight)
bestInShowFrame:SetPoint("left", UIParent, "left", 0, 0)
bestInShowFrame:Hide()
--apply the standard backdrop from the framework and remove/hide/ the border
detailsFramework:ApplyStandardBackdrop(bestInShowFrame)
bestInShowFrame:SetBackdropBorderColor(0, 0, 0, 0)
--create an animation that will slide the frame from out of the screen from the left to the right, the frame will fade in while moving, the size of the momevent is the width of the frame, on the animation start, set its alpha to zero and set its point to be out of the screen in the left side, when the animation end stick the frame where the animation ended and make the frame be visible
local onStartAnimation = function()
bestInShowFrame:Show()
bestInShowFrame:SetAlpha(0)
--clear the frame points and set it to be out of the frame with the right side attached to the left of the screen
bestInShowFrame:ClearAllPoints()
bestInShowFrame:SetPoint("right", UIParent, "left", 0, 0)
end
local onEndAnimation = function()
bestInShowFrame:SetAlpha(1)
bestInShowFrame:ClearAllPoints()
bestInShowFrame:SetPoint("left", UIParent, "left", 0, 0)
end
local animShow = detailsFramework:CreateAnimationHub(bestInShowFrame, onStartAnimation, onEndAnimation)
local fade1Anim = detailsFramework:CreateAnimation(animShow, "Alpha", 1, 0.10, 0, 1)
local translate1Anim = detailsFramework:CreateAnimation(animShow, "Translation", 1, 0.15, bestInShowFrame:GetWidth(), 0)
--create an animation that is the contrary of the first one, which will move the frame to the left, fade out and hide it
--no need the start animation here as the frame is already shown from the animShow animation
local onEndOnHideAnimation = function()
bestInShowFrame:Hide()
end
local animHide = detailsFramework:CreateAnimationHub(bestInShowFrame, nil, onEndOnHideAnimation)
local fade2Anim = detailsFramework:CreateAnimation(animHide, "Alpha", 1, 0.10, 1, 0)
local translate2Anim = detailsFramework:CreateAnimation(animHide, "Translation", 1, 0.15, -bestInShowFrame:GetWidth(), 0)
--
DetailsBestInShowFrame.ShowAnimation = animShow
--C_Commentator
-- /run DetailsBestInShowFrame.ShowAnimation:Play()
---@class commentator : table
---@field GetBestInShowFrame fun():frame return a frame object which can be used to attach other widgets on it to show information
---@field ShowBestInShowFrame fun(secondsToHide:number?) show the best in show frame using the animShow animation and hide it after X seconds
Details.Commentator = {}
function Details.Commentator.GetBestInShowFrame()
return bestInShowFrame
end
---@param secondsToHide number? the amount of seconds to hide the frame after it is shown
---@param height number? the height of the frame
function Details.Commentator.ShowBestInShowFrame(secondsToHide, height)
if (bestInShowFrame:IsShown()) then
return
end
height = height or frameHeight
bestInShowFrame:SetHeight(height)
animShow:Play()
local timer = C_Timer.NewTimer(secondsToHide or 7, function()
animShow:Stop()
animHide:Play()
end)
--save the timer in details commentator table
Details.Commentator.HideTimer = timer
end
end
+1 -1
View File
@@ -221,7 +221,7 @@ function mythicDungeonCharts:OnStartMythicDungeon()
mythicDungeonCharts.ChartTable.Ticker = C_Timer.NewTicker(1, tickerCallback)
--save the chart for development
if (debugmode) then
if (Details222.Debug.MythicPlusChartWindowDebug) then
Details.mythic_plus.last_mythicrun_chart = mythicDungeonCharts.ChartTable
end
+2 -2
View File
@@ -205,7 +205,7 @@ function DetailsMythicPlusFrame.MergeSegmentsOnEnd() --~merge
Details222.MythicPlus.LogStep("MergeSegmentsOnEnd started | creating the overall segment at the end of the run.")
--create a new combat to be the overall for the mythic run
Details:StartCombat()
Details222.StartCombat()
--get the current combat just created and the table with all past segments
local newCombat = Details:GetCurrentCombat()
@@ -455,7 +455,7 @@ function DetailsMythicPlusFrame.MergeRemainingTrashAfterAllBossesDone()
if (not Details:GetCurrentCombat()) then
--assuming there's no segment from the dungeon run
Details:StartCombat()
Details222.StartCombat()
Details:EndCombat()
end
+2 -2
View File
@@ -1286,7 +1286,7 @@ function SlashCmdList.DETAILS (msg, editbox)
end
--create a new combat to be the overall for the mythic run
Details:EntrarEmCombate()
Details222.StartCombat()
--get the current combat just created and the table with all past segments
local newCombat = Details:GetCurrentCombat()
@@ -1439,7 +1439,7 @@ function SlashCmdList.DETAILS (msg, editbox)
local tokenId = line:match("%s%s(.*)"):match("^(.-),")
if (tokenId == "ENCOUNTER_START") then
Details:StartCombat()
Details222.StartCombat()
end
if (tokenId == "ENCOUNTER_END") then