2019-05-14 13:18:06 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2024-07-13 16:47:36 +08:00
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2019-05-14 13:18:06 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
2019-06-11 14:22:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-05-14 13:18:06 +08:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2021-01-18 15:48:12 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2023-11-24 12:16:04 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-04-21 13:37:11 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2019-05-14 14:19:23 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2019-05-14 13:18:06 +08:00
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2020-10-22 13:19:12 +08:00
|
|
|
|
public abstract partial class FullscreenOverlay<T> : WaveOverlayContainer, INamedOverlayComponent
|
2020-09-03 15:27:31 +08:00
|
|
|
|
where T : OverlayHeader
|
2019-05-14 13:18:06 +08:00
|
|
|
|
{
|
2023-11-24 12:16:04 +08:00
|
|
|
|
public virtual IconUsage Icon => Header.Title.Icon;
|
2021-04-21 13:37:11 +08:00
|
|
|
|
public virtual LocalisableString Title => Header.Title.Title;
|
|
|
|
|
public virtual LocalisableString Description => Header.Title.Description;
|
2020-09-03 14:46:56 +08:00
|
|
|
|
|
2024-07-13 16:47:36 +08:00
|
|
|
|
public T Header { get; private set; }
|
2020-09-03 14:46:56 +08:00
|
|
|
|
|
2021-02-09 17:32:44 +08:00
|
|
|
|
protected virtual Color4 BackgroundColour => ColourProvider.Background5;
|
|
|
|
|
|
2019-05-14 13:18:06 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
protected IAPIProvider API { get; private set; } = null!;
|
|
|
|
|
|
2020-01-26 19:02:05 +08:00
|
|
|
|
[Cached]
|
2020-01-30 11:50:15 +08:00
|
|
|
|
protected readonly OverlayColourProvider ColourProvider;
|
2020-01-24 17:24:35 +08:00
|
|
|
|
|
2021-01-18 15:48:12 +08:00
|
|
|
|
protected override Container<Drawable> Content => content;
|
|
|
|
|
|
2024-07-13 16:47:36 +08:00
|
|
|
|
private readonly Box background;
|
2021-01-18 15:48:12 +08:00
|
|
|
|
private readonly Container content;
|
|
|
|
|
|
|
|
|
|
protected FullscreenOverlay(OverlayColourScheme colourScheme)
|
2019-05-14 13:18:06 +08:00
|
|
|
|
{
|
2024-07-13 16:47:36 +08:00
|
|
|
|
RecreateHeader();
|
2020-09-03 15:27:31 +08:00
|
|
|
|
|
2020-01-30 11:50:15 +08:00
|
|
|
|
ColourProvider = new OverlayColourProvider(colourScheme);
|
2020-01-24 17:24:35 +08:00
|
|
|
|
|
2019-05-14 13:18:06 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
RelativePositionAxes = Axes.Both;
|
|
|
|
|
Width = 0.85f;
|
|
|
|
|
Anchor = Anchor.TopCentre;
|
|
|
|
|
Origin = Anchor.TopCentre;
|
|
|
|
|
|
|
|
|
|
Masking = true;
|
|
|
|
|
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0),
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
2023-05-23 17:48:10 +08:00
|
|
|
|
Hollow = true,
|
2019-05-14 13:18:06 +08:00
|
|
|
|
Radius = 10
|
|
|
|
|
};
|
2021-01-18 15:48:12 +08:00
|
|
|
|
|
|
|
|
|
base.Content.AddRange(new Drawable[]
|
|
|
|
|
{
|
2024-07-13 16:47:36 +08:00
|
|
|
|
background = new Box
|
2021-01-18 15:48:12 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
content = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
}
|
|
|
|
|
});
|
2019-05-14 13:18:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-24 17:24:35 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2024-07-13 16:47:36 +08:00
|
|
|
|
UpdateColours();
|
2020-01-24 17:24:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-01-18 15:48:12 +08:00
|
|
|
|
protected abstract T CreateHeader();
|
|
|
|
|
|
2024-07-13 16:47:36 +08:00
|
|
|
|
[MemberNotNull(nameof(Header))]
|
|
|
|
|
protected void RecreateHeader()
|
|
|
|
|
{
|
|
|
|
|
Header = CreateHeader();
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 14:22:27 +08:00
|
|
|
|
public override void Show()
|
|
|
|
|
{
|
|
|
|
|
if (State.Value == Visibility.Visible)
|
|
|
|
|
{
|
|
|
|
|
// re-trigger the state changed so we can potentially surface to front
|
|
|
|
|
State.TriggerChange();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
base.Show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-18 04:58:47 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Updates the colours of the background and the top waves with the latest colour shades provided by <see cref="ColourProvider"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected void UpdateColours()
|
2024-07-13 16:47:36 +08:00
|
|
|
|
{
|
|
|
|
|
Waves.FirstWaveColour = ColourProvider.Light4;
|
|
|
|
|
Waves.SecondWaveColour = ColourProvider.Light3;
|
|
|
|
|
Waves.ThirdWaveColour = ColourProvider.Dark4;
|
|
|
|
|
Waves.FourthWaveColour = ColourProvider.Dark3;
|
|
|
|
|
background.Colour = BackgroundColour;
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-14 14:19:23 +08:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
|
|
|
|
base.PopIn();
|
2023-05-24 11:38:27 +08:00
|
|
|
|
FadeEdgeEffectTo(WaveContainer.SHADOW_OPACITY, WaveContainer.APPEAR_DURATION, Easing.Out);
|
2019-05-14 14:19:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
base.PopOut();
|
|
|
|
|
FadeEdgeEffectTo(0, WaveContainer.DISAPPEAR_DURATION, Easing.In).OnComplete(_ => PopOutComplete());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void PopOutComplete()
|
|
|
|
|
{
|
|
|
|
|
}
|
2019-05-14 13:18:06 +08:00
|
|
|
|
}
|
|
|
|
|
}
|