From 5ed1d98ecc0e5439be962fe6edefc6a1609dfe0b Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Thu, 23 Jul 2026 23:07:09 -0500 Subject: [PATCH] Raid Pets and Optimized Chat Bubble Styling commit f19d7402810637fc32460864104cb792ac5af863 Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Wed Jul 22 01:05:52 2026 -0500 remove comment commit 60f4968f06d19d42bdc6347f98ff4d5a34785e97 Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Wed Jul 22 01:05:06 2026 -0500 Bump ClassicAPI minimum version to 10705 Update the minimum required ClassicAPI version from 10704 (1.7.4) to 10705 (1.7.5). commit 088dba4c23f4aa7ce98b9ce9d75bc5892cd40520 Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Wed Jul 22 01:04:04 2026 -0500 Add raid-pet frames: an independent, roster-driven pet grid New "raidpet" unitframe type that shows raid members' pets (raidpet1..40) in their own movable block (pfRaidPetCluster), off by default. It's a flat pool of frames laid out by pfUI.uf.raid:LayoutPets straight from the raid roster -- cell N shows raidpet -- so it's fully decoupled from how the raid grid arranges its own slots. Layout is independent of the raid grid: raidpet carries its own width/height plus a Layout section (raidlayout / raidpadding / raidfill), and its own Collapse Empty Slots toggle that packs only the pets that exist into the leading cells. The raid grid gets the same collapse option (sequential slot assignment in AddUnitToGroup instead of by subgroup). Collapsed pets re-pack on roster changes and on UNIT_PET so summons and dismisses track live without polling. Also: - unitframes: a "raidpet" branch in UpdateVisibility (hide when the pet is out of range or its raid owner is gone), and fix cache_raid so the "pfRaid" prefix check doesn't misread pfRaidPet frames (char 7 is non-numeric -> nil compare crash). - New "Owner Name" text option: on any pet frame (raidpet/partypet/pet) it shows the owner's class-colored name so you can tell whose pet it is. - unlock: a pfRaidPet drag cluster, a numeric-suffix guard so pfRaid no longer matches (and crashes on) pet frames, and RaidPet config mappings. - config/gui/translations for all of the above. commit 52f02c8963fe7ec90f36100ebe069c7807529301 Author: Brues <5278969+brues-code@users.noreply.github.com> Date: Mon Jul 20 23:09:06 2026 -0500 Enumerate chat bubbles via ClassicAPI instead of scanning WorldFrame ClassicAPI's C_ChatBubbles.GetAllChatBubbles() walks the engine's own bubble list and returns the exact set of live bubble frames, with real GetRegions(), so the decoration idiom works unchanged. Replace the WorldFrame:GetChildren() sweep and drop the IsBubble heuristic (unnamed frame whose first region is the ChatBubble-Background texture) -- the API only ever hands back bubbles, so that guess is both redundant and more fragile than the engine list. Cheaper too: it iterates only live bubbles rather than every world child on each chat event. --- api/config.lua | 24 +++++++- api/unitframes.lua | 20 ++++++- env/translations_deDE.lua | 3 + env/translations_enUS.lua | 3 + env/translations_esES.lua | 3 + env/translations_frFR.lua | 3 + env/translations_koKR.lua | 3 + env/translations_ruRU.lua | 3 + env/translations_zhCN.lua | 3 + env/translations_zhTW.lua | 3 + modules/bubbles.lua | 11 +--- modules/gui.lua | 10 ++++ modules/raid.lua | 117 +++++++++++++++++++++++++++++++++++--- modules/unlock.lua | 8 ++- pfUI.lua | 2 +- 15 files changed, 194 insertions(+), 22 deletions(-) diff --git a/api/config.lua b/api/config.lua index 7987b824..f9f60cff 100644 --- a/api/config.lua +++ b/api/config.lua @@ -382,6 +382,27 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "grouppet", "glowcombat", "0") pfUI:UpdateConfig("unitframes", "grouppet", "txthpright", "healthperc") + pfUI:UpdateConfig("unitframes", "raidpet", "portrait", "off") + pfUI:UpdateConfig("unitframes", "raidpet", "width", "50") + pfUI:UpdateConfig("unitframes", "raidpet", "height", "14") + pfUI:UpdateConfig("unitframes", "raidpet", "pheight", "0") + pfUI:UpdateConfig("unitframes", "raidpet", "buffs", "off") + pfUI:UpdateConfig("unitframes", "raidpet", "buffsize", "16") + pfUI:UpdateConfig("unitframes", "raidpet", "debuffs", "off") + pfUI:UpdateConfig("unitframes", "raidpet", "debuffsize", "16") + pfUI:UpdateConfig("unitframes", "raidpet", "faderange", "1") + pfUI:UpdateConfig("unitframes", "raidpet", "glowcombat", "0") + pfUI:UpdateConfig("unitframes", "raidpet", "txthpright", "healthperc") + -- off by default; mirrors the raid grid layout when enabled + pfUI:UpdateConfig("unitframes", "raidpet", "visible", "0") + -- collapse: pack only pets that exist (from the roster snapshot) instead + -- of mirroring every raid slot + pfUI:UpdateConfig("unitframes", "raidpet", "collapse", "1") + -- pet block has its own layout, independent of the raid grid + pfUI:UpdateConfig("unitframes", "raidpet", "raidlayout", "8x5") + pfUI:UpdateConfig("unitframes", "raidpet", "raidpadding", "3") + pfUI:UpdateConfig("unitframes", "raidpet", "raidfill", "VERTICAL") + pfUI:UpdateConfig("unitframes", "raid", "portrait", "off") pfUI:UpdateConfig("unitframes", "raid", "width", "50") pfUI:UpdateConfig("unitframes", "raid", "height", "26") @@ -400,6 +421,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "raid", "raidlayout", "8x5") pfUI:UpdateConfig("unitframes", "raid", "raidpadding", "3") pfUI:UpdateConfig("unitframes", "raid", "raidfill", "VERTICAL") + pfUI:UpdateConfig("unitframes", "raid", "collapse", "0") pfUI:UpdateConfig("unitframes", "raid", "raidgrouplabel", "0") pfUI:UpdateConfig("unitframes", "raid", "grouplabelxoff", "0") pfUI:UpdateConfig("unitframes", "raid", "grouplabelyoff", "8") @@ -455,7 +477,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "ptarget", "txthpright", "none") pfUI:UpdateConfig("unitframes", "ptarget", "overhealperc", "10") - local ufs = { "player", "target", "focus", "focustarget", "group", "grouptarget", "grouppet", "raid", "ttarget", "pet", "ptarget", "fallback", "tttarget" } + local ufs = { "player", "target", "focus", "focustarget", "group", "grouptarget", "grouppet", "raid", "raidpet", "ttarget", "pet", "ptarget", "fallback", "tttarget" } for _, unit in pairs(ufs) do pfUI:UpdateConfig("unitframes", unit, "selfdebuff", "0") pfUI:UpdateConfig("unitframes", unit, "visible", "1") diff --git a/api/unitframes.lua b/api/unitframes.lua index 3ed7ce44..88c06b77 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -293,7 +293,7 @@ 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)) + self.cache_raid = tonumber(strsub(self:GetName(),7,8)) or 0 else self.cache_raid = 0 end @@ -372,6 +372,11 @@ function pfUI.uf:UpdateVisibility() self:Hide() return end + elseif self.label == "raidpet" then + if not UnitIsVisible(unitstr) or not UnitExists("raid" .. self.id) then + self:Hide() + return + end elseif self.label == "pettarget" then if not UnitIsVisible(unitstr) or not UnitExists("pet") then self:Hide() @@ -2864,6 +2869,19 @@ function pfUI.uf:GetStatusValue(unit, pos) else return "" end + elseif config == "ownername" then + local owner + if unit.label == "raidpet" then owner = "raid" .. unit.id + elseif unit.label == "partypet" then owner = "party" .. unit.id + elseif unit.label == "pet" then owner = "player" end + if not (owner and UnitExists(owner)) then return "" end + local color = "" + if unit.config["classcolor"] == "1" and UnitIsPlayer(owner) then + local _, r, g, b = GetUnitColor(owner) + if C.unitframes.pastel == "1" then r, g, b = (r+.75)*.5, (g+.75)*.5, (b+.75)*.5 end + color = rgbhex(r, g, b) + end + return color .. pfUI.uf:GetNameString(owner) -- health elseif config == "health" then diff --git a/env/translations_deDE.lua b/env/translations_deDE.lua index 087cc342..c9029b92 100644 --- a/env/translations_deDE.lua +++ b/env/translations_deDE.lua @@ -124,6 +124,7 @@ pfUI_translation["deDE"] = { ["Click Casting"] = nil, ["Clock"] = nil, ["Close"] = nil, + ["Collapse Empty Slots"] = nil, ["Color"] = nil, ["Color Buff Stacks"] = nil, ["Color Debuff Stacks"] = nil, @@ -568,6 +569,7 @@ pfUI_translation["deDE"] = { ["Overwrite If Unit Is Attacking Others"] = nil, ["Overwrite If Unit Is Attacking You"] = nil, ["Overwrite If Unit Is Casting"] = nil, + ["Owner Name"] = nil, ["Pageable"] = nil, ["Paging Actionbar"] = nil, ["Panel"] = nil, @@ -615,6 +617,7 @@ pfUI_translation["deDE"] = { ["Raid Mark X-Offset"] = nil, ["Raid Mark Y-Offset"] = nil, ["Raid Padding"] = nil, + ["Raid-Pet"] = nil, ["Random"] = nil, ["Random Roll Announcement Rarity"] = nil, ["Random Rolling"] = nil, diff --git a/env/translations_enUS.lua b/env/translations_enUS.lua index 873a786a..b6b835b2 100644 --- a/env/translations_enUS.lua +++ b/env/translations_enUS.lua @@ -126,6 +126,7 @@ pfUI_translation["enUS"] = { ["Click Casting"] = nil, ["Clock"] = nil, ["Close"] = nil, + ["Collapse Empty Slots"] = nil, ["Color"] = nil, ["Color Buff Stacks"] = nil, ["Color Debuff Stacks"] = nil, @@ -576,6 +577,7 @@ pfUI_translation["enUS"] = { ["Overwrite If Unit Is Attacking Others"] = nil, ["Overwrite If Unit Is Attacking You"] = nil, ["Overwrite If Unit Is Casting"] = nil, + ["Owner Name"] = nil, ["Pageable"] = nil, ["Paging Actionbar"] = nil, ["Panel"] = nil, @@ -623,6 +625,7 @@ pfUI_translation["enUS"] = { ["Raid Mark X-Offset"] = nil, ["Raid Mark Y-Offset"] = nil, ["Raid Padding"] = nil, + ["Raid-Pet"] = nil, ["Random"] = nil, ["Random Roll Announcement Rarity"] = nil, ["Random Rolling"] = nil, diff --git a/env/translations_esES.lua b/env/translations_esES.lua index 53c5dc9b..2c9142d6 100644 --- a/env/translations_esES.lua +++ b/env/translations_esES.lua @@ -124,6 +124,7 @@ pfUI_translation["esES"] = { ["Click Casting"] = "Lanzamiento al hacer click", ["Clock"] = "Reloj", ["Close"] = "Cerrar", + ["Collapse Empty Slots"] = nil, ["Color"] = nil, ["Color Buff Stacks"] = "Colorear pilas de beneficios", ["Color Debuff Stacks"] = "Colorear pilas de perjuicios", @@ -568,6 +569,7 @@ pfUI_translation["esES"] = { ["Overwrite If Unit Is Attacking Others"] = nil, ["Overwrite If Unit Is Attacking You"] = nil, ["Overwrite If Unit Is Casting"] = nil, + ["Owner Name"] = nil, ["Pageable"] = "Paginable", ["Paging Actionbar"] = "Paginando la barra de acción", ["Panel"] = "Panel", @@ -615,6 +617,7 @@ pfUI_translation["esES"] = { ["Raid Mark X-Offset"] = nil, ["Raid Mark Y-Offset"] = nil, ["Raid Padding"] = "Espaciado del marco de banda", + ["Raid-Pet"] = nil, ["Random"] = "Aleatorio", ["Random Roll Announcement Rarity"] = "Anuncio para tirar los dados aleatoriamente", ["Random Rolling"] = "Tirar los dados aleatoriamente", diff --git a/env/translations_frFR.lua b/env/translations_frFR.lua index 5563b428..b4dec778 100644 --- a/env/translations_frFR.lua +++ b/env/translations_frFR.lua @@ -124,6 +124,7 @@ pfUI_translation["frFR"] = { ["Click Casting"] = "Clique sur le lancement de sort", ["Clock"] = "Horloge", ["Close"] = "Fermer", + ["Collapse Empty Slots"] = nil, ["Color"] = nil, ["Color Buff Stacks"] = "Couleur des l'empilements des Améliorations", ["Color Debuff Stacks"] = "Couleur de l'empilements de Affaiblissements", @@ -568,6 +569,7 @@ pfUI_translation["frFR"] = { ["Overwrite If Unit Is Attacking Others"] = nil, ["Overwrite If Unit Is Attacking You"] = nil, ["Overwrite If Unit Is Casting"] = nil, + ["Owner Name"] = nil, ["Pageable"] = "Pageable", ["Paging Actionbar"] = "Barre d'action de pagination", ["Panel"] = "Panneau", @@ -615,6 +617,7 @@ pfUI_translation["frFR"] = { ["Raid Mark X-Offset"] = nil, ["Raid Mark Y-Offset"] = nil, ["Raid Padding"] = "Remplissage du Raid", + ["Raid-Pet"] = nil, ["Random"] = "Aléatoire", ["Random Roll Announcement Rarity"] = "Rareté des annonces des jets de dés aléatoires", ["Random Rolling"] = "Lancer de dés aléatoires", diff --git a/env/translations_koKR.lua b/env/translations_koKR.lua index 17d950f4..5fd796eb 100644 --- a/env/translations_koKR.lua +++ b/env/translations_koKR.lua @@ -124,6 +124,7 @@ pfUI_translation["koKR"] = { ["Click Casting"] = nil, ["Clock"] = "시계", ["Close"] = "닫기", + ["Collapse Empty Slots"] = nil, ["Color"] = nil, ["Color Buff Stacks"] = nil, ["Color Debuff Stacks"] = nil, @@ -568,6 +569,7 @@ pfUI_translation["koKR"] = { ["Overwrite If Unit Is Attacking Others"] = nil, ["Overwrite If Unit Is Attacking You"] = nil, ["Overwrite If Unit Is Casting"] = nil, + ["Owner Name"] = nil, ["Pageable"] = nil, ["Paging Actionbar"] = nil, ["Panel"] = "패널", @@ -615,6 +617,7 @@ pfUI_translation["koKR"] = { ["Raid Mark X-Offset"] = nil, ["Raid Mark Y-Offset"] = nil, ["Raid Padding"] = nil, + ["Raid-Pet"] = nil, ["Random"] = nil, ["Random Roll Announcement Rarity"] = nil, ["Random Rolling"] = nil, diff --git a/env/translations_ruRU.lua b/env/translations_ruRU.lua index ca6c77f0..7bb7282c 100644 --- a/env/translations_ruRU.lua +++ b/env/translations_ruRU.lua @@ -124,6 +124,7 @@ pfUI_translation["ruRU"] = { ["Click Casting"] = "Каст по нажатию", ["Clock"] = "Часы", ["Close"] = "Закрыть", + ["Collapse Empty Slots"] = nil, ["Color"] = nil, ["Color Buff Stacks"] = "Цвет стаков баффа", ["Color Debuff Stacks"] = "Цвет стаков дебаффа", @@ -568,6 +569,7 @@ pfUI_translation["ruRU"] = { ["Overwrite If Unit Is Attacking Others"] = nil, ["Overwrite If Unit Is Attacking You"] = nil, ["Overwrite If Unit Is Casting"] = nil, + ["Owner Name"] = nil, ["Pageable"] = "Прокрутка страниц", ["Paging Actionbar"] = "Прокрутка панелей", ["Panel"] = "Панель", @@ -615,6 +617,7 @@ pfUI_translation["ruRU"] = { ["Raid Mark X-Offset"] = nil, ["Raid Mark Y-Offset"] = nil, ["Raid Padding"] = "Отступ рейда", + ["Raid-Pet"] = nil, ["Random"] = "Случайно", ["Random Roll Announcement Rarity"] = "Оповещение случайного броска для качества предмета", ["Random Rolling"] = "Случайный бросок костей для", diff --git a/env/translations_zhCN.lua b/env/translations_zhCN.lua index 1578985a..7d2c07a7 100644 --- a/env/translations_zhCN.lua +++ b/env/translations_zhCN.lua @@ -124,6 +124,7 @@ pfUI_translation["zhCN"] = { ["Click Casting"] = "点击施法", ["Clock"] = "时间", ["Close"] = "关闭", + ["Collapse Empty Slots"] = nil, ["Color"] = "颜色", ["Color Buff Stacks"] = "Buff堆叠颜色", ["Color Debuff Stacks"] = "Debuff堆叠颜色", @@ -568,6 +569,7 @@ pfUI_translation["zhCN"] = { ["Overwrite If Unit Is Attacking Others"] = "如果单位正在攻击其它单位则变色", ["Overwrite If Unit Is Attacking You"] = "如果单位正在攻击你则变色", ["Overwrite If Unit Is Casting"] = "如果单位正在施法则变色", + ["Owner Name"] = nil, ["Pageable"] = "可分页", ["Paging Actionbar"] = "分页动作条", ["Panel"] = "面板", @@ -615,6 +617,7 @@ pfUI_translation["zhCN"] = { ["Raid Mark X-Offset"] = nil, ["Raid Mark Y-Offset"] = nil, ["Raid Padding"] = "团队填充", + ["Raid-Pet"] = nil, ["Random"] = "给随机玩家", ["Random Roll Announcement Rarity"] = "随机Roll点稀有度", ["Random Rolling"] = "随机Roll点 物品:", diff --git a/env/translations_zhTW.lua b/env/translations_zhTW.lua index ddcdf251..e0eae7cb 100644 --- a/env/translations_zhTW.lua +++ b/env/translations_zhTW.lua @@ -124,6 +124,7 @@ pfUI_translation["zhTW"] = { ["Click Casting"] = nil, ["Clock"] = "時間", ["Close"] = "關閉", + ["Collapse Empty Slots"] = nil, ["Color"] = nil, ["Color Buff Stacks"] = nil, ["Color Debuff Stacks"] = nil, @@ -568,6 +569,7 @@ pfUI_translation["zhTW"] = { ["Overwrite If Unit Is Attacking Others"] = "如果单位正在攻擊其它单位則覆蓋", ["Overwrite If Unit Is Attacking You"] = "如果单位正在攻擊你則覆蓋", ["Overwrite If Unit Is Casting"] = "如果单位正在施法則覆蓋", + ["Owner Name"] = nil, ["Pageable"] = nil, ["Paging Actionbar"] = nil, ["Panel"] = "面板", @@ -615,6 +617,7 @@ pfUI_translation["zhTW"] = { ["Raid Mark X-Offset"] = nil, ["Raid Mark Y-Offset"] = nil, ["Raid Padding"] = nil, + ["Raid-Pet"] = nil, ["Random"] = "給隨機玩家", ["Random Roll Announcement Rarity"] = "隨機Roll點公示稀有度", ["Random Rolling"] = "隨機Roll點 物品:", diff --git a/modules/bubbles.lua b/modules/bubbles.lua index 302075cb..8d98cbdf 100644 --- a/modules/bubbles.lua +++ b/modules/bubbles.lua @@ -17,12 +17,6 @@ pfUI:RegisterModule("bubbles", function () RunNextFrame(function() pfUI.bubbles:ScanBubbles() end) end) - function pfUI.bubbles:IsBubble(f) - if f:GetName() then return end - if not f:GetRegions() then return end - return f:GetRegions().GetTexture and f:GetRegions():GetTexture() == "Interface\\Tooltips\\ChatBubble-Background" - end - function pfUI.bubbles:ProcessBubble(f) f.text:Hide() f.text:SetFont(pfUI.font_default, tonumber(C.global.font_size) * UIParent:GetScale(), "OUTLINE") @@ -34,9 +28,8 @@ pfUI:RegisterModule("bubbles", function () end function pfUI.bubbles:ScanBubbles() - local childs = { WorldFrame:GetChildren() } - for _, f in pairs(childs) do - if not f.frame and pfUI.bubbles:IsBubble(f) then + for _, f in ipairs(C_ChatBubbles.GetAllChatBubbles()) do + if not f.frame then local textures = {f:GetRegions()} for _, object in pairs(textures) do if object:GetObjectType() == "Texture" then diff --git a/modules/gui.lua b/modules/gui.lua index 8b214b4e..259edc87 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -1068,6 +1068,7 @@ pfUI:RegisterModule("gui", function () "unitrev:" .. T["Unit String (Reverse)"], "name:" .. T["Name"], "nameshort:" .. T["Name (Short)"], + "ownername:" .. T["Owner Name"], "level:" .. T["Level"], "class:" .. T["Class"], "namehealth:" .. T["Name | Health Missing"], @@ -2184,6 +2185,7 @@ pfUI:RegisterModule("gui", function () [10] = { "grouptarget", T["Group-Target"]}, [11] = { "grouppet", T["Group-Pet"] }, [12] = { "raid", T["Raid"] }, + [13] = { "raidpet", T["Raid-Pet"] }, } CreateGUIEntry(T["Unit Frames"], T["Click Casting"], function() @@ -2233,6 +2235,7 @@ pfUI:RegisterModule("gui", function () U.ptarget = U["pettarget"] U.grouptarget = U["group"] U.grouppet = U["group"] + U.raidpet = U["raid"] -- build config entries CreateConfig(U[c], T["Display Frame"] .. ": " .. t, C.unitframes[c], "visible", "checkbox") @@ -2277,6 +2280,13 @@ pfUI:RegisterModule("gui", function () CreateConfig(U["raid"], T["Raid Padding"], C.unitframes[c], "raidpadding") CreateConfig(U["raid"], T["Raid Layout"], C.unitframes[c], "raidlayout", "dropdown", pfUI.gui.dropdowns.uf_raidlayout) CreateConfig(U["raid"], T["Raid Fill Direction"], C.unitframes[c], "raidfill", "dropdown", pfUI.gui.dropdowns.orientation) + CreateConfig(U["raid"], T["Collapse Empty Slots"], C.unitframes[c], "collapse", "checkbox") + elseif c == "raidpet" then + CreateConfig(U[c], T["Layout"], nil, nil, "header") + CreateConfig(U["raid"], T["Raid Padding"], C.unitframes[c], "raidpadding") + CreateConfig(U["raid"], T["Raid Layout"], C.unitframes[c], "raidlayout", "dropdown", pfUI.gui.dropdowns.uf_raidlayout) + CreateConfig(U["raid"], T["Raid Fill Direction"], C.unitframes[c], "raidfill", "dropdown", pfUI.gui.dropdowns.orientation) + CreateConfig(U["raid"], T["Collapse Empty Slots"], C.unitframes[c], "collapse", "checkbox") end CreateConfig(U[c], T["Healthbar"], nil, nil, "header") diff --git a/modules/raid.lua b/modules/raid.lua index 0f52381f..e71d8cb0 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -13,11 +13,32 @@ pfUI:RegisterModule("raid", function () local rawborder, default_border = GetBorderSize("chat") local cluster = CreateFrame("Frame", "pfRaidCluster", UIParent) cluster:SetFrameLevel(20) - cluster:SetWidth(120) - cluster:SetHeight(10) + cluster:SetSize(120, 10) cluster:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", default_border*2, C.chat.left.height + default_border*5) UpdateMovable(cluster) + -- Separate, independently-movable block that mirrors the raid grid layout + -- for pet frames (raidpet1..40). Defaults to the right of the raid grid. + local petcluster = CreateFrame("Frame", "pfRaidPetCluster", UIParent) + petcluster:SetFrameLevel(20) + petcluster:SetSize(120, 10) + petcluster:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", default_border*2 + 300, C.chat.left.height + default_border*5) + UpdateMovable(petcluster) + + -- flat pool of pet frames, laid out by LayoutPets (mirror or collapsed) + pfUI.uf.raid.pets = {} + + -- 1-based grid slot -> (row, col) for the current fill direction, matching + -- the raid grid's own fill loops. + local function SlotToCoord(slot, fill, x, y) + slot = slot - 1 + if fill == "VERTICAL" then + return floor(slot / y) + 1, mod(slot, y) + 1 + else + return mod(slot, x) + 1, floor(slot / x) + 1 + end + end + pfUI.uf.raid.tanksfirst = { ["PF_TANK_TOGGLE"] = { T["Toggle as Tank"], "toggleTank" } } @@ -28,6 +49,8 @@ pfUI:RegisterModule("raid", function () function pfUI.uf.raid:UpdateConfig() local rawborder, default_border = GetBorderSize("unitframes") maxraid = tonumber(C.unitframes.maxraid) + local showpets = C.unitframes.raidpet.visible == "1" + self.showpets = showpets for i=1,maxraid do pfUI.uf.raid[i] = pfUI.uf.raid[i] or pfUI.uf:CreateUnitFrame("Raid", i, C.unitframes.raid) @@ -36,6 +59,18 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid[i]:UpdateConfig() pfUI.uf.raid[i]:UpdateFrameSize() + + if showpets then + self.pets[i] = self.pets[i] or pfUI.uf:CreateUnitFrame("RaidPet", i, C.unitframes.raidpet, 0.5) + self.pets[i]:SetParent(petcluster) + self.pets[i]:SetFrameLevel(5) + self.pets[i]:UpdateConfig() + self.pets[i]:UpdateFrameSize() + elseif self.pets[i] then + self.pets[i]:UpdateConfig() + self.pets[i]:Hide() + RemoveMovable(self.pets[i]) + end end local i = 1 @@ -47,6 +82,17 @@ pfUI:RegisterModule("raid", function () local _, _, x, y = string.find(layout,"(.+)x(.+)") x, y = tonumber(x), tonumber(y) + if showpets then + local petcfg = C.unitframes.raidpet + local _, _, px, py = string.find(petcfg.raidlayout, "(.+)x(.+)") + self.petgrid = { + fill = petcfg.raidfill, x = tonumber(px), y = tonumber(py), + pad = tonumber(petcfg.raidpadding) * GetPerfectPixel(), + w = self.pets[1]:GetWidth()+2*default_border, + h = self.pets[1]:GetHeight()+2*default_border, + } + end + if fill == "VERTICAL" then for r=1, x do for g=1, y do if pfUI.uf.raid[i] then @@ -66,6 +112,43 @@ pfUI:RegisterModule("raid", function () i = i + 1 end end end + + self:LayoutPets() + + self:Show() + end + + function pfUI.uf.raid:LayoutPets() + if not self.showpets or not self.petgrid then return end + local grid = self.petgrid + + local function place(pet, cell, id) + pet.id = id + local r, g = SlotToCoord(cell, grid.fill, grid.x, grid.y) + pet:ClearAllPoints() + pet:SetPoint("BOTTOMLEFT", petcluster, "BOTTOMLEFT", (r-1)*(grid.pad+grid.w), (g-1)*(grid.pad+grid.h)) + UpdateMovable(pet, true) + pet:UpdateVisibility() + end + + if C.unitframes.raidpet.collapse == "1" then + -- Pack the pets that exist into the leading cells, no gaps. + local k = 0 + for id = 1, maxraid do + if UnitExists("raidpet"..id) and self.pets[k+1] then + k = k + 1 + place(self.pets[k], k, id) + end + end + for j = k+1, maxraid do + if self.pets[j] then self.pets[j].id = 0 self.pets[j]:Hide() end + end + else + -- Mirror: cell N always shows raidpet at a fixed position. + for id = 1, maxraid do + if self.pets[id] then place(self.pets[id], id, id) end + end + end end pfUI.uf.raid:UpdateConfig() @@ -76,13 +159,22 @@ pfUI:RegisterModule("raid", function () frame:UpdateVisibility() end - -- add units to the beginning of their groups + -- add units to their groups; collapse packs everyone into the leading slots function pfUI.uf.raid:AddUnitToGroup(index, group) - for subindex = 1, 5 do - local ids = subindex + 5*(group-1) - if pfUI.uf.raid[ids] and pfUI.uf.raid[ids].id == 0 and pfUI.uf.raid[ids].config.visible == "1" then - SetRaidIndex(pfUI.uf.raid[ids], index) - return + if C.unitframes.raid.collapse == "1" then + for ids = 1, maxraid do + if pfUI.uf.raid[ids] and pfUI.uf.raid[ids].id == 0 and pfUI.uf.raid[ids].config.visible == "1" then + SetRaidIndex(pfUI.uf.raid[ids], index) + return + end + end + else + for subindex = 1, 5 do + local ids = subindex + 5*(group-1) + if pfUI.uf.raid[ids] and pfUI.uf.raid[ids].id == 0 and pfUI.uf.raid[ids].config.visible == "1" then + SetRaidIndex(pfUI.uf.raid[ids], index) + return + end end end end @@ -92,7 +184,14 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid:RegisterEvent("PARTY_MEMBERS_CHANGED") pfUI.uf.raid:RegisterEvent("PARTY_LEADER_CHANGED") pfUI.uf.raid:RegisterEvent("VARIABLES_LOADED") + pfUI.uf.raid:RegisterEvent("UNIT_PET") pfUI.uf.raid:SetScript("OnEvent", function() + if event == "UNIT_PET" then + if this.showpets and C.unitframes.raidpet.collapse == "1" then + this:LayoutPets() + end + return + end this:Show() -- Debounce: delay update by 0.5s to batch rapid roster changes (mass swaps) this.pendingUpdate = GetTime() + 0.5 @@ -127,6 +226,8 @@ pfUI:RegisterModule("raid", function () end end + this:LayoutPets() + -- Smart GUID-based updates: only refresh frames where unit changed if pfUI.uf.guidTracker then local tracker = pfUI.uf.guidTracker diff --git a/modules/unlock.lua b/modules/unlock.lua index d439daca..ebdc54a0 100644 --- a/modules/unlock.lua +++ b/modules/unlock.lua @@ -6,6 +6,7 @@ pfUI:RegisterModule("unlock", function () -- Name Shift Ctrl { "pfCombo", 5 }, { "pfRaid", 40, 5 }, + { "pfRaidPet", 40, 5 }, { "pfGroup", 4 }, { "pfLootRollFrame", 4 }, } @@ -35,6 +36,8 @@ pfUI:RegisterModule("unlock", function () -- groupframes ["Raid%d"] = { T["Group Frames"], T["Raid"] }, ["Raid%d%d"] = { T["Group Frames"], T["Raid"] }, + ["RaidPet%d"] = { T["Group Frames"], T["Raid-Pet"] }, + ["RaidPet%d%d"] = { T["Group Frames"], T["Raid-Pet"] }, ["Group%d"] = { T["Group Frames"], T["Group"] }, ["Party%dTarget"] = { T["Group Frames"], T["Group-Target"] }, ["PartyPet%d"] = { T["Group Frames"], T["Group-Pet"] }, @@ -98,7 +101,8 @@ pfUI:RegisterModule("unlock", function () -- search and add clustered frames for id, cluster in pairs(clusters) do local len = strlen(cluster[1]) - if strsub(frame:GetName(),0,len) == cluster[1] then + local fid = tonumber(strsub(frame:GetName(),len+1,len+2)) + if fid and strsub(frame:GetName(),0,len) == cluster[1] then if IsShiftKeyDown() and cluster[2] then for i = 1, cluster[2] do if _G[cluster[1] .. i] ~= frame then @@ -106,7 +110,7 @@ pfUI:RegisterModule("unlock", function () end end elseif IsControlKeyDown() and cluster[3] then - local id = tonumber(strsub(frame:GetName(),len+1,len+2)) + local id = fid local b = 1 for i = cluster[3]+1, cluster[2], cluster[3] do diff --git a/pfUI.lua b/pfUI.lua index 12f967e5..2e3ea610 100644 --- a/pfUI.lua +++ b/pfUI.lua @@ -23,7 +23,7 @@ do -- ClassicAPI dependency check. -- pfUI relies pervasively on the modern C_* / SuperWoW / nameplate / focus -- API surface that ClassicAPI polyfills, so presence is required. - local PFUI_CLASSIC_API_MIN = 10704 -- (X*10000 + Y*100 + Z) + local PFUI_CLASSIC_API_MIN = 10705 -- (X*10000 + Y*100 + Z) local PFUI_CLASSIC_API_LATEST = PFUI_CLASSIC_API_MIN local PFUI_CLASSIC_API_WEBSITE = "https://github.com/brues-code/ClassicAPI" local PFUI_CLASSIC_API_LATEST_URL = PFUI_CLASSIC_API_WEBSITE .. "/releases/latest"