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

Provide ruleset dependencies only to Compose Placement Blueprints

This commit is contained in:
Derrick Timmermans 2022-11-27 21:43:33 +01:00
parent 65e5c9a3ae
commit 70c320b2e8
No known key found for this signature in database
GPG Key ID: B1771434E9B3282C
11 changed files with 60 additions and 24 deletions

View File

@ -13,8 +13,8 @@ namespace osu.Game.Rulesets.Catch.Edit
{
public class CatchBlueprintContainer : ComposeBlueprintContainer
{
public CatchBlueprintContainer(CatchHitObjectComposer composer)
: base(composer)
public CatchBlueprintContainer(CatchHitObjectComposer composer, Ruleset ruleset)
: base(composer, ruleset)
{
}

View File

@ -148,7 +148,7 @@ namespace osu.Game.Rulesets.Catch.Edit
return result;
}
protected override ComposeBlueprintContainer CreateBlueprintContainer() => new CatchBlueprintContainer(this);
protected override ComposeBlueprintContainer CreateBlueprintContainer() => new CatchBlueprintContainer(this, Ruleset);
[CanBeNull]
private PalpableCatchHitObject getLastSnappableHitObject(double time)

View File

@ -13,8 +13,8 @@ namespace osu.Game.Rulesets.Mania.Edit
{
public class ManiaBlueprintContainer : ComposeBlueprintContainer
{
public ManiaBlueprintContainer(HitObjectComposer composer)
: base(composer)
public ManiaBlueprintContainer(HitObjectComposer composer, Ruleset ruleset)
: base(composer, ruleset)
{
}

View File

@ -68,7 +68,7 @@ namespace osu.Game.Rulesets.Mania.Edit
}
protected override ComposeBlueprintContainer CreateBlueprintContainer()
=> new ManiaBlueprintContainer(this);
=> new ManiaBlueprintContainer(this, Ruleset);
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]
{

View File

@ -15,8 +15,8 @@ namespace osu.Game.Rulesets.Osu.Edit
{
public class OsuBlueprintContainer : ComposeBlueprintContainer
{
public OsuBlueprintContainer(HitObjectComposer composer)
: base(composer)
public OsuBlueprintContainer(HitObjectComposer composer, Ruleset ruleset)
: base(composer, ruleset)
{
}

View File

@ -88,7 +88,7 @@ namespace osu.Game.Rulesets.Osu.Edit
}
protected override ComposeBlueprintContainer CreateBlueprintContainer()
=> new OsuBlueprintContainer(this);
=> new OsuBlueprintContainer(this, Ruleset);
public override string ConvertSelectionToString()
=> string.Join(',', selectedHitObjects.Cast<OsuHitObject>().OrderBy(h => h.StartTime).Select(h => (h.IndexInCurrentCombo + 1).ToString()));

View File

@ -12,8 +12,8 @@ namespace osu.Game.Rulesets.Taiko.Edit
{
public class TaikoBlueprintContainer : ComposeBlueprintContainer
{
public TaikoBlueprintContainer(HitObjectComposer composer)
: base(composer)
public TaikoBlueprintContainer(HitObjectComposer composer, Ruleset ruleset)
: base(composer, ruleset)
{
}

View File

@ -24,6 +24,6 @@ namespace osu.Game.Rulesets.Taiko.Edit
};
protected override ComposeBlueprintContainer CreateBlueprintContainer()
=> new TaikoBlueprintContainer(this);
=> new TaikoBlueprintContainer(this, Ruleset);
}
}

View File

@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Edit
protected readonly Ruleset Ruleset;
// Provides `Playfield`
private DrawableRulesetDependencies dependencies;
private DependencyContainer dependencies;
[Resolved]
protected EditorClock EditorClock { get; private set; }
@ -79,7 +79,7 @@ namespace osu.Game.Rulesets.Edit
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
dependencies = new DrawableRulesetDependencies(Ruleset, base.CreateChildDependencies(parent));
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
@ -218,7 +218,7 @@ namespace osu.Game.Rulesets.Edit
/// <summary>
/// Construct a relevant blueprint container. This will manage hitobject selection/placement input handling and display logic.
/// </summary>
protected virtual ComposeBlueprintContainer CreateBlueprintContainer() => new ComposeBlueprintContainer(this);
protected virtual ComposeBlueprintContainer CreateBlueprintContainer() => new ComposeBlueprintContainer( this, Ruleset);
/// <summary>
/// Construct a drawable ruleset for the provided ruleset.
@ -410,13 +410,6 @@ namespace osu.Game.Rulesets.Edit
}
#endregion
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
dependencies.Dispose();
}
}
/// <summary>

View File

@ -0,0 +1,34 @@
// 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;
namespace osu.Game.Rulesets.UI
{
public class DrawableRulesetDependenciesProvidingContainer : Container
{
private Ruleset ruleset;
private DrawableRulesetDependencies rulesetDependencies = null!;
public DrawableRulesetDependenciesProvidingContainer(Ruleset ruleset)
{
this.ruleset = ruleset;
RelativeSizeAxes = Axes.Both;
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
return rulesetDependencies = new DrawableRulesetDependencies(ruleset, base.CreateChildDependencies(parent));
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
rulesetDependencies?.Dispose();
}
}
}

View File

@ -15,11 +15,13 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Audio;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Edit.Components.TernaryButtons;
using osuTK;
using osuTK.Input;
@ -37,15 +39,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
private PlacementBlueprint currentPlacement;
private readonly Ruleset ruleset;
/// <remarks>
/// Positional input must be received outside the container's bounds,
/// in order to handle composer blueprints which are partially offscreen.
/// </remarks>
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public ComposeBlueprintContainer(HitObjectComposer composer)
public ComposeBlueprintContainer(HitObjectComposer composer, Ruleset ruleset)
: base(composer)
{
this.ruleset = ruleset;
placementBlueprintContainer = new Container<PlacementBlueprint>
{
RelativeSizeAxes = Axes.Both
@ -57,7 +63,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
TernaryStates = CreateTernaryButtons().ToArray();
AddInternal(placementBlueprintContainer);
AddInternal(new DrawableRulesetDependenciesProvidingContainer(ruleset)
{
Child = placementBlueprintContainer
});
}
protected override void LoadComplete()