Skip to content

Commit

Permalink
Fix shoot delay not being used in slide placement
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed Jan 12, 2025
1 parent 97685f1 commit 9ecce63
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
Expand Down Expand Up @@ -66,11 +67,12 @@ protected override void Update()
highlight.SlideTapPiece.Y = -snapProvider.GetDistanceRelativeToCurrentTime(HitObject.StartTime, SentakkiPlayfield.NOTESTARTDISTANCE);
}

private SlideBodyInfo commitedSlideBodyInfo = null!;
private SlideBodyInfo? commitedSlideBodyInfo = null!;
private SlideBodyInfo previewSlideBodyInfo = null!;
private int currentLaneOffset;

private Bindable<SlideBodyPart> currentPart = new Bindable<SlideBodyPart>();
private Bindable<float> shootDelay = new Bindable<float>();

protected override void LoadComplete()
{
Expand All @@ -85,6 +87,13 @@ protected override void LoadComplete()
};
bodyHighlight.Path = previewSlideBodyInfo.SlidePath;
}, true);

shootDelay.BindTo(slidePlacementToolbox.ShootDelayBindable);
shootDelay.BindValueChanged(v =>
{
if (commitedSlideBodyInfo is not null)
commitedSlideBodyInfo.ShootDelay = v.NewValue;
});
}

protected override bool OnMouseDown(MouseDownEvent e)
Expand All @@ -98,7 +107,10 @@ protected override bool OnMouseDown(MouseDownEvent e)

EditorClock.SeekSmoothlyTo(HitObject.StartTime);

HitObject.SlideInfoList.Add(commitedSlideBodyInfo = new SlideBodyInfo());
HitObject.SlideInfoList.Add(commitedSlideBodyInfo = new SlideBodyInfo()
{
ShootDelay = shootDelay.Value
});

commited.Rotation = HitObject.Lane.GetRotationForLane();
bodyHighlight.Rotation = HitObject.Lane.GetRotationForLane();
Expand All @@ -118,11 +130,17 @@ protected override void OnMouseUp(MouseUpEvent e)
return;

if (PlacementActive == PlacementState.Active)
{
Debug.Assert(commitedSlideBodyInfo is not null);
EndPlacement(bodyParts.Count > 0 && commitedSlideBodyInfo.Duration > 0);
}
}

protected override bool OnKeyDown(KeyDownEvent e)
{
if (PlacementActive != PlacementState.Active)
return base.OnKeyDown(e);

switch (e.Key)
{
case Key.BackSpace:
Expand Down Expand Up @@ -150,6 +168,7 @@ public override void UpdateTimeAndPosition(SnapResult result)

if (PlacementActive == PlacementState.Active)
{
Debug.Assert(commitedSlideBodyInfo is not null);
double endTime = EditorClock.CurrentTime;

HitObject.StartTime = endTime < originalStartTime ? endTime : originalStartTime;
Expand Down Expand Up @@ -181,6 +200,7 @@ public override void UpdateTimeAndPosition(SnapResult result)

private void commitCurrentPart()
{
Debug.Assert(commitedSlideBodyInfo is not null);
laneOffsets.Push(slidePlacementToolbox.CurrentPart.EndOffset);
bodyParts.Add(slidePlacementToolbox.CurrentPart);

Expand All @@ -193,6 +213,7 @@ private void commitCurrentPart()

private void uncommitLastPart()
{
Debug.Assert(commitedSlideBodyInfo is not null);
if (laneOffsets.Count == 0)
return;

Expand Down
11 changes: 6 additions & 5 deletions osu.Game.Rulesets.Sentakki/Edit/SlideEditorToolboxGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ public partial class SlideEditorToolboxGroup : EditorToolboxGroup
public readonly Bindable<int> LaneOffset = new Bindable<int>(4);
private Bindable<bool> mirrored = new Bindable<bool>(); // This is locked

private Bindable<float> shootDelay = new Bindable<float>();
public Bindable<float> ShootDelayBindable = new Bindable<float>();

public readonly Bindable<SlideBodyPart> CurrentPartBindable = new Bindable<SlideBodyPart>(new SlideBodyPart(SlidePaths.PathShapes.Straight, 4, false));

public SlideBodyPart CurrentPart => CurrentPartBindable.Value;
public float CurrentShootDelay => ShootDelayBindable.Value;

public SlideEditorToolboxGroup() : base("slide")
{
Expand All @@ -35,7 +36,7 @@ public SlideEditorToolboxGroup() : base("slide")
Current = LaneOffset
},
new ShootDelayCounter(){
Current = shootDelay
Current = ShootDelayBindable
},
new ExpandableCheckbox("Mirrored"){
Current = mirrored
Expand Down Expand Up @@ -88,15 +89,15 @@ protected override bool OnKeyDown(KeyDownEvent e)
switch (e.Key)
{
case Key.Plus:
shootDelay.Value += 1f / beatSnapProvider.BeatDivisor;
ShootDelayBindable.Value += 1f / beatSnapProvider.BeatDivisor;
break;

case Key.Minus:
shootDelay.Value = Math.Max(0, shootDelay.Value - (1f / beatSnapProvider.BeatDivisor));
ShootDelayBindable.Value = Math.Max(0, ShootDelayBindable.Value - (1f / beatSnapProvider.BeatDivisor));
break;

case Key.Number0:
shootDelay.Value = 1;
ShootDelayBindable.Value = 1;
break;

case Key.BackSlash:
Expand Down

0 comments on commit 9ecce63

Please sign in to comment.