goodbye freeplaySonglist.json, hi meta.json
This commit is contained in:
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Blammed",
|
||||
"bpm": 165.0,
|
||||
"icon": "pico",
|
||||
"color": "#941653",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Bopeebo",
|
||||
"bpm": 100.0,
|
||||
"icon": "dad",
|
||||
"color": "#9271FD",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Cocoa",
|
||||
"bpm": 100.0,
|
||||
"icon": "parents-christmas",
|
||||
"color": "#A0D1FF",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Dadbattle",
|
||||
"bpm": 180.0,
|
||||
"icon": "dad",
|
||||
"color": "#9271FD",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Eggnog",
|
||||
"bpm": 150.0,
|
||||
"icon": "parents-christmas",
|
||||
"color": "#A0D1FF",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Fresh",
|
||||
"bpm": 120.0,
|
||||
"icon": "dad",
|
||||
"color": "#9271FD",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Guns",
|
||||
"bpm": 185.0,
|
||||
"icon": "tankman",
|
||||
"color": "#F6B604",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "High",
|
||||
"bpm": 125.0,
|
||||
"icon": "mom",
|
||||
"color": "#FC96D7",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "MILF",
|
||||
"bpm": 180.0,
|
||||
"icon": "mom",
|
||||
"color": "#FC96D7",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Monster",
|
||||
"bpm": 95.0,
|
||||
"icon": "monster",
|
||||
"color": "#223344",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Philly Nice",
|
||||
"bpm": 175.0,
|
||||
"icon": "pico",
|
||||
"color": "#941653",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Pico",
|
||||
"bpm": 150.0,
|
||||
"icon": "pico",
|
||||
"color": "#941653",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Roses",
|
||||
"bpm": 120.0,
|
||||
"icon": "senpai",
|
||||
"color": "#FF78BF",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Satin Panties",
|
||||
"bpm": 110.0,
|
||||
"icon": "mom",
|
||||
"color": "#FC96D7",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Senpai",
|
||||
"bpm": 144.0,
|
||||
"icon": "senpai",
|
||||
"color": "#FF78BF",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "South",
|
||||
"bpm": 165.0,
|
||||
"icon": "spooky",
|
||||
"color": "#223344",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Spookeez",
|
||||
"bpm": 150.0,
|
||||
"icon": "spooky",
|
||||
"color": "#223344",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"displayName": "Stress",
|
||||
"bpm": 178.0,
|
||||
"icon": "tankman",
|
||||
"color": "#F6B604",
|
||||
"difficulties": ["EASY", "NORMAL", "HARD"],
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"displayName": "test",
|
||||
"bpm": 150.0,
|
||||
"icon": "bf",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Thorns",
|
||||
"bpm": 190.0,
|
||||
"icon": "spirit",
|
||||
"color": "#FF78BF",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Tutorial",
|
||||
"bpm": 100.0,
|
||||
"icon": "gf",
|
||||
"color": "#9271FD",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Ugh",
|
||||
"bpm": 160.0,
|
||||
"icon": "tankman",
|
||||
"color": "#F6B604",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"displayName": "Winter Horrorland",
|
||||
"bpm": 159.0,
|
||||
"icon": "monster",
|
||||
"color": "#A0D1FF",
|
||||
"coopAllowed": true,
|
||||
"opponentModeAllowed": true
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2328
|
||||
2331
|
||||
@@ -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<String>;
|
||||
public var ?coopAllowed:Bool;
|
||||
public var ?opponentModeAllowed:Bool;
|
||||
|
||||
// NOT TO BE EXPORTED
|
||||
public var ?parsedColor:FlxColor;
|
||||
}
|
||||
|
||||
typedef ChartStrumLine = {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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<SongMetadata> = [];
|
||||
public var songs:Array<ChartMetaData> = [];
|
||||
|
||||
/**
|
||||
* 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<SongMetadata> = [];
|
||||
public var songs:Array<ChartMetaData> = [];
|
||||
|
||||
public function new() {
|
||||
|
||||
}
|
||||
|
||||
private function _addJSONSongs(songs:Array<FreeplaySong>, 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<String> = [];
|
||||
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<FreeplaySong> = [];
|
||||
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() {
|
||||
@@ -453,56 +412,3 @@ class FreeplaySonglist {
|
||||
return songList;
|
||||
}
|
||||
}
|
||||
|
||||
typedef FreeplayJSON = {
|
||||
public var addOGSongs:Null<Bool>;
|
||||
public var songs:Array<FreeplaySong>;
|
||||
}
|
||||
|
||||
typedef FreeplaySong = {
|
||||
public var name:String;
|
||||
public var ?icon:String;
|
||||
public var ?color:Dynamic;
|
||||
public var ?difficulties:Array<String>;
|
||||
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<String> = ["EASY", "NORMAL", "HARD"];
|
||||
public var coopAllowed:Bool = false;
|
||||
public var opponentModeAllowed:Bool = false;
|
||||
|
||||
public function new(song:String, songCharacter:String, color:FlxColor, ?difficulties:Array<String>, 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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user