Initial implementation

This commit is contained in:
David Zhao
2019-03-22 20:01:58 +09:00
parent e93311fdc9
commit 6e98a8dd7c
3 changed files with 67 additions and 9 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Screens.Menu;
using osuTK;
@ -13,14 +14,62 @@ namespace osu.Game.Graphics.Containers
[Cached]
private Facade facade;
private OsuLogo logo;
private bool tracking;
private bool smoothTransform;
public FacadeContainer()
{
facade = new Facade();
}
public void SetLogo(OsuLogo logo)
private Vector2 logoTrackingPosition => logo.Parent.ToLocalSpace(facade.ScreenSpaceDrawQuad.Centre);
public void SetLogo(OsuLogo logo, bool resuming, double transformDelay)
{
facade.Size = new Vector2(logo.SizeForFlow);
if (logo != null)
{
facade.Size = new Vector2(logo.SizeForFlow * 0.3f);
this.logo = logo;
Scheduler.AddDelayed(() =>
{
tracking = true;
smoothTransform = !resuming;
}, transformDelay);
}
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
facade.Size = new Vector2(logo.SizeForFlow * 0.3f);
if (!tracking)
return;
logo.RelativePositionAxes = Axes.None;
bool childrenLoaded = true;
foreach (var d in Children)
{
if (!d.IsAlive)
childrenLoaded = false;
}
if (smoothTransform && childrenLoaded)
{
// Our initial movement to the tracking location should be smooth.
Schedule(() => logo.MoveTo(logoTrackingPosition, 500, Easing.InOutExpo));
smoothTransform = false;
}
else if (logo.Transforms.Count == 0)
{
// If all transforms have finished playing, the logo constantly track the position of the facade.
logo.Position = logoTrackingPosition;
}
}
}