From a7aab0044a0a938c7f86621550fc8dc839d809f6 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Fri, 7 Apr 2023 15:04:50 +0200 Subject: [PATCH] few adjustements --- source/funkin/menus/FreeplayState.hx | 9 ++++++--- source/funkin/menus/PauseSubState.hx | 2 +- source/funkin/{system => utils}/FunkinParentDisabler.hx | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) rename source/funkin/{system => utils}/FunkinParentDisabler.hx (98%) diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index f8c5b4ba..4dbb6eec 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -272,6 +272,8 @@ class FreeplayState extends MusicBeatState opponentMode = curCoopMode == 1; } + if (songs[curSelected].difficulties.length <= 0) return; + var event = event("onSelect", EventManager.get(FreeplaySongSelectEvent).recycle(songs[curSelected].name, songs[curSelected].difficulties[curDifficulty], opponentMode, coopMode)); if (event.cancelled) return; @@ -299,20 +301,21 @@ class FreeplayState extends MusicBeatState if (change == 0 && !force) return; var curSong = songs[curSelected]; - var event = event("onChangeDiff", EventManager.get(MenuChangeEvent).recycle(curDifficulty, FlxMath.wrap(curDifficulty + change, 0, curSong.difficulties.length-1), change)); + var validDifficulties = curSong.difficulties.length > 0; + var event = event("onChangeDiff", EventManager.get(MenuChangeEvent).recycle(curDifficulty, validDifficulties ? FlxMath.wrap(curDifficulty + change, 0, curSong.difficulties.length-1) : 0, change)); if (event.cancelled) return; curDifficulty = event.value; #if !switch - intendedScore = Highscore.getScore(curSong.name, curSong.difficulties[curDifficulty]).score; + intendedScore = validDifficulties ? Highscore.getScore(curSong.name, curSong.difficulties[curDifficulty]).score : 0; #end if (curSong.difficulties.length > 1) diffText.text = '< ${curSong.difficulties[curDifficulty]} >'; else - diffText.text = curSong.difficulties[curDifficulty]; + diffText.text = validDifficulties ? curSong.difficulties[curDifficulty] : "-"; } /** diff --git a/source/funkin/menus/PauseSubState.hx b/source/funkin/menus/PauseSubState.hx index 85c5bc41..ac5d5f3c 100644 --- a/source/funkin/menus/PauseSubState.hx +++ b/source/funkin/menus/PauseSubState.hx @@ -13,7 +13,7 @@ import flixel.tweens.FlxTween; import flixel.util.FlxColor; import funkin.options.keybinds.KeybindsOptions; import funkin.menus.StoryMenuState; -import funkin.system.FunkinParentDisabler; +import funkin.utils.FunkinParentDisabler; class PauseSubState extends MusicBeatSubstate { diff --git a/source/funkin/system/FunkinParentDisabler.hx b/source/funkin/utils/FunkinParentDisabler.hx similarity index 98% rename from source/funkin/system/FunkinParentDisabler.hx rename to source/funkin/utils/FunkinParentDisabler.hx index dd63f4c3..3f9b6ca9 100644 --- a/source/funkin/system/FunkinParentDisabler.hx +++ b/source/funkin/utils/FunkinParentDisabler.hx @@ -1,4 +1,4 @@ -package funkin.system; +package funkin.utils; import flixel.util.FlxTimer; import flixel.tweens.FlxTween;