1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 12:22:55 +08:00
osu-lazer/osu.Game/Overlays/FullscreenOverlay.cs

105 lines
3.1 KiB
C#
Raw Normal View History

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.
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2019-05-14 13:18:06 +08:00
using osu.Framework.Graphics.Effects;
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
{
public abstract class FullscreenOverlay : WaveOverlayContainer, IOnlineComponent
{
[Resolved]
protected IAPIProvider API { get; private set; }
2020-01-24 17:24:35 +08:00
private readonly OverlayColourScheme colourScheme;
protected FullscreenOverlay(OverlayColourScheme colourScheme)
2019-05-14 13:18:06 +08:00
{
2020-01-24 17:24:35 +08:00
this.colourScheme = colourScheme;
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,
Radius = 10
};
}
2020-01-24 17:24:35 +08:00
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
[BackgroundDependencyLoader]
private void load()
{
OverlayColourProvider colourProvider;
dependencies.Cache(colourProvider = new OverlayColourProvider(colourScheme));
Waves.FirstWaveColour = colourProvider.Highlight1;
Waves.SecondWaveColour = colourProvider.Link4;
Waves.ThirdWaveColour = colourProvider.Dark3;
Waves.FourthWaveColour = colourProvider.Dark1;
2020-01-24 17:24:35 +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();
}
}
2019-05-14 14:19:23 +08:00
protected override void PopIn()
{
base.PopIn();
FadeEdgeEffectTo(0.4f, WaveContainer.APPEAR_DURATION, Easing.Out);
}
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
protected override void LoadComplete()
{
base.LoadComplete();
API.Register(this);
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
2019-05-14 16:08:42 +08:00
API?.Unregister(this);
2019-05-14 13:18:06 +08:00
}
public virtual void APIStateChanged(IAPIProvider api, APIState state)
{
}
}
}