Skip to content

Commit

Permalink
add lines connecting visually-offset tick notes
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Dec 14, 2024
1 parent f72e81a commit 8d78a59
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 30 deletions.
36 changes: 19 additions & 17 deletions fluXis.Game/Map/Structures/HitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using fluXis.Game.Screens.Edit.Tabs.Charting.Playfield;
using JetBrains.Annotations;
using Newtonsoft.Json;
using osu.Framework.Graphics;

namespace fluXis.Game.Map.Structures;

Expand Down Expand Up @@ -55,25 +56,26 @@ public double EndTime
[JsonIgnore]
public HitResult HoldEndResult { get; set; }

/// <summary>
/// The next HitObject in the same lane.
/// </summary>
[CanBeNull]
[JsonIgnore]
public EditorHitObject EditorDrawable { get; set; }
public HitObject NextObject { get; set; }

public HitObject Copy()
{
return new HitObject
{
Time = Time,
Lane = Lane,
VisualLane = VisualLane,
HoldTime = HoldTime,
HitSound = HitSound,
Type = Type
};
}
/// <summary>
/// The ease type the start of this note has.
/// </summary>
[JsonIgnore]
public Easing StartEasing { get; set; } = Easing.None;

public override string ToString()
{
return $"Time: {Time}, Lane: {Lane}, HoldTime: {HoldTime}, HitSound: {HitSound}";
}
/// <summary>
/// The ease type the end of this note has.
/// </summary>
[JsonIgnore]
public Easing EndEasing { get; set; } = Easing.None;

[CanBeNull]
[JsonIgnore]
public EditorHitObject EditorDrawable { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public void ReSnapAll()

public void Copy(bool deleteAfter = false)
{
var hits = BlueprintContainer.SelectionHandler.SelectedObjects.OfType<HitObject>().Select(h => h.Copy()).ToList();
var hits = BlueprintContainer.SelectionHandler.SelectedObjects.OfType<HitObject>().Select(h => h.JsonCopy()).ToList();

if (!hits.Any())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public partial class DrawableHitObject : CompositeDrawable
protected double ScrollVelocityTime { get; private set; }
protected double ScrollVelocityEndTime { get; private set; }

private Easing easing = Easing.None;

public FluXisGameplayKeybind Keybind { get; set; }

public virtual bool CanBeRemoved => false;
Expand All @@ -54,7 +52,6 @@ private void load()

ScrollVelocityTime = Column.ScrollVelocityPositionFromTime(Data.Time);
ScrollVelocityEndTime = Column.ScrollVelocityPositionFromTime(Data.EndTime);
easing = ObjectManager.EasingAtTime(Data.Time);
}

protected override void LoadComplete()
Expand All @@ -70,7 +67,7 @@ protected override void Update()
base.Update();

X = ObjectManager.PositionAtLane(Data.Lane);
Y = Column.PositionAtTime(ScrollVelocityTime, easing);
Y = Column.PositionAtTime(ScrollVelocityTime, Data.StartEasing);
Width = ObjectManager.WidthOfLane(Data.Lane);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public override bool CanBeRemoved
private DrawableLongNoteTail tailPiece;
private DrawableLongNoteHead headPiece;

private Easing endEasing = Easing.None;

private bool missed;

private readonly Colour4 missTint = new(.4f, .4f, .4f, 1);
Expand All @@ -53,8 +51,6 @@ private void load()
headPiece = new DrawableLongNoteHead(Data)
};

endEasing = ObjectManager.EasingAtTime(Data.EndTime);

