Skip to content

Commit

Permalink
Merge pull request #91 from riconuts/song-bs
Browse files Browse the repository at this point in the history
SongMetadata.songName and a bunch of Song code stuff
  • Loading branch information
riconuts authored Feb 21, 2025
2 parents 6b5bd0a + 9a518c2 commit 15a5567
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 248 deletions.
1 change: 1 addition & 0 deletions default_content/base-game/songs/milf/metadata.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"songName": "M.I.L.F",
"artist": "Kawai Sprite"
}
36 changes: 20 additions & 16 deletions source/funkin/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class Paths

inline static public function sound(key:String, ?library:String):Null<Sound>
{
return returnSound('sounds', key, library);
return returnFolderSound('sounds', key, library);
}

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

inline static public function music(key:String, ?library:String):Null<Sound>
{
return returnSound('music', key, library);
return returnFolderSound('music', key, library);
}

inline static public function track(song:String, track:String):Null<Sound>
{
return returnSound('songs', '${formatToSongPath(song)}/$track');
return returnFolderSound('songs', '${formatToSongPath(song)}/$track');
}

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

public static function returnSound(path:String, key:String, ?library:String)
{
var gottenPath:String = soundPath(path, key, library);

if (currentTrackedSounds.exists(gottenPath)) {
if (!localTrackedAssets.contains(gottenPath))
localTrackedAssets.push(gottenPath);
inline public static function returnFolderSound(path:String, key:String, ?library:String)
return returnSound(soundPath(path, key, library), library);

return currentTrackedSounds.get(gottenPath);
public static function returnSound(path:String, ?library:String)
{
if (currentTrackedSounds.exists(path)) {
if (!localTrackedAssets.contains(path))
localTrackedAssets.push(path);

return currentTrackedSounds.get(path);
}

var sound = getSound(gottenPath);
var sound = getSound(path);
if (sound != null) {
currentTrackedSounds.set(gottenPath, sound);
currentTrackedSounds.set(path, sound);

if (!localTrackedAssets.contains(gottenPath))
localTrackedAssets.push(gottenPath);
if (!localTrackedAssets.contains(path))
localTrackedAssets.push(path);

return sound;
}

if (Main.showDebugTraces)
trace('sound $path, $key => $gottenPath returned null');
trace('sound $path returned null');

return null;
}
Expand All @@ -571,6 +572,9 @@ class Paths
return null;
}

public static inline function getFolderPath(folder:String = ""):String
return (folder == "") ? getPreloadPath() : mods(folder);

////
public static var currentModDirectory(default, set):String = '';
static function set_currentModDirectory(v:String){
Expand Down
6 changes: 3 additions & 3 deletions source/funkin/data/Cache.hx
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ class Cache
default:
Paths.image(toLoad.path, toLoad.library);
case SOUND:
Paths.returnSound("sounds", toLoad.path, toLoad.library);
Paths.returnFolderSound("sounds", toLoad.path, toLoad.library);
case MUSIC:
Paths.returnSound("music", toLoad.path, toLoad.library);
Paths.returnFolderSound("music", toLoad.path, toLoad.library);
case SONG:
Paths.returnSound("songs", toLoad.path, toLoad.library);
Paths.returnFolderSound("songs", toLoad.path, toLoad.library);
}

#if traceLoading
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/data/FNFTroll.hx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class FNFTroll extends FNFLegacyBasic<TrollJSONFormat> {
}

data.song.metadata ??= {};
//data.song.metadata.songName = chart.meta.title;
data.song.metadata.songName = chart.meta.title;
data.song.metadata.artist = chart.meta.extraData.get("SONG_ARTIST");
data.song.metadata.charter = chart.meta.extraData.get("SONG_CHARTER");

Expand Down
Loading

0 comments on commit 15a5567

Please sign in to comment.