diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 44c14be06e..8a3a61185a 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -3649,6 +3649,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); @@ -3716,6 +3718,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); @@ -3740,6 +3744,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) { @@ -3748,6 +3762,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 { @@ -3757,6 +3778,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); + } } } @@ -3769,6 +3796,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 { @@ -3778,6 +3812,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); + } } } diff --git a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx index ff8446c499..15e06dc60d 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx @@ -41,6 +41,30 @@ class ChartEditorHoldNoteSprite extends SustainTrail return value; } + public var overrideStepTime(default, set):Null = null; + + function set_overrideStepTime(value:Null):Null + { + if (overrideStepTime == value) return overrideStepTime; + + overrideStepTime = value; + updateHoldNotePosition(); + return overrideStepTime; + } + + public var overrideData(default, set):Null = null; + + function set_overrideData(value:Null):Null + { + 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(); @@ -215,7 +239,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)) @@ -236,10 +260,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) {