You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

406 lines
14 KiB

4 years ago
local Details = _G.Details
3 years ago
local detailsFramework = _G.DetailsFramework
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0", true)
local addonName, Details222 = ...
4 years ago
local breakdownWindowPlayerList = {}
3 years ago
local unpack = table.unpack or unpack
4 years ago
local C_Timer = _G.C_Timer
local tinsert = _G.tinsert
local scrollbox_size = {215, 405}
local scrollbox_lines = 23
4 years ago
local player_line_height = 21.7
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_highlight = {.9, .9, .9, 0.5}
local player_scroll_size = {195, 288}
--header setup
local headerTable = {
{text = "", width = 20},
{text = "Player Name", width = 100},
{text = "iLvL", width = 30},
{text = "WCL Parse", width = 60},
}
local headerOptions = {
padding = 2,
}
3 years ago
4 years ago
function breakdownWindowPlayerList.CreatePlayerListFrame()
local f = _G.DetailsPlayerDetailsWindow
3 years ago
4 years ago
local refreshPlayerList = function(self, data, offset, totalLines)
--update the scroll
local topResult = data[1]
if (topResult) then
topResult = topResult.total
end
3 years ago
local combatObject = Details:GetCombatFromBreakdownWindow()
local encounterId = combatObject:GetEncounterCleuID()
local difficultyId = combatObject:GetDifficulty()
for i = 1, totalLines do --~refresh
4 years ago
local index = i + offset
local playerObject = data[index]
if (playerObject) then
local line = self:GetLine(i)
line.playerObject = playerObject
line.combatObject = combatObject
4 years ago
line.index = index
line:UpdateLine(topResult, encounterId, difficultyId)
4 years ago
end
end
end
3 years ago
4 years ago
local lineOnClick = function(self)
if (self.playerObject ~= Details:GetPlayerObjectFromBreakdownWindow()) then
Details:OpenPlayerBreakdown(Details:GetActiveWindowFromBreakdownWindow(), self.playerObject)
f.playerScrollBox:Refresh()
end
end
3 years ago
4 years ago
local lineOnEnter = function(self)
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color_highlight))
self.specIcon:SetBlendMode("ADD")
self.roleIcon:SetBlendMode("ADD")
end
3 years ago
4 years ago
local lineOnLeave = function(self)
if (self.isSelected) then
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color_selected))
else
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color))
end
self.specIcon:SetBlendMode("BLEND")
self.roleIcon:SetBlendMode("BLEND")
end
local updatePlayerLine = function(self, topResult, encounterId, difficultyId) --~update
4 years ago
local playerSelected = Details:GetPlayerObjectFromBreakdownWindow()
if (playerSelected and playerSelected == self.playerObject) then
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color_selected))
self.isSelected = true
else
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color))
self.isSelected = nil
end
local specRole
--adjust the player icon
if (self.playerObject.spellicon) then
self.specIcon:SetTexture(self.playerObject.spellicon)
self.specIcon:SetTexCoord(.1, .9, .1, .9)
else
local specIcon, L, R, T, B = Details:GetSpecIcon(self.playerObject.spec, false)
if (specIcon) then
self.specIcon:SetTexture(specIcon)
self.specIcon:SetTexCoord(L, R, T, B)
if (DetailsFramework.IsTimewalkWoW()) then
specRole = "NONE"
else
3 years ago
specRole = select(5, _G.GetSpecializationInfoByID(self.playerObject.spec))
4 years ago
end
else
3 years ago
self.specIcon:SetTexture("")
4 years ago
end
end
--adjust the role icon
if (specRole) then
local roleIcon, L, R, T, B = Details:GetRoleIcon(specRole)
if (roleIcon) then
self.roleIcon:SetTexture(roleIcon)
self.roleIcon:SetTexCoord(L, R, T, B)
else
3 years ago
self.roleIcon:SetTexture("")
4 years ago
end
else
3 years ago
self.roleIcon:SetTexture("")
4 years ago
end
3 years ago
local playerGear = openRaidLib and openRaidLib.GetUnitGear(self.playerObject.nome)
4 years ago
--do not show the role icon
self.roleIcon:SetTexture("") --not in use
3 years ago
4 years ago
--set the player name
self.playerName:SetText(Details:GetOnlyName(self.playerObject.nome))
self.rankText:SetText(self.index) --not in use
3 years ago
4 years ago
--set the player class name
--self.className:SetText(string.lower(_G.UnitClass(self.playerObject.nome) or self.playerObject:Class())) --not in use
--item level
self.itemLevelText:SetText(self.playerObject.ilvl or (playerGear and playerGear.ilevel) or "0")
local actorSpecId = self.playerObject.spec
local actorTotal = self.playerObject.total
local combatObject = self.combatObject
--warcraftlogs percentile
if (self.playerObject.tipo == DETAILS_ATTRIBUTE_DAMAGE) then
local actorDPS = self.playerObject.total / combatObject:GetCombatTime()
local parsePercent = Details222.WarcraftLogs.GetDamageParsePercent(encounterId, difficultyId, actorSpecId, actorDPS)
if (parsePercent) then
parsePercent = math.floor(parsePercent)
local colorName = Details222.WarcraftLogs.GetParseColor(parsePercent)
self.percentileText:SetTextColor(detailsFramework:ParseColors(colorName))
self.percentileText:SetText(math.floor(parsePercent))
self.percentileText.alpha = 1
else
parsePercent = Details222.ParsePercent.GetPercent(DETAILS_ATTRIBUTE_DAMAGE, difficultyId, encounterId, actorSpecId, actorDPS)
if (parsePercent) then
parsePercent = math.floor(parsePercent)
local colorName = Details222.WarcraftLogs.GetParseColor(parsePercent)
self.percentileText:SetTextColor(detailsFramework:ParseColors(colorName))
self.percentileText:SetText(math.floor(parsePercent))
self.percentileText.alpha = 1
else
self.percentileText:SetText("#.def")
self.percentileText:SetAlpha(0.25)
end
end
else
self.percentileText:SetText("#.def")
self.percentileText:SetAlpha(0.25)
end
4 years ago
--set the statusbar
local r, g, b = self.playerObject:GetClassColor()
self.totalStatusBar:SetStatusBarColor(r, g, b, 1)
self.totalStatusBar:SetMinMaxValues(0, topResult)
self.totalStatusBar:SetValue(actorTotal)
4 years ago
end
3 years ago
--get a Details! window
local lowerInstanceId = Details:GetLowerInstanceNumber()
local fontFile
local fontSize
local fontOutline
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
4 years ago
local createPlayerLine = function(self, index)
--create a new line
local line = _G.CreateFrame("button", "$parentLine" .. index, self, "BackdropTemplate")
detailsFramework:Mixin(line, detailsFramework.HeaderFunctions)
local upFrame = CreateFrame("frame", nil, line)
upFrame:SetFrameLevel(line:GetFrameLevel()+2)
upFrame:SetAllPoints()
4 years ago
--set its parameters
line:SetPoint("topleft", self, "topleft", 1, -((index) * (player_line_height+1)) - 1)
line:SetSize(scrollbox_size[1], player_line_height)
--line:SetSize(scrollbox_size[1]-19, player_line_height)
4 years ago
line:RegisterForClicks("LeftButtonDown", "RightButtonDown")
line:SetScript("OnEnter", lineOnEnter)
line:SetScript("OnLeave", lineOnLeave)
line:SetScript("OnClick", lineOnClick)
detailsFramework:ApplyStandardBackdrop(line)
4 years ago
local specIcon = upFrame:CreateTexture("$parentSpecIcon", "artwork")
specIcon:SetSize(headerTable[1].width - 1, headerTable[1].width - 1)
4 years ago
specIcon:SetAlpha(0.71)
3 years ago
local roleIcon = upFrame:CreateTexture("$parentRoleIcon", "overlay")
4 years ago
roleIcon:SetSize((player_line_height-2) / 2, (player_line_height-2) / 2)
roleIcon:SetAlpha(0.71)
local playerName = detailsFramework:CreateLabel(upFrame, "", 11, "white", "GameFontNormal")
3 years ago
if (fontFile) then
playerName.fontface = fontFile
end
if (fontSize) then
playerName.fontsize = fontSize
end
if (fontOutline) then
playerName.outline = fontOutline
end
--~create
4 years ago
playerName.textcolor = {1, 1, 1, .9}
3 years ago
local className = detailsFramework:CreateLabel(upFrame, "", "GameFontNormal")
4 years ago
className.textcolor = {.95, .8, .2, 0}
className.textsize = 9
local itemLevelText = detailsFramework:CreateLabel(upFrame, "", "GameFontNormal")
itemLevelText.textcolor = {1, 1, 1, .7}
itemLevelText.textsize = 11
local percentileText = detailsFramework:CreateLabel(upFrame, "", "GameFontNormal")
percentileText.textcolor = {1, 1, 1, .7}
percentileText.textsize = 11
local rankText = detailsFramework:CreateLabel(upFrame, "", "GameFontNormal")
4 years ago
rankText.textcolor = {.3, .3, .3, .7}
rankText.textsize = fontSize
4 years ago
local totalStatusBar = CreateFrame("statusbar", nil, line)
totalStatusBar:SetSize(scrollbox_size[1]-player_line_height, 4)
4 years ago
totalStatusBar:SetMinMaxValues(0, 100)
totalStatusBar:SetStatusBarTexture([[Interface\AddOns\Details\images\bar_skyline]])
totalStatusBar:SetFrameLevel(line:GetFrameLevel()+1)
totalStatusBar:SetAlpha(0.5)
4 years ago
--setup anchors
--specIcon:SetPoint("topleft", line, "topleft", 0, 0)
--roleIcon:SetPoint("topleft", specIcon, "topright", 2, 0)
--playerName:SetPoint("topleft", specIcon, "topright", 2, -3)
--className:SetPoint("topleft", roleIcon, "bottomleft", 0, -2)
--rankText:SetPoint("right", line, "right", -2, 0)
4 years ago
totalStatusBar:SetPoint("bottomleft", specIcon, "bottomright", 0, 0)
line.specIcon = specIcon
line.roleIcon = roleIcon
line.playerName = playerName
line.className = className
line.rankText = rankText
line.totalStatusBar = totalStatusBar
line.itemLevelText = itemLevelText
line.percentileText = percentileText
line:AddFrameToHeaderAlignment(specIcon)
line:AddFrameToHeaderAlignment(playerName)
line:AddFrameToHeaderAlignment(itemLevelText)
line:AddFrameToHeaderAlignment(percentileText)
line:AlignWithHeader(f.Header, "left")
4 years ago
line.UpdateLine = updatePlayerLine
return line
end
3 years ago
local playerScroll = detailsFramework:CreateScrollBox(f, "$parentPlayerScrollBox", refreshPlayerList, {}, player_scroll_size[1] + 22, player_scroll_size[2], scrollbox_lines, player_line_height)
detailsFramework:ReskinSlider(playerScroll)
4 years ago
playerScroll.ScrollBar:ClearAllPoints()
playerScroll.ScrollBar:SetPoint("topright", playerScroll, "topright", -2, -37)
4 years ago
playerScroll.ScrollBar:SetPoint("bottomright", playerScroll, "bottomright", -2, 17)
playerScroll.ScrollBar:Hide()
4 years ago
playerScroll:SetPoint("topright", f, "topleft", -1, 0)
playerScroll:SetPoint("bottomright", f, "bottomleft", -1, 0)
playerScroll:SetBackdrop({edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1, bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true})
playerScroll:SetBackdropColor(0, 0, 0, 0.2)
playerScroll:SetBackdropBorderColor(0, 0, 0, 1)
f.playerScrollBox = playerScroll
3 years ago
--need to be created before
f.Header = DetailsFramework:CreateHeader(f, headerTable, headerOptions)
f.Header:SetPoint("topleft", playerScroll, "topleft", 0, -1)
f.Header:SetPoint("topright", playerScroll, "topright", 0, -1)
detailsFramework:ApplyStandardBackdrop(f.Header)
f.Header.__background:SetColorTexture(.60, .60, .60)
--print(f.Header:GetSize())
local playerSelectionLabel = detailsFramework:CreateLabel(playerScroll, "click to select a player", 14)
playerSelectionLabel:SetPoint("bottom", playerScroll, "bottom", 0, 7)
4 years ago
--create the scrollbox lines
for i = 1, scrollbox_lines do
playerScroll:CreateLine(createPlayerLine)
end
3 years ago
4 years ago
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,
4 years ago
}
--get the player list from the segment and build a table compatible with the scroll box
function breakdownWindowPlayerList.BuildPlayerList()
local segment = Details:GetCombatFromBreakdownWindow()
local playerTable = {}
3 years ago
4 years ago
if (segment) then
local displayType = Details:GetDisplayTypeFromBreakdownWindow()
local containerType = displayType == 1 and DETAILS_ATTRIBUTE_DAMAGE or DETAILS_ATTRIBUTE_HEAL
local container = segment:GetContainer(containerType)
3 years ago
4 years ago
for index, playerObject in container:ListActors() do
if (playerObject:IsPlayer()) then
local unitClassID = classIds [playerObject:Class()] or 13
local unitName = playerObject:Name()
3 years ago
local playerPosition = (((unitClassID or 0) + 128) ^ 4) + tonumber(string.byte(unitName, 1) .. "" .. string.byte(unitName, 2))
4 years ago
tinsert(playerTable, {playerObject, playerPosition, playerObject.total})
end
end
end
3 years ago
table.sort(playerTable, detailsFramework.SortOrder3)
4 years ago
local resultTable = {}
for i = 1, #playerTable do
resultTable[#resultTable+1] = playerTable[i][1]
end
return resultTable
end
local updatePlayerList = function()
local playerList = breakdownWindowPlayerList.BuildPlayerList()
playerScroll:SetData(playerList)
4 years ago
playerScroll:Refresh()
playerScroll:Show()
end
function Details:UpdateBreakdownPlayerList()
--run the update on the next tick
C_Timer.After(0, updatePlayerList)
--DF.Schedules.RunNextTick(updatePlayerList)
end
f:HookScript("OnShow", function()
Details:UpdateBreakdownPlayerList()
end)
f:HookScript("OnHide", function()
for lineIndex, line in ipairs(f.playerScrollBox:GetLines()) do
line.playerObject = nil
line.combatObject = nil
end
end)
local gradientStartColor = Details222.ColorScheme.GetColorFor("gradient-background")
local gradientBelow = DetailsFramework:CreateTexture(f.playerScrollBox,
{gradient = "vertical", fromColor = gradientStartColor, toColor = "transparent"}, 1, 90, "artwork", {0, 1, 0, 1})
gradientBelow:SetPoint("bottoms", 1, 1)
4 years ago
end
3 years ago
function Details.PlayerBreakdown.CreatePlayerListFrame()
if (not Details.PlayerBreakdown.playerListFrameCreated) then
breakdownWindowPlayerList.CreatePlayerListFrame()
Details.PlayerBreakdown.playerListFrameCreated = true
end
end