Remove DI requirement for the Facade in PlayerLoader

This commit is contained in:
David Zhao 2019-03-27 11:32:26 +09:00
parent 3fe52be77f
commit 384eee3395
3 changed files with 14 additions and 22 deletions

View File

@ -93,7 +93,7 @@ private class TestFacadeContainer : FacadeContainer
private class TestScreen : OsuScreen
{
private TestFacadeContainer facadeContainer;
private FacadeFlowComponent facadeFlowComponent;
private Facade facadeFlowComponent;
private readonly bool randomPositions;
public TestScreen(bool randomPositions = false)
@ -104,13 +104,8 @@ public TestScreen(bool randomPositions = false)
[BackgroundDependencyLoader]
private void load()
{
InternalChild = facadeContainer = new TestFacadeContainer
{
Child = facadeFlowComponent = new FacadeFlowComponent
{
AutoSizeAxes = Axes.Both
}
};
InternalChild = facadeContainer = new TestFacadeContainer();
facadeContainer.Child = facadeFlowComponent = facadeContainer.Facade;
}
protected override void LogoArriving(OsuLogo logo, bool resuming)

View File

@ -1,7 +1,6 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.MathUtils;
@ -18,19 +17,15 @@ public class FacadeContainer : Container
{
protected virtual Facade CreateFacade() => new Facade();
public Facade Facade => facade;
public readonly Facade Facade;
/// <summary>
/// Whether or not the logo assigned to this FacadeContainer should be tracking the position its facade.
/// </summary>
public bool Tracking;
[Cached]
private Facade facade;
private OsuLogo logo;
private float facadeScale;
private Vector2 startPosition;
private Easing easing;
private double startTime;
@ -38,11 +33,11 @@ public class FacadeContainer : Container
public FacadeContainer()
{
facade = CreateFacade();
Facade = CreateFacade();
}
/// <summary>
/// Set the logo that should track the Facade's position, as well as how it should transform to its initial position.
/// Assign the logo that should track the Facade's position, as well as how it should transform to its initial position.
/// </summary>
/// <param name="logo"> The instance of the logo to be used for tracking. </param>
/// <param name="facadeScale"> The scale of the facade. </param>
@ -60,7 +55,7 @@ public void SetLogo(OsuLogo logo, float facadeScale, double duration = 0, Easing
this.easing = easing;
}
private Vector2 logoTrackingPosition => logo.Parent.ToLocalSpace(facade.ScreenSpaceDrawQuad.Centre);
private Vector2 logoTrackingPosition => logo.Parent.ToLocalSpace(Facade.ScreenSpaceDrawQuad.Centre);
protected override void UpdateAfterChildren()
{
@ -69,9 +64,9 @@ protected override void UpdateAfterChildren()
if (logo == null || !Tracking)
return;
facade.Size = new Vector2(logo.SizeForFlow * facadeScale);
Facade.Size = new Vector2(logo.SizeForFlow * facadeScale);
if (facade.IsLoaded && logo.Position != logoTrackingPosition)
if (Facade.IsLoaded && logo.Position != logoTrackingPosition)
{
// Required for the correct position of the logo to be set with respect to logoTrackingPosition
logo.RelativePositionAxes = Axes.None;

View File

@ -68,7 +68,7 @@ private void load()
facadeContainer.RelativeSizeAxes = Axes.Both;
facadeContainer.Children = new Drawable[]
{
info = new BeatmapMetadataDisplay(Beatmap.Value)
info = new BeatmapMetadataDisplay(Beatmap.Value, facadeContainer.Facade)
{
Alpha = 0,
Anchor = Anchor.Centre,
@ -310,6 +310,7 @@ public MetadataLine(string left, string right)
}
private readonly WorkingBeatmap beatmap;
private readonly Facade facade;
private LoadingAnimation loading;
private Sprite backgroundSprite;
private ModDisplay modDisplay;
@ -331,13 +332,14 @@ public bool Loading
}
}
public BeatmapMetadataDisplay(WorkingBeatmap beatmap)
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Facade facade)
{
this.beatmap = beatmap;
this.facade = facade;
}
[BackgroundDependencyLoader]
private void load(Facade facade)
private void load()
{
var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata();