From c6d0a16af8cf0f2192c3f0c52ddb14043eb87afa Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Fri, 30 Dec 2022 17:35:11 -0300 Subject: [PATCH] Api update with Details:GetActorFromCache(unitName or GUID) only work during combat, very fast way to get a danage actorObject --- Libs/DF/fw.lua | 2 +- Libs/DF/panel.lua | 4 ++- classes/container_actors.lua | 67 ++++++++++++++++++++++++------------ core/parser.lua | 4 +++ 4 files changed, 53 insertions(+), 24 deletions(-) diff --git a/Libs/DF/fw.lua b/Libs/DF/fw.lua index cf1f4b43..2614a97c 100644 --- a/Libs/DF/fw.lua +++ b/Libs/DF/fw.lua @@ -1,6 +1,6 @@ -local dversion = 408 +local dversion = 409 local major, minor = "DetailsFramework-1.0", dversion local DF, oldminor = LibStub:NewLibrary(major, minor) diff --git a/Libs/DF/panel.lua b/Libs/DF/panel.lua index c1a1435b..9c1b6b68 100644 --- a/Libs/DF/panel.lua +++ b/Libs/DF/panel.lua @@ -6838,8 +6838,10 @@ detailsFramework.StatusBarFunctions = { self.barTextureMask:SetTexture([[Interface\CHATFRAME\CHATFRAMEBACKGROUND]]) --border texture - self.barBorderTextureForMask = self:CreateTexture(nil, "artwork", nil, 7) + self.barBorderTextureForMask = self:CreateTexture(nil, "overlay", nil, 7) self.barBorderTextureForMask:SetAllPoints() + --self.barBorderTextureForMask:SetPoint("topleft", self, "topleft", -1, 1) + --self.barBorderTextureForMask:SetPoint("bottomright", self, "bottomright", 1, -1) self.barBorderTextureForMask:Hide() barTexture:AddMaskTexture(self.barTextureMask) diff --git a/classes/container_actors.lua b/classes/container_actors.lua index 2b204466..41eca095 100644 --- a/classes/container_actors.lua +++ b/classes/container_actors.lua @@ -73,38 +73,60 @@ local debugPetname = false - local KirinTor = GetFactionInfoByID (1090) or "1" - local Valarjar = GetFactionInfoByID (1948) or "1" - local HighmountainTribe = GetFactionInfoByID (1828) or "1" - local CourtofFarondis = GetFactionInfoByID (1900) or "1" - local Dreamweavers = GetFactionInfoByID (1883) or "1" - local TheNightfallen = GetFactionInfoByID (1859) or "1" - local TheWardens = GetFactionInfoByID (1894) or "1" - local SPELLID_SANGUINE_HEAL = 226510 local sanguineActorName = GetSpellInfo(SPELLID_SANGUINE_HEAL) - local IsFactionNpc = { - [KirinTor] = true, - [Valarjar] = true, - [HighmountainTribe] = true, - [CourtofFarondis] = true, - [Dreamweavers] = true, - [TheNightfallen] = true, - [TheWardens] = true, - } - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --api functions +---attempt to the owner of a pet using tooltip scan, if the owner isn't found, return nil +---@param petGUID string +---@param petName string +---@return string|nil ownerName +---@return string|nil ownerGUID +---@return integer|nil ownerFlags function Details222.Pets.GetPetOwner(petGUID, petName) pet_tooltip_frame:SetOwner(WorldFrame, "ANCHOR_NONE") pet_tooltip_frame:SetHyperlink(("unit:" .. petGUID) or "") if (bIsDragonflight) then - local tooltipData = pet_tooltip_frame:GetTooltipData() - if (tooltipData and tooltipData.lines[1]) then - if (tooltipData.lines[1].leftText == petName) then + local tooltipData = pet_tooltip_frame:GetTooltipData() --is pet tooltip reliable with the new tooltips changes? + if (tooltipData) then + local tooltipLines = tooltipData.lines + for lineIndex = 1, #tooltipLines do + local thisLine = tooltipLines[lineIndex] + --get the type of information this line is showing + local lineType = thisLine.type --type 0 = 'friendly' type 2 = 'name' type 16 = controller guid + + --parse the different types of information + if (lineType == 2) then --unit name + if (thisLine.leftText ~= petName) then + --tooltip isn't showing our pet + return + end + + elseif (lineType == 16) then --controller guid + --assuming the unit name always comes before the controller guid + local GUID = thisLine.guid + --very fast way to get an actorObject, this cache only lives while in combat + local actorObject = Details:GetActorFromCache(GUID) + if (actorObject) then + --Details:Msg("(debug) pet found (1)", petName, "owner:", actorObject.nome) + return actorObject.nome, GUID, actorObject.flag_original + else + --return the actor name for a guid, this cache lives for current combat until next segment + local guidCache = Details:GetParserPlayerCache() + local ownerName = guidCache[GUID] + if (ownerName) then + --Details:Msg("(debug) pet found (2)", petName, "owner:", ownerName) + return ownerName, GUID, 0x514 + end + end + end + end + + --[=[ + if (tooltipData.lines[1].leftText == petName) then --should rely on the first line carrying the pet name? for i = 2, #tooltipData.lines do local tooltipLine = tooltipData.lines[i] local args = tooltipLine.args @@ -114,12 +136,13 @@ local guidCache = Details:GetParserPlayerCache() local ownerName = guidCache[ownerGUID] if (ownerName) then - return ownerName, ownerGUID + return ownerName, ownerGUID, 0x514 end end end end end + --]=] end end diff --git a/core/parser.lua b/core/parser.lua index 864b99a1..7f92f8e5 100755 --- a/core/parser.lua +++ b/core/parser.lua @@ -6340,6 +6340,10 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1 container_pets = _detalhes.tabela_pets.pets end + function Details:GetActorFromCache(value) + return damage_cache[value] or damage_cache_pets[value] or damage_cache_petsOwners[value] + end + function _detalhes:PrintParserCacheIndexes() local amount = 0 for n, nn in pairs(damage_cache) do