Added an option to nest pet spells within a bar showing the pet name
This commit is contained in:
@@ -418,17 +418,17 @@ end
|
||||
Details222.BreakdownWindow.ExpandedSpells = {}
|
||||
|
||||
---set a spell as expanded or not in the breakdown window
|
||||
---@param spellID number
|
||||
---@param key any
|
||||
---@param bIsExpanded boolean
|
||||
function Details222.BreakdownWindow.SetSpellAsExpanded(spellID, bIsExpanded)
|
||||
Details222.BreakdownWindow.ExpandedSpells[spellID] = bIsExpanded
|
||||
function Details222.BreakdownWindow.SetSpellAsExpanded(key, bIsExpanded)
|
||||
Details222.BreakdownWindow.ExpandedSpells[key] = bIsExpanded
|
||||
end
|
||||
|
||||
---get the state of the expanded for a spell
|
||||
---@param spellID number
|
||||
---@param key any
|
||||
---@return boolean
|
||||
function Details222.BreakdownWindow.IsSpellExpanded(spellID)
|
||||
return Details222.BreakdownWindow.ExpandedSpells[spellID]
|
||||
function Details222.BreakdownWindow.IsSpellExpanded(key)
|
||||
return Details222.BreakdownWindow.ExpandedSpells[key]
|
||||
end
|
||||
|
||||
---receives spell data to show in the summary tab
|
||||
|
||||
@@ -2238,7 +2238,7 @@ local onClickExpandButton = function(expandButton, button)
|
||||
--todo: check is any other bar has expanded state true, and close the expand (or not)
|
||||
|
||||
--toggle this spell expand mode
|
||||
Details222.BreakdownWindow.SetSpellAsExpanded(expandButton.spellId, not bIsSpellExpaded)
|
||||
Details222.BreakdownWindow.SetSpellAsExpanded(expandButton.petName or expandButton.spellId, not bIsSpellExpaded)
|
||||
|
||||
--call the refresh function of the window
|
||||
---@type instance
|
||||
@@ -2291,20 +2291,34 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll
|
||||
---@type spelltable
|
||||
local spellTable
|
||||
|
||||
local petName = ""
|
||||
|
||||
spellBar.bkSpellData = bkSpellData
|
||||
|
||||
if (bIsMainLine) then
|
||||
local petName = ""
|
||||
---@type boolean @if true, this is the main line of an actor which has its spells nested in the bkSpellData.nestedData
|
||||
local bIsActorHeader = bkSpellData.bIsActorHeader
|
||||
|
||||
if (bIsMainLine and bIsActorHeader) then
|
||||
spellTable = bkSpellData
|
||||
value = bkSpellData.total
|
||||
spellId = 0
|
||||
petName = actorName
|
||||
|
||||
elseif (bIsMainLine) then
|
||||
spellTable = bkSpellData
|
||||
value = bkSpellData.total
|
||||
spellId = bkSpellData.id
|
||||
petName = bkSpellData.nestedData[spellTableIndex].petName
|
||||
petName = bkSpellData.nestedData[spellTableIndex].actorName
|
||||
|
||||
else
|
||||
spellTable = bkSpellData.nestedData[spellTableIndex].spellTable
|
||||
value = spellTable.total
|
||||
spellId = spellTable.id
|
||||
petName = bkSpellData.nestedData[spellTableIndex].petName
|
||||
|
||||
--if isn't a spell from a nested actor, then it can use the pet name in the spell name
|
||||
if (not bkSpellData.nestedData[spellTableIndex].bIsActorHeader) then
|
||||
petName = bkSpellData.nestedData[spellTableIndex].actorName
|
||||
end
|
||||
|
||||
spellBar.bIsExpandedSpell = true
|
||||
end
|
||||
|
||||
@@ -2315,6 +2329,10 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll
|
||||
|
||||
---@type string, number, string
|
||||
local spellName, _, spellIcon = Details.GetSpellInfo(spellId)
|
||||
if (not spellName) then
|
||||
spellName = actorName
|
||||
spellIcon = bkSpellData.actorIcon or ""
|
||||
end
|
||||
|
||||
---@type number
|
||||
local amtCasts = combatObject:GetSpellCastAmount(actorName, spellName)
|
||||
@@ -2335,9 +2353,9 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll
|
||||
end
|
||||
|
||||
if (petName ~= "") then
|
||||
--if is a pet spell and has more pets nested
|
||||
--if is a pet spell and has more pets nested || nop, now is a pet with its spells nested
|
||||
if (spellTablesAmount > 1 and bIsMainLine) then
|
||||
spellName = formatPetName("", spellName, "")
|
||||
spellName = formatPetName("", spellName, "") --causing error as spellName is nil
|
||||
elseif (bIsMainLine) then
|
||||
spellName = formatPetName(petName, spellName, actorName)
|
||||
else
|
||||
@@ -2361,7 +2379,7 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll
|
||||
local text = spellBar.InLineTexts[textIndex]
|
||||
local header = headerTable[headerIndex]
|
||||
|
||||
if (header.name == "icon") then --ok
|
||||
if (header.name == "icon") then
|
||||
spellBar.spellIcon:Show()
|
||||
spellBar.spellIcon:SetTexture(spellIcon)
|
||||
spellBar.spellIcon:SetAlpha(0.92)
|
||||
@@ -2377,7 +2395,7 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll
|
||||
targetsSquareFrame.bIsMainLine = bIsMainLine
|
||||
spellBar:AddFrameToHeaderAlignment(targetsSquareFrame)
|
||||
|
||||
elseif (header.name == "rank") then --ok
|
||||
elseif (header.name == "rank") then
|
||||
text:SetText(index)
|
||||
spellBar:AddFrameToHeaderAlignment(text)
|
||||
spellBar.rank = index
|
||||
@@ -2390,9 +2408,8 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll
|
||||
|
||||
if (bkSpellData.bCanExpand and bIsMainLine) then
|
||||
spellBar.expandButton:Show()
|
||||
local bIsSpellExpaded = Details222.BreakdownWindow.IsSpellExpanded(spellId)
|
||||
|
||||
spellBar.expandButton.spellId = spellId
|
||||
local bIsSpellExpaded = Details222.BreakdownWindow.IsSpellExpanded(bIsActorHeader and actorName or spellId)
|
||||
spellBar.expandButton.spellId = bIsActorHeader and actorName or spellId
|
||||
spellBar.expandButton.bIsSpellExpaded = bIsSpellExpaded
|
||||
spellBar.expandButton:SetScript("OnClick", onClickExpandButton)
|
||||
|
||||
@@ -2409,18 +2426,18 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll
|
||||
spellBar.expandButton.texture:SetSize(16, 16)
|
||||
end
|
||||
|
||||
elseif (header.name == "name") then --ok
|
||||
text:SetText(spellName)
|
||||
elseif (header.name == "name") then
|
||||
text:SetText(Details:RemoveOwnerName(spellName))
|
||||
spellBar.name = spellName
|
||||
spellBar:AddFrameToHeaderAlignment(text)
|
||||
textIndex = textIndex + 1
|
||||
|
||||
elseif (header.name == "amount") then --ok
|
||||
elseif (header.name == "amount") then
|
||||
text:SetText(Details:Format(value))
|
||||
spellBar:AddFrameToHeaderAlignment(text)
|
||||
textIndex = textIndex + 1
|
||||
|
||||
elseif (header.name == "persecond") then --ok
|
||||
elseif (header.name == "persecond") then
|
||||
spellBar.perSecond = value / combatTime
|
||||
|
||||
---@type string
|
||||
@@ -2430,7 +2447,7 @@ local updateSpellBar = function(spellBar, index, actorName, combatObject, scroll
|
||||
spellBar:AddFrameToHeaderAlignment(text)
|
||||
textIndex = textIndex + 1
|
||||
|
||||
elseif (header.name == "percent") then --ok
|
||||
elseif (header.name == "percent") then
|
||||
spellBar.percent = value / totalValue * 100
|
||||
---@type string
|
||||
local percentFormatted = string.format("%.1f", spellBar.percent) .. "%"
|
||||
@@ -2562,12 +2579,18 @@ local refreshSpellsFunc = function(scrollFrame, scrollData, offset, totalLines)
|
||||
if (mainSpellBar) then
|
||||
lineIndex = lineIndex + 1
|
||||
local bIsMainLine = true
|
||||
updateSpellBar(mainSpellBar, index, actorName, combatObject, scrollFrame, headerTable, bkSpellData, 1, totalValue, topValue, bIsMainLine, keyToSort, spellTablesAmount)
|
||||
|
||||
if (bkSpellData.bIsActorHeader) then
|
||||
updateSpellBar(mainSpellBar, index, bkSpellData.actorName, combatObject, scrollFrame, headerTable, bkSpellData, 1, totalValue, topValue, bIsMainLine, keyToSort, spellTablesAmount)
|
||||
else
|
||||
updateSpellBar(mainSpellBar, index, actorName, combatObject, scrollFrame, headerTable, bkSpellData, 1, totalValue, topValue, bIsMainLine, keyToSort, spellTablesAmount)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--if the spell is expanded
|
||||
--then it adds the lines for each spell merged, but it cannot use the bkSpellData, it needs the spellTable, it's kinda using bkSpellData, need to debug
|
||||
if (bkSpellData.bIsExpanded and spellTablesAmount > 1) then
|
||||
if (bkSpellData.bIsExpanded and (spellTablesAmount > 1)) then
|
||||
--filling necessary information to sort the data by the selected header column
|
||||
for spellTableIndex = 1, spellTablesAmount do
|
||||
---@type bknesteddata
|
||||
@@ -2599,7 +2622,7 @@ local refreshSpellsFunc = function(scrollFrame, scrollData, offset, totalLines)
|
||||
|
||||
lineIndex = lineIndex + 1
|
||||
---@type string
|
||||
local petName = nestedBkSpellData.petName
|
||||
local petName = nestedBkSpellData.actorName
|
||||
---@type string
|
||||
local nameToUse = petName ~= "" and petName or actorName
|
||||
local bIsMainLine = false
|
||||
|
||||
@@ -201,25 +201,51 @@ local createOptionsPanel = function()
|
||||
},
|
||||
|
||||
{type = "blank"},
|
||||
{type = "label", get = function() return "Merge Options" end, text_template = subSectionTitleTextTemplate},
|
||||
{ --merge player spells
|
||||
{type = "label", get = function() return "Group Player Spells:" end, text_template = subSectionTitleTextTemplate},
|
||||
{ --nest player spells | merge player spells
|
||||
type = "toggle",
|
||||
get = function() return Details.breakdown_spell_tab.merge_players_spells_with_same_name end,
|
||||
get = function() return Details.breakdown_spell_tab.nest_players_spells_with_same_name end,
|
||||
set = function(self, fixedparam, value)
|
||||
Details.breakdown_spell_tab.merge_players_spells_with_same_name = value
|
||||
Details.breakdown_spell_tab.nest_players_spells_with_same_name = value
|
||||
end,
|
||||
name = "Group Player Spells With Same Name",
|
||||
desc = "Group Player Spells With Same Name",
|
||||
desc = "Group spells casted by players which has the same name",
|
||||
},
|
||||
|
||||
{ --merge pet spells with the same name
|
||||
{type = "blank"},
|
||||
{type = "label", get = function() return "Group Pet Spells:" end, text_template = subSectionTitleTextTemplate},
|
||||
|
||||
{ --nest pet spells with the same name
|
||||
type = "toggle",
|
||||
get = function() return Details.breakdown_spell_tab.merge_pet_spells_with_same_name end,
|
||||
get = function() return Details.breakdown_spell_tab.nest_pet_spells_by_name end,
|
||||
set = function(self, fixedparam, value)
|
||||
Details.breakdown_spell_tab.merge_pet_spells_with_same_name = value
|
||||
Details.breakdown_spell_tab.nest_pet_spells_by_name = value
|
||||
end,
|
||||
name = "Group Pets By Spell",
|
||||
name = "Group Pet Names Under a Pet Spell Bar",
|
||||
desc = "Group Pets By Name",
|
||||
hooks = {["OnSwitch"] = function()
|
||||
if (Details.breakdown_spell_tab.nest_pet_spells_by_name) then
|
||||
Details.breakdown_spell_tab.nest_pet_spells_by_caster = false
|
||||
DetailsSpellBreakdownOptionsPanel:RefreshOptions()
|
||||
end
|
||||
end}
|
||||
},
|
||||
|
||||
{ --nest pet spells with the same name
|
||||
type = "toggle",
|
||||
get = function() return Details.breakdown_spell_tab.nest_pet_spells_by_caster end,
|
||||
set = function(self, fixedparam, value)
|
||||
Details.breakdown_spell_tab.nest_pet_spells_by_caster = value
|
||||
|
||||
end,
|
||||
name = "Group Pet Spells Under a Pet Name Bar",
|
||||
desc = "Group Pets By Spell",
|
||||
hooks = {["OnSwitch"] = function()
|
||||
if (Details.breakdown_spell_tab.nest_pet_spells_by_caster) then
|
||||
Details.breakdown_spell_tab.nest_pet_spells_by_name = false
|
||||
DetailsSpellBreakdownOptionsPanel:RefreshOptions()
|
||||
end
|
||||
end}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user