diff --git a/source/funkin/audio/waveform/WaveformData.hx b/source/funkin/audio/waveform/WaveformData.hx index b82d141e7..1f649b472 100644 --- a/source/funkin/audio/waveform/WaveformData.hx +++ b/source/funkin/audio/waveform/WaveformData.hx @@ -187,6 +187,8 @@ class WaveformData */ public function merge(that:WaveformData):WaveformData { + if (that == null) return this.clone(); + var result = this.clone([]); for (channelIndex in 0...this.channels) diff --git a/source/funkin/data/song/SongData.hx b/source/funkin/data/song/SongData.hx index 4deba7088..cc568ec66 100644 --- a/source/funkin/data/song/SongData.hx +++ b/source/funkin/data/song/SongData.hx @@ -110,7 +110,8 @@ class SongMetadata implements ICloneable */ public function serialize(pretty:Bool = true):String { - var writer = new json2object.JsonWriter(); + var ignoreNullOptionals = true; + var writer = new json2object.JsonWriter(ignoreNullOptionals); // I believe @:jignored should be iggnored by the writer? // var output = this.clone(); // output.variation = null; // Not sure how to make a field optional on the reader and ignored on the writer. @@ -597,7 +598,8 @@ class SongChartData implements ICloneable */ public function serialize(pretty:Bool = true):String { - var writer = new json2object.JsonWriter(); + var ignoreNullOptionals = true; + var writer = new json2object.JsonWriter(ignoreNullOptionals); return writer.write(this, pretty ? ' ' : null); } diff --git a/source/funkin/ui/debug/charting/commands/SelectItemsCommand.hx b/source/funkin/ui/debug/charting/commands/SelectItemsCommand.hx index 88f73cfed..891ac9ebd 100644 --- a/source/funkin/ui/debug/charting/commands/SelectItemsCommand.hx +++ b/source/funkin/ui/debug/charting/commands/SelectItemsCommand.hx @@ -34,7 +34,7 @@ class SelectItemsCommand implements ChartEditorCommand } // If we just selected one or more events (and no notes), then we should make the event data toolbox display the event data for the selected event. - if (this.notes.length == 0 && this.events.length >= 1) + if (this.notes.length == 0 && this.events.length == 1) { var eventSelected = this.events[0]; @@ -60,7 +60,7 @@ class SelectItemsCommand implements ChartEditorCommand } // If we just selected one or more notes (and no events), then we should make the note data toolbox display the note data for the selected note. - if (this.events.length == 0 && this.notes.length >= 1) + if (this.events.length == 0 && this.notes.length == 1) { var noteSelected = this.notes[0]; diff --git a/source/funkin/ui/debug/charting/commands/SetItemSelectionCommand.hx b/source/funkin/ui/debug/charting/commands/SetItemSelectionCommand.hx index 5cc89e137..0b540dbeb 100644 --- a/source/funkin/ui/debug/charting/commands/SetItemSelectionCommand.hx +++ b/source/funkin/ui/debug/charting/commands/SetItemSelectionCommand.hx @@ -31,7 +31,7 @@ class SetItemSelectionCommand implements ChartEditorCommand state.currentEventSelection = events; // If we just selected one or more events (and no notes), then we should make the event data toolbox display the event data for the selected event. - if (this.notes.length == 0 && this.events.length >= 1) + if (this.notes.length == 0 && this.events.length == 1) { var eventSelected = this.events[0]; @@ -57,7 +57,7 @@ class SetItemSelectionCommand implements ChartEditorCommand } // IF we just selected one or more notes (and no events), then we should make the note data toolbox display the note data for the selected note. - if (this.events.length == 0 && this.notes.length >= 1) + if (this.events.length == 0 && this.notes.length == 1) { var noteSelected = this.notes[0]; diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx index c384e7a6d..1432c9205 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorFreeplayToolbox.hx @@ -289,10 +289,10 @@ class ChartEditorFreeplayToolbox extends ChartEditorBaseToolbox // Build player waveform. // waveformMusic.waveform.forceUpdate = true; var perfStart = haxe.Timer.stamp(); - var waveformData1 = playerVoice.waveformData; - var waveformData2 = opponentVoice?.waveformData ?? playerVoice.waveformData; // this null check is for songs that only have 1 vocals file! + var waveformData1 = playerVoice?.waveformData; + var waveformData2 = opponentVoice?.waveformData ?? playerVoice?.waveformData; // this null check is for songs that only have 1 vocals file! var waveformData3 = chartEditorState.audioInstTrack.waveformData; - var waveformData = waveformData1.merge(waveformData2).merge(waveformData3); + var waveformData = waveformData3.merge(waveformData1).merge(waveformData2); trace('Waveform data merging took: ${haxe.Timer.stamp() - perfStart} seconds'); waveformMusic.waveform.waveformData = waveformData; diff --git a/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx b/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx index fd9209294..af1d75444 100644 --- a/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx +++ b/source/funkin/ui/debug/charting/toolboxes/ChartEditorOffsetsToolbox.hx @@ -270,24 +270,21 @@ class ChartEditorOffsetsToolbox extends ChartEditorBaseToolbox // Build player waveform. // waveformPlayer.waveform.forceUpdate = true; - waveformPlayer.waveform.waveformData = playerVoice.waveformData; + waveformPlayer.waveform.waveformData = playerVoice?.waveformData; // Set the width and duration to render the full waveform, with the clipRect applied we only render a segment of it. - waveformPlayer.waveform.duration = playerVoice.length / Constants.MS_PER_SEC; + waveformPlayer.waveform.duration = (playerVoice?.length ?? 1000) / Constants.MS_PER_SEC; // Build opponent waveform. // waveformOpponent.waveform.forceUpdate = true; // note: if song only has one set of vocals (Vocals.ogg/mp3) then this is null and crashes charting editor // so we null check - if (opponentVoice != null) - { - waveformOpponent.waveform.waveformData = opponentVoice.waveformData; - waveformOpponent.waveform.duration = opponentVoice.length / Constants.MS_PER_SEC; - } + waveformOpponent.waveform.waveformData = opponentVoice?.waveformData; + waveformOpponent.waveform.duration = (opponentVoice?.length ?? 1000) / Constants.MS_PER_SEC; // Build instrumental waveform. // waveformInstrumental.waveform.forceUpdate = true; waveformInstrumental.waveform.waveformData = chartEditorState.audioInstTrack.waveformData; - waveformInstrumental.waveform.duration = instTrack.length / Constants.MS_PER_SEC; + waveformInstrumental.waveform.duration = (instTrack?.length ?? 1000) / Constants.MS_PER_SEC; addOffsetsToAudioPreview(); }