mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 08:22:56 +08:00
Further refactorings along with shadow implementation
This commit is contained in:
parent
84bc14c1dd
commit
38244c081f
@ -67,8 +67,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
SpectatorPlayerClock = clock;
|
SpectatorPlayerClock = clock;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Masking = true;
|
|
||||||
CornerRadius = 5;
|
|
||||||
|
|
||||||
AudioContainer audioContainer;
|
AudioContainer audioContainer;
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
|
@ -83,8 +83,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
var facade = new Facade();
|
var facade = new Facade();
|
||||||
facadeContainer.Add(facade);
|
facadeContainer.Add(facade);
|
||||||
|
|
||||||
var cell = new Cell(index, content) { ToggleMaximisationState = toggleMaximisationState };
|
var cell = new Cell(index, content, facade) { ToggleMaximisationState = toggleMaximisationState };
|
||||||
cell.SetFacade(facade);
|
|
||||||
|
|
||||||
cellContainer.Add(cell);
|
cellContainer.Add(cell);
|
||||||
}
|
}
|
||||||
@ -99,30 +98,28 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
|
|
||||||
private void toggleMaximisationState(Cell target)
|
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.
|
// Iterate through all cells to ensure only one is maximised at any time.
|
||||||
foreach (var cell in cellContainer.ToList())
|
foreach (var cell in cellContainer.ToList())
|
||||||
{
|
{
|
||||||
if (cell != target)
|
if (hasMaximised && cell == target)
|
||||||
cell.IsMaximised = false;
|
|
||||||
|
|
||||||
if (cell.IsMaximised)
|
|
||||||
{
|
{
|
||||||
// Transfer cell to the maximised facade.
|
// Transfer cell to the maximised facade.
|
||||||
cell.SetFacade(MaximisedFacade);
|
cell.SetFacade(MaximisedFacade, true);
|
||||||
cellContainer.ChangeChildDepth(cell, maximisedInstanceDepth -= 0.001f);
|
cellContainer.ChangeChildDepth(cell, maximisedInstanceDepth -= 0.001f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Transfer cell back to its original facade.
|
// 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()
|
protected override void Update()
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -33,23 +31,27 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// An action that toggles the maximisation state of this cell.
|
/// An action that toggles the maximisation state of this cell.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<Cell> ToggleMaximisationState;
|
public Action<Cell>? ToggleMaximisationState;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether this cell is currently maximised.
|
/// Whether this cell is currently maximised.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsMaximised;
|
public bool IsMaximised { get; private set; }
|
||||||
|
|
||||||
private Facade facade;
|
private Facade facade;
|
||||||
|
|
||||||
private bool isAnimating;
|
private bool isAnimating;
|
||||||
|
|
||||||
public Cell(int facadeIndex, Drawable content)
|
public Cell(int facadeIndex, Drawable content, Facade facade)
|
||||||
{
|
{
|
||||||
FacadeIndex = facadeIndex;
|
FacadeIndex = facadeIndex;
|
||||||
|
this.facade = facade;
|
||||||
|
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
InternalChild = Content = content;
|
InternalChild = Content = content;
|
||||||
|
|
||||||
|
Masking = true;
|
||||||
|
CornerRadius = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -78,10 +80,18 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Makes this cell track a new facade.
|
/// Makes this cell track a new facade.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetFacade([NotNull] Facade newFacade)
|
public void SetFacade(Facade newFacade, bool isMaximised)
|
||||||
{
|
{
|
||||||
facade = newFacade;
|
facade = newFacade;
|
||||||
|
IsMaximised = isMaximised;
|
||||||
isAnimating = true;
|
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() =>
|
private Vector2 getFinalPosition() =>
|
||||||
@ -93,7 +103,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
|
|||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
ToggleMaximisationState(this);
|
ToggleMaximisationState?.Invoke(this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user