private static BeatSaberJSONClass.InfoJSON GenerateInfoFile(BeatMapData data) { BeatSaberJSONClass.InfoJSON info = new BeatSaberJSONClass.InfoJSON(); info.authorName = data.mapArtist; info.songName = data.songName; info.songSubName = data.songArtist; info.beatsPerMinute = (int)data.beatsPerMinute; info.previewStartTime = 0; info.previewDuration = 10; info.coverImagePath = "cover.jpg"; info.environmentName = "DefaultEnvironment"; info.difficultyLevels = new BeatSaberJSONClass.DifficultyLevel[1]; info.difficultyLevels[0] = BeatSaberJSONClass.DifficultyLevel.Generate(data.difficulty, data.songFileName, (int)data.songOffset); return(info); }
public static BeatSaberJSONClass SaveToDisk(BeatMapData data) { Debug.LogWarning("Save to disk called with note count " + data.notes.Length); Debug.LogWarning("data song file name - " + data.songFileName); BeatSaberJSONClass beatSaberJSON = BeatSaberJSONClass.ConvertUnityDataToBSData(data); string levelJSON = JsonUtility.ToJson(beatSaberJSON.level, false); BeatSaberJSONClass.InfoJSON info = GenerateInfoFile(data); string infoJSON = JsonUtility.ToJson(info, false); string songFolder = BeatMap.savePath + data.songName + "/"; string levelFileName; if (data.difficulty == BeatSaveDifficulty.Easy) { levelFileName = "Easy.json"; } else if (data.difficulty == BeatSaveDifficulty.Normal) { levelFileName = "Normal.json"; } else if (data.difficulty == BeatSaveDifficulty.Hard) { levelFileName = "Hard.json"; } else if (data.difficulty == BeatSaveDifficulty.Expert) { levelFileName = "Expert.json"; } else { levelFileName = "ExpertPlus.json"; } if (!Directory.Exists(songFolder)) { Directory.CreateDirectory(songFolder); } string levelOutputPath = songFolder + levelFileName; string infoOutputPath = songFolder + "info.json"; WriteToDisk(infoOutputPath, infoJSON); WriteToDisk(levelOutputPath, levelJSON); BeatMap.Log("Save complete to file " + levelOutputPath); return(beatSaberJSON); }