2019-01-24 16:43:03 +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.
|
2018-04-15 15:44:40 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
2023-08-24 17:13:23 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Audio;
|
|
|
|
|
using osu.Framework.Audio.Sample;
|
2018-04-15 15:44:40 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-04-02 13:51:28 +08:00
|
|
|
|
using osu.Framework.Graphics.Effects;
|
2018-04-15 15:44:40 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-15 15:44:40 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.Containers
|
|
|
|
|
{
|
|
|
|
|
public partial class WaveContainer : VisibilityContainer
|
|
|
|
|
{
|
|
|
|
|
public const float APPEAR_DURATION = 800;
|
|
|
|
|
public const float DISAPPEAR_DURATION = 500;
|
2023-05-24 11:38:27 +08:00
|
|
|
|
public const float SHADOW_OPACITY = 0.2f;
|
2018-04-15 15:44:40 +08:00
|
|
|
|
|
|
|
|
|
private const Easing easing_show = Easing.OutSine;
|
|
|
|
|
private const Easing easing_hide = Easing.InSine;
|
|
|
|
|
|
|
|
|
|
private readonly Wave firstWave;
|
|
|
|
|
private readonly Wave secondWave;
|
|
|
|
|
private readonly Wave thirdWave;
|
|
|
|
|
private readonly Wave fourthWave;
|
|
|
|
|
|
|
|
|
|
private readonly Container<Wave> wavesContainer;
|
|
|
|
|
private readonly Container contentContainer;
|
|
|
|
|
|
|
|
|
|
protected override Container<Drawable> Content => contentContainer;
|
|
|
|
|
|
2019-07-02 14:21:57 +08:00
|
|
|
|
protected override bool StartHidden => true;
|
|
|
|
|
|
2023-08-24 17:13:23 +08:00
|
|
|
|
private Sample? samplePopIn;
|
|
|
|
|
private Sample? samplePopOut;
|
|
|
|
|
|
2023-08-24 17:20:36 +08:00
|
|
|
|
// required due to LoadAsyncComplete() in `VisibilityContainer` calling PopOut() during load - similar workaround to `OsuDropdownMenu`
|
|
|
|
|
private bool wasShown;
|
2023-08-24 17:13:23 +08:00
|
|
|
|
|
2018-04-15 15:44:40 +08:00
|
|
|
|
public Color4 FirstWaveColour
|
|
|
|
|
{
|
|
|
|
|
get => firstWave.Colour;
|
|
|
|
|
set => firstWave.Colour = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color4 SecondWaveColour
|
|
|
|
|
{
|
|
|
|
|
get => secondWave.Colour;
|
|
|
|
|
set => secondWave.Colour = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color4 ThirdWaveColour
|
|
|
|
|
{
|
|
|
|
|
get => thirdWave.Colour;
|
|
|
|
|
set => thirdWave.Colour = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color4 FourthWaveColour
|
|
|
|
|
{
|
|
|
|
|
get => fourthWave.Colour;
|
|
|
|
|
set => fourthWave.Colour = value;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-24 17:13:23 +08:00
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
|
private void load(AudioManager audio)
|
|
|
|
|
{
|
2023-08-25 00:08:22 +08:00
|
|
|
|
samplePopIn = audio.Samples.Get("UI/wave-pop-in");
|
|
|
|
|
samplePopOut = audio.Samples.Get("UI/overlay-big-pop-out");
|
2023-08-24 17:13:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-04-15 15:44:40 +08:00
|
|
|
|
public WaveContainer()
|
|
|
|
|
{
|
|
|
|
|
Masking = true;
|
|
|
|
|
|
|
|
|
|
AddInternal(wavesContainer = new Container<Wave>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Masking = true,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
firstWave = new Wave
|
|
|
|
|
{
|
|
|
|
|
Rotation = 13,
|
|
|
|
|
FinalPosition = -930,
|
|
|
|
|
},
|
|
|
|
|
secondWave = new Wave
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Rotation = -7,
|
|
|
|
|
FinalPosition = -560,
|
|
|
|
|
},
|
|
|
|
|
thirdWave = new Wave
|
|
|
|
|
{
|
|
|
|
|
Rotation = 4,
|
|
|
|
|
FinalPosition = -390,
|
|
|
|
|
},
|
|
|
|
|
fourthWave = new Wave
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Rotation = -2,
|
|
|
|
|
FinalPosition = -220,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddInternal(contentContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-07-02 14:17:35 +08:00
|
|
|
|
RelativePositionAxes = Axes.Both,
|
2018-04-15 15:44:40 +08:00
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
2024-01-23 04:32:11 +08:00
|
|
|
|
foreach (var w in wavesContainer)
|
2019-06-11 13:28:52 +08:00
|
|
|
|
w.Show();
|
2018-04-15 15:44:40 +08:00
|
|
|
|
|
|
|
|
|
contentContainer.MoveToY(0, APPEAR_DURATION, Easing.OutQuint);
|
2023-08-24 17:13:23 +08:00
|
|
|
|
samplePopIn?.Play();
|
|
|
|
|
wasShown = true;
|
2018-04-15 15:44:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2024-01-23 04:32:11 +08:00
|
|
|
|
foreach (var w in wavesContainer)
|
2019-06-11 13:28:52 +08:00
|
|
|
|
w.Hide();
|
2018-04-15 15:44:40 +08:00
|
|
|
|
|
2019-07-02 14:17:35 +08:00
|
|
|
|
contentContainer.MoveToY(2, DISAPPEAR_DURATION, Easing.In);
|
2023-08-24 17:13:23 +08:00
|
|
|
|
|
|
|
|
|
if (wasShown)
|
|
|
|
|
samplePopOut?.Play();
|
2018-04-15 15:44:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
|
|
|
|
|
// This is done as an optimization, such that invisible parts of the waves
|
|
|
|
|
// are masked away, and thus do not consume fill rate.
|
2019-07-02 23:21:16 +08:00
|
|
|
|
// todo: revert https://github.com/ppy/osu/commit/aff9e3617da0c8fe252169fae287e39b44575b5e after FTB is fixed on iOS.
|
2019-07-02 21:33:33 +08:00
|
|
|
|
wavesContainer.Height = Math.Max(0, DrawHeight - (contentContainer.DrawHeight - contentContainer.Y * DrawHeight));
|
2018-04-15 15:44:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private partial class Wave : VisibilityContainer
|
|
|
|
|
{
|
|
|
|
|
public float FinalPosition;
|
|
|
|
|
|
|
|
|
|
protected override bool StartHidden => true;
|
|
|
|
|
|
|
|
|
|
public Wave()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Width = 1.5f;
|
|
|
|
|
Masking = true;
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(50),
|
|
|
|
|
Radius = 20f,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Child = new Box { RelativeSizeAxes = Axes.Both };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
|
|
|
|
|
|
|
|
|
// We can not use RelativeSizeAxes for Height, because the height
|
|
|
|
|
// of our parent diminishes as the content moves up.
|
2023-10-17 16:40:44 +08:00
|
|
|
|
Height = Parent!.Parent!.DrawSize.Y * 1.5f;
|
2018-04-15 15:44:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-18 15:13:01 +08:00
|
|
|
|
protected override void PopIn() => Schedule(() => this.MoveToY(FinalPosition, APPEAR_DURATION, easing_show));
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
|
|
|
|
double duration = IsLoaded ? DISAPPEAR_DURATION : 0;
|
|
|
|
|
|
|
|
|
|
// scheduling is required as parent may not be present at the time this is called.
|
2023-10-17 16:40:44 +08:00
|
|
|
|
Schedule(() => this.MoveToY(Parent!.Parent!.DrawSize.Y, duration, easing_hide));
|
2019-10-18 15:13:01 +08:00
|
|
|
|
}
|
2018-04-15 15:44:40 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|