diff --git a/Core_Cata.lua b/Core_Cata.lua index efa81a56..0ae7f9c6 100644 --- a/Core_Cata.lua +++ b/Core_Cata.lua @@ -192,6 +192,15 @@ function F.IsGroupTypeHidden(layoutGroupType) return layoutGroupType and Cell.vars.layoutAutoSwitch and Cell.vars.layoutAutoSwitch[layoutGroupType] == "hide" end +--! The layout a frame group has to be laid out for, from the same mapping: nil when that entry is "hide" +--! (or unknown), so a frame group can lay itself out ahead of time for a group type the player is not in. +function F.GetGroupTypeLayout(layoutGroupType) + local layout = layoutGroupType and Cell.vars.layoutAutoSwitch and Cell.vars.layoutAutoSwitch[layoutGroupType] + if layout and layout ~= "hide" and CellDB["layouts"][layout] then + return layout + end +end + local bgMaxPlayers = { [2197] = 40, -- 科尔拉克的复仇 } diff --git a/Core_Mists.lua b/Core_Mists.lua index 4a91d8d1..a9b9d70e 100644 --- a/Core_Mists.lua +++ b/Core_Mists.lua @@ -212,6 +212,15 @@ function F.IsGroupTypeHidden(layoutGroupType) return layoutGroupType and Cell.vars.layoutAutoSwitch and Cell.vars.layoutAutoSwitch[layoutGroupType] == "hide" end +--! The layout a frame group has to be laid out for, from the same mapping: nil when that entry is "hide" +--! (or unknown), so a frame group can lay itself out ahead of time for a group type the player is not in. +function F.GetGroupTypeLayout(layoutGroupType) + local layout = layoutGroupType and Cell.vars.layoutAutoSwitch and Cell.vars.layoutAutoSwitch[layoutGroupType] + if layout and layout ~= "hide" and CellDB["layouts"][layout] then + return layout + end +end + local bgMaxPlayers = { [2197] = 40, -- 科尔拉克的复仇 } diff --git a/Core_Vanilla.lua b/Core_Vanilla.lua index 9290bd8b..b7c6aaef 100644 --- a/Core_Vanilla.lua +++ b/Core_Vanilla.lua @@ -197,6 +197,15 @@ function F.IsGroupTypeHidden(layoutGroupType) return layoutGroupType and Cell.vars.layoutAutoSwitch and Cell.vars.layoutAutoSwitch[layoutGroupType] == "hide" end +--! The layout a frame group has to be laid out for, from the same mapping: nil when that entry is "hide" +--! (or unknown), so a frame group can lay itself out ahead of time for a group type the player is not in. +function F.GetGroupTypeLayout(layoutGroupType) + local layout = layoutGroupType and Cell.vars.layoutAutoSwitch and Cell.vars.layoutAutoSwitch[layoutGroupType] + if layout and layout ~= "hide" and CellDB["layouts"][layout] then + return layout + end +end + -- layout auto switch local instanceType local function PreUpdateLayout() diff --git a/Core_Wrath.lua b/Core_Wrath.lua index c4b3b949..3d884b51 100644 --- a/Core_Wrath.lua +++ b/Core_Wrath.lua @@ -192,6 +192,15 @@ function F.IsGroupTypeHidden(layoutGroupType) return layoutGroupType and Cell.vars.layoutAutoSwitch and Cell.vars.layoutAutoSwitch[layoutGroupType] == "hide" end +--! The layout a frame group has to be laid out for, from the same mapping: nil when that entry is "hide" +--! (or unknown), so a frame group can lay itself out ahead of time for a group type the player is not in. +function F.GetGroupTypeLayout(layoutGroupType) + local layout = layoutGroupType and Cell.vars.layoutAutoSwitch and Cell.vars.layoutAutoSwitch[layoutGroupType] + if layout and layout ~= "hide" and CellDB["layouts"][layout] then + return layout + end +end + local bgMaxPlayers = { [2197] = 40, -- 科尔拉克的复仇 } diff --git a/Modules/Layouts/Layouts.lua b/Modules/Layouts/Layouts.lua index cb007610..a60b931a 100644 --- a/Modules/Layouts/Layouts.lua +++ b/Modules/Layouts/Layouts.lua @@ -1831,6 +1831,10 @@ local function GetDropdownItems(indices, groupType) -- LoadLayoutDB(Cell.vars.currentLayout) UpdateButtonStates() -- UpdateEnabledLayoutText() + elseif Cell.vars.layoutGroupType then + --! frame groups are laid out ahead of time for the group types the player is not in + --! (see F.GetGroupTypeLayout), so let them pick up the new assignment + F.UpdateLayout(Cell.vars.layoutGroupType, true) end end, }) diff --git a/RaidFrames/Groups/PartyFrame.lua b/RaidFrames/Groups/PartyFrame.lua index 66646fcf..1801fe2a 100644 --- a/RaidFrames/Groups/PartyFrame.lua +++ b/RaidFrames/Groups/PartyFrame.lua @@ -116,7 +116,20 @@ local function PartyFrame_UpdateLayout(layout, which) RegisterAttributeDriver(partyFrame, "state-visibility", "[@raid1,exists] hide;[@party1,exists] show;[group:party] show;hide") end - if Cell.vars.groupType ~= "party" then return end + -- Layout: applied for every frame group, not only the active one, so that the first show of a group + -- type since login can happen in combat. F.UpdateLayout defers itself until combat ends, so a party frame + -- that had never been active came up with no sizes, anchors or header attributes when the group changed + -- in combat, and stayed blank until combat ended. See F.GetGroupTypeLayout. + if Cell.vars.groupType ~= "party" then + local ownLayout = F.GetGroupTypeLayout(Cell.vars.partyLayoutGroupType) + if not ownLayout then return end + if which then + -- partial update from the Layouts tab: only relevant when the edited layout is the one used here + if layout ~= ownLayout then return end + else + layout = ownLayout + end + end end -- update diff --git a/RaidFrames/Groups/RaidFrame.lua b/RaidFrames/Groups/RaidFrame.lua index 3bfcab2a..3aab04d0 100644 --- a/RaidFrames/Groups/RaidFrame.lua +++ b/RaidFrames/Groups/RaidFrame.lua @@ -279,8 +279,9 @@ function F.GetRaidFramePoints(layout) return point, anchorPoint, groupAnchorPoint, P.Scale(unitSpacing), P.Scale(groupSpacing), P.Scale(unitSpacingX), P.Scale(unitSpacingY), verticalSpacing, horizontalSpacing, headerPoint, headerColumnAnchorPoint end -local function UpdateHeadersShowRaidAttribute() - if Cell.vars.currentLayoutTable["main"]["combineGroups"] then +local function UpdateHeadersShowRaidAttribute(layout) + -- NOTE: layout table passed in, the raid frame can be laid out for a layout that is not the current one + if layout["main"]["combineGroups"] then combinedHeader:SetAttribute("showRaid", true) for _, header in ipairs(separatedHeaders) do header:SetAttribute("showRaid", nil) @@ -366,7 +367,20 @@ local function RaidFrame_UpdateLayout(layout, which) RegisterAttributeDriver(raidFrame, "state-visibility", "[@raid1,exists] show;hide") end - if Cell.vars.groupType ~= "raid" then return end + -- Layout: applied for every frame group, not only the active one, so that the first show of a group + -- type since login can happen in combat. F.UpdateLayout defers itself until combat ends, so a raid frame + -- that had never been active came up with no sizes, anchors or header attributes when the group changed + -- in combat, and stayed blank until combat ended. See F.GetGroupTypeLayout. + if Cell.vars.groupType ~= "raid" then + local ownLayout = F.GetGroupTypeLayout(Cell.vars.raidLayoutGroupType) + if not ownLayout then return end + if which then + -- partial update from the Layouts tab: only relevant when the edited layout is the one used here + if layout ~= ownLayout then return end + else + layout = ownLayout + end + end end -- update @@ -414,7 +428,7 @@ local function RaidFrame_UpdateLayout(layout, which) end if not which or which == "header" then - UpdateHeadersShowRaidAttribute() + UpdateHeadersShowRaidAttribute(layout) end if layout["main"]["combineGroups"] then diff --git a/RaidFrames/Groups/SoloFrame.lua b/RaidFrames/Groups/SoloFrame.lua index 4d3e8a6e..c0a7f730 100644 --- a/RaidFrames/Groups/SoloFrame.lua +++ b/RaidFrames/Groups/SoloFrame.lua @@ -44,7 +44,20 @@ local function SoloFrame_UpdateLayout(layout, which) RegisterAttributeDriver(soloFrame, "state-visibility", "[@raid1,exists] hide;[@party1,exists] hide;[group] hide;show") end - if Cell.vars.groupType ~= "solo" then return end + -- Layout: applied for every frame group, not only the active one, so that the first show of a group + -- type since login can happen in combat. F.UpdateLayout defers itself until combat ends, so a solo frame + -- that had never been active came up with no sizes, anchors or header attributes when the group changed + -- in combat, and stayed blank until combat ended. See F.GetGroupTypeLayout. + if Cell.vars.groupType ~= "solo" then + local ownLayout = F.GetGroupTypeLayout(Cell.vars.soloLayoutGroupType) + if not ownLayout then return end + if which then + -- partial update from the Layouts tab: only relevant when the edited layout is the one used here + if layout ~= ownLayout then return end + else + layout = ownLayout + end + end end -- update