if (ObjectManager.UseSnapColors)
{
var startIdx = Column.GetSnapIndex(Data.Time);
Expand Down Expand Up @@ -106,7 +102,7 @@ protected override void Update()
if (IsBeingHeld.Value)
Y = ObjectManager.HitPosition;

var endY = Column.PositionAtTime(ScrollVelocityEndTime, endEasing);
var endY = Column.PositionAtTime(ScrollVelocityEndTime, Data.EndEasing);
var height = Y - endY;

bodyPiece.Height = height;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
using System;
using fluXis.Game.Input;
using fluXis.Game.Map.Structures;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osuTK;

namespace fluXis.Game.Screens.Gameplay.Ruleset.HitObjects;

Expand All @@ -9,6 +13,7 @@ public partial class DrawableTickNote : DrawableHitObject
public override bool CanBeRemoved => Judged || Time.Current - Data.Time > HitWindows.TimingFor(HitWindows.LowestHitable);

private bool isBeingHeld;
private Circle followLine;

public DrawableTickNote(HitObject data)
: base(data)
Expand All @@ -18,7 +23,18 @@ public DrawableTickNote(HitObject data)
[BackgroundDependencyLoader]
private void load()
{
InternalChild = SkinManager.GetTickNote(Data.Lane, ObjectManager.KeyCount, Data.HoldTime > 0);
InternalChildren = new[]
{
followLine = new Circle()
{
BypassAutoSizeAxes = Axes.Both,
Colour = Colour4.FromHex("#F2C979").Opacity(.4f),
Size = new Vector2(8),
Anchor = Anchor.Centre,
Origin = Anchor.Centre
},
SkinManager.GetTickNote(Data.Lane, ObjectManager.KeyCount, Data.HoldTime > 0)
};
}

protected override void Update()
Expand All @@ -30,6 +46,23 @@ protected override void Update()

if (isBeingHeld)
UpdateJudgement(true);

var next = Data.NextObject;

if (next?.Type == 1 && next.Lane == Data.Lane && (Data.VisualLane != 0 || next.VisualLane != 0))
{
var l = next.VisualLane == 0 ? next.Lane : next.VisualLane;
var pos = Column.FullPositionAt(next.Time, l, next.StartEasing);
var delta = pos - Position;
var distance = delta.Length;

followLine.Alpha = 1;
followLine.Position = delta / 2;
followLine.Height = distance;
followLine.Rotation = -(float)(Math.Atan2(delta.X, delta.Y) * (180 / Math.PI));
}
else
followLine.Alpha = 0;
}

protected override void CheckJudgement(bool byUser, double offset)
Expand Down
21 changes: 19 additions & 2 deletions fluXis.Game/Screens/Gameplay/Ruleset/HitObjects/HitObjectColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
using fluXis.Game.Screens.Gameplay.Ruleset.Playfields;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
using osuTK;

namespace fluXis.Game.Screens.Gameplay.Ruleset.HitObjects;

Expand Down Expand Up @@ -62,7 +62,21 @@ public HitObjectColumn(MapInfo map, HitObjectManager hitManager, int lane)
Lane = lane;
HitManager = hitManager;

Map.HitObjects.Where(h => h.Lane == Lane).ForEach(FutureHitObjects.Add);
var objects = Map.HitObjects.Where(h => h.Lane == Lane).ToList();
objects.Sort((a, b) => a.Time.CompareTo(b.Time));
objects.ForEach(FutureHitObjects.Add);

HitObject last = null;

foreach (var hit in FutureHitObjects)
{
if (last != null)
last.NextObject = hit;

hit.StartEasing = HitManager.EasingAtTime(hit.Time);
hit.EndEasing = HitManager.EasingAtTime(hit.EndTime);
last = hit;
}

initScrollVelocityMarks();
initSnapIndices();
Expand Down Expand Up @@ -129,6 +143,9 @@ public bool ShouldDisplay(double time)
return y >= 0;
}

public Vector2 FullPositionAt(double time, float lane, Easing ease = Easing.None)
=> new(HitManager.PositionAtLane(lane), PositionAtTime(time, ease));

public float PositionAtTime(double time, Easing ease = Easing.None)
{
var pos = HitManager.HitPosition;
Expand Down

0 comments on commit 8d78a59

Please sign in to comment.