From d75e28023848bf55cacd9bea96dee1d3f27cfe20 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 13 Aug 2026 18:03:30 -0500 Subject: [PATCH] Show party pets in raidpet frames under raidforgroup When "Use Raid Frames To Display Group Members" is on and in a party, raid pet frames tried to show raidpet1..40 (nonexistent in a party) instead of the player pet and partypet1..4. Remap raidpet grid slots to pet / partypet in UpdateVisibility, keyed on a stable pfRaidPet slot, mirroring the raid player frames. LayoutPets now mirror-places the party pet slots, and the raid updater runs LayoutPets when in a party (not just a raid). Also exclude raid pet frames (label "partypet", cache_raidpet set) from the hide_in_raid group-hiding clause so they are not hidden. --- api/unitframes.lua | 36 +++++++++++++++++++++++++++++++----- modules/raid.lua | 26 ++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 2bca3930..783677c9 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -205,8 +205,13 @@ function pfUI.uf:UpdateVisibility() -- cache result of strsub to avoid repeating calls if not self.cache_raid then - if strsub(self:GetName(),0,6) == "pfRaid" then - self.cache_raid = tonumber(strsub(self:GetName(),7,8)) or 0 + local name = self:GetName() + if strsub(name,0,9) == "pfRaidPet" then + -- pet grid slot (pfRaidPet1..40); used to mirror party pets below + self.cache_raid = 0 + self.cache_raidpet = tonumber(strsub(name,10)) or 0 + elseif strsub(name,0,6) == "pfRaid" then + self.cache_raid = tonumber(strsub(name,7,8)) or 0 else self.cache_raid = 0 end @@ -238,6 +243,26 @@ function pfUI.uf:UpdateVisibility() end end + -- show raidpet frames as party pets when a party is shown as a raid grid + if self.cache_raidpet then + if not IsInRaid() and IsInGroup() and C.unitframes.raidforgroup == "1" then + local id = self.cache_raidpet + if id == 1 then + -- grid slot 1 mirrors the player, so its pet is the player's pet + self.id = "" + self.label = "pet" + elseif id <= 5 then + self.id = id - 1 + self.label = "partypet" + end + + -- reset to regular raidpet unitstrings after leaving party mode + elseif self.label == "pet" or self.label == "partypet" then + self.id = self.cache_raidpet + self.label = "raidpet" + end + end + -- display every unit as player while pfUI.uf.showall is set if pfUI.uf.showall then self._label = self._label or self.label @@ -266,9 +291,10 @@ function pfUI.uf:UpdateVisibility() -- frame shall not be visible visibility = "hide" self.visible = nil - elseif hide_group and self.cache_raid == 0 and self.label and strsub(self.label,0,5) == "party" then - -- hide group while shown as a raid grid and option is set (raid frames - -- carry label "party" under raidforgroup, so exclude them by cache_raid) + elseif hide_group and self.cache_raid == 0 and not self.cache_raidpet and self.label and strsub(self.label,0,5) == "party" then + -- hide group while shown as a raid grid and option is set (raid player + -- frames carry label "party" and raid pet frames carry label "partypet" + -- under raidforgroup, so exclude them by cache_raid / cache_raidpet) visibility = "hide" self.visible = nil elseif ( self.fname == "Group0" or self.fname == "PartyPet0" or self.fname == "Party0Target" ) diff --git a/modules/raid.lua b/modules/raid.lua index 81f4389f..f4022de6 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -125,6 +125,7 @@ pfUI:RegisterModule("raid", function () local grid = self.petgrid local function place(pet, cell, id) + pet.label = "raidpet" pet.id = id local r, g = SlotToCoord(cell, grid.fill, grid.x, grid.y) pet:ClearAllPoints() @@ -140,6 +141,22 @@ pfUI:RegisterModule("raid", function () return end + -- Party shown as a raid grid: mirror slots 1..5 (player + party members) + -- into fixed cells. UpdateVisibility maps each slot to pet / partypet. + if not IsInRaid() and IsInGroup() and C.unitframes.raidforgroup == "1" then + for id = 1, maxraid do + if self.pets[id] then + if id <= 5 then + place(self.pets[id], id, id) + else + self.pets[id].id = 0 + self.pets[id]:Hide() + end + end + end + return + end + if C.unitframes.raidpet.collapse == "1" then -- Pack the pets that exist into the leading cells, no gaps. local k = 0 @@ -213,8 +230,13 @@ pfUI:RegisterModule("raid", function () this.tick = GetTime() + 1.0 this.pendingUpdate = nil - -- don't proceed without raid - if not IsInRaid() then return end + -- Without a raid there is nothing to sort, but a party shown as a raid + -- grid still needs its pet frames placed and mapped to the party pets. + if not IsInRaid() then + this:LayoutPets() + this:Hide() + return + end -- clear all existing frames for i=1, maxraid do SetRaidIndex(pfUI.uf.raid[i], 0) end