store params in chart

chart editor still doesnt fully work
This commit is contained in:
lemz
2024-07-12 02:13:20 -04:00
committed by EliteMasterEric
parent 764cdee63d
commit c41d846df5
5 changed files with 111 additions and 12 deletions
@@ -35,6 +35,7 @@ import funkin.data.song.SongData.SongEventData;
import funkin.data.song.SongData.SongMetadata;
import funkin.data.song.SongData.SongNoteData;
import funkin.data.song.SongData.SongOffsets;
import funkin.data.song.SongData.NoteParamData;
import funkin.data.song.SongDataUtils;
import funkin.data.song.SongRegistry;
import funkin.data.stage.StageData;
@@ -539,6 +540,11 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
*/
var noteKindToPlace:Null<String> = null;
/**
* The note params to use for notes being placed in the chart. Defaults to `[]`.
*/
var noteParamsToPlace:Array<NoteParamData> = [];
/**
* The event type to use for events being placed in the chart. Defaults to `''`.
*/
@@ -2437,7 +2443,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
gridGhostNote = new ChartEditorNoteSprite(this);
gridGhostNote.alpha = 0.6;
gridGhostNote.noteData = new SongNoteData(0, 0, 0, "");
gridGhostNote.noteData = new SongNoteData(0, 0, 0, "", []);
gridGhostNote.visible = false;
add(gridGhostNote);
gridGhostNote.zIndex = 11;
@@ -4731,7 +4737,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
else
{
// Create a note and place it in the chart.
var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace);
var newNoteData:SongNoteData = new SongNoteData(cursorSnappedMs, cursorColumn, 0, noteKindToPlace, noteParamsToPlace.clone());
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
@@ -4890,11 +4896,13 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (gridGhostNote == null) throw "ERROR: Tried to handle cursor, but gridGhostNote is null! Check ChartEditorState.buildGrid()";
var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0, noteKindToPlace);
var noteData:SongNoteData = gridGhostNote.noteData != null ? gridGhostNote.noteData : new SongNoteData(cursorMs, cursorColumn, 0, noteKindToPlace,
noteParamsToPlace.clone());
if (cursorColumn != noteData.data || noteKindToPlace != noteData.kind)
if (cursorColumn != noteData.data || noteKindToPlace != noteData.kind || noteParamsToPlace != noteData.params)
{
noteData.kind = noteKindToPlace;
noteData.params = noteParamsToPlace;
noteData.data = cursorColumn;
gridGhostNote.noteStyle = NoteKindManager.getNoteStyleId(noteData.kind, isPixelStyle()) ?? currentSongNoteStyle;
gridGhostNote.playNoteAnimation();
@@ -5202,7 +5210,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
if (notesAtPos.length == 0 && !removeNoteInstead)
{
trace('Placing note. ${column}');
var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, noteKindToPlace);
var newNoteData:SongNoteData = new SongNoteData(playheadPosSnappedMs, column, 0, noteKindToPlace, noteParamsToPlace.clone());
performCommand(new AddNotesCommand([newNoteData], FlxG.keys.pressed.CONTROL));
currentLiveInputPlaceNoteData[column] = newNoteData;
}
@@ -5655,6 +5663,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState
FlxG.watch.addQuick('musicTime', audioInstTrack?.time ?? 0.0);
FlxG.watch.addQuick('noteKindToPlace', noteKindToPlace);
FlxG.watch.addQuick('noteParamsToPlace', noteParamsToPlace);
FlxG.watch.addQuick('eventKindToPlace', eventKindToPlace);
FlxG.watch.addQuick('scrollPosInPixels', scrollPositionInPixels);
@@ -9,6 +9,8 @@ import haxe.ui.core.Component;
import haxe.ui.events.UIEvent;
import funkin.ui.debug.charting.util.ChartEditorDropdowns;
import funkin.play.notes.notekind.NoteKindManager;
import funkin.play.notes.notekind.NoteKind.NoteKindParam;
import funkin.data.song.SongData.NoteParamData;
/**
* The toolbox which allows modifying information like Note Kind.
@@ -60,6 +62,13 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
trace('ChartEditorToolboxHandler.buildToolboxNoteDataLayout() - Note kind changed: $noteKind');
var noteKindParams:Array<NoteKindParam> = NoteKindManager.getParams(noteKind);
var noteParamData:Array<NoteParamData> = [];
for (noteKindParam in noteKindParams)
{
noteParamData.push(new NoteParamData(noteKindParam.name, noteKindParam.data.defaultValue));
}
// Edit the note data to place.
if (noteKind == '~CUSTOM~')
{
@@ -71,10 +80,11 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
{
hideCustom();
chartEditorState.noteKindToPlace = noteKind;
chartEditorState.noteParamsToPlace = noteParamData;
toolboxNotesCustomKind.value = chartEditorState.noteKindToPlace;
clearNoteKindParams();
for (param in NoteKindManager.getParams(noteKind))
for (param in noteKindParams)
{
var paramLabel:Label = new Label();
paramLabel.value = param.description;
@@ -107,10 +117,22 @@ class ChartEditorNoteDataToolbox extends ChartEditorBaseToolbox
if (!_initializing && chartEditorState.currentNoteSelection.length > 0)
{
for (i in 0...toolboxNotesParams.length)
{
var toolboxComponent:Component = toolboxNotesParams[i].component;
toolboxComponent.onChange = function(event:UIEvent) {
for (note in chartEditorState.currentNoteSelection)
{
note.params[i].value = toolboxComponent.value;
}
}
}
for (note in chartEditorState.currentNoteSelection)
{
// Edit the note data of any selected notes.
note.kind = chartEditorState.noteKindToPlace;
note.params = noteParamData.clone();
// update note sprites
for (noteSprite in chartEditorState.renderedNotes.members)