Skip to content

[BUGFIX/POLISH?] Fix how HitNoteScriptEvent not being called, because of hitsounds volume #5147

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
44 changes: 22 additions & 22 deletions source/funkin/ui/debug/charting/ChartEditorState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -6239,45 +6239,45 @@ 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;
tempNote.scrollFactor.set(0, 0);
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);
}
}

Expand Down
Loading