From ec3f9d84f3433ae274ead30a71cf4369cf000d41 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 6 Apr 2025 17:50:38 +0200 Subject: [PATCH] raid-party: allow to use frames to display group --- ShaguTweaks-extras.toc | 1 + mods/raid-party.lua | 62 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 mods/raid-party.lua diff --git a/ShaguTweaks-extras.toc b/ShaguTweaks-extras.toc index c32b17f..7199f06 100644 --- a/ShaguTweaks-extras.toc +++ b/ShaguTweaks-extras.toc @@ -34,6 +34,7 @@ mods\chat-text-shadow.lua # raid frames mods\raid.lua +mods\raid-party.lua # reduced actionbar size mods\reduced-actionbar-bags.lua diff --git a/mods/raid-party.lua b/mods/raid-party.lua new file mode 100644 index 0000000..c21639a --- /dev/null +++ b/mods/raid-party.lua @@ -0,0 +1,62 @@ +local _G = ShaguTweaks.GetGlobalEnv() +local T = ShaguTweaks.T + +local module = ShaguTweaks:register({ + title = T["Use As Party Frames"], + description = T["Use raid frames to display party members in regular groups"], + expansions = { ["vanilla"] = true, ["tbc"] = false }, + category = T["Raid Frames"], + maintainer = "@shagu (GitHub)", + enabled = nil, +}) + +module.enable = function(self) + local raid = ShaguTweaksRaidFrame + if not raid then return end + + local RaidOnEvent = raid:GetScript("OnEvent") + raid:RegisterEvent("PARTY_LEADER_CHANGED") + raid:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") + raid:RegisterEvent("PARTY_MEMBERS_CHANGED") + + raid:SetScript("OnEvent", function() + -- run default scripts + RaidOnEvent() + + -- break here in normal raid scenario + if UnitInRaid("player") then return end + + -- check for party mode + if GetNumPartyMembers() > 0 then + -- initialize raid frame + local x, y = 1, 0 + for index = 1, 40 do + -- clear current unitstr assignments + this.cluster.frames[index].unitstr = nil + this.cluster.frames[index]:Hide() + + if index <= 5 then + -- determine best unitstr + local unitstr = index == 1 and "player" or "party" .. index-1 + + -- assign party to first raid group of frames + this.cluster.frames[index].unitstr = unitstr + this.cluster.frames[index].groupid = 1 + this.cluster.frames[index]:Show() + + -- save required raid frame size + if UnitExists(unitstr) then + y = math.max(y, index) + end + end + end + + -- set raid frame size + raid.cluster:SetWidth(x * (raid.cluster.config.width+2) + 6) + raid.cluster:SetHeight(y * (raid.cluster.config.height+1) + 7) + raid:Show() + else + raid:Hide() + end + end) +end