Skip to content

Commit

Permalink
Fix all repeat sliders being draggable
Browse files Browse the repository at this point in the history
  • Loading branch information
OliBomby committed Dec 20, 2023
1 parent 66f4dcc commit f7cb6b9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ private void updateCirclePieceColour()
{
Color4 colour = colours.Yellow;

if (IsHovered && Slider.RepeatCount % 2 == 0)
if (IsHovered)
colour = colour.Lighten(1);

CirclePiece.Colour = colour;
}

protected override bool OnDragStart(DragStartEvent e)
{
// Disable dragging if the slider has an uneven number of repeats because the slider tail will be on the wrong side of the path.
if (e.Button == MouseButton.Right || !inputManager.CurrentState.Keyboard.ShiftPressed || Slider.RepeatCount % 2 == 1)
if (e.Button == MouseButton.Right || !inputManager.CurrentState.Keyboard.ShiftPressed)
return false;

isDragging = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ protected override void Update()
{
base.Update();

var circle = position == SliderPosition.Start ? (HitCircle)Slider.HeadCircle : Slider.TailCircle;
var circle = position == SliderPosition.Start ? (HitCircle)Slider.HeadCircle :
Slider.RepeatCount % 2 == 0 ? Slider.TailCircle : Slider.LastRepeat;

CirclePiece.UpdateFrom(circle);
marker.UpdateFrom(circle);
Expand Down
8 changes: 7 additions & 1 deletion osu.Game.Rulesets.Osu/Objects/Slider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ public double SliderVelocityMultiplier
[JsonIgnore]
public SliderTailCircle TailCircle { get; protected set; }

[JsonIgnore]
public SliderRepeat LastRepeat { get; protected set; }

public Slider()
{
SamplesBindable.CollectionChanged += (_, _) => UpdateNestedSamples();
Expand Down Expand Up @@ -225,7 +228,7 @@ protected override void CreateNestedHitObjects(CancellationToken cancellationTok
break;

case SliderEventType.Repeat:
AddNested(new SliderRepeat(this)
AddNested(LastRepeat = new SliderRepeat(this)
{
RepeatIndex = e.SpanIndex,
StartTime = StartTime + (e.SpanIndex + 1) * SpanDuration,
Expand All @@ -248,6 +251,9 @@ private void updateNestedPositions()

if (TailCircle != null)
TailCircle.Position = EndPosition;

if (LastRepeat != null)
LastRepeat.Position = RepeatCount % 2 == 0 ? Position : Position + Path.PositionAt(1);
}

protected void UpdateNestedSamples()
Expand Down

0 comments on commit f7cb6b9

Please sign in to comment.