Added segments list for the breakdown window

This commit is contained in:
Tercio Jose
2024-02-26 13:54:00 -03:00
parent c4040ac4de
commit 483d9c6976
@@ -1,4 +1,6 @@
--this file controls the left panel of the breakdown window, where the player list and plugins are shown
---@type details
local Details = _G.Details
---@class detailsframework
@@ -17,80 +19,119 @@ local GetSpecializationInfoByID = GetSpecializationInfoByID
local PixelUtil = PixelUtil
local scrollbox_size = {215, 405}
local scrollbox_lines = 19
local player_line_height = 21.7
local scrollbox_lines = 20
local player_line_height = 20
local scrollbox_line_backdrop_color = {0.2, 0.2, 0.2, 0.5}
local scrollbox_line_backdrop_color_selected = {.6, .6, .1, 0.7}
local scrollbox_line_backdrop_color_selected = {1, 1, 0, 0.934}
local scrollbox_line_backdrop_color_highlight = {.9, .9, .9, 0.5}
local player_scroll_size = {195, 288}
local player_scroll_y = -300
function breakdownWindowPlayerList.CreatePlayerListFrame()
---@type table<uniquecombatid, actorname>
local lastSelectedPlayerPerSegment = {}
---@type actorname
local lastSelectedPlayerName = ""
local onPlayerSelected = function(breakdownWindowFrame, playerObject)
---@type instance
local instanceObject = Details:GetActiveWindowFromBreakdownWindow()
Details:OpenBreakdownWindow(instanceObject, playerObject, false, true)
--cache the latest selected player for this combat
---@type combat
local combatObject = instanceObject:GetCombat()
---@type actorname
local playerName = playerObject:Name()
lastSelectedPlayerPerSegment[combatObject:GetCombatUID()] = playerName
lastSelectedPlayerName = playerName
breakdownWindowFrame.playerScrollBox:Refresh()
end
local getActorToShowInBreakdownWindow = function(combatObject)
---@type breakdownwindow
local breakdownWindowFrame = Details.BreakdownWindowFrame
---@type frame
local breakdownSideMenu = breakdownWindowFrame.BreakdownSideMenuFrame
---@type frame
local pluginsFrame = breakdownWindowFrame.BreakdownPluginSelectionFrame
breakdownSideMenu:SetSize(scrollbox_size[1], scrollbox_size[2])
PixelUtil.SetPoint(breakdownSideMenu, "topright", breakdownWindowFrame, "topleft", -2, 0)
PixelUtil.SetPoint(breakdownSideMenu, "bottomright", breakdownWindowFrame, "bottomleft", -2, 0)
--when the select is selected, figure out which player need to be selected in the playerScroll
---@type instance
local instanceObject = Details:GetActiveWindowFromBreakdownWindow()
---@type uniquecombatid
local combatUID = combatObject:GetCombatUID()
detailsFramework:AddRoundedCornersToFrame(breakdownSideMenu, Details.PlayerBreakdown.RoundedCornerPreset)
local displayId, subDisplayId = instanceObject:GetDisplay()
local titleHeight = 20
--plugins menu title bar
local titleBarPlugins = CreateFrame("frame", nil, breakdownSideMenu, "BackdropTemplate")
PixelUtil.SetPoint(titleBarPlugins, "topleft", breakdownSideMenu, "topleft", 2, -0)
PixelUtil.SetPoint(titleBarPlugins, "topright", breakdownSideMenu, "topright", -2, -0)
titleBarPlugins:SetHeight(titleHeight)
---@type actorname
local playerName = lastSelectedPlayerPerSegment[combatUID]
---@type df_roundedpanel_preset
if (playerName) then
---@type actor
local playerObject = combatObject:GetActor(displayId, playerName)
return playerObject
else
---@type actor
local playerObject = combatObject:GetActor(displayId, lastSelectedPlayerName)
if (playerObject) then
lastSelectedPlayerPerSegment[combatUID] = playerObject:Name()
return playerObject
else
playerObject = combatObject:GetActor(displayId, Details.playername)
if (playerObject) then
lastSelectedPlayerPerSegment[combatUID] = playerObject:Name()
return playerObject
end
--title label
local titleBarPlugins_TitleLabel = detailsFramework:NewLabel(titleBarPlugins, titleBarPlugins, nil, "titulo", "Plugins", "GameFontHighlightLeft", 12, {227/255, 186/255, 4/255})
PixelUtil.SetPoint(titleBarPlugins_TitleLabel, "center", titleBarPlugins , "center", 0, 0)
PixelUtil.SetPoint(titleBarPlugins_TitleLabel, "top", titleBarPlugins , "top", 0, -5)
--plugins menu title bar
local titleBarPlayerSeparator = CreateFrame("frame", nil, breakdownSideMenu, "BackdropTemplate")
titleBarPlayerSeparator:SetHeight(titleHeight)
--title label
local titleBarTools_TitleLabel = detailsFramework:NewLabel(titleBarPlayerSeparator, titleBarPlayerSeparator, nil, "titulo", "Players", "GameFontHighlightLeft", 12, {227/255, 186/255, 4/255})
PixelUtil.SetPoint(titleBarTools_TitleLabel, "center", titleBarPlayerSeparator , "center", 0, 0)
PixelUtil.SetPoint(titleBarTools_TitleLabel, "top", titleBarPlayerSeparator , "top", 0, -5)
titleBarPlayerSeparator:SetPoint("topleft", pluginsFrame, "bottomleft", 0, -1)
titleBarPlayerSeparator:SetPoint("topright", pluginsFrame, "bottomright", 0, -1)
local refreshPluginButtons = function()
local amountPluginButtons = #breakdownWindowFrame.RegisteredPluginButtons
local pluginButtonHeight = 20
for i = 1, amountPluginButtons do
---@type button
local pluginButton = breakdownWindowFrame.RegisteredPluginButtons[i]
pluginButton:Show()
pluginButton:SetWidth(pluginsFrame:GetWidth() - 4)
pluginButton:SetHeight(pluginButtonHeight)
pluginButton:ClearAllPoints()
if (i == 1) then
pluginButton:SetPoint("topleft", pluginsFrame, "topleft", 2, -22)
else
pluginButton:SetPoint("topleft", breakdownWindowFrame.RegisteredPluginButtons[i - 1], "bottomleft", 0, -2)
--get the top player from the combat display and subDisplay and select it
---@type actor
local actorObject = instanceObject:GetActorBySubDisplayAndRank(displayId, subDisplayId, 1)
if (actorObject) then
lastSelectedPlayerPerSegment[combatUID] = actorObject:Name()
return actorObject
end
end
end
end
pluginsFrame:SetPoint("topleft", breakdownSideMenu, "topleft", 0, 0)
pluginsFrame:SetWidth(breakdownSideMenu:GetWidth())
pluginsFrame:SetHeight(amountPluginButtons * pluginButtonHeight + 22 + (amountPluginButtons * 2))
---this function get the list of active plugins which has a frame to show in the breakdown window and create a button for each one
---@param breakdownWindowFrame breakdownwindow
---@param pluginsFrame frame
---@param breakdownSideMenu frame
---@return number height how much space pluginsFrame is using
local refreshPluginButtons = function(breakdownWindowFrame, pluginsFrame, breakdownSideMenu)
local amountPluginButtons = #breakdownWindowFrame.RegisteredPluginButtons
local pluginButtonHeight = 20
local spacingBetweenButtons = 2
local totalHeight = 0
for i = 1, amountPluginButtons do
---@type button
local pluginButton = breakdownWindowFrame.RegisteredPluginButtons[i]
pluginButton:Show()
pluginButton:SetWidth(pluginsFrame:GetWidth() - 4)
pluginButton:SetHeight(pluginButtonHeight)
pluginButton:ClearAllPoints()
if (i == 1) then
pluginButton:SetPoint("topleft", pluginsFrame, "topleft", 2, -22)
else
pluginButton:SetPoint("topleft", breakdownWindowFrame.RegisteredPluginButtons[i - 1], "bottomleft", 0, -spacingBetweenButtons)
end
totalHeight = totalHeight + pluginButtonHeight + spacingBetweenButtons
end
local refreshScrollFunc = function(self, data, offset, totalLines)
--update the scroll
--add the height of the header and the spacing between the header and the first button and the last button and the bottom of the frame
totalHeight = totalHeight + 20 + 2
pluginsFrame:SetPoint("topleft", breakdownSideMenu, "topleft", 0, 0)
pluginsFrame:SetWidth(breakdownSideMenu:GetWidth())
pluginsFrame:SetHeight(amountPluginButtons * pluginButtonHeight + 22 + (amountPluginButtons * 2))
return totalHeight
end
local createPlayerScrollBox = function(breakdownWindowFrame, breakdownSideMenu, playerSelectionHeaderFrame)
local refreshPlayerScrollFunc = function(self, data, offset, totalLines)
local topResult = data[1]
if (topResult) then
topResult = topResult.total
@@ -118,8 +159,7 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
local lineOnClick = function(self)
if (self.playerObject ~= Details:GetActorObjectFromBreakdownWindow() or breakdownWindowFrame.shownPluginObject) then
Details:OpenBreakdownWindow(Details:GetActiveWindowFromBreakdownWindow(), self.playerObject)
breakdownWindowFrame.playerScrollBox:Refresh()
onPlayerSelected(breakdownWindowFrame, self.playerObject)
end
end
@@ -140,8 +180,8 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
end
local updatePlayerLine = function(self, topResult, encounterId, difficultyId) --~update
local playerSelected = Details:GetActorObjectFromBreakdownWindow()
if (playerSelected and playerSelected == self.playerObject) then
local playerSelected = lastSelectedPlayerName
if (playerSelected == self.playerObject:Name()) then
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color_selected))
self.isSelected = true
else
@@ -278,8 +318,7 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
upFrame:SetAllPoints()
--set its parameters
--line:SetPoint("topleft", self, "topleft", 1, -((index) * (player_line_height+1)) - 1)
line:SetPoint("topleft", breakdownWindowFrame.Header, "topleft", 1, -((index) * (player_line_height*1.02)))
line:SetPoint("topleft", breakdownWindowFrame.PlayerSelectionHeader, "topleft", 1, -((index) * (player_line_height)))
line:SetSize(scrollbox_size[1]-2, player_line_height)
line:RegisterForClicks("LeftButtonDown", "RightButtonDown")
@@ -350,7 +389,7 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
line:AddFrameToHeaderAlignment(itemLevelText)
line:AddFrameToHeaderAlignment(percentileText)
line:AlignWithHeader(breakdownWindowFrame.Header, "left")
line:AlignWithHeader(breakdownWindowFrame.PlayerSelectionHeader, "left")
line.UpdateLine = updatePlayerLine
@@ -362,7 +401,7 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
---@type height
local height = player_scroll_size[2]
local playerScroll = detailsFramework:CreateScrollBox(breakdownSideMenu, "DetailsBreakdownWindowPlayerScrollBox", refreshScrollFunc, {}, width, height, scrollbox_lines, player_line_height)
local playerScroll = detailsFramework:CreateScrollBox(breakdownSideMenu, "DetailsBreakdownWindowPlayerScrollBox", refreshPlayerScrollFunc, {}, width, height, scrollbox_lines, player_line_height)
detailsFramework:ReskinSlider(playerScroll)
playerScroll.ScrollBar:ClearAllPoints()
playerScroll.ScrollBar:SetPoint("topright", playerScroll, "topright", -2, -37)
@@ -376,40 +415,262 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
playerScroll:SetBackdropBorderColor(0, 0, 0, 0)
playerScroll.__background:Hide()
--need to be created before
breakdownWindowFrame.Header = DetailsFramework:CreateHeader(playerScroll, headerTable, headerOptions)
breakdownWindowFrame.Header:SetAlpha(0.823)
breakdownWindowFrame.Header:SetPoint("topleft", titleBarPlayerSeparator, "bottomleft", 0, -2)
breakdownWindowFrame.Header:SetPoint("topright", titleBarPlayerSeparator, "bottomright", 0, -2)
--create the header frame for the player scrollbox selection
---@type df_headerframe
breakdownWindowFrame.PlayerSelectionHeader = DetailsFramework:CreateHeader(playerScroll, headerTable, headerOptions)
breakdownWindowFrame.PlayerSelectionHeader:SetAlpha(0.823)
breakdownWindowFrame.PlayerSelectionHeader:SetPoint("topleft", playerSelectionHeaderFrame, "bottomleft", 0, -2)
breakdownWindowFrame.PlayerSelectionHeader:SetPoint("topright", playerSelectionHeaderFrame, "bottomright", 0, -2)
playerScroll:SetPoint("topleft", breakdownWindowFrame.Header, "bottomleft", 0, -2)
playerScroll:SetPoint("topright", breakdownWindowFrame.Header, "bottomright", 0, -2)
playerScroll:SetPoint("bottomleft", breakdownSideMenu, "bottomleft", 0, 0)
playerScroll:SetPoint("bottomright", breakdownSideMenu, "bottomright", 0, 0)
detailsFramework:ApplyStandardBackdrop(breakdownWindowFrame.Header)
breakdownWindowFrame.Header.__background:SetColorTexture(.60, .60, .60)
detailsFramework:ApplyStandardBackdrop(breakdownWindowFrame.PlayerSelectionHeader)
breakdownWindowFrame.PlayerSelectionHeader.__background:SetColorTexture(.60, .60, .60)
--create the scrollbox lines
for i = 1, scrollbox_lines do
playerScroll:CreateLine(createPlayerLine)
end
local classIds = {
WARRIOR = 1,
PALADIN = 2,
HUNTER = 3,
ROGUE = 4,
PRIEST = 5,
DEATHKNIGHT = 6,
SHAMAN = 7,
MAGE = 8,
WARLOCK = 9,
MONK = 10,
DRUID = 11,
DEMONHUNTER = 12,
EVOKER = 13,
return playerScroll
end
local createSegmentsScrollBox = function(breakdownWindowFrame, breakdownSideMenu, playerSelectionHeaderFrame)
local refreshSegmentsScrollFunc = function(self, data, offset, totalLines)
for lineIndex = 1, totalLines do --~refresh
local index = lineIndex + offset
---@type breakdownsegmentdata
local segmentData = data[index]
if (segmentData) then
---@type breakdownsegmentline
local line = self:GetLine(lineIndex)
if (line) then
line:UpdateLine(lineIndex, segmentData)
end
end
end
end
local lineOnClick = function(self)
--unique combat id from the button clicked
local combatUniqueID = self.combatUniqueID
if (not Details:DoesCombatWithUIDExists(combatUniqueID)) then
Details:Msg("This segment is not available anymore.")
return
end
local currentBKCombat = Details:GetCombatFromBreakdownWindow()
--unique combat id from the combat the breakdown window is using
local currentBKCombatUniqueID = currentBKCombat:GetCombatUID()
if (combatUniqueID ~= currentBKCombatUniqueID) then
local newCombatToShowInBreakdownWindow = Details:GetCombatByUID(combatUniqueID)
if (newCombatToShowInBreakdownWindow) then
---@cast newCombatToShowInBreakdownWindow combat
local instanceObject = Details:GetActiveWindowFromBreakdownWindow()
--set the segment of the instance to be the segment just selected by the user
instanceObject:SetSegment(newCombatToShowInBreakdownWindow:GetSegmentSlotId())
local bFromAttributeChange = false
local bIsRefresh = true
local actor = getActorToShowInBreakdownWindow(newCombatToShowInBreakdownWindow)
if (actor) then
Details:OpenBreakdownWindow(instanceObject, actor, bFromAttributeChange, bIsRefresh)
else
local actorObject = Details:GetActorObjectFromBreakdownWindow()
lastSelectedPlayerPerSegment[combatUniqueID] = actorObject:Name()
Details:OpenBreakdownWindow(instanceObject, actorObject, bFromAttributeChange, bIsRefresh)
end
breakdownWindowFrame.segmentScrollBox:Refresh()
end
end
end
local lineOnEnter = function(self)
if (not self.isSelected) then
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color_highlight))
end
end
local lineOnLeave = function(self)
if (not self.isSelected) then
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color))
end
end
---update the segment line from the segments scrollbox
---@param self breakdownsegmentline
---@param index number
---@param segmentData breakdownsegmentdata
local updateSegmentLine = function(self, index, segmentData) --~update
local combatName = segmentData.combatName
local r, g, b = segmentData.r, segmentData.g, segmentData.b
local atlasInfo = segmentData.combatIcon
self.segmentText:SetText(combatName)
self.segmentText:SetTextColor(r, g, b)
detailsFramework:TruncateText(self.segmentText, player_scroll_size[1] - 20)
detailsFramework:SetAtlas(self.segmentIcon, atlasInfo)
self.combatUniqueID = segmentData.UID
local combatSelected = Details:GetCombatFromBreakdownWindow()
if (combatSelected and combatSelected:GetCombatUID() == segmentData.UID) then
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color_selected))
self.isSelected = true
else
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color))
self.isSelected = false
end
end
--get a Details! window
local lowerInstanceId = Details:GetLowerInstanceNumber()
local fontFile
local fontSize
local fontOutline
--header setup
local headerTable = {
{text = "Segment Name", width = 100},
}
local headerOptions = {
padding = 2,
}
if (lowerInstanceId) then
local instance = Details:GetInstance(lowerInstanceId)
if (instance) then
fontFile = instance.row_info.font_face
fontSize = instance.row_info.font_size
fontOutline = instance.row_info.textL_outline
end
end
local createSegmentLine = function(self, index)
--create a new line
local line = CreateFrame("button", "$parentLine" .. index, self, "BackdropTemplate")
detailsFramework:Mixin(line, detailsFramework.HeaderFunctions)
--set its parameters
line:SetPoint("topleft", self, "topleft", 1, -((index-1) * (player_line_height)))
line:SetSize(scrollbox_size[1]-2, player_line_height)
line:RegisterForClicks("LeftButtonDown", "RightButtonDown")
line:SetScript("OnEnter", lineOnEnter)
line:SetScript("OnLeave", lineOnLeave)
line:SetScript("OnClick", lineOnClick)
detailsFramework:ApplyStandardBackdrop(line)
--segment icon, this icon will tell which type of segment the line is
local segmentIcon = detailsFramework:CreateTexture(line, "", player_line_height, player_line_height - 1, "artwork")
segmentIcon:SetSize(player_line_height - 4, player_line_height - 4)
segmentIcon:SetAlpha(0.834)
local segmentText = detailsFramework:CreateLabel(line, "", fontSize or 11, "white", "GameFontNormal")
segmentText.outline = fontOutline or "none"
segmentText.textcolor = {1, 1, 1, .9}
if (fontFile) then
segmentText.textfont = fontFile
end
line.segmentText = segmentText
line.segmentIcon = segmentIcon
segmentIcon:SetPoint("left", line, "left", 2, 0)
segmentText:SetPoint("left", segmentIcon, "right", 3, 1)
line.UpdateLine = updateSegmentLine
return line
end
---@type width
local width = player_scroll_size[1] + 22
---@type height
local height = player_scroll_size[2]
local segmentsScroll = detailsFramework:CreateScrollBox(breakdownSideMenu, "DetailsBreakdownWindowSegmentsScrollBox", refreshSegmentsScrollFunc, {}, width, height, scrollbox_lines, player_line_height)
detailsFramework:ReskinSlider(segmentsScroll)
segmentsScroll.ScrollBar:ClearAllPoints()
segmentsScroll.ScrollBar:SetPoint("topright", segmentsScroll, "topright", -2, -37)
segmentsScroll.ScrollBar:SetPoint("bottomright", segmentsScroll, "bottomright", -2, 17)
segmentsScroll.ScrollBar:Hide()
breakdownWindowFrame.segmentScrollBox = segmentsScroll
--remove the standard backdrop
segmentsScroll:SetBackdrop({})
--create the scrollbox lines
for i = 1, scrollbox_lines do
segmentsScroll:CreateLine(createSegmentLine)
end
return segmentsScroll
end
function breakdownWindowPlayerList.CreatePlayerListFrame()
---@type breakdownwindow
local breakdownWindowFrame = Details.BreakdownWindowFrame
---@type frame
local breakdownSideMenu = breakdownWindowFrame.BreakdownSideMenuFrame
---@type frame
local pluginsFrame = breakdownWindowFrame.BreakdownPluginSelectionFrame
breakdownSideMenu:SetSize(scrollbox_size[1], scrollbox_size[2])
PixelUtil.SetPoint(breakdownSideMenu, "topright", breakdownWindowFrame, "topleft", -2, 0)
PixelUtil.SetPoint(breakdownSideMenu, "bottomright", breakdownWindowFrame, "bottomleft", -2, 0)
detailsFramework:AddRoundedCornersToFrame(breakdownSideMenu, Details.PlayerBreakdown.RoundedCornerPreset)
--> create headers
local sectionHeaderHeight = 20
--plugins header frame
local pluginHeaderFrame = CreateFrame("frame", nil, breakdownSideMenu, "BackdropTemplate")
PixelUtil.SetPoint(pluginHeaderFrame, "topleft", breakdownSideMenu, "topleft", 2, -0)
PixelUtil.SetPoint(pluginHeaderFrame, "topright", breakdownSideMenu, "topright", -2, -0)
pluginHeaderFrame:SetHeight(sectionHeaderHeight)
--plugins header label
local titleBarPlugins_TitleLabel = detailsFramework:CreateLabel(pluginHeaderFrame, "Plugins", 12, "DETAILS_HEADER_YELLOW", "GameFontHighlightLeft", "pluginsLabel", nil, "overlay")
PixelUtil.SetPoint(titleBarPlugins_TitleLabel, "center", pluginHeaderFrame , "center", 0, 0)
PixelUtil.SetPoint(titleBarPlugins_TitleLabel, "top", pluginHeaderFrame , "top", 0, -5)
--player selection header frame
local playerSelectionHeaderFrame = CreateFrame("frame", nil, breakdownSideMenu, "BackdropTemplate")
playerSelectionHeaderFrame:SetHeight(sectionHeaderHeight)
playerSelectionHeaderFrame:SetPoint("topleft", pluginsFrame, "bottomleft", 0, -1)
playerSelectionHeaderFrame:SetPoint("topright", pluginsFrame, "bottomright", 0, -1)
--player selection header label
--converting from detailsFramework:NewLabel to detailsFramework:CreateLabel
--local titleBarTools_TitleLabel = detailsFramework:NewLabel(titleBarPlayerSeparator, titleBarPlayerSeparator, nil, "titulo", "Players", "GameFontHighlightLeft", 12, {227/255, 186/255, 4/255})
local titleBarTools_TitleLabel = detailsFramework:CreateLabel(playerSelectionHeaderFrame, "Select Player", 12, "DETAILS_HEADER_YELLOW", "GameFontHighlightLeft", "playersLabel", nil, "overlay")
PixelUtil.SetPoint(titleBarTools_TitleLabel, "center", playerSelectionHeaderFrame , "center", 0, 0)
PixelUtil.SetPoint(titleBarTools_TitleLabel, "top", playerSelectionHeaderFrame , "top", 0, -5)
--segment selection header frame
local segmentSelectionHeaderFrame = CreateFrame("frame", nil, breakdownSideMenu, "BackdropTemplate")
segmentSelectionHeaderFrame:SetHeight(sectionHeaderHeight)
--segment selection header label
local titleBarSegment_TitleLabel = detailsFramework:CreateLabel(segmentSelectionHeaderFrame, "Select Segment", 12, "DETAILS_HEADER_YELLOW", "GameFontHighlightLeft", "segmentsLabel", nil, "overlay")
PixelUtil.SetPoint(titleBarSegment_TitleLabel, "center", segmentSelectionHeaderFrame , "center", 0, 0)
PixelUtil.SetPoint(titleBarSegment_TitleLabel, "top", segmentSelectionHeaderFrame , "top", 0, -5)
local playerScroll = createPlayerScrollBox(breakdownWindowFrame, breakdownSideMenu, playerSelectionHeaderFrame)
playerScroll:SetPoint("topleft", breakdownWindowFrame.PlayerSelectionHeader, "bottomleft", 0, -2)
playerScroll:SetPoint("topright", breakdownWindowFrame.PlayerSelectionHeader, "bottomright", 0, -2)
local segmentsScroll = createSegmentsScrollBox(breakdownWindowFrame, breakdownSideMenu, playerSelectionHeaderFrame)
segmentsScroll:SetPoint("topleft", playerScroll, "bottomleft", 0, -20)
segmentsScroll:SetPoint("topright", playerScroll, "bottomright", 0, -20)
PixelUtil.SetPoint(segmentSelectionHeaderFrame, "topleft", playerScroll, "bottomleft", 0, -1)
PixelUtil.SetPoint(segmentSelectionHeaderFrame, "topright", playerScroll, "bottomright", 0, -1)
local classIds = detailsFramework.ClassFileNameToIndex
---get the player list from the segment and build a table compatible with the scroll box
---@return actor[]
@@ -430,6 +691,7 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
if (actorObject:IsPlayer() and actorObject:IsGroupPlayer()) then
local unitClassID = classIds[actorObject:Class()] or 13
local unitName = actorObject:Name()
--actor position calculation: if two actors has the same amount of a total number, the sort function would flip they around, so we need to add a unique number to the position based on the class and the two first letters of the name
local playerPosition = (((unitClassID or 0) + 128) ^ 4) + tonumber(string.byte(unitName, 1) .. "" .. string.byte(unitName, 2))
---@type {key1: actor, key2: number, key3: number}
@@ -452,22 +714,85 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
return resultTable
end
local updatePlayerList = function()
refreshPluginButtons()
local updatePlayerAndSegmentsList = function()
--the left menu side has 620 pixels of height
playerScroll:SetNumFramesShown(math.floor(playerScroll:GetHeight() / player_line_height)) --looks like it is not updating the 'totalLines' at the refresh function
--when updating the player list, update the plugin buttons as well for convenience
--the refreshPluginButtons function returns the height occupied by the pluginsFrame
--this height is then used to set the amount of lines the player and segments scroll frames will show
local heightOccupied = refreshPluginButtons(breakdownWindowFrame, pluginsFrame, breakdownSideMenu)
--the height of the player and segments scroll is determined by the height of the pluginsFrame, by the amount of players needed to be shown and the amount of segments needed to be shown
--calculate the height "free" to use for both scrolls
local heightFree = breakdownSideMenu:GetHeight() - heightOccupied
--the -60 is the space used by the player and segments labels, plus the player scroll header
--the -5 is the space between the player and segments scroll
heightFree = heightFree - 60 - 5
---@type actor[]
local playerList = breakdownWindowPlayerList.BuildPlayerList()
local amountOfLines = math.floor(heightFree / player_line_height)
local linesForPlayerScroll = math.floor(amountOfLines/2)
if (linesForPlayerScroll < 5) then
linesForPlayerScroll = 5
elseif (linesForPlayerScroll > 10) then
linesForPlayerScroll = 10
end
local selectedPlayerName = Details:GetActorObjectFromBreakdownWindow():Name()
lastSelectedPlayerPerSegment[Details:GetCombatFromBreakdownWindow():GetCombatUID()] = selectedPlayerName
lastSelectedPlayerName = selectedPlayerName
--recalculate the height free, now that we know the amount of lines the player scroll will show
heightFree = heightFree - (linesForPlayerScroll * player_line_height)
local linesForSegmentsScroll = math.floor(heightFree/player_line_height)
playerScroll:SetNumFramesShown(linesForPlayerScroll) --looks like it is not updating the 'totalLines' at the refresh function
playerScroll:SetHeight(linesForPlayerScroll * player_line_height)
segmentsScroll:SetNumFramesShown(linesForSegmentsScroll)
segmentsScroll:SetHeight(linesForSegmentsScroll * player_line_height)
playerScroll:SetData(playerList)
playerScroll:Refresh()
playerScroll:Show()
---@type breakdownsegmentdata[]
local segmentsData = {}
---@type combat[]
local segmentsTable = Details:GetCombatSegments()
for i = 1, #segmentsTable do
---@type combat
local combatObject = segmentsTable[i]
---@type uniquecombatid
local UID = combatObject:GetCombatUID()
local combatName, r, g, b = combatObject:GetCombatName(true)
local combatIcon = combatObject:GetCombatIcon()
segmentsData[i] = {
UID = UID,
combatName = combatName,
combatIcon = combatIcon,
r = r or 1,
g = g or 1,
b = b or 1,
}
end
segmentsScroll:SetData(segmentsData)
segmentsScroll:Refresh()
segmentsScroll:Show()
end
function Details:UpdateBreakdownPlayerList()
--run the update on the next tick
C_Timer.After(0, updatePlayerList)
C_Timer.After(0, updatePlayerAndSegmentsList)
end
breakdownWindowFrame:HookScript("OnShow", function()
@@ -480,11 +805,6 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
line.combatObject = nil
end
end)
--local gradientStartColor = Details222.ColorScheme.GetColorFor("gradient-background")
--local gradientBelow = DetailsFramework:CreateTexture(breakdownWindowFrame.playerScrollBox,
--{gradient = "vertical", fromColor = gradientStartColor, toColor = "transparent"}, 1, 90, "artwork", {0, 1, 0, 1})
--gradientBelow:SetPoint("bottoms", 1, 1)
end
function Details.PlayerBreakdown.CreatePlayerListFrame()