mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-26 22:00:49 +00:00
unitframes: add special secure state drivers
This commit is contained in:
+78
-76
@@ -179,75 +179,100 @@ end
|
|||||||
function pfUI.uf:UpdateVisibility()
|
function pfUI.uf:UpdateVisibility()
|
||||||
local self = self or this
|
local self = self or this
|
||||||
|
|
||||||
if InCombatLockdown and InCombatLockdown() then return end
|
-- we're infight, delay the update
|
||||||
|
if InCombatLockdown and InCombatLockdown() then
|
||||||
if self.config.visible == "0" then
|
pfUI.uf.delayed[self] = true
|
||||||
if UnregisterStateDriver then
|
|
||||||
UnregisterStateDriver(self, "visibility")
|
|
||||||
self.visible = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
self:Hide()
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if InCombatLockdown and not InCombatLockdown() then
|
-- show groupframes as raid
|
||||||
if pfUI.unlock and pfUI.unlock:IsShown() then
|
if strsub(self:GetName(),0,6) == "pfRaid" then
|
||||||
if self.visible then
|
local id = tonumber(strsub(self:GetName(),7,8))
|
||||||
UnregisterStateDriver(self, "visibility")
|
|
||||||
self.visible = nil
|
-- always show self in raidframes
|
||||||
|
if not UnitInRaid("player") and GetNumPartyMembers() == 0 and C.unitframes.selfinraid == "1" and id == 1 then
|
||||||
|
self.id = ""
|
||||||
|
self.label = "player"
|
||||||
|
|
||||||
|
-- use raidframes for groups
|
||||||
|
elseif not UnitInRaid("player") and GetNumPartyMembers() > 0 and C.unitframes.raidforgroup == "1" then
|
||||||
|
if id == 1 then
|
||||||
|
self.id = ""
|
||||||
|
self.label = "player"
|
||||||
|
elseif id <= 5 then
|
||||||
|
self.id = id - 1
|
||||||
|
self.label = "party"
|
||||||
end
|
end
|
||||||
elseif not self.visible then
|
|
||||||
RegisterStateDriver(self, "visibility", self.visibilitycondition)
|
-- reset to regular raid unitstrings
|
||||||
self.visible = true
|
elseif self.label == "party" or self.label == "player" then
|
||||||
|
self.id = id
|
||||||
|
self.label = "raid"
|
||||||
end
|
end
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local unitstr = string.format("%s%s", self.label or "", self.id or "")
|
local unitstr = string.format("%s%s", self.label or "", self.id or "")
|
||||||
|
local visibility = string.format("[target=%s,exists] show; hide", unitstr)
|
||||||
|
|
||||||
if pfUI.unlock and pfUI.unlock:IsShown() then
|
if pfUI.unlock and pfUI.unlock:IsShown() then
|
||||||
self:Show()
|
-- display during unlock mode
|
||||||
return
|
visibility = "show"
|
||||||
|
self.visible = true
|
||||||
--keep focus and named frames visible
|
elseif self.config.visible == "0" then
|
||||||
elseif self.unitname and self.unitname ~= "focus" then
|
-- frame shall not be visible
|
||||||
self:Show()
|
visibility = "hide"
|
||||||
return
|
self.visible = nil
|
||||||
|
elseif C["unitframes"]["group"]["hide_in_raid"] == "1" and self.label and strsub(self.label,0,5) == "party" and UnitInRaid("player") then
|
||||||
-- only update visibility state for existing units
|
|
||||||
elseif UnitName(unitstr) then
|
|
||||||
-- hide group while in raid and option is set
|
-- hide group while in raid and option is set
|
||||||
if C["unitframes"]["group"]["hide_in_raid"] == "1" and strsub(self.label,0,5) == "party" and UnitInRaid("player") then
|
visibility = "hide"
|
||||||
self:Hide()
|
self.visible = nil
|
||||||
return
|
elseif ( self.fname == "Group0" or self.fname == "PartyPet0" or self.fname == "Party0Target" )
|
||||||
|
and (GetNumPartyMembers() <= 0 or (C["unitframes"]["group"]["hide_in_raid"] == "1" and UnitInRaid("player"))) then
|
||||||
|
-- hide self in group if solo or hide in raid is set
|
||||||
|
visibility = "hide"
|
||||||
|
self.visible = nil
|
||||||
|
end
|
||||||
|
|
||||||
-- hide existing but too far away pet and pets of old group members
|
-- tbc visibility
|
||||||
elseif self.label == "partypet" then
|
if self.SetAttribute and RegisterStateDriver then
|
||||||
if not UnitIsVisible(unitstr) or not UnitExists("party" .. self.id) then
|
self:SetAttribute("unit", unitstr)
|
||||||
self:Hide()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
elseif self.label == "pettarget" then
|
-- update visibility condition on change
|
||||||
if not UnitIsVisible(unitstr) or not UnitExists("pet") then
|
if self.visibilitycondition ~= visibility then
|
||||||
self.frame:Hide()
|
RegisterStateDriver(self, 'visibility', visibility)
|
||||||
return
|
self.visibilitycondition = visibility
|
||||||
end
|
self.visible = true
|
||||||
|
|
||||||
-- hide self in group if solo or hide in raid is set
|
|
||||||
elseif self.fname == "Group0" or self.fname == "PartyPet0" or self.fname == "Party0Target" then
|
|
||||||
if GetNumPartyMembers() <= 0 or ( C["unitframes"]["group"]["hide_in_raid"] == "1" and UnitInRaid("player") ) then
|
|
||||||
self:Hide()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- show everything else that has a name
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- vanilla visibility
|
||||||
|
if self.unitname and self.unitname ~= "focus" then
|
||||||
|
self:Show()
|
||||||
|
elseif visibility == "hide" then
|
||||||
|
self:Hide()
|
||||||
|
elseif visibility == "show" then
|
||||||
self:Show()
|
self:Show()
|
||||||
else
|
else
|
||||||
self.lastUnit = nil
|
if UnitName(unitstr) then
|
||||||
self:Hide()
|
-- hide existing but too far away pet and pets of old group members
|
||||||
return
|
if self.label == "partypet" then
|
||||||
|
if not UnitIsVisible(unitstr) or not UnitExists("party" .. self.id) then
|
||||||
|
self:Hide()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
elseif self.label == "pettarget" then
|
||||||
|
if not UnitIsVisible(unitstr) or not UnitExists("pet") then
|
||||||
|
self.frame:Hide()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:Show()
|
||||||
|
else
|
||||||
|
self.lastUnit = nil
|
||||||
|
self:Hide()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1203,29 +1228,6 @@ function pfUI.uf:RefreshUnit(unit, component)
|
|||||||
if pfScanActive == true then return end
|
if pfScanActive == true then return end
|
||||||
end
|
end
|
||||||
|
|
||||||
local C = pfUI_config
|
|
||||||
|
|
||||||
-- show groupframes as raid
|
|
||||||
if strsub(unit:GetName(),0,6) == "pfRaid" then
|
|
||||||
local id = tonumber(strsub(unit:GetName(),7,8))
|
|
||||||
|
|
||||||
if not UnitInRaid("player") and GetNumPartyMembers() == 0 and C.unitframes.selfinraid == "1" and id == 1 then
|
|
||||||
unit.id = ""
|
|
||||||
unit.label = "player"
|
|
||||||
elseif not UnitInRaid("player") and GetNumPartyMembers() > 0 and C.unitframes.raidforgroup == "1" then
|
|
||||||
if id == 1 then
|
|
||||||
unit.id = ""
|
|
||||||
unit.label = "player"
|
|
||||||
elseif id <= 5 then
|
|
||||||
unit.id = id - 1
|
|
||||||
unit.label = "party"
|
|
||||||
end
|
|
||||||
elseif unit.label == "party" or unit.label == "player" then
|
|
||||||
unit.id = id
|
|
||||||
unit.label = "raid"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- hide unused and invalid frames
|
-- hide unused and invalid frames
|
||||||
unit:UpdateVisibility()
|
unit:UpdateVisibility()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user