Added more tools to debug pets on '/details debug' and '/details mypets'

This commit is contained in:
Tercio Jose
2024-07-13 23:56:21 -03:00
committed by andrew6180
parent a90ab80de3
commit 7538b36b2a
10 changed files with 366 additions and 24 deletions
+11 -11
View File
@@ -13,17 +13,17 @@ local wipe = wipe
--definitions
---@class df_headercolumndata : table
---@field key string
---@field name string
---@field icon string
---@field texcoord table
---@field text string
---@field canSort boolean
---@field selected boolean
---@field width number
---@field height number
---@field align string
---@field offset number
---@field key string?
---@field name string?
---@field icon string?
---@field texcoord table?
---@field text string?
---@field canSort boolean?
---@field selected boolean?
---@field width number?
---@field height number?
---@field align string?
---@field offset number?
---@class df_headerchild : uiobject
---@field FramesToAlign table
+1
View File
@@ -131,6 +131,7 @@ detailsFramework.ScrollBoxFunctions = {
---@return frame line The line object at the specified index.
GetLine = function(self, lineIndex)
local line = self.Frames[lineIndex]
--print(self, line, line and line:GetName(), lineIndex, self:GetName())
if (line) then
line._InUse = true
end
+8 -1
View File
@@ -73,6 +73,8 @@
DamageSpellsCache = {}
}
Details222.StartUp = {}
Details222.Unknown = _G["UNKNOWN"]
--namespace color
@@ -115,7 +117,12 @@
Details222.DamageSpells = {}
--namespace for texture
Details222.Textures = {}
Details222.Debug = {}
Details222.Debug = {
DebugPets = false,
DebugPlayerPets = false,
}
Details222.Tvs = tvs
--namespace for pet
Details222.Pets = {}
+13 -2
View File
@@ -639,7 +639,7 @@ end
---@param actorName string
---@param actorFlags number
---@param bShouldCreateActor boolean
---@return table|nil, table|nil, string|nil
---@return actor|nil, actor|nil, actorname|nil
function actorContainer:PegarCombatente(actorSerial, actorName, actorFlags, bShouldCreateActor)
return self:GetOrCreateActor(actorSerial, actorName, actorFlags, bShouldCreateActor)
end
@@ -648,7 +648,7 @@ end
---@param actorName string
---@param actorFlags number
---@param bShouldCreateActor boolean
---@return table|nil, table|nil, string|nil
---@return actor|nil, actor|nil, actorname|nil
function actorContainer:GetOrCreateActor(actorSerial, actorName, actorFlags, bShouldCreateActor)
--need to check if the actor is a pet
local petOwnerObject
@@ -657,12 +657,23 @@ end
--check if this actor is a pet and the pet is in the pet cache
if (petContainer.IsPetInCache(actorSerial)) then --this is a registered pet
--hashName is "petName <ownerName>"
--actorSerial: petGuid, actorName: petName
local hashName, ownerName, ownerGuid, ownerFlag = petContainer.GetOwner(actorSerial, actorName) --hashName, ownerName, ownerGuid, ownerFlags
if (hashName and ownerName and ownerGuid and ownerGuid ~= actorSerial and ownerFlag) then
actorName = hashName
petOwnerObject = self:PegarCombatente(ownerGuid, ownerName, ownerFlag, true)
end
if (Details222.Debug.DebugPets or Details222.Debug.DebugPlayerPets) then
Details:Msg("DebugPets|ActorContainer|petContainer.IsPetInCache(actorSerial) = true")
if (hashName) then
Details:Msg("DebugPets|ActorContainer|Owner Found In Pet Cache|OwnerName:", ownerName, "Actor Hash:", hashName, "petOwnerObject:", petOwnerObject)
else
Details:Msg("DebugPets|ActorContainer|Pet Is Orphan|petContainer.GetOwner(", actorSerial, actorName, ") == nil")
end
end
--this actor isn't in the pet cache
elseif (not petBlackList[actorSerial]) then --check if is a pet
--try to find the owner
+24
View File
@@ -100,6 +100,22 @@ function Details.DebugPets()
dumpt(toShow)
end
function Details.DebugMyPets()
local amountPets = 0
local myPets = {}
local playerGUID = UnitGUID("player")
for petGuid, petData in pairs(petContainer.Pets) do
---@cast petData petdata
if (petData.ownerGuid == playerGUID) then
myPets[petGuid] = petData
amountPets = amountPets + 1
end
end
dumpt(myPets)
end
---add a pet guid into the ignored list, when a pet is ignored the system will not try to find its owner as it already failed to find it once
---@param petGuid guid
function petContainer.IgnorePet(petGuid)
@@ -119,6 +135,7 @@ end
---return the pet data from the cache by passing the pet guid
---@param petGuid guid
---@return petdata?
function petContainer.GetPetInfo(petGuid)
return petContainer.Pets[petGuid]
end
@@ -161,6 +178,13 @@ function petContainer.AddPet(petGuid, petName, petFlags, ownerGuid, ownerName, o
return
end
if (Details222.Debug.DebugPets) then
Details:Msg("petContainer.AddPet", petGuid, petName, petFlags, ownerGuid, ownerName, ownerFlags, summonSpellId)
elseif (Details222.Debug.DebugPlayerPets and ownerName == Details.playername) then
Details:Msg("petContainer.AddPet", petGuid, petName, petFlags, ownerGuid, ownerName, ownerFlags, summonSpellId)
end
--print("====================================")
--print(petName)
--print(debugstack())
+26 -1
View File
@@ -664,6 +664,14 @@
if (not damage_cache[ownerActor.serial] and ownerActor.serial ~= "") then
damage_cache[ownerActor.serial] = ownerActor
end
if (ownerActor) then
if (Details222.Debug.DebugPets) then
Details:Msg("Parser|DebugPets|ActorCreated|PetName:", sourceActor:Name(), "sourceName:", sourceName, "ownerName:", ownerActor:Name())
elseif (Details222.Debug.DebugPlayerPets and sourceName == Details.playername) then
Details:Msg("Parser|DebugPets|ActorCreated|PetName:", sourceActor:Name(), "sourceName:", sourceName, "ownerName:", ownerActor:Name())
end
end
else
--there's no owner actor
if (sourceFlags) then
@@ -680,6 +688,19 @@
end
end
--if a owner actor isn't found and debug pets is enabled and this is a pet or guardian
if (not ownerActor and (Details222.Debug.DebugPets or Details222.Debug.DebugPlayerPets) and bitBand(sourceFlags, 0x00003000) ~= 0) then --OBJECT_TYPE_PETGUARDIAN
--note: the actor wasn't found in the cache and got created
Details:Msg("DebugPets|Parser|Owner Actor Not Found|", sourceName, sourceSerial, sourceFlags, bitBand(sourceFlags, 0x00003000) ~= 0)
---@type petdata?
local petData = petContainer.GetPetInfo(sourceSerial)
if (sourceName == "Fire Spirit") then
Details:Msg("DebugPets|Parser|PetData|Exists?", petData, sourceName, "Dumping petData on dumpt.")
dumpt(petData)
end
end
elseif (ownerActor) then --has (sourceActor and ownerActor)
--sourceName is the name of the pet
local cachedPetName = names_cache[sourceSerial]
@@ -1675,6 +1696,10 @@
end
end
if (Details222.Debug.DebugPets) then
end
--differenciate army and apoc pets for DK
if (spellId == 42651) then --army of the dead
dk_pets_cache.army[petSerial] = sourceName
@@ -5693,7 +5718,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
local playerLogin = CreateFrame("frame")
playerLogin:RegisterEvent("PLAYER_LOGIN")
playerLogin:SetScript("OnEvent", function()
Details:StartMeUp()
Details222.StartUp.StartMeUp()
end)
function Details.parser_functions:PET_BATTLE_OPENING_START(...)
+268 -3
View File
@@ -6,19 +6,21 @@ local detailsFramework = DetailsFramework
local _
--frame options
local windowWidth = 800
local windowWidth = 1024
local windowHeight = 670
local scrollWidth = 790
local scrollWidth = 990
local scrollHeightBuff = 400
local scrollHeightDebuff = 200
local scrollLineAmountBuff = 20
local scrollLineAmountDebuff = 10
local scrollLineHeight = 20
local amountOfLines = 26
local lineHeight = 19
local createDebugOptionsFrame = function()
--create a panel
--parent, width, height, title, frameName, panelOptions
local debugOptionsPanel = DetailsFramework:CreateSimplePanel(UIParent, windowWidth, windowHeight, "Details! Debug Options", "DetailsDebugOptionsPanel", {})
local debugOptionsPanel = DetailsFramework:CreateSimplePanel(UIParent, windowWidth/2, windowHeight, "Details! Debug Options", "DetailsDebugOptionsPanel", {})
detailsFramework:ApplyStandardBackdrop(debugOptionsPanel)
@@ -142,6 +144,54 @@ local createDebugOptionsFrame = function()
name = "Encounter Storage Debug",
desc = "Internal tests of the storage feature.",
},
{type = "blank"},
{--pet debug
type = "toggle",
get = function()
return Details222.Debug.DebugPets
end,
set = function(self, fixedparam, value)
Details222.Debug.DebugPets = value
if (Details222.Debug.DebugPets) then
Details:Msg("Pet Debug is ON.")
Details:ShowCleuDebugWindow(function(token, who_serial, who_name, who_flags, target_serial, target_name, target_flags, A1, A2, A3)
if (token == "SPELL_SUMMON") then
return true
end
end)
else
Details:Msg("Pet Debug is OFF.")
end
end,
name = "General Pet Debug",
desc = "General Pet Debug",
},
{--pet debug
type = "toggle",
get = function()
return Details222.Debug.DebugPlayerPets
end,
set = function(self, fixedparam, value)
Details222.Debug.DebugPlayerPets = value
if (Details222.Debug.DebugPlayerPets) then
Details:Msg("Player Pet Debug is ON.")
Details:ShowCleuDebugWindow(function(token, who_serial, sourceName, who_flags, target_serial, target_name, target_flags, A1, A2, A3)
if (token == "SPELL_SUMMON") then
if (sourceName == Details.playername) then
return true
end
end
end)
else
Details:Msg("Player Pet Debug is OFF.")
end
end,
name = "Player Pets Debug",
desc = "Player Pets Debug",
},
}
options.always_boxfirst = true
@@ -164,4 +214,219 @@ function Details.ShowDebugOptionsPanel()
else
createDebugOptionsFrame()
end
end
function Details:ShowCleuDebugWindow(filterFunction)
if (not DetailsCleuDebugWindow) then
--create a simple panel from the framework with size of 400 x 800
--this panel will have a scrollbox with 20 lines, these lines will show data
--each line will have an icon, 6 text entries and 3 labels
--the scrollbox is attached to a header frame from the framework for organization
--create a panel
--parent, width, height, title, frameName, panelOptions
local cleuDebugPanel = detailsFramework:CreateSimplePanel(UIParent, windowWidth, windowHeight, "Details! Cleu Debug", "DetailsCleuDebugWindow", {})
detailsFramework:ApplyStandardBackdrop(cleuDebugPanel)
cleuDebugPanel:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
cleuDebugPanel:SetScript("OnShow", function()
cleuDebugPanel:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end)
cleuDebugPanel:SetScript("OnHide", function()
cleuDebugPanel:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
end)
--disable the buil-in mouse integration of the simple panel, doing this to use LibWindow-1.1 as the window management
cleuDebugPanel:SetScript("OnMouseDown", nil)
cleuDebugPanel:SetScript("OnMouseUp", nil)
--need to create a window frame button that only accepts right clicks and when clicked it'll hide the panel
--register in the libWindow
local LibWindow = LibStub("LibWindow-1.1")
LibWindow.RegisterConfig(cleuDebugPanel, Details.cleu_debug_panel.position)
LibWindow.MakeDraggable(cleuDebugPanel)
LibWindow.RestorePosition(cleuDebugPanel)
--scale bar
local scaleBar = detailsFramework:CreateScaleBar(cleuDebugPanel, Details.cleu_debug_panel.scaletable)
cleuDebugPanel:SetScale(Details.cleu_debug_panel.scaletable.scale)
--status bar
local statusBar = detailsFramework:CreateStatusBar(cleuDebugPanel)
statusBar.text = statusBar:CreateFontString(nil, "overlay", "GameFontNormal")
statusBar.text:SetPoint("left", statusBar, "left", 5, 0)
statusBar.text:SetText("By Terciob | Part of Details! Damage Meter")
detailsFramework:SetFontSize(statusBar.text, 11)
detailsFramework:SetFontColor(statusBar.text, "gray")
---@type df_headercolumndata[]
local headerTable = {
{text = "", width = 20},
{text = "Source Name", width = 150},
{text = "Spell Name", width = 150},
{text = "Pet Name", width = 150},
{text = "Spell ID", width = 50},
{text = "Data 1", width = 150},
{text = "Data 2", width = 150},
{text = "Data 3", width = 150},
}
local headerOptions = {
padding = 2,
}
---@type df_headerframe
local headerFrame = detailsFramework:CreateHeader(cleuDebugPanel, headerTable, headerOptions)
cleuDebugPanel.Header = headerFrame
local onRefreshScroll = function(self, data, offSet, totalLines)
for i = 1, totalLines do
local index = i + offSet
local spellData = data[index]
if (spellData) then
local time, token, sourceGUID, sourceName, sourceFlags, targetGUID, targetName, targetFlags, A1, A2, A3 = unpack(spellData)
local line = self:GetLine(i)
if (line) then
line.Icon:SetTexture(select(3, Details222.GetSpellInfo(A1)))
line.casterNameText:SetText(sourceName)
line.spellNameText:SetText(A2)
line.targetNameText:SetText(targetName)
line.spellIdText:SetText(A1)
if (Details222.Debug.DebugPets or Details222.Debug.DebugPlayerPets) then
local petContainer = Details222.PetContainer
---@type petdata?
local petData = petContainer.GetPetInfo(targetGUID)
if (petData) then
--print(targetGUID, petData.ownerName, petData.petName, petData.petFlags)
line.data1Text:SetText(petData.ownerName)
line.data2Text:SetText(petData.petName)
line.data3Text:SetText(petData.petFlags)
else
line.data1Text:SetText("Pet not found")
line.data2Text:SetText("")
line.data3Text:SetText("")
end
else
line.data1Text:SetText("")
line.data2Text:SetText("")
line.data3Text:SetText("")
end
end
end
end
end
local dropdownTemplate = DetailsFramework:GetTemplate("dropdown", "OPTIONS_DROPDOWNDARK_TEMPLATE")
local createLineFunc = function(self, index)
--create the line for a scrollbox
local line = CreateFrame("frame", "$parentLine" .. index, self, "BackdropTemplate")
--set the point using the line index, line height and scrollbox width
line:SetPoint("topleft", self, "topleft", 1, -((index-1)*(lineHeight+1)) - 1)
line:SetSize(scrollWidth - 2, lineHeight)
--import functions from the header feature
detailsFramework:Mixin(line, detailsFramework.HeaderFunctions)
--create the spell icon texture
local icon = line:CreateTexture(nil, "overlay")
icon:SetSize(lineHeight-2, lineHeight-2)
--create the caster name text entry
local casterNameText = DetailsFramework:CreateTextEntry(line, function()end, headerTable[2].width, lineHeight, _, _, _, dropdownTemplate)
--create the spell name text entry
local spellNameText = DetailsFramework:CreateTextEntry(line, function()end, headerTable[3].width, lineHeight, _, _, _, dropdownTemplate)
--create the target name text entry
local targetNameText = DetailsFramework:CreateTextEntry(line, function()end, headerTable[4].width, lineHeight, _, _, _, dropdownTemplate)
--create the spell id text entry
local spellIdText = DetailsFramework:CreateTextEntry(line, function()end, headerTable[5].width, lineHeight, _, _, _, dropdownTemplate)
--create a negeric text entry
local data1Text = DetailsFramework:CreateTextEntry(line, function()end, headerTable[6].width, lineHeight, _, _, _, dropdownTemplate)
--create a negeric text entry
local data2Text = DetailsFramework:CreateTextEntry(line, function()end, headerTable[7].width, lineHeight, _, _, _, dropdownTemplate)
--create a negeric text entry
local data3Text = DetailsFramework:CreateTextEntry(line, function()end, headerTable[8].width, lineHeight, _, _, _, dropdownTemplate)
line:AddFrameToHeaderAlignment(icon)
line:AddFrameToHeaderAlignment(casterNameText)
line:AddFrameToHeaderAlignment(spellNameText)
line:AddFrameToHeaderAlignment(targetNameText)
line:AddFrameToHeaderAlignment(spellIdText)
line:AddFrameToHeaderAlignment(data1Text)
line:AddFrameToHeaderAlignment(data2Text)
line:AddFrameToHeaderAlignment(data3Text)
line:AlignWithHeader(headerFrame, "left")
line.Icon = icon
line.casterNameText = casterNameText
line.spellNameText = spellNameText
line.targetNameText = targetNameText
line.spellIdText = spellIdText
line.data1Text = data1Text
line.data2Text = data2Text
line.data3Text = data3Text
return line
end
cleuDebugPanel.ScrollBoxData = {}
--create a scrollbox
---@type df_scrollbox
local scrollBox = detailsFramework:CreateScrollBox(cleuDebugPanel, "$parentScrollBox", onRefreshScroll, cleuDebugPanel.ScrollBoxData, scrollWidth, windowHeight - 60, amountOfLines, lineHeight)
scrollBox:SetPoint("topleft", cleuDebugPanel, "topleft", 5, -46)
cleuDebugPanel.ScrollBox = scrollBox
cleuDebugPanel.Header:SetPoint("bottomleft", scrollBox, "topleft", 0, 2)
for i = 1, amountOfLines do
--just call the line creation function with the scrollbox as the parent argument and the line index
scrollBox:CreateLine(createLineFunc)
end
local bHasScheduled = false
cleuDebugPanel:SetScript("OnEvent", function()
local time, token, hidding, who_serial, who_name, who_flags, who_flags2, target_serial, target_name, target_flags, target_flags2, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12 = CombatLogGetCurrentEventInfo()
local addLine = filterFunction(token, who_serial, who_name, who_flags, target_serial, target_name, target_flags, A1, A2, A3)
if (addLine) then
table.insert(cleuDebugPanel.ScrollBoxData, {
GetTime() - cleuDebugPanel.Time,
token,
who_serial,
who_name,
who_flags,
target_serial,
target_name,
target_flags,
A1,
A2,
A3
})
if (not bHasScheduled) then
bHasScheduled = true
C_Timer.After(0.1, function()
bHasScheduled = false
scrollBox:Refresh()
end)
end
end
end)
end
DetailsCleuDebugWindow:Show()
table.wipe(DetailsCleuDebugWindow.ScrollBoxData) --clear the data
DetailsCleuDebugWindow.ScrollBox:Refresh()
DetailsCleuDebugWindow.Time = GetTime()
end
+4
View File
@@ -1185,6 +1185,10 @@ local default_global_data = {
damage_scroll_position = {
scale = 1,
},
cleu_debug_panel = {
position = {},
scaletable = {scale = 1},
},
data_wipes_exp = {
["9"] = false,
["10"] = false,
+3
View File
@@ -389,6 +389,9 @@ function SlashCmdList.DETAILS (msg, editbox)
elseif (msg == "pets") then
Details.DebugPets()
elseif (msg == "mypets") then
Details.DebugMyPets()
elseif (msg == "model") then
local frame = CreateFrame("PlayerModel");
frame:SetPoint("center",UIParent,"center");
+8 -6
View File
@@ -1,15 +1,11 @@
--[=[
Details startup file
The function Details:StartMeUp() is called when the addon is fully loaded with saved variables and profiles
--]=]
local Loc = _G.LibStub("AceLocale-3.0"):GetLocale("Details")
local _
local tocName, Details222 = ...
local detailsFramework = DetailsFramework
--start funtion
function Details:StartMeUp()
function Details222.StartUp.StartMeUp()
if (Details.AndIWillNeverStop) then
return
end
@@ -351,6 +347,12 @@ function Details:StartMeUp()
Details:AddDefaultCustomDisplays()
end
Details:FillUserCustomSpells()
if (C_CVar) then
if (not InCombatLockdown() and DetailsFramework.IsDragonflightAndBeyond()) then
C_CVar.SetCVar("cameraDistanceMaxZoomFactor", 2.6)
end
end
end
--check is this is the first run of this version