Add support for hiding unit frames in raid groups

This commit is contained in:
2023-03-16 04:43:26 +01:00
parent 86825dd6e5
commit c0446ad8be
2 changed files with 22 additions and 17 deletions

View File

@@ -46,31 +46,28 @@ function CreateRaidFrames(left, top, width, height)
frame:SetPosition(left + (j-2)*width, top - i*height) frame:SetPosition(left + (j-2)*width, top - i*height)
end end
end end
local player = UnitFrame:new("player", width, height)
player:SetPosition(left-3*width - 50, top)
local target = UnitFrame:new("target", width, height)
target:SetPosition(left+3*width + 50, top)
end end
function CreatePartyFrames(left, top, width, height) function CreatePartyFrames(left, top, width, height)
local player = UnitFrame:new("player", width, height) local player = UnitFrame:new("player", width, height, true)
player:SetPosition(-2*width, top) player:SetPosition(-2*width, top)
for i=1,4 do for i=1,4 do
local frame = UnitFrame:new("party" .. i, width, height) local frame = UnitFrame:new("party" .. i, width, height, true)
frame:SetPosition((i-2)*width, top) frame:SetPosition((i-2)*width, top)
end end
end
function CreateTargetFrames(left, top, width, height)
local target = UnitFrame:new("target", width, height) local target = UnitFrame:new("target", width, height)
target:SetPosition(3*width + 50, top) target:SetPosition(left, top)
local focus = UnitFrame:new("focus", width, height) local focus = UnitFrame:new("focus", width, height)
focus:SetPosition(3*width + 50, top - height) focus:SetPosition(left, top-height)
end end
function CreateFrames() function CreateFrames()
CreatePartyFrames(0, -290, 110, 45) CreatePartyFrames(0, -290, 110, 45)
--CreateRaidFrames(-850, 400, 110, 45) CreateRaidFrames(0, -290, 110, 45)
--CreateRaidFrames(0, -290, 100, 45) CreateTargetFrames(110*3+50, -290, 110, 45)
HideBlizzardFrames() HideBlizzardFrames()
end end
omif.SetEventHandler("OMICRON_LOADING", CreateFrames) omif.SetEventHandler("OMICRON_LOADING", CreateFrames)

View File

@@ -43,8 +43,9 @@ local colors = {
white = {1.0, 1.0, 1.0} white = {1.0, 1.0, 1.0}
} }
function UnitFrame:Init(unit, width, height) function UnitFrame:Init(unit, width, height, hideInRaid)
self.unit = unit self.unit = unit
self.hideInRaid = hideInRaid or false
local secure = self:CreateSecureFrame(width, height) local secure = self:CreateSecureFrame(width, height)
secure:Hide() secure:Hide()
self.hp = StatusBar:new(self, width, height) self.hp = StatusBar:new(self, width, height)
@@ -187,8 +188,13 @@ function UnitFrame:CreateSecureFrame(width, height)
end end
function UnitFrame:Enable() function UnitFrame:Enable()
if self.unit ~= "player" then local secure = self.secureFrame
RegisterUnitWatch(self.secureFrame) if self.hideInRaid then
local condition = "[@UNIT,exists,nogroup:raid] show; hide"
condition = condition:gsub("@UNIT", "@" .. self.unit)
RegisterAttributeDriver(secure, "state-visibility", condition)
elseif self.unit ~= "player" then
RegisterUnitWatch(self.secureFrame, false)
else else
self.secureFrame:Show() self.secureFrame:Show()
end end
@@ -198,8 +204,10 @@ function UnitFrame:Enable()
end end
function UnitFrame:Disable() function UnitFrame:Disable()
if self.unit ~= "player" then if self.hideInRaid then
UnregisterUnitWatch(self.secure_frame) UnregisterAttributeDriver(self.secureFrame, "state-visibility")
elseif self.unit ~= "player" then
UnregisterUnitWatch(self.secure_frame, self.condition)
else else
self.secureFrame:Hide() self.secureFrame:Hide()
end end