Add support for hiding unit frames in raid groups
This commit is contained in:
@@ -43,8 +43,9 @@ local colors = {
|
||||
white = {1.0, 1.0, 1.0}
|
||||
}
|
||||
|
||||
function UnitFrame:Init(unit, width, height)
|
||||
function UnitFrame:Init(unit, width, height, hideInRaid)
|
||||
self.unit = unit
|
||||
self.hideInRaid = hideInRaid or false
|
||||
local secure = self:CreateSecureFrame(width, height)
|
||||
secure:Hide()
|
||||
self.hp = StatusBar:new(self, width, height)
|
||||
@@ -187,8 +188,13 @@ function UnitFrame:CreateSecureFrame(width, height)
|
||||
end
|
||||
|
||||
function UnitFrame:Enable()
|
||||
if self.unit ~= "player" then
|
||||
RegisterUnitWatch(self.secureFrame)
|
||||
local secure = 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
|
||||
self.secureFrame:Show()
|
||||
end
|
||||
@@ -198,8 +204,10 @@ function UnitFrame:Enable()
|
||||
end
|
||||
|
||||
function UnitFrame:Disable()
|
||||
if self.unit ~= "player" then
|
||||
UnregisterUnitWatch(self.secure_frame)
|
||||
if self.hideInRaid then
|
||||
UnregisterAttributeDriver(self.secureFrame, "state-visibility")
|
||||
elseif self.unit ~= "player" then
|
||||
UnregisterUnitWatch(self.secure_frame, self.condition)
|
||||
else
|
||||
self.secureFrame:Hide()
|
||||
end
|
||||
|
Reference in New Issue
Block a user