Skip to content

Commit 15a5567

Browse files
authored
Merge pull request #91 from riconuts/song-bs
SongMetadata.songName and a bunch of Song code stuff
2 parents 6b5bd0a + 9a518c2 commit 15a5567

File tree

8 files changed

+294
-248
lines changed

8 files changed

+294
-248
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"songName": "M.I.L.F",
23
"artist": "Kawai Sprite"
34
}

source/funkin/Paths.hx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class Paths
252252

253253
inline static public function sound(key:String, ?library:String):Null<Sound>
254254
{
255-
return returnSound('sounds', key, library);
255+
return returnFolderSound('sounds', key, library);
256256
}
257257

258258
inline static public function soundRandom(key:String, min:Int, max:Int, ?library:String)
@@ -262,12 +262,12 @@ class Paths
262262

263263
inline static public function music(key:String, ?library:String):Null<Sound>
264264
{
265-
return returnSound('music', key, library);
265+
return returnFolderSound('music', key, library);
266266
}
267267

268268
inline static public function track(song:String, track:String):Null<Sound>
269269
{
270-
return returnSound('songs', '${formatToSongPath(song)}/$track');
270+
return returnFolderSound('songs', '${formatToSongPath(song)}/$track');
271271
}
272272

273273
inline static public function voices(song:String):Null<Sound>
@@ -528,29 +528,30 @@ class Paths
528528
return getPath('$path/$key.$SOUND_EXT');
529529
}
530530

531-
public static function returnSound(path:String, key:String, ?library:String)
532-
{
533-
var gottenPath:String = soundPath(path, key, library);
534-
535-
if (currentTrackedSounds.exists(gottenPath)) {
536-
if (!localTrackedAssets.contains(gottenPath))
537-
localTrackedAssets.push(gottenPath);
531+
inline public static function returnFolderSound(path:String, key:String, ?library:String)
532+
return returnSound(soundPath(path, key, library), library);
538533

539-
return currentTrackedSounds.get(gottenPath);
534+
public static function returnSound(path:String, ?library:String)
535+
{
536+
if (currentTrackedSounds.exists(path)) {
537+
if (!localTrackedAssets.contains(path))
538+
localTrackedAssets.push(path);
539+
540+
return currentTrackedSounds.get(path);
540541
}
541542

542-
var sound = getSound(gottenPath);
543+
var sound = getSound(path);
543544
if (sound != null) {
544-
currentTrackedSounds.set(gottenPath, sound);
545+
currentTrackedSounds.set(path, sound);
545546

546-
if (!localTrackedAssets.contains(gottenPath))
547-
localTrackedAssets.push(gottenPath);
547+
if (!localTrackedAssets.contains(path))
548+
localTrackedAssets.push(path);
548549

549550
return sound;
550551
}
551552

552553
if (Main.showDebugTraces)
553-
trace('sound $path, $key => $gottenPath returned null');
554+
trace('sound $path returned null');
554555

555556
return null;
556557
}
@@ -571,6 +572,9 @@ class Paths
571572
return null;
572573
}
573574

575+
public static inline function getFolderPath(folder:String = ""):String
576+
return (folder == "") ? getPreloadPath() : mods(folder);
577+
574578
////
575579
public static var currentModDirectory(default, set):String = '';
576580
static function set_currentModDirectory(v:String){

source/funkin/data/Cache.hx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ class Cache
198198
default:
199199
Paths.image(toLoad.path, toLoad.library);
200200
case SOUND:
201-
Paths.returnSound("sounds", toLoad.path, toLoad.library);
201+
Paths.returnFolderSound("sounds", toLoad.path, toLoad.library);
202202
case MUSIC:
203-
Paths.returnSound("music", toLoad.path, toLoad.library);
203+
Paths.returnFolderSound("music", toLoad.path, toLoad.library);
204204
case SONG:
205-
Paths.returnSound("songs", toLoad.path, toLoad.library);
205+
Paths.returnFolderSound("songs", toLoad.path, toLoad.library);
206206
}
207207

208208
#if traceLoading

source/funkin/data/FNFTroll.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class FNFTroll extends FNFLegacyBasic<TrollJSONFormat> {
212212
}
213213

214214
data.song.metadata ??= {};
215-
//data.song.metadata.songName = chart.meta.title;
215+
data.song.metadata.songName = chart.meta.title;
216216
data.song.metadata.artist = chart.meta.extraData.get("SONG_ARTIST");
217217
data.song.metadata.charter = chart.meta.extraData.get("SONG_CHARTER");
218218

0 commit comments

Comments
 (0)