1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 20:22:55 +08:00

Remove IPlayfieldProvider by caching Playfield

This commit is contained in:
ekrctb 2021-06-17 10:07:52 +09:00
parent 418dbf3f3e
commit 9dcd0bf311
4 changed files with 14 additions and 19 deletions

View File

@ -5,7 +5,6 @@ using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Beatmaps; using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
@ -14,13 +13,13 @@ using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Mania.Tests.Editor namespace osu.Game.Rulesets.Mania.Tests.Editor
{ {
[Cached(typeof(IPlayfieldProvider))] public abstract class ManiaSelectionBlueprintTestScene : SelectionBlueprintTestScene
public abstract class ManiaSelectionBlueprintTestScene : SelectionBlueprintTestScene, IPlayfieldProvider
{ {
protected override Container<Drawable> Content => blueprints ?? base.Content; protected override Container<Drawable> Content => blueprints ?? base.Content;
private readonly Container blueprints; private readonly Container blueprints;
[Cached(typeof(Playfield))]
public Playfield Playfield { get; } public Playfield Playfield { get; }
private readonly ScrollingTestContainer scrollingTestContainer; private readonly ScrollingTestContainer scrollingTestContainer;

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling; using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints namespace osu.Game.Rulesets.Mania.Edit.Blueprints
@ -14,12 +15,12 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
where T : ManiaHitObject where T : ManiaHitObject
{ {
[Resolved] [Resolved]
private IPlayfieldProvider playfieldProvider { get; set; } private Playfield playfield { get; set; }
[Resolved] [Resolved]
private IScrollingInfo scrollingInfo { get; set; } private IScrollingInfo scrollingInfo { get; set; }
protected ScrollingHitObjectContainer HitObjectContainer => ((ManiaPlayfield)playfieldProvider.Playfield).GetColumn(HitObject.Column).HitObjectContainer; protected ScrollingHitObjectContainer HitObjectContainer => ((ManiaPlayfield)playfield).GetColumn(HitObject.Column).HitObjectContainer;
protected ManiaSelectionBlueprint(T hitObject) protected ManiaSelectionBlueprint(T hitObject)
: base(hitObject) : base(hitObject)

View File

@ -43,6 +43,9 @@ namespace osu.Game.Rulesets.Edit
protected readonly Ruleset Ruleset; protected readonly Ruleset Ruleset;
// Provides `Playfield`
private DependencyContainer dependencies;
[Resolved] [Resolved]
protected EditorClock EditorClock { get; private set; } protected EditorClock EditorClock { get; private set; }
@ -69,6 +72,9 @@ namespace osu.Game.Rulesets.Edit
Ruleset = ruleset; Ruleset = ruleset;
} }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
@ -88,6 +94,8 @@ namespace osu.Game.Rulesets.Edit
return; return;
} }
dependencies.CacheAs(Playfield);
const float toolbar_width = 200; const float toolbar_width = 200;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
@ -415,8 +423,7 @@ namespace osu.Game.Rulesets.Edit
/// </summary> /// </summary>
[Cached(typeof(HitObjectComposer))] [Cached(typeof(HitObjectComposer))]
[Cached(typeof(IPositionSnapProvider))] [Cached(typeof(IPositionSnapProvider))]
[Cached(typeof(IPlayfieldProvider))] public abstract class HitObjectComposer : CompositeDrawable, IPositionSnapProvider
public abstract class HitObjectComposer : CompositeDrawable, IPositionSnapProvider, IPlayfieldProvider
{ {
protected HitObjectComposer() protected HitObjectComposer()
{ {

View File

@ -1,12 +0,0 @@
// 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.Game.Rulesets.UI;
namespace osu.Game.Rulesets.Edit
{
public interface IPlayfieldProvider
{
Playfield Playfield { get; }
}
}