From 32a8e2708f99063f04c75ff4d0813a9b3e3870a8 Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Tue, 21 Feb 2023 03:13:07 +0100 Subject: [PATCH] goodbye freeplaySonglist.json, hi meta.json --- assets/data/freeplaySonglist.json | 180 ----------------------- assets/data/freeplaySonglist.txt | 30 ++++ assets/songs/blammed/meta.json | 8 + assets/songs/bopeebo/meta.json | 8 + assets/songs/cocoa/meta.json | 8 + assets/songs/dadbattle/meta.json | 8 + assets/songs/eggnog/meta.json | 8 + assets/songs/fresh/meta.json | 8 + assets/songs/guns/meta.json | 8 + assets/songs/high/meta.json | 8 + assets/songs/milf/meta.json | 8 + assets/songs/monster/meta.json | 8 + assets/songs/philly nice/meta.json | 8 + assets/songs/pico/meta.json | 8 + assets/songs/roses/meta.json | 8 + assets/songs/satin panties/meta.json | 8 + assets/songs/senpai/meta.json | 8 + assets/songs/south/meta.json | 8 + assets/songs/spookeez/meta.json | 8 + assets/songs/stress/meta.json | 9 ++ assets/songs/test/meta.json | 7 + assets/songs/thorns/meta.json | 8 + assets/songs/tutorial/meta.json | 8 + assets/songs/ugh/meta.json | 8 + assets/songs/winter horrorland/meta.json | 8 + buildnumber.txt | 2 +- source/funkin/chart/Chart.hx | 76 +++++++++- source/funkin/game/GameOverSubstate.hx | 2 +- source/funkin/game/PlayState.hx | 2 +- source/funkin/menus/FreeplayState.hx | 142 +++--------------- source/funkin/menus/PauseSubState.hx | 2 +- 31 files changed, 310 insertions(+), 310 deletions(-) delete mode 100644 assets/data/freeplaySonglist.json create mode 100644 assets/data/freeplaySonglist.txt create mode 100644 assets/songs/blammed/meta.json create mode 100644 assets/songs/bopeebo/meta.json create mode 100644 assets/songs/cocoa/meta.json create mode 100644 assets/songs/dadbattle/meta.json create mode 100644 assets/songs/eggnog/meta.json create mode 100644 assets/songs/fresh/meta.json create mode 100644 assets/songs/guns/meta.json create mode 100644 assets/songs/high/meta.json create mode 100644 assets/songs/milf/meta.json create mode 100644 assets/songs/monster/meta.json create mode 100644 assets/songs/philly nice/meta.json create mode 100644 assets/songs/pico/meta.json create mode 100644 assets/songs/roses/meta.json create mode 100644 assets/songs/satin panties/meta.json create mode 100644 assets/songs/senpai/meta.json create mode 100644 assets/songs/south/meta.json create mode 100644 assets/songs/spookeez/meta.json create mode 100644 assets/songs/stress/meta.json create mode 100644 assets/songs/test/meta.json create mode 100644 assets/songs/thorns/meta.json create mode 100644 assets/songs/tutorial/meta.json create mode 100644 assets/songs/ugh/meta.json create mode 100644 assets/songs/winter horrorland/meta.json diff --git a/assets/data/freeplaySonglist.json b/assets/data/freeplaySonglist.json deleted file mode 100644 index fda09509..00000000 --- a/assets/data/freeplaySonglist.json +++ /dev/null @@ -1,180 +0,0 @@ -{ - "addOGSongs": false, - "songs": [ - { - "name": "test", - "icon": "bf", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Tutorial", - "icon": "gf", - "color": "#9271FD", - "coopAllowed": true, - "opponentModeAllowed": true - }, - - - { - "name": "Bopeebo", - "icon": "dad", - "color": "#9271FD", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Fresh", - "icon": "dad", - "color": "#9271FD", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Dadbattle", - "icon": "dad", - "color": "#9271FD", - "coopAllowed": true, - "opponentModeAllowed": true - }, - - - { - "name": "Spookeez", - "icon": "spooky", - "color": "#223344", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "South", - "icon": "spooky", - "color": "#223344", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Monster", - "icon": "monster", - "color": "#223344", - "coopAllowed": true, - "opponentModeAllowed": true - }, - - - { - "name": "Pico", - "icon": "pico", - "color": "#941653", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Philly Nice", - "icon": "pico", - "color": "#941653", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Blammed", - "icon": "pico", - "color": "#941653", - "coopAllowed": true, - "opponentModeAllowed": true - }, - - - { - "name": "Satin Panties", - "icon": "mom", - "color": "#FC96D7", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "High", - "icon": "mom", - "color": "#FC96D7", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "MILF", - "icon": "mom", - "color": "#FC96D7", - "coopAllowed": true, - "opponentModeAllowed": true - }, - - - { - "name": "Cocoa", - "icon": "parents-christmas", - "color": "#A0D1FF", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Eggnog", - "icon": "parents-christmas", - "color": "#A0D1FF", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Winter Horrorland", - "icon": "monster", - "color": "#A0D1FF", - "coopAllowed": true, - "opponentModeAllowed": true - }, - - - { - "name": "Senpai", - "icon": "senpai", - "color": "#FF78BF", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Roses", - "icon": "senpai", - "color": "#FF78BF", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Thorns", - "icon": "spirit", - "color": "#FF78BF", - "coopAllowed": true, - "opponentModeAllowed": true - }, - - - { - "name": "Ugh", - "icon": "tankman", - "color": "#F6B604", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Guns", - "icon": "tankman", - "color": "#F6B604", - "coopAllowed": true, - "opponentModeAllowed": true - }, - { - "name": "Stress", - "icon": "tankman", - "color": "#F6B604", - "difficulties": ["EASY", "NORMAL", "HARD"], - "coopAllowed": true, - "opponentModeAllowed": true - } - ] -} \ No newline at end of file diff --git a/assets/data/freeplaySonglist.txt b/assets/data/freeplaySonglist.txt new file mode 100644 index 00000000..269b679f --- /dev/null +++ b/assets/data/freeplaySonglist.txt @@ -0,0 +1,30 @@ +test +tutorial + +bopeebo +fresh +dadbattle + +spookeez +south +monster + +pico +philly nice +blammed + +satin panties +high +milf + +cocoa +eggnog +winter horrorland + +senpai +roses +thorns + +ugh +guns +stress \ No newline at end of file diff --git a/assets/songs/blammed/meta.json b/assets/songs/blammed/meta.json new file mode 100644 index 00000000..aeee779f --- /dev/null +++ b/assets/songs/blammed/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Blammed", + "bpm": 165.0, + "icon": "pico", + "color": "#941653", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/bopeebo/meta.json b/assets/songs/bopeebo/meta.json new file mode 100644 index 00000000..a1e82cad --- /dev/null +++ b/assets/songs/bopeebo/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Bopeebo", + "bpm": 100.0, + "icon": "dad", + "color": "#9271FD", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/cocoa/meta.json b/assets/songs/cocoa/meta.json new file mode 100644 index 00000000..23079da7 --- /dev/null +++ b/assets/songs/cocoa/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Cocoa", + "bpm": 100.0, + "icon": "parents-christmas", + "color": "#A0D1FF", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/dadbattle/meta.json b/assets/songs/dadbattle/meta.json new file mode 100644 index 00000000..b70612ad --- /dev/null +++ b/assets/songs/dadbattle/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Dadbattle", + "bpm": 180.0, + "icon": "dad", + "color": "#9271FD", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/eggnog/meta.json b/assets/songs/eggnog/meta.json new file mode 100644 index 00000000..8761dbe7 --- /dev/null +++ b/assets/songs/eggnog/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Eggnog", + "bpm": 150.0, + "icon": "parents-christmas", + "color": "#A0D1FF", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/fresh/meta.json b/assets/songs/fresh/meta.json new file mode 100644 index 00000000..ad6be7d5 --- /dev/null +++ b/assets/songs/fresh/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Fresh", + "bpm": 120.0, + "icon": "dad", + "color": "#9271FD", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/guns/meta.json b/assets/songs/guns/meta.json new file mode 100644 index 00000000..f78f004a --- /dev/null +++ b/assets/songs/guns/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Guns", + "bpm": 185.0, + "icon": "tankman", + "color": "#F6B604", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/high/meta.json b/assets/songs/high/meta.json new file mode 100644 index 00000000..5488e51b --- /dev/null +++ b/assets/songs/high/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "High", + "bpm": 125.0, + "icon": "mom", + "color": "#FC96D7", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/milf/meta.json b/assets/songs/milf/meta.json new file mode 100644 index 00000000..f15c5268 --- /dev/null +++ b/assets/songs/milf/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "MILF", + "bpm": 180.0, + "icon": "mom", + "color": "#FC96D7", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/monster/meta.json b/assets/songs/monster/meta.json new file mode 100644 index 00000000..f9ddd015 --- /dev/null +++ b/assets/songs/monster/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Monster", + "bpm": 95.0, + "icon": "monster", + "color": "#223344", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/philly nice/meta.json b/assets/songs/philly nice/meta.json new file mode 100644 index 00000000..8b40889a --- /dev/null +++ b/assets/songs/philly nice/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Philly Nice", + "bpm": 175.0, + "icon": "pico", + "color": "#941653", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/pico/meta.json b/assets/songs/pico/meta.json new file mode 100644 index 00000000..a757febc --- /dev/null +++ b/assets/songs/pico/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Pico", + "bpm": 150.0, + "icon": "pico", + "color": "#941653", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/roses/meta.json b/assets/songs/roses/meta.json new file mode 100644 index 00000000..aeb2d6e1 --- /dev/null +++ b/assets/songs/roses/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Roses", + "bpm": 120.0, + "icon": "senpai", + "color": "#FF78BF", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/satin panties/meta.json b/assets/songs/satin panties/meta.json new file mode 100644 index 00000000..e7273a39 --- /dev/null +++ b/assets/songs/satin panties/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Satin Panties", + "bpm": 110.0, + "icon": "mom", + "color": "#FC96D7", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/senpai/meta.json b/assets/songs/senpai/meta.json new file mode 100644 index 00000000..5ff8acbc --- /dev/null +++ b/assets/songs/senpai/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Senpai", + "bpm": 144.0, + "icon": "senpai", + "color": "#FF78BF", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/south/meta.json b/assets/songs/south/meta.json new file mode 100644 index 00000000..a99f1d54 --- /dev/null +++ b/assets/songs/south/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "South", + "bpm": 165.0, + "icon": "spooky", + "color": "#223344", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/spookeez/meta.json b/assets/songs/spookeez/meta.json new file mode 100644 index 00000000..26d97cce --- /dev/null +++ b/assets/songs/spookeez/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Spookeez", + "bpm": 150.0, + "icon": "spooky", + "color": "#223344", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/stress/meta.json b/assets/songs/stress/meta.json new file mode 100644 index 00000000..a8b834a0 --- /dev/null +++ b/assets/songs/stress/meta.json @@ -0,0 +1,9 @@ +{ + "displayName": "Stress", + "bpm": 178.0, + "icon": "tankman", + "color": "#F6B604", + "difficulties": ["EASY", "NORMAL", "HARD"], + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/test/meta.json b/assets/songs/test/meta.json new file mode 100644 index 00000000..10dbec86 --- /dev/null +++ b/assets/songs/test/meta.json @@ -0,0 +1,7 @@ +{ + "displayName": "test", + "bpm": 150.0, + "icon": "bf", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/thorns/meta.json b/assets/songs/thorns/meta.json new file mode 100644 index 00000000..530dd4ce --- /dev/null +++ b/assets/songs/thorns/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Thorns", + "bpm": 190.0, + "icon": "spirit", + "color": "#FF78BF", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/tutorial/meta.json b/assets/songs/tutorial/meta.json new file mode 100644 index 00000000..3498512e --- /dev/null +++ b/assets/songs/tutorial/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Tutorial", + "bpm": 100.0, + "icon": "gf", + "color": "#9271FD", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/ugh/meta.json b/assets/songs/ugh/meta.json new file mode 100644 index 00000000..f65a10a1 --- /dev/null +++ b/assets/songs/ugh/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Ugh", + "bpm": 160.0, + "icon": "tankman", + "color": "#F6B604", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/assets/songs/winter horrorland/meta.json b/assets/songs/winter horrorland/meta.json new file mode 100644 index 00000000..83eaf90b --- /dev/null +++ b/assets/songs/winter horrorland/meta.json @@ -0,0 +1,8 @@ +{ + "displayName": "Winter Horrorland", + "bpm": 159.0, + "icon": "monster", + "color": "#A0D1FF", + "coopAllowed": true, + "opponentModeAllowed": true +} \ No newline at end of file diff --git a/buildnumber.txt b/buildnumber.txt index 896f46ec..583f9c4e 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2328 \ No newline at end of file +2331 \ No newline at end of file diff --git a/source/funkin/chart/Chart.hx b/source/funkin/chart/Chart.hx index a088a840..b027fd14 100644 --- a/source/funkin/chart/Chart.hx +++ b/source/funkin/chart/Chart.hx @@ -1,22 +1,77 @@ package funkin.chart; +import flixel.util.FlxColor; +import haxe.io.Path; import funkin.system.Song.SwagSong; import haxe.Json; import openfl.utils.Assets; class Chart { + public static function loadChartMeta(songName:String, difficulty:String = "normal") { + var metaPath = Paths.file('songs/${songName.toLowerCase()}/meta.json'); + var metaDiffPath = Paths.file('songs/${songName.toLowerCase()}/meta-${difficulty.toLowerCase()}.json'); + + var data:ChartMetaData = null; + var fromMods:Bool = false; + for(path in [metaDiffPath, metaPath]) { + if (Assets.exists(path)) { + fromMods = Paths.assetsTree.existsSpecific(path, "TEXT", MODS); + try { + data = Json.parse(Assets.getText(path)); + } catch(e) { + Logs.trace('Failed to load song metadata for ${songName} ($path): ${Std.string(e)}', ERROR); + } + if (data != null) break; + } + } + + if (data == null) + data = { + name: songName, + bpm: 100 + }; + data.setFieldDefault("name", songName); + data.setFieldDefault("beatsPerMesure", 4); + data.setFieldDefault("stepsPerBeat", 4); + data.setFieldDefault("needsVoices", true); + data.setFieldDefault("icon", "face"); + data.setFieldDefault("difficulties", []); + data.setFieldDefault("coopAllowed", false); + data.setFieldDefault("opponentModeAllowed", false); + data.setFieldDefault("displayName", data.name); + data.setFieldDefault("parsedColor", data.color.getColorFromDynamic()); + + if (data.difficulties.length <= 0) { + data.difficulties = [for(f in Paths.getFolderContent('songs/${songName.toLowerCase()}/charts/', false, !fromMods)) if (Path.extension(f = f.toUpperCase()) == "JSON") Path.withoutExtension(f)]; + if (data.difficulties.length == 3) { + var hasHard = false, hasNormal = false, hasEasy = false; + for(d in data.difficulties) { + switch(d) { + case "EASY": hasEasy = true; + case "NORMAL": hasNormal = true; + case "HARD": hasHard = true; + } + } + if (hasHard && hasNormal && hasEasy) { + data.difficulties[0] = "EASY"; + data.difficulties[1] = "NORMAL"; + data.difficulties[2] = "HARD"; + } + } + } + if (data.difficulties.length <= 0) + data.difficulties.push("CHART MISSING"); + + return data; + } + public static function parse(songName:String, difficulty:String = "normal"):ChartData { var chartPath = Paths.chart(songName, difficulty); var base:ChartData = { strumLines: [], noteTypes: [], events: [], - meta: { - name: songName, - bpm: 0, - beatsPerMesure: 4, - stepsPerBeat: 4 - }, + meta: null, scrollSpeed: 2, stage: "stage", codenameChart: true, @@ -47,8 +102,6 @@ class Chart { base.scrollSpeed = data.speed; base.stage = data.stage; - base.meta.name = data.song; - base.meta.bpm = data.bpm; base.strumLines.push({ characters: [data.player2], @@ -127,6 +180,9 @@ class Chart { curTime += curCrochet * beatsPerMesure; } } + + if (base.meta == null) + base.meta = loadChartMeta(songName, difficulty); return base; } @@ -158,6 +214,7 @@ typedef ChartData = { typedef ChartMetaData = { public var name:String; public var bpm:Float; + public var ?displayName:String; public var ?beatsPerMesure:Float; public var ?stepsPerBeat:Float; public var ?needsVoices:Bool; @@ -166,6 +223,9 @@ typedef ChartMetaData = { public var ?difficulties:Array; public var ?coopAllowed:Bool; public var ?opponentModeAllowed:Bool; + + // NOT TO BE EXPORTED + public var ?parsedColor:FlxColor; } typedef ChartStrumLine = { diff --git a/source/funkin/game/GameOverSubstate.hx b/source/funkin/game/GameOverSubstate.hx index 169b9c3b..86879e68 100644 --- a/source/funkin/game/GameOverSubstate.hx +++ b/source/funkin/game/GameOverSubstate.hx @@ -57,7 +57,7 @@ class GameOverSubstate extends MusicBeatSubstate lossSFX = FlxG.sound.play(Paths.sound(lossSFXName)); Conductor.changeBPM(100); - DiscordUtil.changePresence('Game Over', PlayState.SONG.meta.name + " (" + PlayState.difficulty + ")"); + DiscordUtil.changePresence('Game Over', PlayState.SONG.meta.displayName + " (" + PlayState.difficulty + ")"); } override function update(elapsed:Float) diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 7834baf2..58e0a589 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -685,7 +685,7 @@ class PlayState extends MusicBeatState * This function is dynamic, which means you can do `updateDiscordPresence = function() {}` in scripts. */ public dynamic function updateDiscordPresence() - DiscordUtil.changeSongPresence(detailsText, (paused ? "Paused - " : "") + SONG.meta.name + " (" + difficulty + ")", inst, getIconRPC()); + DiscordUtil.changeSongPresence(detailsText, (paused ? "Paused - " : "") + SONG.meta.displayName + " (" + difficulty + ")", inst, getIconRPC()); /** * Starts a cutscene. diff --git a/source/funkin/menus/FreeplayState.hx b/source/funkin/menus/FreeplayState.hx index 602743ad..dc3bfd7a 100644 --- a/source/funkin/menus/FreeplayState.hx +++ b/source/funkin/menus/FreeplayState.hx @@ -1,5 +1,7 @@ package funkin.menus; +import funkin.chart.Chart; +import funkin.chart.Chart.ChartMetaData; import haxe.io.Path; import flash.text.TextField; import flixel.FlxG; @@ -35,7 +37,7 @@ class FreeplayState extends MusicBeatState /** * Array containing all of the songs metadatas */ - public var songs:Array = []; + public var songs:Array = []; /** * Currently selected song @@ -133,12 +135,12 @@ class FreeplayState extends MusicBeatState for (i in 0...songs.length) { - var songText:Alphabet = new Alphabet(0, (70 * i) + 30, songs[i].songName, true, false); + var songText:Alphabet = new Alphabet(0, (70 * i) + 30, songs[i].displayName, true, false); songText.isMenuItem = true; songText.targetY = i; grpSongs.add(songText); - var icon:HealthIcon = new HealthIcon(songs[i].songCharacter); + var icon:HealthIcon = new HealthIcon(songs[i].icon); icon.sprTracker = songText; // using a FlxGroup is too much fuss! @@ -220,7 +222,7 @@ class FreeplayState extends MusicBeatState scoreText.x = coopText.x = scoreBG.x + 4; diffText.x = Std.int(scoreBG.x + ((scoreBG.width - diffText.width) / 2)); - interpColor.fpsLerpTo(songs[curSelected].color, 0.0625); + interpColor.fpsLerpTo(songs[curSelected].parsedColor, 0.0625); bg.color = interpColor.color; @@ -228,7 +230,7 @@ class FreeplayState extends MusicBeatState #if PRELOAD_ALL autoplayElapsed += elapsed; if (!songInstPlaying && (autoplayElapsed > timeUntilAutoplay || FlxG.keys.justPressed.SPACE)) { - if (curPlayingInst != (curPlayingInst = Paths.inst(songs[curSelected].songName, songs[curSelected].difficulties[curDifficulty]))) + if (curPlayingInst != (curPlayingInst = Paths.inst(songs[curSelected].name, songs[curSelected].difficulties[curDifficulty]))) FlxG.sound.playMusic(curPlayingInst, 0); songInstPlaying = true; dontPlaySongThisFrame = true; @@ -261,7 +263,7 @@ class FreeplayState extends MusicBeatState opponentMode = curCoopMode == 1; } - var event = event("onSelect", EventManager.get(FreeplaySongSelectEvent).recycle(songs[curSelected].songName, songs[curSelected].difficulties[curDifficulty], opponentMode, coopMode)); + var event = event("onSelect", EventManager.get(FreeplaySongSelectEvent).recycle(songs[curSelected].name, songs[curSelected].difficulties[curDifficulty], opponentMode, coopMode)); if (event.cancelled) return; @@ -286,7 +288,7 @@ class FreeplayState extends MusicBeatState curDifficulty = event.value; #if !switch - intendedScore = Highscore.getScore(curSong.songName, curSong.difficulties[curDifficulty]).score; + intendedScore = Highscore.getScore(curSong.name, curSong.difficulties[curDifficulty]).score; #end if (curSong.difficulties.length > 1) @@ -377,71 +379,28 @@ class FreeplayState extends MusicBeatState } class FreeplaySonglist { - public var addOGSongs:Bool = false; - public var songs:Array = []; + public var songs:Array = []; public function new() { } - private function _addJSONSongs(songs:Array, source:Bool = false) { - if (songs != null && songs is Array) { - for(e in songs) { - if (e is Dynamic) { - if (e.name == null) continue; - if (e.icon == null) e.icon = "bf"; - if (e.color == null) e.color = FreeplayState.defaultColor; - if (e.coopAllowed == null) e.coopAllowed = false; - if (e.opponentModeAllowed == null) e.opponentModeAllowed = false; - - var meta = new SongMetadata(e.name, - e.icon.getDefault("bf"), - CoolUtil.getColorFromDynamic(e.color).getDefault(FreeplayState.defaultColor), e.difficulties, source); - - meta.coopAllowed = e.coopAllowed; - meta.opponentModeAllowed = e.opponentModeAllowed; - this.songs.push(meta); - } - } - } - } - - private function getSongsFromSource(source:funkin.system.AssetsLibraryList.AssetSource) { - var path:String = Paths.json('freeplaySonglist'); - var addOGSongs:Bool = true; + public function getSongsFromSource(source:funkin.system.AssetsLibraryList.AssetSource) { + var path:String = Paths.txt('freeplaySonglist'); + var songsFound:Array = []; if (Paths.assetsTree.existsSpecific(path, "TEXT", source)) { - try { - var json:FreeplayJSON = Json.parse(Paths.assetsTree.getSpecificAsset(path, "TEXT", source)); - addOGSongs = CoolUtil.getDefault(json.addOGSongs, true); - _addJSONSongs(json.songs, source == SOURCE); - } catch(e) { - Logs.trace('Couldn\'t parse Freeplay JSON: ${e.toString()}'); - } + var trim = ""; + songsFound = [for(line in Assets.getText(path).split("\n")) if ((trim = line.trim()) != "" && !trim.startsWith("#")) trim]; } else { - var found:Array = []; - for(s in Paths.getFolderDirectories('songs', false, source)) { - var sMetaPath = Paths.file('songs/${s}/meta.json'); - if (Paths.assetsTree.existsSpecific(sMetaPath, "TEXT", source)) { - try { - var meta:FreeplaySong = Json.parse(Paths.assetsTree.getSpecificAsset(sMetaPath, "TEXT", source)); - if (meta.name == null) - meta.name = s; - found.push(meta); - } catch(e) { - Logs.trace('Couldn\'t parse metadata for song ${s}: ${e.toString()}'); - found.push({ - name: s - }); - } - } else { - found.push({ - name: s - }); - } - } - _addJSONSongs(found, source == SOURCE); + songsFound = Paths.getFolderDirectories('songs', false, source); } - return addOGSongs; + + if (songsFound.length > 0) { + for(s in songsFound) + songs.push(Chart.loadChartMeta(s)); + return false; + } + return true; } public static function get() { @@ -452,57 +411,4 @@ class FreeplaySonglist { return songList; } -} - -typedef FreeplayJSON = { - public var addOGSongs:Null; - public var songs:Array; -} - -typedef FreeplaySong = { - public var name:String; - public var ?icon:String; - public var ?color:Dynamic; - public var ?difficulties:Array; - public var ?coopAllowed:Bool; - public var ?opponentModeAllowed:Bool; -} - -class SongMetadata -{ - public var songName:String = ""; - public var color:FlxColor = FreeplayState.defaultColor; - public var songCharacter:String = ""; - public var difficulties:Array = ["EASY", "NORMAL", "HARD"]; - public var coopAllowed:Bool = false; - public var opponentModeAllowed:Bool = false; - - public function new(song:String, songCharacter:String, color:FlxColor, ?difficulties:Array, fromSource:Bool = false) - { - this.songName = song; - this.color = color; - this.songCharacter = songCharacter; - if (difficulties != null && difficulties.length > 0) { - this.difficulties = difficulties; - } else { - this.difficulties = difficulties = [for(f in Paths.getFolderContent('songs/${song.toLowerCase()}/charts/', false, fromSource)) if (Path.extension(f = f.toUpperCase()) == "JSON") Path.withoutExtension(f)]; - if (difficulties.length == 3) { - var hasHard = false, hasNormal = false, hasEasy = false; - for(d in difficulties) { - switch(d) { - case "EASY": hasEasy = true; - case "NORMAL": hasNormal = true; - case "HARD": hasHard = true; - } - } - if (hasHard && hasNormal && hasEasy) { - difficulties[0] = "EASY"; - difficulties[1] = "NORMAL"; - difficulties[2] = "HARD"; - } - } - } - if (this.difficulties.length <= 0) - this.difficulties.push("NORMAL"); - } -} +} \ No newline at end of file diff --git a/source/funkin/menus/PauseSubState.hx b/source/funkin/menus/PauseSubState.hx index 5d76728f..0de9f822 100644 --- a/source/funkin/menus/PauseSubState.hx +++ b/source/funkin/menus/PauseSubState.hx @@ -65,7 +65,7 @@ class PauseSubState extends MusicBeatSubstate bg.scrollFactor.set(); add(bg); - var levelInfo:FlxText = new FlxText(20, 15, 0, PlayState.SONG.meta.name, 32); + var levelInfo:FlxText = new FlxText(20, 15, 0, PlayState.SONG.meta.displayName, 32); var levelDifficulty:FlxText = new FlxText(20, 15 + 32, 0, PlayState.difficulty.toUpperCase(), 32); var multiplayerText:FlxText = new FlxText(20, 15 + 32 + 32, 0, PlayState.opponentMode ? 'OPPONENT MODE' : (PlayState.coopMode ? 'CO-OP MODE' : ''), 32);