Added new plugin to update the comparison window

This commit is contained in:
Tercio Jose
2022-11-26 23:08:49 -03:00
parent e3161ff29c
commit 25cb9e8ffe
11 changed files with 2203 additions and 35 deletions
+108 -30
View File
@@ -1,6 +1,8 @@
local Details = _G.Details
local detailsFramework = _G.DetailsFramework
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0")
local addonName, Details222 = ...
local breakdownWindowPlayerList = {}
@@ -8,13 +10,24 @@
local C_Timer = _G.C_Timer
local tinsert = _G.tinsert
local scrollbox_size = {200, 405}
local scrollbox_lines = 25
local scrollbox_size = {215, 405}
local scrollbox_lines = 23
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 = {180, 288}
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,
}
function breakdownWindowPlayerList.CreatePlayerListFrame()
local f = _G.DetailsPlayerDetailsWindow
@@ -26,14 +39,18 @@
topResult = topResult.total
end
for i = 1, totalLines do
local combatObject = Details:GetCombatFromBreakdownWindow()
local encounterId = combatObject:GetEncounterCleuID()
local difficultyId = combatObject:GetDifficulty()
for i = 1, totalLines do --~refresh
local index = i + offset
local playerObject = data[index]
if (playerObject) then
local line = self:GetLine(i)
line.playerObject = playerObject
line.index = index
line:UpdateLine(topResult)
line:UpdateLine(topResult, encounterId, difficultyId)
end
end
end
@@ -61,7 +78,7 @@
self.roleIcon:SetBlendMode("BLEND")
end
local updatePlayerLine = function(self, topResult)
local updatePlayerLine = function(self, topResult, encounterId, difficultyId) --~update
local playerSelected = Details:GetPlayerObjectFromBreakdownWindow()
if (playerSelected and playerSelected == self.playerObject) then
self:SetBackdropColor(unpack(scrollbox_line_backdrop_color_selected))
@@ -107,21 +124,50 @@
self.roleIcon:SetTexture("")
end
local playerGear = openRaidLib.GetUnitGear(self.playerObject.nome)
--do not show the role icon
self.roleIcon:SetTexture("")
self.roleIcon:SetTexture("") --not in use
--set the player name
self.playerName:SetText(Details:GetOnlyName(self.playerObject.nome))
self.rankText:SetText(self.index)
self.rankText:SetText(self.index) --not in use
--set the player class name
self.className:SetText(string.lower(_G.UnitClass(self.playerObject.nome) or self.playerObject:Class()))
--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
--warcraftlogs percentile
if (self.playerObject.tipo == DETAILS_ATTRIBUTE_DAMAGE) then
local parcePercent = Details222.WarcraftLogs.GetDamageParsePercent(encounterId, difficultyId, actorSpecId, actorTotal)
if (parcePercent) then
self.percentileText:SetText(math.floor(parcePercent))
self.percentileText.alpha = 1
else
parcePercent = Details222.ParsePercent.GetPercent(DETAILS_ATTRIBUTE_DAMAGE, difficultyId, encounterId, actorSpecId, actorTotal)
if (parcePercent) then
self.percentileText:SetText(math.floor(parcePercent))
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
--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(self.playerObject.total)
self.totalStatusBar:SetValue(actorTotal)
end
--get a Details! window
@@ -142,29 +188,33 @@
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()
--set its parameters
line:SetPoint("topleft", self, "topleft", 1, -((index-1) * (player_line_height+1)) - 1)
line:SetSize(scrollbox_size[1]-19, player_line_height)
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)
line:RegisterForClicks("LeftButtonDown", "RightButtonDown")
line:SetScript("OnEnter", lineOnEnter)
line:SetScript("OnLeave", lineOnLeave)
line:SetScript("OnClick", lineOnClick)
line:SetBackdrop({bgFile = [[Interface\Tooltips\UI-Tooltip-Background]], tileSize = 64, tile = true, edgeFile = [[Interface\Buttons\WHITE8X8]], edgeSize = 1})
line:SetBackdropColor(unpack(scrollbox_line_backdrop_color))
line:SetBackdropBorderColor(0, 0, 0, 1)
detailsFramework:ApplyStandardBackdrop(line)
local specIcon = line:CreateTexture("$parentSpecIcon", "artwork")
specIcon:SetSize(player_line_height, player_line_height)
local specIcon = upFrame:CreateTexture("$parentSpecIcon", "artwork")
specIcon:SetSize(headerTable[1].width - 1, headerTable[1].width - 1)
specIcon:SetAlpha(0.71)
local roleIcon = line:CreateTexture("$parentRoleIcon", "overlay")
local roleIcon = upFrame:CreateTexture("$parentRoleIcon", "overlay")
roleIcon:SetSize((player_line_height-2) / 2, (player_line_height-2) / 2)
roleIcon:SetAlpha(0.71)
local playerName = detailsFramework:CreateLabel(line, "", 11, "white", "GameFontNormal")
local playerName = detailsFramework:CreateLabel(upFrame, "", 11, "white", "GameFontNormal")
if (fontFile) then
playerName.fontface = fontFile
end
@@ -177,26 +227,35 @@
playerName.textcolor = {1, 1, 1, .9}
local className = detailsFramework:CreateLabel(line, "", "GameFontNormal")
local className = detailsFramework:CreateLabel(upFrame, "", "GameFontNormal")
className.textcolor = {.95, .8, .2, 0}
className.textsize = 9
local rankText = detailsFramework:CreateLabel(line, "", "GameFontNormal")
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")
rankText.textcolor = {.3, .3, .3, .7}
rankText.textsize = 13
rankText.textsize = fontSize
local totalStatusBar = CreateFrame("statusbar", nil, line)
totalStatusBar:SetSize(scrollbox_size[1]-19-player_line_height, 4)
totalStatusBar:SetMinMaxValues(0, 100)
totalStatusBar:SetStatusBarTexture([[Interface\AddOns\Details\images\bar_skyline]])
totalStatusBar:SetFrameLevel(line:GetFrameLevel()-1)
totalStatusBar:SetFrameLevel(line:GetFrameLevel()+1)
totalStatusBar:SetAlpha(0.5)
--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)
--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)
totalStatusBar:SetPoint("bottomleft", specIcon, "bottomright", 0, 0)
line.specIcon = specIcon
@@ -205,6 +264,15 @@
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")
line.UpdateLine = updatePlayerLine
@@ -214,8 +282,9 @@
local playerScroll = detailsFramework:CreateScrollBox(f, "$parentPlayerScrollBox", refreshPlayerList, {}, player_scroll_size[1] + 22, player_scroll_size[2], scrollbox_lines, player_line_height)
detailsFramework:ReskinSlider(playerScroll)
playerScroll.ScrollBar:ClearAllPoints()
playerScroll.ScrollBar:SetPoint("topright", playerScroll, "topright", -2, -17)
playerScroll.ScrollBar:SetPoint("topright", playerScroll, "topright", -2, -37)
playerScroll.ScrollBar:SetPoint("bottomright", playerScroll, "bottomright", -2, 17)
playerScroll.ScrollBar:Hide()
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})
@@ -223,6 +292,14 @@
playerScroll:SetBackdropBorderColor(0, 0, 0, 1)
f.playerScrollBox = playerScroll
--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)
local playerSelectionLabel = detailsFramework:CreateLabel(playerScroll, "click to select a player", 14)
playerSelectionLabel:SetPoint("bottom", playerScroll, "bottom", 0, 7)
--create the scrollbox lines
for i = 1, scrollbox_lines do
playerScroll:CreateLine(createPlayerLine)
@@ -241,6 +318,7 @@
MONK = 10,
DRUID = 11,
DEMONHUNTER = 12,
EVOKER = 13,
}
--get the player list from the segment and build a table compatible with the scroll box
@@ -275,7 +353,7 @@
local updatePlayerList = function()
local playerList = breakdownWindowPlayerList.BuildPlayerList()
playerScroll:SetData (playerList)
playerScroll:SetData(playerList)
playerScroll:Refresh()
playerScroll:Show()
end