From d3d8aaae7bfbfa8975a9573807b9a3ca68a1ff55 Mon Sep 17 00:00:00 2001 From: Kolo <67389779+JustKolosaki@users.noreply.github.com> Date: Sun, 9 Feb 2025 15:22:49 +0100 Subject: [PATCH] move da hold note trails --- .../ui/debug/charting/ChartEditorState.hx | 41 +++++++++++++++++++ .../components/ChartEditorHoldNoteSprite.hx | 29 ++++++++++++- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index 1177132f5..7d1204669 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -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); + } } } diff --git a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx index e4012d552..00d87e9fd 100644 --- a/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx +++ b/source/funkin/ui/debug/charting/components/ChartEditorHoldNoteSprite.hx @@ -37,6 +37,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(); @@ -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) {