1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 01:02:54 +08:00

Remove non-generic DrawableEditRuleset

This commit is contained in:
smoogipoo 2019-08-29 18:12:29 +09:00
parent 59296d12f3
commit 87e28ab1f9
3 changed files with 23 additions and 36 deletions

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mania.Edit
[Cached(Type = typeof(IManiaHitObjectComposer))] [Cached(Type = typeof(IManiaHitObjectComposer))]
public class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>, IManiaHitObjectComposer public class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>, IManiaHitObjectComposer
{ {
protected new DrawableManiaEditRuleset DrawableRuleset { get; private set; } private DrawableManiaEditRuleset drawableRuleset;
public ManiaHitObjectComposer(Ruleset ruleset) public ManiaHitObjectComposer(Ruleset ruleset)
: base(ruleset) : base(ruleset)
@ -33,23 +33,23 @@ namespace osu.Game.Rulesets.Mania.Edit
/// </summary> /// </summary>
/// <param name="screenSpacePosition">The screen-space position.</param> /// <param name="screenSpacePosition">The screen-space position.</param>
/// <returns>The column which intersects with <paramref name="screenSpacePosition"/>.</returns> /// <returns>The column which intersects with <paramref name="screenSpacePosition"/>.</returns>
public Column ColumnAt(Vector2 screenSpacePosition) => DrawableRuleset.GetColumnByPosition(screenSpacePosition); public Column ColumnAt(Vector2 screenSpacePosition) => drawableRuleset.GetColumnByPosition(screenSpacePosition);
private DependencyContainer dependencies; private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(base.CreateChildDependencies(parent)); => dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
public int TotalColumns => ((ManiaPlayfield)DrawableRuleset.Playfield).TotalColumns; public int TotalColumns => ((ManiaPlayfield)drawableRuleset.Playfield).TotalColumns;
protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods) protected override DrawableRuleset<ManiaHitObject> CreateDrawableRuleset(Ruleset ruleset, WorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
{ {
DrawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods); drawableRuleset = new DrawableManiaEditRuleset(ruleset, beatmap, mods);
// This is the earliest we can cache the scrolling info to ourselves, before masks are added to the hierarchy and inject it // This is the earliest we can cache the scrolling info to ourselves, before masks are added to the hierarchy and inject it
dependencies.CacheAs(DrawableRuleset.ScrollingInfo); dependencies.CacheAs(drawableRuleset.ScrollingInfo);
return DrawableRuleset; return drawableRuleset;
} }
protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[] protected override IReadOnlyList<HitObjectCompositionTool> CompositionTools => new HitObjectCompositionTool[]

View File

@ -11,27 +11,10 @@ using osu.Game.Screens.Edit;
namespace osu.Game.Rulesets.Edit namespace osu.Game.Rulesets.Edit
{ {
public abstract class DrawableEditRuleset : CompositeDrawable public class DrawableEditRuleset<TObject> : CompositeDrawable
{
/// <summary>
/// The <see cref="Playfield"/> contained by this <see cref="DrawableEditRuleset"/>.
/// </summary>
public abstract Playfield Playfield { get; }
public abstract PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer();
internal DrawableEditRuleset()
{
RelativeSizeAxes = Axes.Both;
}
}
public class DrawableEditRuleset<TObject> : DrawableEditRuleset
where TObject : HitObject where TObject : HitObject
{ {
public override Playfield Playfield => drawableRuleset.Playfield; public Playfield Playfield => drawableRuleset.Playfield;
public override PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => drawableRuleset.CreatePlayfieldAdjustmentContainer();
private readonly DrawableRuleset<TObject> drawableRuleset; private readonly DrawableRuleset<TObject> drawableRuleset;
@ -42,6 +25,8 @@ namespace osu.Game.Rulesets.Edit
{ {
this.drawableRuleset = drawableRuleset; this.drawableRuleset = drawableRuleset;
RelativeSizeAxes = Axes.Both;
InternalChild = drawableRuleset; InternalChild = drawableRuleset;
} }
@ -76,6 +61,8 @@ namespace osu.Game.Rulesets.Edit
drawableRuleset.Playfield.PostProcess(); drawableRuleset.Playfield.PostProcess();
} }
public PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => drawableRuleset.CreatePlayfieldAdjustmentContainer();
protected override void Dispose(bool isDisposing) protected override void Dispose(bool isDisposing)
{ {
base.Dispose(isDisposing); base.Dispose(isDisposing);

View File

@ -30,7 +30,6 @@ namespace osu.Game.Rulesets.Edit
where TObject : HitObject where TObject : HitObject
{ {
protected IRulesetConfigManager Config { get; private set; } protected IRulesetConfigManager Config { get; private set; }
protected DrawableEditRuleset DrawableRuleset { get; private set; }
protected readonly Ruleset Ruleset; protected readonly Ruleset Ruleset;
@ -39,6 +38,7 @@ namespace osu.Game.Rulesets.Edit
private EditorBeatmap<TObject> editorBeatmap; private EditorBeatmap<TObject> editorBeatmap;
private IBeatmapProcessor beatmapProcessor; private IBeatmapProcessor beatmapProcessor;
private DrawableEditRuleset<TObject> drawableRuleset;
private BlueprintContainer blueprintContainer; private BlueprintContainer blueprintContainer;
private readonly List<Container> layerContainers = new List<Container>(); private readonly List<Container> layerContainers = new List<Container>();
@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Edit
{ {
try try
{ {
DrawableRuleset = new DrawableEditRuleset<TObject>(CreateDrawableRuleset(Ruleset, workingBeatmap.Value, Array.Empty<Mod>())) drawableRuleset = new DrawableEditRuleset<TObject>(CreateDrawableRuleset(Ruleset, workingBeatmap.Value, Array.Empty<Mod>()))
{ {
Clock = framedClock Clock = framedClock
}; };
@ -66,10 +66,10 @@ namespace osu.Game.Rulesets.Edit
return; return;
} }
var layerBelowRuleset = DrawableRuleset.CreatePlayfieldAdjustmentContainer(); var layerBelowRuleset = drawableRuleset.CreatePlayfieldAdjustmentContainer();
layerBelowRuleset.Child = new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both }; layerBelowRuleset.Child = new EditorPlayfieldBorder { RelativeSizeAxes = Axes.Both };
var layerAboveRuleset = DrawableRuleset.CreatePlayfieldAdjustmentContainer(); var layerAboveRuleset = drawableRuleset.CreatePlayfieldAdjustmentContainer();
layerAboveRuleset.Child = blueprintContainer = new BlueprintContainer(); layerAboveRuleset.Child = blueprintContainer = new BlueprintContainer();
layerContainers.Add(layerBelowRuleset); layerContainers.Add(layerBelowRuleset);
@ -100,7 +100,7 @@ namespace osu.Game.Rulesets.Edit
Children = new Drawable[] Children = new Drawable[]
{ {
layerBelowRuleset, layerBelowRuleset,
DrawableRuleset, drawableRuleset,
layerAboveRuleset layerAboveRuleset
} }
} }
@ -153,10 +153,10 @@ namespace osu.Game.Rulesets.Edit
layerContainers.ForEach(l => layerContainers.ForEach(l =>
{ {
l.Anchor = DrawableRuleset.Playfield.Anchor; l.Anchor = drawableRuleset.Playfield.Anchor;
l.Origin = DrawableRuleset.Playfield.Origin; l.Origin = drawableRuleset.Playfield.Origin;
l.Position = DrawableRuleset.Playfield.Position; l.Position = drawableRuleset.Playfield.Position;
l.Size = DrawableRuleset.Playfield.Size; l.Size = drawableRuleset.Playfield.Size;
}); });
} }
@ -173,8 +173,8 @@ namespace osu.Game.Rulesets.Edit
beatmapProcessor?.PostProcess(); beatmapProcessor?.PostProcess();
} }
public override IEnumerable<DrawableHitObject> HitObjects => DrawableRuleset.Playfield.AllHitObjects; public override IEnumerable<DrawableHitObject> HitObjects => drawableRuleset.Playfield.AllHitObjects;
public override bool CursorInPlacementArea => DrawableRuleset.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position); public override bool CursorInPlacementArea => drawableRuleset.Playfield.ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position);
protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; } protected abstract IReadOnlyList<HitObjectCompositionTool> CompositionTools { get; }