From 8a8f7bcd8b594b3e9e518f3b6529271c0e82eab6 Mon Sep 17 00:00:00 2001 From: SomeKitten Date: Wed, 18 Aug 2021 22:11:35 -0400 Subject: [PATCH] Songs can now have spaces or dashes. --- source/Paths.hx | 15 +++++++++++++-- source/gameFolder/gameObjects/Stage.hx | 3 ++- source/gameFolder/meta/CoolUtil.hx | 10 ++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/source/Paths.hx b/source/Paths.hx index e972ec5cd..98bb8a8d7 100644 --- a/source/Paths.hx +++ b/source/Paths.hx @@ -5,6 +5,7 @@ package; */ import flixel.FlxG; import flixel.graphics.frames.FlxAtlasFrames; +import gameFolder.meta.CoolUtil; import openfl.utils.AssetType; import openfl.utils.Assets as OpenFlAssets; @@ -132,12 +133,22 @@ class Paths inline static public function voices(song:String) { - return getPath('songs/${song.toLowerCase()}/Voices.$SOUND_EXT', MUSIC, null); + var voicePath = 'songs/${song.toLowerCase()}/Voices.$SOUND_EXT'; + if (!OpenFlAssets.exists(voicePath)) + { + voicePath = 'songs/${CoolUtil.swapSpaceDash(song.toLowerCase())}/Voices.$SOUND_EXT'; + } + return getPath(voicePath, MUSIC, null); } inline static public function inst(song:String) { - return getPath('songs/${song.toLowerCase()}/Inst.$SOUND_EXT', MUSIC, null); + var instPath = 'songs/${song.toLowerCase()}/Inst.$SOUND_EXT'; + if (!OpenFlAssets.exists(instPath)) + { + instPath = 'songs/${CoolUtil.swapSpaceDash(song.toLowerCase())}/Inst.$SOUND_EXT'; + } + return getPath(instPath, MUSIC, null); } inline static public function image(key:String, ?library:String) diff --git a/source/gameFolder/gameObjects/Stage.hx b/source/gameFolder/gameObjects/Stage.hx index fec47ed44..617b0a944 100644 --- a/source/gameFolder/gameObjects/Stage.hx +++ b/source/gameFolder/gameObjects/Stage.hx @@ -13,6 +13,7 @@ import flixel.math.FlxPoint; import flixel.system.FlxSound; import flixel.text.FlxText; import gameFolder.gameObjects.background.*; +import gameFolder.meta.CoolUtil; import gameFolder.meta.state.PlayState; using StringTools; @@ -57,7 +58,7 @@ class Stage extends FlxTypedGroup { // this is because I want to avoid editing the fnf chart type // custom stage stuffs will come with forever charts - switch (PlayState.SONG.song.toLowerCase()) + switch (CoolUtil.spaceToDash(PlayState.SONG.song.toLowerCase())) { case 'spookeez' | 'south' | 'monster': curStage = 'spooky'; diff --git a/source/gameFolder/meta/CoolUtil.hx b/source/gameFolder/meta/CoolUtil.hx index c1e019f74..b7abf3576 100644 --- a/source/gameFolder/meta/CoolUtil.hx +++ b/source/gameFolder/meta/CoolUtil.hx @@ -21,6 +21,16 @@ class CoolUtil return string.replace("-", " "); } + public static function spaceToDash(string:String):String + { + return string.replace(" ", "-"); + } + + public static function swapSpaceDash(string:String):String + { + return StringTools.contains(string, '-') ? dashToSpace(string) : spaceToDash(string); + } + public static function coolTextFile(path:String):Array { var daList:Array = Assets.getText(path).trim().split('\n');