Skip to content

Commit

Permalink
Fixes #479
Browse files Browse the repository at this point in the history
  • Loading branch information
Wutname1 committed Dec 8, 2022
1 parent 987949b commit aaecbd4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 40 deletions.
6 changes: 3 additions & 3 deletions Modules/UnitFrames/Framework.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function UF:PositionFrame(unit)
UnitFrame:SetPoint(point, anchor, secondaryPoint, x, y)
end
else
for frameName, config in pairs(UF.Unit:GetFrameList()) do
for frameName, config in pairs(UF.Unit:GetBuiltFrameList()) do
if not config.isChild then
local UnitFrame = UF.Unit:Get(frameName)
local point, anchor, secondaryPoint, x, y = strsplit(',', positionData[frameName])
Expand Down Expand Up @@ -159,7 +159,7 @@ function UF:OnEnable()
UF:PositionFrame()

-- Create movers
for unit, config in pairs(UF.Unit:GetFrameList()) do
for unit, config in pairs(UF.Unit:GetBuiltFrameList()) do
if not config.isChild then
MoveIt:CreateMover(UF.Unit:Get(unit), unit, nil, nil, 'Unit frames')
end
Expand Down Expand Up @@ -229,7 +229,7 @@ function UF:ScaleFrames(scale)
return
end

for unitName, config in pairs(UF.Unit:GetFrameList()) do
for unitName, config in pairs(UF.Unit:GetBuiltFrameList()) do
if not config.isChild then
local UFrame = UF.Unit:Get(unitName)
if UFrame and UFrame.mover then
Expand Down
10 changes: 9 additions & 1 deletion Modules/UnitFrames/Handlers/Units.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local FrameData = {} ---@type table<UnitFrameName, table>

local Unit = {
UnitsLoaded = {}, ---@type table<UnitFrameName, SUI.UF.Unit.Config>
UnitsBuilt = {}, ---@type table<UnitFrameName, SUI.UF.Unit.Config>
GroupsLoaded = {}, ---@type table<UnitFrameName, SUI.UF.Unit.Config>
defaultConfigs = {} ---@type table<string, SUI.UF.Unit.Settings>
}
Expand Down Expand Up @@ -248,14 +249,21 @@ function Unit:BuildFrame(frameName, frame)

if Unit:GetConfig(frameName).config.IsGroup then
if not BuiltFrames[frameName] then
print('NO WHERE TO STORE FRAME FOR ' .. frameName)
return
end

table.insert(BuiltFrames[frameName].frames, frame)
else
BuiltFrames[frameName] = frame
end

Unit.UnitsBuilt[frameName] = frame.config.config
end

---Gets a table of all the frames that are currently built and their default settings
---@return table<UnitFrameName, SUI.UF.Unit.Config>
function Unit:GetBuiltFrameList()
return Unit.UnitsBuilt
end

---Gets a table of all the frames that are currently loaded and their default settings
Expand Down
2 changes: 1 addition & 1 deletion Modules/UnitFrames/Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ function Options:Initialize()
SUI.opt.args.General.args.style.args.Unitframes = UFOptions.args.BaseStyle

-- Build frame options
for frameName, FrameConfig in pairs(UF.Unit:GetFrameList()) do
for frameName, _ in pairs(UF.Unit:GetBuiltFrameList()) do
local FrameOptSet = CreateOptionSet(frameName)
AddGeneral(FrameOptSet)

Expand Down
66 changes: 32 additions & 34 deletions Modules/UnitFrames/SpawnFrames.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,46 +271,44 @@ function UF:SpawnFrames()

-- Spawn all main frames
for frameName, config in pairs(UF.Unit:GetFrameList()) do
if config.IsGroup then
local groupElement = UF.Unit:BuildGroup(frameName)
local firstElement = groupElement.header or groupElement.frames[1] or groupElement
if firstElement then
local function GroupFrameUpdateAll(groupFrame)
if VisibilityCheck(frameName) and UF.CurrentSettings[frameName].enabled then
if firstElement.visibility then
RegisterStateDriver(firstElement, firstElement.visibility)
end
firstElement:Show()
local settings = UF.CurrentSettings[frameName]
if settings.enabled then
if config.IsGroup then
local groupElement = UF.Unit:BuildGroup(frameName)
local firstElement = groupElement.header or groupElement.frames[1] or groupElement
if firstElement then
local function GroupFrameUpdateAll(groupFrame)
if VisibilityCheck(frameName) and UF.CurrentSettings[frameName].enabled then
if firstElement.visibility then
RegisterStateDriver(firstElement, firstElement.visibility)
end
firstElement:Show()

for i, f in pairs(groupFrame.frames) do
if f.UpdateAll then
f:UpdateAll()
for i, f in pairs(groupFrame.frames) do
if f.UpdateAll then
f:UpdateAll()
end
end
else
UnregisterStateDriver(firstElement, 'visibility')
firstElement:Hide()
end
else
UnregisterStateDriver(firstElement, 'visibility')
firstElement:Hide()
end
end

groupElement.UpdateAll = GroupFrameUpdateAll
groupElement.ElementUpdate = GroupFrameElementUpdate
groupElement.Enable = GroupFrameEnable
groupElement.Disable = GroupFrameDisable
groupElement.EnableElement = GroupEnableElement
groupElement.DisableElement = GroupDisableElement
groupElement.UpdateAll = GroupFrameUpdateAll
groupElement.ElementUpdate = GroupFrameElementUpdate
groupElement.Enable = GroupFrameEnable
groupElement.Disable = GroupFrameDisable
groupElement.EnableElement = GroupEnableElement
groupElement.DisableElement = GroupDisableElement
end
UF.Unit[frameName] = groupElement
else
UF.Unit[frameName] = SUIUF:Spawn(frameName, 'SUI_UF_' .. frameName)
end
UF.Unit[frameName] = groupElement
else
UF.Unit[frameName] = SUIUF:Spawn(frameName, 'SUI_UF_' .. frameName)
end

-- Trigger update
UF.Unit[frameName]:UpdateAll()

-- Disable objects based on settings
if not UF.CurrentSettings[frameName].enabled then
UF.Unit[frameName]:Disable()
-- Trigger update
UF.Unit[frameName]:UpdateAll()
end
end

Expand Down Expand Up @@ -339,7 +337,7 @@ function UF:SpawnFrames()
end

function UF:UpdateAll(event, ...)
for frameName, config in pairs(UF.Unit:GetFrameList()) do
for frameName, config in pairs(UF.Unit:GetBuiltFrameList()) do
local frame = UF.Unit:Get(frameName)
if frame and frame.UpdateAll then
frame:UpdateAll()
Expand Down
2 changes: 1 addition & 1 deletion Modules/UnitFrames/Units/raid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ local function GroupBuilder(holder)
'showRaid',
true,
'showParty',
true,
false,
'showPlayer',
UF.CurrentSettings.raid.showSelf,
'showSolo',
Expand Down

0 comments on commit aaecbd4

Please sign in to comment.