1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 15:23:14 +08:00

Expose Ruleset from HitObjectComposer instead

This commit is contained in:
Derrick Timmermans 2022-11-30 12:17:58 +01:00
parent bb0237d4a9
commit 6a61e70766
No known key found for this signature in database
GPG Key ID: B1771434E9B3282C
11 changed files with 21 additions and 23 deletions

View File

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

View File

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

View File

@ -90,6 +90,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
public override bool CursorInPlacementArea => false; public override bool CursorInPlacementArea => false;
public TestHitObjectComposer(Playfield playfield) public TestHitObjectComposer(Playfield playfield)
: base(new ManiaRuleset())
{ {
Playfield = playfield; Playfield = playfield;
} }

View File

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

View File

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

View File

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

View File

@ -88,7 +88,7 @@ namespace osu.Game.Rulesets.Osu.Edit
} }
protected override ComposeBlueprintContainer CreateBlueprintContainer() protected override ComposeBlueprintContainer CreateBlueprintContainer()
=> new OsuBlueprintContainer(this, Ruleset); => new OsuBlueprintContainer(this);
public override string ConvertSelectionToString() public override string ConvertSelectionToString()
=> string.Join(',', selectedHitObjects.Cast<OsuHitObject>().OrderBy(h => h.StartTime).Select(h => (h.IndexInCurrentCombo + 1).ToString())); => 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 partial class TaikoBlueprintContainer : ComposeBlueprintContainer public partial class TaikoBlueprintContainer : ComposeBlueprintContainer
{ {
public TaikoBlueprintContainer(HitObjectComposer composer, Ruleset ruleset) public TaikoBlueprintContainer(HitObjectComposer composer)
: base(composer, ruleset) : base(composer)
{ {
} }

View File

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

View File

@ -45,8 +45,6 @@ namespace osu.Game.Rulesets.Edit
{ {
protected IRulesetConfigManager Config { get; private set; } protected IRulesetConfigManager Config { get; private set; }
protected readonly Ruleset Ruleset;
// Provides `Playfield` // Provides `Playfield`
private DependencyContainer dependencies; private DependencyContainer dependencies;
@ -74,8 +72,8 @@ namespace osu.Game.Rulesets.Edit
private IBindable<bool> hasTiming; private IBindable<bool> hasTiming;
protected HitObjectComposer(Ruleset ruleset) protected HitObjectComposer(Ruleset ruleset)
: base(ruleset)
{ {
Ruleset = ruleset;
} }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) => protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) =>
@ -218,7 +216,7 @@ namespace osu.Game.Rulesets.Edit
/// <summary> /// <summary>
/// Construct a relevant blueprint container. This will manage hitobject selection/placement input handling and display logic. /// Construct a relevant blueprint container. This will manage hitobject selection/placement input handling and display logic.
/// </summary> /// </summary>
protected virtual ComposeBlueprintContainer CreateBlueprintContainer() => new ComposeBlueprintContainer(this, Ruleset); protected virtual ComposeBlueprintContainer CreateBlueprintContainer() => new ComposeBlueprintContainer(this);
/// <summary> /// <summary>
/// Construct a drawable ruleset for the provided ruleset. /// Construct a drawable ruleset for the provided ruleset.
@ -419,8 +417,11 @@ namespace osu.Game.Rulesets.Edit
[Cached] [Cached]
public abstract partial class HitObjectComposer : CompositeDrawable, IPositionSnapProvider public abstract partial class HitObjectComposer : CompositeDrawable, IPositionSnapProvider
{ {
protected HitObjectComposer() public readonly Ruleset Ruleset;
protected HitObjectComposer(Ruleset ruleset)
{ {
Ruleset = ruleset;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }

View File

@ -15,7 +15,6 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
@ -39,7 +38,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
private PlacementBlueprint currentPlacement; private PlacementBlueprint currentPlacement;
private readonly Ruleset ruleset;
/// <remarks> /// <remarks>
/// Positional input must be received outside the container's bounds, /// Positional input must be received outside the container's bounds,
@ -47,11 +45,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </remarks> /// </remarks>
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public ComposeBlueprintContainer(HitObjectComposer composer, Ruleset ruleset) public ComposeBlueprintContainer(HitObjectComposer composer)
: base(composer) : base(composer)
{ {
this.ruleset = ruleset;
placementBlueprintContainer = new Container<PlacementBlueprint> placementBlueprintContainer = new Container<PlacementBlueprint>
{ {
RelativeSizeAxes = Axes.Both RelativeSizeAxes = Axes.Both
@ -63,7 +59,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
{ {
TernaryStates = CreateTernaryButtons().ToArray(); TernaryStates = CreateTernaryButtons().ToArray();
AddInternal(new DrawableRulesetDependenciesProvidingContainer(ruleset) AddInternal(new DrawableRulesetDependenciesProvidingContainer(Composer.Ruleset)
{ {
Child = placementBlueprintContainer Child = placementBlueprintContainer
}); });