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

@ -7,7 +7,9 @@ using osu.Framework.Graphics;
using osu.Framework.Screens; using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Screens; using osu.Game.Screens;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osuTK;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
{ {
@ -16,6 +18,9 @@ namespace osu.Game.Tests.Visual
private PlayerLoader loader; private PlayerLoader loader;
private readonly ScreenStack stack; private readonly ScreenStack stack;
[Cached]
private OsuLogo logo;
[Cached] [Cached]
private BackgroundScreenStack backgroundStack; private BackgroundScreenStack backgroundStack;
@ -23,6 +28,7 @@ namespace osu.Game.Tests.Visual
{ {
InputManager.Add(backgroundStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both }); InputManager.Add(backgroundStack = new BackgroundScreenStack { RelativeSizeAxes = Axes.Both });
InputManager.Add(stack = new ScreenStack { RelativeSizeAxes = Axes.Both }); InputManager.Add(stack = new ScreenStack { RelativeSizeAxes = Axes.Both });
InputManager.Add(logo = new OsuLogo());
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
@ -30,6 +36,8 @@ namespace osu.Game.Tests.Visual
{ {
Beatmap.Value = new DummyWorkingBeatmap(game); Beatmap.Value = new DummyWorkingBeatmap(game);
AddStep("Reset logo position", () => logo = new OsuLogo { Position = new Vector2(0, 0) });
AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player AddStep("load dummy beatmap", () => stack.Push(loader = new PlayerLoader(() => new Player
{ {
AllowPause = false, AllowPause = false,
@ -57,8 +65,6 @@ namespace osu.Game.Tests.Visual
AllowLeadIn = false, AllowLeadIn = false,
AllowResults = false, AllowResults = false,
})); }));
Scheduler.AddDelayed(() => slow.Ready = true, 5000);
}); });
AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen()); AddUntilStep("wait for no longer current", () => !loader.IsCurrentScreen());

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
using osuTK; using osuTK;
@ -13,14 +14,62 @@ namespace osu.Game.Graphics.Containers
[Cached] [Cached]
private Facade facade; private Facade facade;
private OsuLogo logo;
private bool tracking;
private bool smoothTransform;
public FacadeContainer() public FacadeContainer()
{ {
facade = new Facade(); 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;
}
} }
} }

View File

@ -149,13 +149,13 @@ namespace osu.Game.Screens.Play
{ {
base.LogoArriving(logo, resuming); base.LogoArriving(logo, resuming);
logo.ScaleTo(new Vector2(0.15f), 300, Easing.In); const double duration = 300;
logo.MoveTo(new Vector2(0.5f), 300, Easing.In);
logo.ScaleTo(new Vector2(0.15f), duration, Easing.In);
logo.MoveTo(new Vector2(0.5f), duration, Easing.In);
logo.FadeIn(350); logo.FadeIn(350);
logo.Delay(resuming ? 0 : 500).MoveToOffset(new Vector2(0, -0.24f), 500, Easing.InOutExpo); content.SetLogo(logo, resuming, duration);
content.SetLogo(logo);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -335,6 +335,9 @@ namespace osu.Game.Screens.Play
{ {
var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata(); var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
facade.Anchor = Anchor.TopCentre;
facade.Origin = Anchor.TopCentre;
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Children = new Drawable[] Children = new Drawable[]
{ {