From b9c25d6ed9afed2d1b51b39b1c9f563365e0de65 Mon Sep 17 00:00:00 2001 From: EliteMasterEric <ericmyllyoja@gmail.com> Date: Fri, 4 Aug 2023 17:25:13 -0400 Subject: [PATCH] Fix crashing, broken countdown, broken miss muting in song preview --- source/funkin/play/Countdown.hx | 10 ++++-- source/funkin/play/PlayState.hx | 7 ++-- source/funkin/play/character/BaseCharacter.hx | 2 +- .../debug/charting/ChartEditorNotePreview.hx | 2 +- .../ui/debug/charting/ChartEditorState.hx | 32 +++++++++++++++---- 5 files changed, 40 insertions(+), 13 deletions(-) diff --git a/source/funkin/play/Countdown.hx b/source/funkin/play/Countdown.hx index f521f9ffc..5ccb6e24c 100644 --- a/source/funkin/play/Countdown.hx +++ b/source/funkin/play/Countdown.hx @@ -31,7 +31,10 @@ class Countdown { countdownStep = BEFORE; var cancelled:Bool = propagateCountdownEvent(countdownStep); - if (cancelled) return false; + if (cancelled) + { + return false; + } // Stop any existing countdown. stopCountdown(); @@ -67,7 +70,10 @@ class Countdown // Event handling bullshit. var cancelled:Bool = propagateCountdownEvent(countdownStep); - if (cancelled) pauseCountdown(); + if (cancelled) + { + pauseCountdown(); + } if (countdownStep == AFTER) { diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index d85cc6a03..5409040ec 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -952,7 +952,7 @@ class PlayState extends MusicBeatSubState { // If there is a substate which requires the game to continue, // then make this a condition. - var shouldPause = true; + var shouldPause = (Std.isOfType(subState, PauseSubState) || Std.isOfType(subState, GameOverSubState)); if (shouldPause) { @@ -966,6 +966,7 @@ class PlayState extends MusicBeatSubState // Pause the countdown. Countdown.pauseCountdown(); } + else {} super.openSubState(subState); } @@ -1672,7 +1673,8 @@ class PlayState extends MusicBeatSubState } FlxG.sound.music.onComplete = endSong; - FlxG.sound.music.play(false, startTimestamp); + FlxG.sound.music.play(); + FlxG.sound.music.time = startTimestamp; trace('Playing vocals...'); add(vocals); vocals.play(); @@ -2627,6 +2629,7 @@ class PlayState extends MusicBeatSubState else { FlxG.sound.music.pause(); + vocals.pause(); remove(vocals); } diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index 42dfd2da4..72f968538 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -235,8 +235,8 @@ class BaseCharacter extends Bopper // Then reapply animOffsets... // applyAnimationOffsets(getCurrentAnimation()); - // Make sure we are playing the idle animation this.dance(true); // Force to avoid the old animation playing with the wrong offset at the start of the song. + // Make sure we are playing the idle animation // ...then update the hitbox so that this.width and this.height are correct. this.updateHitbox(); diff --git a/source/funkin/ui/debug/charting/ChartEditorNotePreview.hx b/source/funkin/ui/debug/charting/ChartEditorNotePreview.hx index 27951f079..d3296c400 100644 --- a/source/funkin/ui/debug/charting/ChartEditorNotePreview.hx +++ b/source/funkin/ui/debug/charting/ChartEditorNotePreview.hx @@ -40,7 +40,7 @@ class ChartEditorNotePreview extends FlxSprite */ function buildBackground():Void { - makeGraphic(WIDTH, 0, BG_COLOR); + makeGraphic(WIDTH, previewHeight, BG_COLOR); } /** diff --git a/source/funkin/ui/debug/charting/ChartEditorState.hx b/source/funkin/ui/debug/charting/ChartEditorState.hx index b89748d87..94cf05fc5 100644 --- a/source/funkin/ui/debug/charting/ChartEditorState.hx +++ b/source/funkin/ui/debug/charting/ChartEditorState.hx @@ -1247,7 +1247,8 @@ class ChartEditorState extends HaxeUIState var height:Int = FlxG.height - MENU_BAR_HEIGHT - GRID_TOP_PAD - 200; notePreview = new ChartEditorNotePreview(height); notePreview.y = MENU_BAR_HEIGHT + GRID_TOP_PAD; - add(notePreview); + // TODO: Re-enable. + // add(notePreview); } function buildSpectrogram(target:FlxSound):Void @@ -3496,14 +3497,23 @@ class ChartEditorState extends HaxeUIState * @param charKey Character to load the vocal track for. * @return Success or failure. */ - public function loadVocalsFromAsset(path:String, charKey:String = 'default'):Bool + public function loadVocalsFromAsset(path:String, charType:CharacterType = OTHER):Bool { var vocalTrack:FlxSound = FlxG.sound.load(path, 1.0, false); if (vocalTrack != null) { - audioVocalTrackGroup.add(vocalTrack); - - audioVocalTrackData.set(charKey, Assets.getBytes(path)); + switch (charType) + { + case CharacterType.BF: + audioVocalTrackGroup.addPlayerVoice(vocalTrack); + audioVocalTrackData.set(currentSongCharacterPlayer, Assets.getBytes(path)); + case CharacterType.DAD: + audioVocalTrackGroup.addOpponentVoice(vocalTrack); + audioVocalTrackData.set(currentSongCharacterOpponent, Assets.getBytes(path)); + default: + audioVocalTrackGroup.add(vocalTrack); + audioVocalTrackData.set('default', Assets.getBytes(path)); + } return true; } @@ -3565,9 +3575,17 @@ class ChartEditorState extends HaxeUIState loadInstrumentalFromAsset(Paths.inst(songId)); var voiceList:Array<String> = song.getDifficulty(selectedDifficulty).buildVoiceList(); - for (voicePath in voiceList) + if (voiceList.length == 2) { - loadVocalsFromAsset(voicePath); + loadVocalsFromAsset(voiceList[0], BF); + loadVocalsFromAsset(voiceList[1], DAD); + } + else + { + for (voicePath in voiceList) + { + loadVocalsFromAsset(voicePath); + } } NotificationManager.instance.addNotification(