move da hold note trails

This commit is contained in:
Kolo
2025-06-06 19:16:29 -04:00
committed by Eric
parent c263b4bc83
commit d3d8aaae7b
2 changed files with 68 additions and 2 deletions
@@ -3623,6 +3623,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var noteLengthPixels:Float = noteSprite.noteData.getStepLength() * GRID_SIZE;
holdNoteSprite.noteData = noteSprite.noteData;
holdNoteSprite.overrideStepTime = null;
holdNoteSprite.overrideData = null;
holdNoteSprite.noteDirection = noteSprite.noteData.getDirection();
holdNoteSprite.setHeightDirectly(noteLengthPixels);
@@ -3690,6 +3692,8 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var noteLengthPixels:Float = noteData.getStepLength() * GRID_SIZE;
holdNoteSprite.noteData = noteData;
holdNoteSprite.overrideStepTime = null;
holdNoteSprite.overrideData = null;
holdNoteSprite.noteDirection = noteData.getDirection();
holdNoteSprite.setHeightDirectly(noteLengthPixels);
@@ -3714,6 +3718,16 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// TODO: Handle selection of hold notes.
if (isNoteSelected(noteSprite.noteData))
{
var holdNoteSprite:ChartEditorHoldNoteSprite = null;
if (noteSprite.noteData != null && noteSprite.noteData.length > 0)
{
for (holdNote in renderedHoldNotes.members)
{
if (holdNote.noteData == noteSprite.noteData && holdNoteSprite == null) holdNoteSprite = holdNote;
}
}
// Determine if the note is being dragged and offset the vertical position accordingly.
if (dragTargetCurrentStep != 0.0)
{
@@ -3722,6 +3736,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
noteSprite.overrideStepTime = (stepTime + dragTargetCurrentStep).clamp(0, songLengthInSteps - (1 * noteSnapRatio));
// Then reapply the note sprite's position relative to the grid.
noteSprite.updateNotePosition(renderedNotes);
// We only need to update the position of the hold note tails as we drag the note.
if (holdNoteSprite != null)
{
holdNoteSprite.overrideStepTime = noteSprite.overrideStepTime;
holdNoteSprite.updateHoldNotePosition(renderedHoldNotes);
}
}
else
{
@@ -3731,6 +3752,12 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
noteSprite.overrideStepTime = null;
// Then reapply the note sprite's position relative to the grid.
noteSprite.updateNotePosition(renderedNotes);
if (holdNoteSprite != null)
{
holdNoteSprite.overrideStepTime = null;
holdNoteSprite.updateHoldNotePosition(renderedHoldNotes);
}
}
}
@@ -3743,6 +3770,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
ChartEditorState.STRUMLINE_SIZE * 2 - 1));
// Then reapply the note sprite's position relative to the grid.
noteSprite.updateNotePosition(renderedNotes);
// We only need to update the position of the hold note tails as we drag the note.
if (holdNoteSprite != null)
{
holdNoteSprite.overrideData = noteSprite.overrideData;
holdNoteSprite.updateHoldNotePosition(renderedHoldNotes);
}
}
else
{
@@ -3752,6 +3786,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
noteSprite.overrideData = null;
// Then reapply the note sprite's position relative to the grid.
noteSprite.updateNotePosition(renderedNotes);
if (holdNoteSprite != null)
{
holdNoteSprite.overrideData = null;
holdNoteSprite.noteDirection = noteSprite.noteData.getDirection();
holdNoteSprite.updateHoldNotePosition(renderedHoldNotes);
}
}
}
@@ -37,6 +37,30 @@ class ChartEditorHoldNoteSprite extends SustainTrail
return value;
}
public var overrideStepTime(default, set):Null<Float> = null;
function set_overrideStepTime(value:Null<Float>):Null<Float>
{
if (overrideStepTime == value) return overrideStepTime;
overrideStepTime = value;
updateHoldNotePosition();
return overrideStepTime;
}
public var overrideData(default, set):Null<Int> = null;
function set_overrideData(value:Null<Int>):Null<Int>
{
if (overrideData == value) return overrideData;
overrideData = value;
if (overrideData != null) this.noteDirection = overrideData;
updateHoldNoteGraphic();
updateHoldNotePosition();
return overrideData;
}
public function new(parent:ChartEditorState)
{
var noteStyle = NoteStyleRegistry.instance.fetchDefault();
@@ -211,7 +235,7 @@ class ChartEditorHoldNoteSprite extends SustainTrail
{
if (this.noteData == null) return;
var cursorColumn:Int = this.noteData.data;
var cursorColumn:Int = (overrideData != null) ? overrideData : this.noteData.data;
if (cursorColumn < 0) cursorColumn = 0;
if (cursorColumn >= (ChartEditorState.STRUMLINE_SIZE * 2 + 1))
@@ -232,10 +256,11 @@ class ChartEditorHoldNoteSprite extends SustainTrail
}
this.x = cursorColumn * ChartEditorState.GRID_SIZE;
updateHoldNoteGraphic();
// Notes far in the song will start far down, but the group they belong to will have a high negative offset.
// noteData.getStepTime() returns a calculated value which accounts for BPM changes
var stepTime:Float =
var stepTime:Float = (overrideStepTime != null) ? overrideStepTime :
inline this.noteData.getStepTime();
if (stepTime >= 0)
{