Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NotHyper-474 committed Oct 14, 2024
1 parent 0a3ffff commit ba9f177
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions source/funkin/ui/debug/charting/ChartEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3664,8 +3664,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
}
}

var stackedNotes = NoteDataFilter.listStackedNotes(currentSongChartNoteData, STACK_NOTE_THRESHOLD);

// Add events that are now visible.
for (eventData in currentSongChartEventData)
{
Expand Down Expand Up @@ -3738,6 +3736,9 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
member.kill();
}

// Gather stacked notes to render later
var stackedNotes = NoteDataFilter.listStackedNotes(currentSongChartNoteData, STACK_NOTE_THRESHOLD);

// Readd selection squares for selected notes.
// Recycle selection squares if possible.
for (noteSprite in renderedNotes.members)
Expand Down Expand Up @@ -3800,22 +3801,19 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
var stepLength = noteSprite.noteData.getStepLength();
selectionSquare.height = (stepLength <= 0) ? GRID_SIZE : ((stepLength + 1) * GRID_SIZE);
}
else
// TODO: Move this to a function like isNoteSelected does
else if (doesNoteOverlap(noteSprite.noteData, stackedNotes))
{
// TODO: Move this to a function like isNoteSelected does
if (noteSprite.noteData != null && stackedNotes.contains(noteSprite.noteData))
{
// TODO: Maybe use another way to display these notes
var selectionSquare:ChartEditorSelectionSquareSprite = renderedSelectionSquares.recycle(buildSelectionSquare);

// Set the position and size (because we might be recycling one with bad values).
selectionSquare.noteData = noteSprite.noteData;
selectionSquare.eventData = null;
selectionSquare.x = noteSprite.x;
selectionSquare.y = noteSprite.y;
selectionSquare.width = selectionSquare.height = GRID_SIZE;
selectionSquare.color = FlxColor.RED;
}
// TODO: Maybe use another way to display these notes
var selectionSquare:ChartEditorSelectionSquareSprite = renderedSelectionSquares.recycle(buildSelectionSquare);

// Set the position and size (because we might be recycling one with bad values).
selectionSquare.noteData = noteSprite.noteData;
selectionSquare.eventData = null;
selectionSquare.x = noteSprite.x;
selectionSquare.y = noteSprite.y;
selectionSquare.width = selectionSquare.height = GRID_SIZE;
selectionSquare.color = FlxColor.RED;
}
}

Expand Down Expand Up @@ -3866,11 +3864,6 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
// Sort the events DESCENDING. This keeps the sustain behind the associated note.
renderedEvents.sort(FlxSort.byY, FlxSort.DESCENDING); // TODO: .group.insertionSort()
}

if (FlxG.keys.pressed.CONTROL && FlxG.keys.justPressed.H)
{
// performCommand(new RemoveNotesCommand(stackedNotes));
}
}

/**
Expand Down Expand Up @@ -6457,6 +6450,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
return note != null && currentNoteSelection.indexOf(note) != -1;
}

function doesNoteOverlap(note:Null<SongNoteData>, curStackedNotes:Array<SongNoteData>):Bool
{
return note != null && curStackedNotes.contains(note);
}

override function destroy():Void
{
super.destroy();
Expand Down

0 comments on commit ba9f177

Please sign in to comment.