diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index ea1d21c97b1..79331c748d2 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -3401,7 +3401,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState var oldStepTime:Float = Conductor.instance.currentStepTime; var oldSongPosition:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset; Conductor.instance.update(audioInstTrack.time); - handleHitsounds(oldSongPosition, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset); + handleSongPosition(oldSongPosition, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset); // Resync vocals. if (Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100) { @@ -3419,7 +3419,7 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState // Else, move the entire view. var oldSongPosition:Float = Conductor.instance.songPosition + Conductor.instance.instrumentalOffset; Conductor.instance.update(audioInstTrack.time); - handleHitsounds(oldSongPosition, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset); + handleSongPosition(oldSongPosition, Conductor.instance.songPosition + Conductor.instance.instrumentalOffset); // Resync vocals. if (Math.abs(audioInstTrack.time - audioVocalTrackGroup.time) > 100) { @@ -6239,27 +6239,18 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState } /** - * Handle the playback of hitsounds. + * Handle the song's position events. */ - function handleHitsounds(oldSongPosition:Float, newSongPosition:Float):Void + function handleSongPosition(oldSongPosition:Float, newSongPosition:Float):Void { - if (!hitsoundsEnabled) return; - - // Assume notes are sorted by time. for (noteData in currentSongChartNoteData) { - // Check for notes between the old and new song positions. - if (noteData.time < oldSongPosition) // Note is in the past. continue; if (noteData.time > newSongPosition) // Note is in the future. return; // Assume all notes are also in the future. - // Note was just hit. - - // Character preview. - // NoteScriptEvent takes a sprite, ehe. Need to rework that. var tempNote:NoteSprite = new NoteSprite(NoteStyleRegistry.instance.fetchDefault()); tempNote.noteData = noteData; @@ -6267,17 +6258,26 @@ class ChartEditorState extends UIState // UIState derives from MusicBeatState var event:NoteScriptEvent = new HitNoteScriptEvent(tempNote, 0.0, 0, 'perfect', false, 0); dispatchEvent(event); - // Calling event.cancelEvent() skips all the other logic! Neat! if (event.eventCanceled) continue; - // Hitsounds. - switch (noteData.getStrumlineIndex()) - { - case 0: // Player - if (hitsoundVolumePlayer > 0) this.playSound(Paths.sound('chartingSounds/hitNotePlayer'), hitsoundVolumePlayer); - case 1: // Opponent - if (hitsoundVolumeOpponent > 0) this.playSound(Paths.sound('chartingSounds/hitNoteOpponent'), hitsoundVolumeOpponent); - } + handleHitsounds(noteData?.getStrumlineIndex()); + } + } + + /** + * Handle the playback of hitsounds. + */ + function handleHitsounds(strumIndex:Int):Void + { + if (!hitsoundsEnabled) return; + + // Hitsounds. + switch (strumIndex) + { + case 0: // Player + if (hitsoundVolumePlayer > 0) this.playSound(Paths.sound('chartingSounds/hitNotePlayer'), hitsoundVolumePlayer); + case 1: // Opponent + if (hitsoundVolumeOpponent > 0) this.playSound(Paths.sound('chartingSounds/hitNoteOpponent'), hitsoundVolumeOpponent); } }