diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerArea.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerArea.cs index 54f03569de..1b03452df7 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerArea.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerArea.cs @@ -67,8 +67,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate SpectatorPlayerClock = clock; RelativeSizeAxes = Axes.Both; - Masking = true; - CornerRadius = 5; AudioContainer audioContainer; InternalChildren = new Drawable[] diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerGrid.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerGrid.cs index c88feb12bd..c162b87727 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerGrid.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerGrid.cs @@ -83,8 +83,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate var facade = new Facade(); facadeContainer.Add(facade); - var cell = new Cell(index, content) { ToggleMaximisationState = toggleMaximisationState }; - cell.SetFacade(facade); + var cell = new Cell(index, content, facade) { ToggleMaximisationState = toggleMaximisationState }; cellContainer.Add(cell); } @@ -99,30 +98,28 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate private void toggleMaximisationState(Cell target) { - bool anyMaximised = target.IsMaximised = !target.IsMaximised; + // in the case the target is the already maximised cell, no cell should be maximised. + bool hasMaximised = !target.IsMaximised; // Iterate through all cells to ensure only one is maximised at any time. foreach (var cell in cellContainer.ToList()) { - if (cell != target) - cell.IsMaximised = false; - - if (cell.IsMaximised) + if (hasMaximised && cell == target) { // Transfer cell to the maximised facade. - cell.SetFacade(MaximisedFacade); + cell.SetFacade(MaximisedFacade, true); cellContainer.ChangeChildDepth(cell, maximisedInstanceDepth -= 0.001f); } else { // Transfer cell back to its original facade. - cell.SetFacade(facadeContainer[cell.FacadeIndex]); + cell.SetFacade(facadeContainer[cell.FacadeIndex], false); } - cell.FadeColour(anyMaximised && cell != target ? Color4.Gray : Color4.White, ANIMATION_DELAY, Easing.Out); + cell.FadeColour(hasMaximised && cell != target ? Color4.Gray : Color4.White, ANIMATION_DELAY, Easing.OutQuint); } - facadeContainer.ScaleTo(anyMaximised ? 0.95f : 1, ANIMATION_DELAY, Easing.OutQuint); + facadeContainer.ScaleTo(hasMaximised ? 0.95f : 1, ANIMATION_DELAY, Easing.OutQuint); } protected override void Update() diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerGrid_Cell.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerGrid_Cell.cs index d11e79d820..4e624da17f 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerGrid_Cell.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/PlayerGrid_Cell.cs @@ -1,12 +1,10 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; -using JetBrains.Annotations; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Effects; using osu.Framework.Input.Events; using osu.Framework.Utils; using osuTK; @@ -33,23 +31,27 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate /// /// An action that toggles the maximisation state of this cell. /// - public Action ToggleMaximisationState; + public Action? ToggleMaximisationState; /// /// Whether this cell is currently maximised. /// - public bool IsMaximised; + public bool IsMaximised { get; private set; } private Facade facade; private bool isAnimating; - public Cell(int facadeIndex, Drawable content) + public Cell(int facadeIndex, Drawable content, Facade facade) { FacadeIndex = facadeIndex; + this.facade = facade; Origin = Anchor.Centre; InternalChild = Content = content; + + Masking = true; + CornerRadius = 5; } protected override void Update() @@ -78,10 +80,18 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate /// /// Makes this cell track a new facade. /// - public void SetFacade([NotNull] Facade newFacade) + public void SetFacade(Facade newFacade, bool isMaximised) { facade = newFacade; + IsMaximised = isMaximised; isAnimating = true; + + TweenEdgeEffectTo(new EdgeEffectParameters + { + Type = EdgeEffectType.Shadow, + Radius = isMaximised ? 30 : 10, + Colour = Colour4.Black.Opacity(isMaximised ? 0.5f : 0.2f), + }, ANIMATION_DELAY, Easing.OutQuint); } private Vector2 getFinalPosition() => @@ -93,7 +103,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate protected override bool OnClick(ClickEvent e) { - ToggleMaximisationState(this); + ToggleMaximisationState?.Invoke(this); return true; } }