More development on the new breakdown window

This commit is contained in:
Tercio Jose
2023-04-12 22:41:34 -03:00
parent f947e26945
commit f735cb63bd
8 changed files with 234 additions and 161 deletions
+25 -19
View File
@@ -7,14 +7,17 @@ local gump = Details.gump
local _
local addonName, Details222 = ...
--lua locals
--remove warnings in the code
local ipairs = ipairs
local pairs = pairs
local tinsert = tinsert
local tremove = tremove
local type = type
local unpack = _G.unpack
--api locals
local PixelUtil = PixelUtil
local UISpecialFrames = UISpecialFrames
local wipe = wipe
local CreateFrame = _G.CreateFrame
local subAttributes = Details.sub_atributos
local breakdownWindow = Details.playerDetailWindow
@@ -220,7 +223,7 @@ function Details:OpenBreakdownWindow(instanceObject, actorObject, bFromAttribute
--spellsTab.ResetBars() --to be implemented
---@type string
local actorClass = actorObject.classe
local actorClass = actorObject.classe --classe not registered because it should be renamed to english
if (not actorClass) then
actorClass = "monster"
@@ -239,7 +242,7 @@ function Details:OpenBreakdownWindow(instanceObject, actorObject, bFromAttribute
local tabsReplaced = {}
local tabReplacedAmount = 0
table.wipe(breakdownWindow.currentTabsInUse)
wipe(breakdownWindow.currentTabsInUse)
for index = 1, #Details.player_details_tabs do
local tab = Details.player_details_tabs[index]
@@ -314,16 +317,11 @@ function Details:OpenBreakdownWindow(instanceObject, actorObject, bFromAttribute
end
end
function Details:CloseBreakdownWindow(fromEscape)
function Details:CloseBreakdownWindow()
if (breakdownWindow.ativo) then
if (fromEscape) then
Details.FadeHandler.Fader(breakdownWindow, "in")
else
Details.FadeHandler.Fader(breakdownWindow, 1)
end
breakdownWindow.ativo = false --sinaliza o addon que a janela esta agora fechada
Details.FadeHandler.Fader(breakdownWindow, 1)
--Details.info_jogador.detalhes = nil
breakdownWindow.ativo = false --sinaliza o addon que a janela esta agora fechada
breakdownWindow.jogador = nil
breakdownWindow.atributo = nil
breakdownWindow.sub_atributo = nil
@@ -331,6 +329,13 @@ function Details:CloseBreakdownWindow(fromEscape)
breakdownWindow.actorName:SetText("")
breakdownWindow.attributeName:SetText("")
--iterate all tabs and clear caches
local tabsInUse = Details:GetBreakdownTabsInUse()
for index = 1, #tabsInUse do
local tabButton = tabsInUse[index]
tabButton.last_actor = nil
end
end
end
@@ -695,16 +700,17 @@ function Details:CreatePlayerDetailsTab(tabName, locName, conditionFunc, fillFun
tabFrame:SetScript("OnShow", function()
---@type actor
local actorObject = Details:GetActorObjectFromBreakdownWindow()
---@type instance
local instanceObject = Details:GetActiveWindowFromBreakdownWindow()
---@type combat
local combatObject = instanceObject:GetCombat()
if (tabButton.last_actor == actorObject) then
return
end
tabButton.last_actor = actorObject
---@type instance
local instanceObject = Details:GetActiveWindowFromBreakdownWindow()
---@type combat
local combatObject = instanceObject:GetCombat()
tabButton.last_actor = actorObject --it's caching the actor, on pre-reset need to clean up this variable (need to check this later)
tabButton:fillfunction(actorObject, combatObject)
end)
end
+59 -12
View File
@@ -52,7 +52,7 @@ function spellsTab.GetCombat()
end
function spellsTab.GetInstance()
return spellsTab.instance
return spellsTab.instance or Details:GetActiveWindowFromBreakdownWindow()
end
---return the breakdownspellscrollframe object, there's only one of this in the breakdown window
@@ -67,6 +67,13 @@ function spellsTab.GetSpellBlockContainer()
return spellsTab.TabFrame.SpellBlockContainer
end
function spellsTab.OnProfileChange()
spellsTab.spellcontainer_header_settings = Details.breakdown_spell_tab.spellcontainer_headers
spellsTab.UpdateHeadersSettings()
end
---default settings for the header of the spells container
---label is a localized string
---@type {name: string, width: number, label: string, align: string, enabled: boolean, attribute: number|nil}[]
local columnInfo = {
{name = "icon", width = 22, label = "", align = "center", enabled = true,},
@@ -86,6 +93,33 @@ local columnInfo = {
{name = "absorbed", label = "absorbed", width = 45, align = "left", enabled = false, attribute = DETAILS_ATTRIBUTE_HEAL},
}
function spellsTab.UpdateHeadersSettings()
--profile settings
---@type table
local settings = spellsTab.spellcontainer_header_settings
--do a loop and check if the column exists in the profile settings, if not, create it
for i = 1, #columnInfo do
--default column settings
local columnData = columnInfo[i]
--column settings for the column on details profile
local columnSettings = settings[columnData.name]
--check if this column does not have a mirror table in details profile
if (not columnSettings) then
--create the mirror table
settings[columnData.name] = {
enabled = columnData.enabled,
width = columnData.width,
align = columnData.align,
}
end
end
spellsTab.spellsHeaderData = spellsTab.BuildHeaderTable()
print("headerTable = ", #spellsTab.spellsHeaderData)
spellsTab.SpellScrollFrame.Header:SetHeaderTable(spellsTab.spellsHeaderData)
end
function spellsTab.BuildHeaderTable()
---@type {name: string, width: number, label: string, align: string, enabled: boolean}[]
local headerTable = {}
@@ -96,9 +130,14 @@ function spellsTab.BuildHeaderTable()
---@type number, number
local mainAttribute, subAttribute = instance:GetDisplay()
--settings from profile | updated at UpdateHeadersSettings() > called on OnProfileChange() and when the tab is opened
local settings = spellsTab.spellcontainer_header_settings
for i = 1, #columnInfo do
local columnData = columnInfo[i]
if (columnData.enabled) then
local columnSettings = settings[columnData.name]
if (columnSettings.enabled) then
local bCanAdd = true
if (columnData.attribute) then
if (columnData.attribute ~= mainAttribute) then
@@ -109,13 +148,14 @@ function spellsTab.BuildHeaderTable()
if (bCanAdd) then
headerTable[#headerTable+1] = {
text = columnData.label,
width = columnData.width,
width = columnSettings.width,
name = columnData.name,
--align = column.align,
}
end
end
end
return headerTable
end
@@ -177,10 +217,14 @@ function spellsTab.OnShownTab()
spellsTab.UnSelectSpellBar()
--reset the spell blocks
spellsTab.GetSpellBlockContainer():ClearBlocks()
--update spells header frame
spellsTab.UpdateHeadersSettings()
end
--called when the tab is getting created
--called when the tab is getting created, run only once
function spellsTab.OnCreateTabCallback(tabButton, tabFrame)
spellsTab.spellcontainer_header_settings = Details.breakdown_spell_tab.spellcontainer_headers
spellBreakdownSettings = Details.breakdown_spell_tab
DetailsFramework:ApplyStandardBackdrop(tabFrame)
@@ -1206,8 +1250,7 @@ local refreshFunc = function(scrollFrame, scrollData, offset, totalLines) --~ref
---@type instance
local instanceObject = spellsTab.GetInstance()
local headerTable = spellsTab.BuildHeaderTable()
scrollFrame.Header:SetHeaderTable(headerTable)
local headerTable = spellsTab.spellsHeaderData
local lineIndex = 1
for i = 1, totalLines do
@@ -1281,7 +1324,9 @@ function spellsTab.CreateSpellScrollContainer(tabFrame)
scrollFrame:SetPoint("topleft", tabFrame, "topleft", 5, -5) --need to set the points
scrollFrame:EnableMouse(true)
scrollFrame:SetMovable(true)
scrollFrame.DontHideChildrenOnPreRefresh = true
tabFrame.SpellScrollFrame = scrollFrame
spellsTab.SpellScrollFrame = scrollFrame
function scrollFrame:RefreshMe(data)
self:SetData(data)
@@ -1860,13 +1905,8 @@ function Details.InitializeSpellBreakdownTab()
end
end,
function() --[4] fill function
--spellsTab.JI_AtualizaContainerBarras(-1) --not in use anymore
spellsTab.TabFrame.no_targets:Hide() --this is nil
spellsTab.TabFrame.no_targets.text:Hide()
function() --[4] fill function | passing a fill function, it'll set a OnShow() script on the tabFrame | only run if the actor is different
spellsTab.OnShownTab()
--spellsTab.TrocaBackgroundInfo(spellsTab.TabFrame)
end,
function(tabButton, tabFrame) --[5] onclick
@@ -1893,5 +1933,12 @@ function Details.InitializeSpellBreakdownTab()
spellsTab.instance = instance
spellsTab.TabFrame.SpellScrollFrame:RefreshMe(data)
end
---@type detailseventlistener
local eventListener = Details:CreateEventListener()
eventListener:RegisterEvent("DETAILS_PROFILE_APPLYED", function()
--this event don't trigger at details startup
spellsTab.OnProfileChange()
end)
end