DI facade

This commit is contained in:
David Zhao 2019-03-22 19:01:32 +09:00
parent 4fa6afdb1f
commit e93311fdc9
2 changed files with 40 additions and 4 deletions

View File

@ -0,0 +1,30 @@
// 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.Containers;
using osu.Game.Screens.Menu;
using osuTK;
namespace osu.Game.Graphics.Containers
{
public class FacadeContainer : Container
{
[Cached]
private Facade facade;
public FacadeContainer()
{
facade = new Facade();
}
public void SetLogo(OsuLogo logo)
{
facade.Size = new Vector2(logo.SizeForFlow);
}
}
public class Facade : Container
{
}
}

View File

@ -14,6 +14,7 @@ using osu.Framework.Screens;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Menu; using osu.Game.Screens.Menu;
@ -32,7 +33,7 @@ namespace osu.Game.Screens.Play
private Player player; private Player player;
private Container content; private FacadeContainer content;
private BeatmapMetadataDisplay info; private BeatmapMetadataDisplay info;
@ -59,7 +60,7 @@ namespace osu.Game.Screens.Play
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
InternalChild = content = new Container InternalChild = content = new FacadeContainer
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -153,6 +154,8 @@ namespace osu.Game.Screens.Play
logo.FadeIn(350); logo.FadeIn(350);
logo.Delay(resuming ? 0 : 500).MoveToOffset(new Vector2(0, -0.24f), 500, Easing.InOutExpo); logo.Delay(resuming ? 0 : 500).MoveToOffset(new Vector2(0, -0.24f), 500, Easing.InOutExpo);
content.SetLogo(logo);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -302,6 +305,8 @@ namespace osu.Game.Screens.Play
private LoadingAnimation loading; private LoadingAnimation loading;
private Sprite backgroundSprite; private Sprite backgroundSprite;
private ModDisplay modDisplay; private ModDisplay modDisplay;
private FillFlowContainer fillFlowContainer;
private FacadeContainer facadeContainer;
public bool Loading public bool Loading
{ {
@ -326,14 +331,14 @@ namespace osu.Game.Screens.Play
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(Facade facade)
{ {
var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata(); var metadata = beatmap.BeatmapInfo?.Metadata ?? new BeatmapMetadata();
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Children = new Drawable[] Children = new Drawable[]
{ {
new FillFlowContainer fillFlowContainer = new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
@ -341,6 +346,7 @@ namespace osu.Game.Screens.Play
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Children = new Drawable[]
{ {
facade,
new OsuSpriteText new OsuSpriteText
{ {
Text = new LocalisedString((metadata.TitleUnicode, metadata.Title)), Text = new LocalisedString((metadata.TitleUnicode, metadata.Title)),