1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:07:25 +08:00

Split out consumption and creation into two separate code paths

This commit is contained in:
Dean Herbert 2019-03-08 14:59:45 +09:00
parent 3ccc76e18f
commit 2c98ba1c0c
2 changed files with 25 additions and 3 deletions

View File

@ -10,6 +10,7 @@ using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables.Connections;
using osu.Game.Rulesets.UI;
using System.Linq;
using osu.Framework.Graphics.Cursor;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Osu.UI.Cursor;
@ -23,6 +24,12 @@ namespace osu.Game.Rulesets.Osu.UI
public static readonly Vector2 BASE_SIZE = new Vector2(512, 384);
private readonly PlayfieldAdjustmentContainer adjustmentContainer;
protected override Container CursorTargetContainer => adjustmentContainer;
protected override CursorContainer CreateCursor() => new GameplayCursorContainer();
public OsuPlayfield()
{
Anchor = Anchor.Centre;
@ -30,7 +37,7 @@ namespace osu.Game.Rulesets.Osu.UI
Size = new Vector2(0.75f);
InternalChild = new PlayfieldAdjustmentContainer
InternalChild = adjustmentContainer = new PlayfieldAdjustmentContainer
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
@ -51,7 +58,6 @@ namespace osu.Game.Rulesets.Osu.UI
RelativeSizeAxes = Axes.Both,
Depth = -1,
},
Cursor = new GameplayCursorContainer(),
}
};
}

View File

@ -56,6 +56,10 @@ namespace osu.Game.Rulesets.UI
RelativeSizeAxes = Axes.Both;
hitObjectContainerLazy = new Lazy<HitObjectContainer>(CreateHitObjectContainer);
Cursor = CreateCursor();
if (Cursor != null)
CursorTargetContainer.Add(Cursor);
}
private WorkingBeatmap beatmap;
@ -86,7 +90,19 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// The cursor currently being used by this <see cref="Playfield"/>. May be null if no cursor is provided.
/// </summary>
public CursorContainer Cursor { get; protected set; }
public CursorContainer Cursor { get; private set; }
/// <summary>
/// Provide an optional cursor which is to be used for gameplay.
/// If providing a cursor, <see cref="CursorTargetContainer"/> must also point to a valid target container.
/// </summary>
/// <returns>The cursor, or null if a cursor is not rqeuired.</returns>
protected virtual CursorContainer CreateCursor() => null;
/// <summary>
/// The target container to add the cursor after it is created.
/// </summary>
protected virtual Container CursorTargetContainer => null;
/// <summary>
/// Registers a <see cref="Playfield"/> as a nested <see cref="Playfield"/>.