mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Add Apply() method for applying new DHOs
This commit is contained in:
@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osuTK;
|
||||
|
||||
@ -21,6 +22,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
|
||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
private HoldNoteNoteSelectionBlueprint headBlueprint;
|
||||
private HoldNoteNoteSelectionBlueprint tailBlueprint;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
||||
@ -33,16 +37,11 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
private void load(IScrollingInfo scrollingInfo)
|
||||
{
|
||||
direction.BindTo(scrollingInfo.Direction);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new HoldNoteNoteSelectionBlueprint(HitObject, HoldNotePosition.Start),
|
||||
new HoldNoteNoteSelectionBlueprint(HitObject, HoldNotePosition.End),
|
||||
headBlueprint = new HoldNoteNoteSelectionBlueprint(HitObject, HoldNotePosition.Start),
|
||||
tailBlueprint = new HoldNoteNoteSelectionBlueprint(HitObject, HoldNotePosition.End),
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -59,6 +58,14 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
||||
};
|
||||
}
|
||||
|
||||
public override void Apply(DrawableHitObject drawableObject)
|
||||
{
|
||||
base.Apply(drawableObject);
|
||||
|
||||
headBlueprint?.Apply(drawableObject);
|
||||
tailBlueprint?.Apply(drawableObject);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
@ -14,6 +14,7 @@ using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit;
|
||||
@ -77,6 +78,14 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
|
||||
BodyPiece.UpdateFrom(HitObject);
|
||||
}
|
||||
|
||||
public override void Apply(DrawableHitObject drawableObject)
|
||||
{
|
||||
base.Apply(drawableObject);
|
||||
|
||||
HeadBlueprint?.Apply(drawableObject);
|
||||
TailBlueprint?.Apply(drawableObject);
|
||||
}
|
||||
|
||||
public override bool HandleQuickDeletion()
|
||||
{
|
||||
var hoveredControlPoint = ControlPointVisualiser?.Pieces.FirstOrDefault(p => p.IsHovered);
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <summary>
|
||||
/// The <see cref="DrawableHitObject"/> which this <see cref="HitObjectSelectionBlueprint"/> applies to.
|
||||
/// </summary>
|
||||
public DrawableHitObject DrawableObject { get; internal set; }
|
||||
public virtual DrawableHitObject DrawableObject { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the blueprint should be shown even when the <see cref="DrawableObject"/> is not alive.
|
||||
@ -28,6 +28,24 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
}
|
||||
|
||||
protected override void LoadAsyncComplete()
|
||||
{
|
||||
// Must be done before base.LoadAsyncComplete() as this may affect children.
|
||||
Apply(DrawableObject);
|
||||
|
||||
base.LoadAsyncComplete();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies a <see cref="DrawableHitObject"/> to this <see cref="HitObjectSelectionBlueprint"/>.
|
||||
/// The represented <see cref="HitObject"/> model does not change.
|
||||
/// </summary>
|
||||
/// <param name="drawableObject">The new <see cref="DrawableHitObject"/>.</param>
|
||||
public virtual void Apply(DrawableHitObject drawableObject)
|
||||
{
|
||||
DrawableObject = drawableObject;
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
public override Vector2 ScreenSpaceSelectionPoint => DrawableObject.ScreenSpaceDrawQuad.Centre;
|
||||
|
@ -245,7 +245,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
if (drawable == null)
|
||||
return null;
|
||||
|
||||
return CreateHitObjectBlueprintFor(item).With(b => b.DrawableObject = drawable);
|
||||
return CreateHitObjectBlueprintFor(item).With(b => b.Apply(drawable));
|
||||
}
|
||||
|
||||
public virtual HitObjectSelectionBlueprint CreateHitObjectBlueprintFor(HitObject hitObject) => null;
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
Add(blueprint.With(d =>
|
||||
{
|
||||
d.DrawableObject = drawableObject;
|
||||
d.Apply(drawableObject);
|
||||
d.Depth = float.MinValue;
|
||||
d.Select();
|
||||
}));
|
||||
|
Reference in New Issue
Block a user