From a9667c54f377a1207b70ba163ceebd8f239a5822 Mon Sep 17 00:00:00 2001 From: EliteMasterEric Date: Thu, 12 Sep 2024 15:48:41 -0400 Subject: [PATCH] Fix FlxAtlasSprite completion handling and music looping --- source/funkin/audio/FunkinSound.hx | 2 ++ .../funkin/graphics/adobeanimate/FlxAtlasSprite.hx | 9 +++++++-- source/funkin/play/ResultState.hx | 6 ++---- source/funkin/play/scoring/Scoring.hx | 13 ------------- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/source/funkin/audio/FunkinSound.hx b/source/funkin/audio/FunkinSound.hx index 18a0b4da2..dae31cd07 100644 --- a/source/funkin/audio/FunkinSound.hx +++ b/source/funkin/audio/FunkinSound.hx @@ -340,6 +340,8 @@ class FunkinSound extends FlxSound implements ICloneable if (songMusicData != null) { Conductor.instance.mapTimeChanges(songMusicData.timeChanges); + + if (songMusicData.looped != null && params.loop == null) params.loop = songMusicData.looped; } else { diff --git a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx index f245afec7..952fa8b71 100644 --- a/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx +++ b/source/funkin/graphics/adobeanimate/FlxAtlasSprite.hx @@ -185,11 +185,12 @@ class FlxAtlasSprite extends FlxAnimate // Move to the first frame of the animation. // goToFrameLabel(id); trace('Playing animation $id'); - if (this.anim.symbolDictionary.exists(id) || (this.anim.getByName(id) != null)) + if ((id == null || id == "") || this.anim.symbolDictionary.exists(id) || (this.anim.getByName(id) != null)) { this.anim.play(id, restart, false, startFrame); - if (id == "Boyfriend DJ fist pump" || startFrame == 4) trace("PUMP COMMAND: " + anim.curFrame); + this.currentAnimation = anim.curSymbol.name; + fr = null; } // Only call goToFrameLabel if there is a frame label with that name. This prevents annoying warnings! @@ -316,6 +317,10 @@ class FlxAtlasSprite extends FlxAnimate { onAnimationComplete.dispatch(currentAnimation); } + else + { + onAnimationComplete.dispatch(''); + } } var prevFrames:Map = []; diff --git a/source/funkin/play/ResultState.hx b/source/funkin/play/ResultState.hx index e0ac3579d..739df167d 100644 --- a/source/funkin/play/ResultState.hx +++ b/source/funkin/play/ResultState.hx @@ -418,8 +418,7 @@ class ResultState extends MusicBeatSubState { startingVolume: 1.0, overrideExisting: true, - restartTrack: true, - loop: rank.shouldMusicLoop() + restartTrack: true }); }); } @@ -429,8 +428,7 @@ class ResultState extends MusicBeatSubState { startingVolume: 1.0, overrideExisting: true, - restartTrack: true, - loop: rank.shouldMusicLoop() + restartTrack: true }); } }); diff --git a/source/funkin/play/scoring/Scoring.hx b/source/funkin/play/scoring/Scoring.hx index 6c9f9bd97..dae098638 100644 --- a/source/funkin/play/scoring/Scoring.hx +++ b/source/funkin/play/scoring/Scoring.hx @@ -577,19 +577,6 @@ enum abstract ScoringRank(String) } } - public function shouldMusicLoop():Bool - { - switch (abstract) - { - case PERFECT_GOLD | PERFECT | EXCELLENT | GREAT | GOOD: - return true; - case SHIT: - return false; - default: - return false; - } - } - public function getHorTextAsset() { switch (abstract)