Skip to content

Commit

Permalink
Add SlideSelectionBlueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed May 1, 2021
1 parent 2247a65 commit 8265d02
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Sentakki.Edit.Blueprints.Taps;
using osu.Game.Rulesets.Sentakki.Objects.Drawables;
using osu.Game.Rulesets.Sentakki.UI;
using osuTK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects.Drawables;

namespace osu.Game.Rulesets.Sentakki.Edit.Blueprints.Taps
namespace osu.Game.Rulesets.Sentakki.Edit.Blueprints
{
public class SentakkiSelectionBlueprint : OverlaySelectionBlueprint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Microsoft.EntityFrameworkCore.Internal;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Lines;
using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Sentakki.UI;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Sentakki.Edit.Blueprints.Slides
{
public class SlideBodyHighlight : CompositeDrawable
{
public readonly SlideEditPath Path;

// This drawable is zero width
// We should use the quad of the note container
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Path.ReceivePositionalInputAt(screenSpacePos);
public override Quad ScreenSpaceDrawQuad => Path.ScreenSpaceDrawQuad.AABBFloat;

public SlideBodyHighlight()
{
Anchor = Origin = Anchor.Centre;
Colour = Color4.YellowGreen;
Alpha = 0.5f;
InternalChildren = new Drawable[]
{
Path = new SlideEditPath()
};
}

public class SlideEditPath : SmoothPath
{
public override Vector2 OriginPosition => Vertices.Any() ? PositionInBoundingBox(Vertices[0]) : base.OriginPosition;

public SlideEditPath()
{
PathRadius = 25;
Position = SentakkiExtensions.GetPositionAlongLane(SentakkiPlayfield.INTERSECTDISTANCE, 0);
}

protected override Color4 ColourAt(float position) => position <= .2f ? Color4.White : Color4.Transparent;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Sentakki.Objects.Drawables;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces;
using osu.Game.Rulesets.Sentakki.UI;
using osuTK;

namespace osu.Game.Rulesets.Sentakki.Edit.Blueprints.Slides
{
public class SlideSelectionBlueprint : SentakkiSelectionBlueprint
{
public new DrawableSlide DrawableObject => (DrawableSlide)base.DrawableObject;

private readonly SlideStarHighlight starHighlight;
private readonly SlideBodyHighlight bodyHighlight;


public SlideSelectionBlueprint(DrawableSlide drawableSlide)
: base(drawableSlide)
{
InternalChildren = new Drawable[]{
bodyHighlight = new SlideBodyHighlight(),
starHighlight = new SlideStarHighlight()
};
}

protected override void Update()
{
base.Update();

var SlideTap = DrawableObject.SlideTaps.Child;

var FirstSlideBody = DrawableObject.SlideBodies.FirstOrDefault();


if (DrawableObject.Time.Current < DrawableObject.HitObject.StartTime)
{
starHighlight.Rotation = SlideTap.HitObject.Lane.GetRotationForLane();
starHighlight.Note.Position = new Vector2(0, Math.Max(SlideTap.TapVisual.Y, -SentakkiPlayfield.INTERSECTDISTANCE));
starHighlight.Note.Scale = SlideTap.TapVisual.Scale;
starHighlight.Note.Rotation = (SlideTap.TapVisual as SlideTapPiece).Stars.Rotation;
}
else
{
if (FirstSlideBody is null)
return;

starHighlight.Rotation = SlideTap.HitObject.Lane.GetRotationForLane() - 22.5f;
starHighlight.Note.Position = FirstSlideBody.SlideStar.Position;
starHighlight.Note.Scale = FirstSlideBody.SlideStar.Scale;
starHighlight.Note.Rotation = FirstSlideBody.SlideStar.Rotation;
}

if (FirstSlideBody is null)
return;

bodyHighlight.Rotation = SlideTap.HitObject.Lane.GetRotationForLane() - 22.5f;
bodyHighlight.Path.Vertices = DrawableObject.SlideBodies.First().HitObject.SlideInfo.SlidePath.Vertices;
}

public override Vector2 ScreenSpaceSelectionPoint => starHighlight.ScreenSpaceDrawQuad.Centre;

public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
=> starHighlight.ReceivePositionalInputAt(screenSpacePos) || bodyHighlight.ReceivePositionalInputAt(screenSpacePos);

public override Quad SelectionQuad => starHighlight.ScreenSpaceDrawQuad;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Lines;
using osu.Framework.Graphics.Primitives;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Sentakki.Edit.Blueprints.Slides
{
public class SlideStarHighlight : CompositeDrawable
{
public readonly Container Note;

// This drawable is zero width
// We should use the quad of the note container
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Note.ReceivePositionalInputAt(screenSpacePos);
public override Quad ScreenSpaceDrawQuad => Note.ScreenSpaceDrawQuad.AABBFloat;


public SlideStarHighlight()
{
Anchor = Origin = Anchor.Centre;
Colour = Color4.YellowGreen;
Alpha = 0.5f;
InternalChildren = new Drawable[]
{
Note = new Container{
Size = new Vector2(75),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Children = new Drawable[]{
new StarPiece()
}
}
};
}
}
}
3 changes: 3 additions & 0 deletions osu.Game.Rulesets.Sentakki/Edit/SentakkiBlueprintContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Sentakki.Edit.Blueprints.Holds;
using osu.Game.Rulesets.Sentakki.Edit.Blueprints.Slides;
using osu.Game.Rulesets.Sentakki.Edit.Blueprints.Taps;
using osu.Game.Rulesets.Sentakki.Objects.Drawables;
using osu.Game.Screens.Edit.Components.TernaryButtons;
Expand All @@ -26,6 +27,8 @@ public override OverlaySelectionBlueprint CreateBlueprintFor(DrawableHitObject h
return new TapSelectionBlueprint(t);
case DrawableHold h:
return new HoldSelectionBlueprint(h);
case DrawableSlide s:
return new SlideSelectionBlueprint(s);
}
return base.CreateBlueprintFor(hitObject);
}
Expand Down
18 changes: 13 additions & 5 deletions osu.Game.Rulesets.Sentakki/Objects/SentakkiSlidePath.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Objects;
using osuTK;
Expand All @@ -20,18 +21,17 @@ public class SentakkiSlidePath

public readonly SliderPath[] SlideSegments;

public readonly IReadOnlyList<Vector2> Vertices;

public SentakkiSlidePath(SliderPath segment, int endLane)
{
SlideSegments = new SliderPath[] { segment };
TotalDistance = SlideSegments.Sum(p => p.Distance);
EndLane = endLane;
}
: this(new SliderPath[] { segment }, endLane) { }

public SentakkiSlidePath(SliderPath[] segments, int endLane)
{
SlideSegments = segments;
TotalDistance = SlideSegments.Sum(p => p.Distance);
EndLane = endLane;
Vertices = SlideSegments.SelectMany(getVerticesOfPath).ToList();
}

public Vector2 PositionAt(double progress)
Expand All @@ -49,5 +49,13 @@ public Vector2 PositionAt(double progress)

return SlideSegments[i].PositionAt(distanceLeft / SlideSegments[i].Distance);
}

private List<Vector2> getVerticesOfPath(SliderPath path)
{
var vertices = new List<Vector2>();

path.GetPathToProgress(vertices, 0, 1);
return vertices;
}
}
}

0 comments on commit 8265d02

Please sign in to comment.