2017-02-23 02:16:23 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2017-02-18 11:28:22 +00:00
|
|
|
|
using OpenTK.Graphics;
|
2017-03-04 18:42:37 +00:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-02-18 11:28:22 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-03-03 19:42:03 +00:00
|
|
|
|
using System;
|
2017-06-20 05:54:23 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-06-28 17:18:12 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2017-02-18 11:28:22 +00:00
|
|
|
|
|
2017-02-23 02:16:23 +00:00
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2017-06-28 17:18:12 +00:00
|
|
|
|
public abstract class WaveOverlayContainer : OsuFocusedOverlayContainer
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
2017-02-23 03:47:20 +00:00
|
|
|
|
protected const float APPEAR_DURATION = 800;
|
|
|
|
|
protected const float DISAPPEAR_DURATION = 500;
|
2017-02-23 03:17:59 +00:00
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
private const Easing easing_show = Easing.OutSine;
|
|
|
|
|
private const Easing easing_hide = Easing.InSine;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly Wave firstWave;
|
|
|
|
|
private readonly Wave secondWave;
|
|
|
|
|
private readonly Wave thirdWave;
|
|
|
|
|
private readonly Wave fourthWave;
|
2017-02-23 02:26:50 +00:00
|
|
|
|
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly Container<Wave> wavesContainer;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
|
|
|
|
|
private readonly Container contentContainer;
|
2017-02-23 03:42:31 +00:00
|
|
|
|
|
2017-12-21 10:34:20 +00:00
|
|
|
|
protected override bool BlockPassThroughKeyboard => true;
|
|
|
|
|
|
2017-02-23 02:16:23 +00:00
|
|
|
|
protected override Container<Drawable> Content => contentContainer;
|
|
|
|
|
|
2017-02-23 03:48:24 +00:00
|
|
|
|
protected Color4 FirstWaveColour
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
return firstWave.Colour;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
if (firstWave.Colour == value) return;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
firstWave.Colour = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 03:48:24 +00:00
|
|
|
|
protected Color4 SecondWaveColour
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
return secondWave.Colour;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
if (secondWave.Colour == value) return;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
secondWave.Colour = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 03:48:24 +00:00
|
|
|
|
protected Color4 ThirdWaveColour
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
return thirdWave.Colour;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
if (thirdWave.Colour == value) return;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
thirdWave.Colour = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 03:48:24 +00:00
|
|
|
|
protected Color4 FourthWaveColour
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
return fourthWave.Colour;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
if (fourthWave.Colour == value) return;
|
2017-02-23 02:16:23 +00:00
|
|
|
|
fourthWave.Colour = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 03:48:24 +00:00
|
|
|
|
protected WaveOverlayContainer()
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
|
|
|
|
Masking = true;
|
|
|
|
|
|
2017-02-23 02:26:50 +00:00
|
|
|
|
AddInternal(wavesContainer = new Container<Wave>
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
2017-03-03 19:42:03 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-02-23 02:16:23 +00:00
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
2017-03-03 19:42:03 +00:00
|
|
|
|
Masking = true,
|
2017-02-23 03:17:59 +00:00
|
|
|
|
Children = new[]
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
2017-02-23 02:22:01 +00:00
|
|
|
|
firstWave = new Wave
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
Rotation = 13,
|
2017-02-23 03:42:31 +00:00
|
|
|
|
FinalPosition = -930,
|
2017-02-23 02:16:23 +00:00
|
|
|
|
},
|
2017-02-23 02:22:01 +00:00
|
|
|
|
secondWave = new Wave
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Anchor = Anchor.TopRight,
|
2017-02-23 03:17:59 +00:00
|
|
|
|
Rotation = -7,
|
2017-02-23 03:42:31 +00:00
|
|
|
|
FinalPosition = -560,
|
2017-02-23 02:16:23 +00:00
|
|
|
|
},
|
2017-02-23 02:22:01 +00:00
|
|
|
|
thirdWave = new Wave
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
Rotation = 4,
|
2017-02-23 03:42:31 +00:00
|
|
|
|
FinalPosition = -390,
|
2017-02-23 02:16:23 +00:00
|
|
|
|
},
|
2017-02-23 02:22:01 +00:00
|
|
|
|
fourthWave = new Wave
|
2017-02-23 02:16:23 +00:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Anchor = Anchor.TopRight,
|
2017-02-23 03:17:59 +00:00
|
|
|
|
Rotation = -2,
|
2017-02-23 03:42:31 +00:00
|
|
|
|
FinalPosition = -220,
|
2017-02-23 02:16:23 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddInternal(contentContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
});
|
2017-02-23 02:22:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 03:42:31 +00:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
2017-03-03 22:05:43 +00:00
|
|
|
|
base.PopIn();
|
|
|
|
|
|
2017-02-23 03:42:31 +00:00
|
|
|
|
foreach (var w in wavesContainer.Children)
|
|
|
|
|
w.State = Visibility.Visible;
|
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
this.FadeIn(100, Easing.OutQuint);
|
|
|
|
|
contentContainer.MoveToY(0, APPEAR_DURATION, Easing.OutQuint);
|
2017-03-04 10:02:13 +00:00
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
this.FadeIn(100, Easing.OutQuint);
|
2017-02-23 03:42:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2017-03-03 22:05:43 +00:00
|
|
|
|
base.PopOut();
|
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
this.FadeOut(DISAPPEAR_DURATION, Easing.InQuint);
|
|
|
|
|
contentContainer.MoveToY(DrawHeight * 2f, DISAPPEAR_DURATION, Easing.In);
|
2017-02-23 03:42:31 +00:00
|
|
|
|
|
|
|
|
|
foreach (var w in wavesContainer.Children)
|
|
|
|
|
w.State = Visibility.Hidden;
|
2017-03-04 10:02:13 +00:00
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
this.FadeOut(DISAPPEAR_DURATION, Easing.InQuint);
|
2017-02-23 03:42:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-03 19:42:03 +00: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.
|
|
|
|
|
wavesContainer.Height = Math.Max(0, DrawHeight - (contentContainer.DrawHeight - contentContainer.Y));
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-28 11:20:19 +00:00
|
|
|
|
private class Wave : VisibilityContainer
|
2017-02-23 02:22:01 +00:00
|
|
|
|
{
|
2017-02-23 03:17:59 +00:00
|
|
|
|
public float FinalPosition;
|
|
|
|
|
|
2017-10-24 08:09:06 +00:00
|
|
|
|
protected override bool StartHidden => true;
|
|
|
|
|
|
2017-02-23 02:22:01 +00:00
|
|
|
|
public Wave()
|
|
|
|
|
{
|
2017-03-03 19:42:03 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Width = 1.5f;
|
2017-02-23 02:22:01 +00:00
|
|
|
|
Masking = true;
|
2017-06-12 03:48:47 +00:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2017-02-23 02:22:01 +00:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(50),
|
|
|
|
|
Radius = 20f,
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-28 11:20:19 +00:00
|
|
|
|
Child = new Box { RelativeSizeAxes = Axes.Both };
|
2017-02-23 02:22:01 +00:00
|
|
|
|
}
|
2017-02-23 03:17:59 +00:00
|
|
|
|
|
2017-03-03 19:42:03 +00:00
|
|
|
|
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.
|
|
|
|
|
Height = Parent.Parent.DrawSize.Y * 1.5f;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-28 11:20:19 +00:00
|
|
|
|
protected override void PopIn() => this.MoveToY(FinalPosition, APPEAR_DURATION, easing_show);
|
|
|
|
|
protected override void PopOut() => this.MoveToY(Parent.Parent.DrawSize.Y, DISAPPEAR_DURATION, easing_hide);
|
2017-02-23 02:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|