Add UnitGroup class to put frames in a grid layout with sorting

This commit is contained in:
2023-03-18 20:35:41 +01:00
parent f14ffbe0bd
commit 9c796159b3
3 changed files with 153 additions and 9 deletions

View File

@@ -16,8 +16,10 @@
-- Omicron Frames. If not, see <https://www.gnu.org/licenses/>.
local omif = select(2, ...)
local UnitFrame = omif.GetModule("types").UnitFrame
local frames = omif.GetModule("frames")
local types = omif.GetModule("types")
local UnitFrame = types.UnitFrame
local UnitGroup = types.UnitGroup
-- re-parent all blizzard frames and then hide the new parent
function HideBlizzardFrames()
@@ -39,35 +41,42 @@ function HideBlizzardFrames()
end
function CreateRaidFrames(left, top, width, height)
local group = UnitGroup:new(left, top, width, height)
for i=0,5 do
for j=0,4 do
local num = i*5 + j + 1
local frame = UnitFrame:new("raid" .. num, width, height)
frame:SetPosition(left + (j-2)*width, top - i*height)
group:AddUnitFrame(frame)
end
end
end
function CreatePartyFrames(left, top, width, height)
local group = UnitGroup:new(left, top, width, height)
local player = UnitFrame:new("player", width, height, true)
player:SetPosition(-2*width, top)
group:AddUnitFrame(player)
for i=1,4 do
local frame = UnitFrame:new("party" .. i, width, height, true)
frame:SetPosition((i-2)*width, top)
group:AddUnitFrame(frame)
end
group:Sort()
end
function CreateTargetFrames(left, top, width, height)
local target = UnitFrame:new("target", width, height)
target:SetPosition(left, top)
local focus = UnitFrame:new("focus", width, height)
focus:SetPosition(left, top-height)
focus:SetPosition(left, top)
local target = UnitFrame:new("target", width, height)
target:SetPosition(left, top - height)
for i=1,4 do
local boss = UnitFrame:new("boss" .. i, width, height)
boss:SetPosition(left, top-(i+1)*height)
end
end
function CreateFrames()
CreatePartyFrames(0, -290, 110, 45)
CreateRaidFrames(0, -290, 110, 45)
CreateTargetFrames(110*3+50, -290, 110, 45)
CreateTargetFrames(110*3+50, -245, 110, 45)
HideBlizzardFrames()
end
omif.SetEventHandler("OMICRON_LOADING", CreateFrames)