diff --git a/Modules/UnitFrames/Framework.lua b/Modules/UnitFrames/Framework.lua index c3e6aa69..f988883f 100644 --- a/Modules/UnitFrames/Framework.lua +++ b/Modules/UnitFrames/Framework.lua @@ -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]) @@ -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 @@ -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 diff --git a/Modules/UnitFrames/Handlers/Units.lua b/Modules/UnitFrames/Handlers/Units.lua index e7f580e3..bcd04448 100644 --- a/Modules/UnitFrames/Handlers/Units.lua +++ b/Modules/UnitFrames/Handlers/Units.lua @@ -6,6 +6,7 @@ local FrameData = {} ---@type table local Unit = { UnitsLoaded = {}, ---@type table + UnitsBuilt = {}, ---@type table GroupsLoaded = {}, ---@type table defaultConfigs = {} ---@type table } @@ -248,7 +249,6 @@ 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 @@ -256,6 +256,14 @@ function Unit:BuildFrame(frameName, 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 +function Unit:GetBuiltFrameList() + return Unit.UnitsBuilt end ---Gets a table of all the frames that are currently loaded and their default settings diff --git a/Modules/UnitFrames/Options.lua b/Modules/UnitFrames/Options.lua index 907f91f3..d150b9a4 100644 --- a/Modules/UnitFrames/Options.lua +++ b/Modules/UnitFrames/Options.lua @@ -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) diff --git a/Modules/UnitFrames/SpawnFrames.lua b/Modules/UnitFrames/SpawnFrames.lua index 46e46be6..64db1bf7 100644 --- a/Modules/UnitFrames/SpawnFrames.lua +++ b/Modules/UnitFrames/SpawnFrames.lua @@ -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 @@ -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() diff --git a/Modules/UnitFrames/Units/raid.lua b/Modules/UnitFrames/Units/raid.lua index 079eeb13..e85ef636 100644 --- a/Modules/UnitFrames/Units/raid.lua +++ b/Modules/UnitFrames/Units/raid.lua @@ -46,7 +46,7 @@ local function GroupBuilder(holder) 'showRaid', true, 'showParty', - true, + false, 'showPlayer', UF.CurrentSettings.raid.showSelf, 'showSolo',