Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Move the Note Trails when moving a Held Note in the Chart Editor #4127

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions source/funkin/ui/debug/charting/ChartEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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)
{
Expand All @@ -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
{
Expand All @@ -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);
}
}
}

Expand All @@ -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
{
Expand All @@ -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);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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();
Expand Down Expand Up @@ -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))
Expand All @@ -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)
{
Expand Down
Loading