mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 04:02:59 +08:00
Remove DI requirement for the Facade in PlayerLoader
This commit is contained in:
parent
3fe52be77f
commit
384eee3395
@ -93,7 +93,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
private class TestScreen : OsuScreen
|
private class TestScreen : OsuScreen
|
||||||
{
|
{
|
||||||
private TestFacadeContainer facadeContainer;
|
private TestFacadeContainer facadeContainer;
|
||||||
private FacadeFlowComponent facadeFlowComponent;
|
private Facade facadeFlowComponent;
|
||||||
private readonly bool randomPositions;
|
private readonly bool randomPositions;
|
||||||
|
|
||||||
public TestScreen(bool randomPositions = false)
|
public TestScreen(bool randomPositions = false)
|
||||||
@ -104,13 +104,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
InternalChild = facadeContainer = new TestFacadeContainer
|
InternalChild = facadeContainer = new TestFacadeContainer();
|
||||||
{
|
facadeContainer.Child = facadeFlowComponent = facadeContainer.Facade;
|
||||||
Child = facadeFlowComponent = new FacadeFlowComponent
|
|
||||||
{
|
|
||||||
AutoSizeAxes = Axes.Both
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
protected override void LogoArriving(OsuLogo logo, bool resuming)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
@ -18,19 +17,15 @@ namespace osu.Game.Graphics.Containers
|
|||||||
{
|
{
|
||||||
protected virtual Facade CreateFacade() => new Facade();
|
protected virtual Facade CreateFacade() => new Facade();
|
||||||
|
|
||||||
public Facade Facade => facade;
|
public readonly Facade Facade;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether or not the logo assigned to this FacadeContainer should be tracking the position its facade.
|
/// Whether or not the logo assigned to this FacadeContainer should be tracking the position its facade.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Tracking;
|
public bool Tracking;
|
||||||
|
|
||||||
[Cached]
|
|
||||||
private Facade facade;
|
|
||||||
|
|
||||||
private OsuLogo logo;
|
private OsuLogo logo;
|
||||||
private float facadeScale;
|
private float facadeScale;
|
||||||
|
|
||||||
private Vector2 startPosition;
|
private Vector2 startPosition;
|
||||||
private Easing easing;
|
private Easing easing;
|
||||||
private double startTime;
|
private double startTime;
|
||||||
@ -38,11 +33,11 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
public FacadeContainer()
|
public FacadeContainer()
|
||||||
{
|
{
|
||||||
facade = CreateFacade();
|
Facade = CreateFacade();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
/// <param name="logo"> The instance of the logo to be used for tracking. </param>
|
/// <param name="logo"> The instance of the logo to be used for tracking. </param>
|
||||||
/// <param name="facadeScale"> The scale of the facade. </param>
|
/// <param name="facadeScale"> The scale of the facade. </param>
|
||||||
@ -60,7 +55,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
this.easing = 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()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
@ -69,9 +64,9 @@ namespace osu.Game.Graphics.Containers
|
|||||||
if (logo == null || !Tracking)
|
if (logo == null || !Tracking)
|
||||||
return;
|
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
|
// Required for the correct position of the logo to be set with respect to logoTrackingPosition
|
||||||
logo.RelativePositionAxes = Axes.None;
|
logo.RelativePositionAxes = Axes.None;
|
||||||
|
@ -68,7 +68,7 @@ namespace osu.Game.Screens.Play
|
|||||||
facadeContainer.RelativeSizeAxes = Axes.Both;
|
facadeContainer.RelativeSizeAxes = Axes.Both;
|
||||||
facadeContainer.Children = new Drawable[]
|
facadeContainer.Children = new Drawable[]
|
||||||
{
|
{
|
||||||
info = new BeatmapMetadataDisplay(Beatmap.Value)
|
info = new BeatmapMetadataDisplay(Beatmap.Value, facadeContainer.Facade)
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -310,6 +310,7 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly WorkingBeatmap beatmap;
|
private readonly WorkingBeatmap beatmap;
|
||||||
|
private readonly Facade facade;
|
||||||
private LoadingAnimation loading;
|
private LoadingAnimation loading;
|
||||||
private Sprite backgroundSprite;
|
private Sprite backgroundSprite;
|
||||||
private ModDisplay modDisplay;
|
private ModDisplay modDisplay;
|
||||||
@ -331,13 +332,14 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeatmapMetadataDisplay(WorkingBeatmap beatmap)
|
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Facade facade)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
|
this.facade = facade;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(Facade facade)
|
private void load()
|
||||||
{
|
{
|
||||||
var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
|
var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user