public static StandardLevelInfoSaveData DeserializeFromJSONString(string stringData, StandardLevelInfoSaveData standardSaveData) { // StandardLevelInfoSaveData standardSaveData = StandardLevelInfoSaveData.DeserializeFromJSONString(stringData); if (standardSaveData.version != "2.0.0") { return(standardSaveData); } Dictionary <string, dynamic> beatmapsByFilename = new Dictionary <string, dynamic>(); OopsAllCustomDatas customDatas = JsonConvert.DeserializeObject <OopsAllCustomDatas>(stringData, new CustomDataConverter()); DifficultyBeatmapSet[] customBeatmapSets = new DifficultyBeatmapSet[standardSaveData.difficultyBeatmapSets.Length]; for (int i = 0; i < standardSaveData.difficultyBeatmapSets.Length; i++) { var standardBeatmapSet = standardSaveData.difficultyBeatmapSets[i]; DifficultyBeatmap[] customBeatmaps = new DifficultyBeatmap[standardBeatmapSet.difficultyBeatmaps.Length]; for (int j = 0; j < standardBeatmapSet.difficultyBeatmaps.Length; j++) { var standardBeatmap = standardBeatmapSet.difficultyBeatmaps[j]; DifficultyBeatmap customBeatmap = new DifficultyBeatmap(standardBeatmap.difficulty, standardBeatmap.difficultyRank, standardBeatmap.beatmapFilename, standardBeatmap.noteJumpMovementSpeed, standardBeatmap.noteJumpStartBeatOffset, customDatas._difficultyBeatmapSets[i]._difficultyBeatmaps[j]._customData ?? Tree()); customBeatmaps[j] = customBeatmap; beatmapsByFilename[customBeatmap.beatmapFilename] = customBeatmap.customData; } customBeatmapSets[i] = new DifficultyBeatmapSet(standardBeatmapSet.beatmapCharacteristicName, customBeatmaps); } CustomLevelInfoSaveData result = new CustomLevelInfoSaveData(standardSaveData.songName, standardSaveData.songSubName, standardSaveData.songAuthorName, standardSaveData.levelAuthorName, standardSaveData.beatsPerMinute, standardSaveData.songTimeOffset, standardSaveData.shuffle, standardSaveData.shufflePeriod, standardSaveData.previewStartTime, standardSaveData.previewDuration, standardSaveData.songFilename, standardSaveData.coverImageFilename, standardSaveData.environmentName, customBeatmapSets, customDatas._customData ?? Tree(), beatmapsByFilename); return(result); }
/// <summary> /// Show the difficulties for the given characteristic /// </summary> /// <param name="name">Characteristic to load from</param> public void SetCharacteristic(string name, bool firstLoad = false) { DeselectDiff(); currentCharacteristic = Song?.difficultyBeatmapSets?.Find(it => it.beatmapCharacteristicName.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (currentCharacteristic == null) { // Create a new set locally if the song doesn't have one, // will only be written back if a difficulty is created currentCharacteristic = new DifficultyBeatmapSet(name); } if (!Characteristics.ContainsKey(name)) { Characteristics.Add(name, new Dictionary <string, DifficultySettings>()); } diffs = Characteristics[name]; loading = true; selectedMemory.TryGetValue(name, out string prevDiffLog); foreach (DifficultyRow row in rows) { bool hasDiff = diffs.ContainsKey(row.Name); row.SetInteractable(diffs.ContainsKey(row.Name)); // Highlight the copy source if it's here row.CopyImage.color = copySource != null && currentCharacteristic == copySource.Characteristic && copySource.Obj == row ? copyColor : Color.white; row.NameInput.text = hasDiff ? diffs[row.Name].CustomName : ""; if (hasDiff) { row.ShowDirtyObjects(diffs[row.Name]); if (firstLoad && Settings.Instance.LastLoadedMap.Equals(Song.directory) && Settings.Instance.LastLoadedDiff.Equals(row.Name)) { selectedMemory[name] = row.Name; OnClick(row); } else if (selected == null || (!firstLoad && selectedMemory.TryGetValue(name, out string prevDiff) && row.Name.Equals(prevDiff))) { OnClick(row); } } else { row.ShowDirtyObjects(false, false); } } loading = false; SetPasteMode(copySource != null); if (selected == null) { njsField.text = ""; songBeatOffsetField.text = ""; envRemoval.ClearList(); } }
public void UpdateParent(DifficultyBeatmapSet newParentSet) { parentBeatmapSet = newParentSet; }
public DifficultyBeatmap(DifficultyBeatmapSet beatmapSet) { parentBeatmapSet = beatmapSet; UpdateName(); }
public static BeatSaberSong GetSongFromFolder(string directory) { try { JSONNode mainNode = GetNodeFromFile(directory + "/info.dat"); if (mainNode == null) { return(null); } BeatSaberSong song = new BeatSaberSong(directory, mainNode); JSONNode.Enumerator nodeEnum = mainNode.GetEnumerator(); while (nodeEnum.MoveNext()) { string key = nodeEnum.Current.Key; JSONNode node = nodeEnum.Current.Value; switch (key) { case "_songName": song.songName = node.Value; break; case "_songSubName": song.songSubName = node.Value; break; case "_songAuthorName": song.songAuthorName = node.Value; break; case "_levelAuthorName": song.levelAuthorName = node.Value; break; case "_beatsPerMinute": song.beatsPerMinute = node.AsFloat; break; case "_songTimeOffset": song.songTimeOffset = node.AsFloat; break; case "_previewStartTime": song.previewStartTime = node.AsFloat; break; case "_previewDuration": song.previewDuration = node.AsFloat; break; case "_shuffle": song.shuffle = node.AsFloat; break; case "_shufflePeriod": song.shufflePeriod = node.AsFloat; break; case "_coverImageFilename": song.coverImageFilename = node.Value; break; case "_songFilename": song.songFilename = node.Value; break; case "_environmentName": song.environmentName = node.Value; break; //Because there is only one option, I wont load from file. //case "_allDirectionsEnvironmentName": song.allDirectionsEnvironmentName = node.Value; break; case "_customData": song.customData = node; foreach (JSONNode n in node) { if (n["_contributors"]?.AsArray != null) { foreach (JSONNode contributor in n["_contributors"].AsArray) { song.contributors.Add(new MapContributor(contributor)); } } if (n["_editor"]?.Value != null) { song.editor = n["_editor"].Value; } } break; case "_difficultyBeatmapSets": foreach (JSONNode n in node) { DifficultyBeatmapSet set = new DifficultyBeatmapSet(); set.beatmapCharacteristicName = n["_beatmapCharacteristicName"]; foreach (JSONNode d in n["_difficultyBeatmaps"]) { DifficultyBeatmap beatmap = new DifficultyBeatmap(set) { difficulty = d["_difficulty"].Value, difficultyRank = d["_difficultyRank"].AsInt, noteJumpMovementSpeed = d["_noteJumpMovementSpeed"].AsFloat, noteJumpStartBeatOffset = d["_noteJumpStartBeatOffset"].AsFloat, customData = d["_customData"], }; if (d["_customData"]["_colorLeft"] != null) { beatmap.colorLeft = GetColorFromJSONNode(d["_customData"]["_colorLeft"]); } if (d["_customData"]["_colorRight"] != null) { beatmap.colorRight = GetColorFromJSONNode(d["_customData"]["_colorRight"]); } if (d["_customData"]["_envColorLeft"] != null) { beatmap.envColorLeft = GetColorFromJSONNode(d["_customData"]["_envColorLeft"]); } else if (d["_customData"]["_colorLeft"] != null) { beatmap.envColorLeft = beatmap.colorLeft; } if (d["_customData"]["_envColorRight"] != null) { beatmap.envColorRight = GetColorFromJSONNode(d["_customData"]["_envColorRight"]); } else if (d["_customData"]["_colorRight"] != null) { beatmap.envColorRight = beatmap.colorRight; } if (d["_customData"]["_obstacleColor"] != null) { beatmap.obstacleColor = GetColorFromJSONNode(d["_customData"]["_obstacleColor"]); } beatmap.UpdateName(d["_beatmapFilename"]); set.difficultyBeatmaps.Add(beatmap); } set.difficultyBeatmaps = set.difficultyBeatmaps.OrderBy(x => x.difficultyRank).ToList(); song.difficultyBeatmapSets.Add(set); } song.difficultyBeatmapSets = song.difficultyBeatmapSets.OrderBy(x => SongInfoEditUI.CharacteristicDropdownToBeatmapName.IndexOf(x.beatmapCharacteristicName)).ToList(); break; } } return(song); } catch (Exception e) { Debug.LogError(e); return(null); } }
public CopySource(DifficultySettings difficultySettings, DifficultyBeatmapSet characteristic, DifficultyRow obj) { DifficultySettings = difficultySettings; Characteristic = characteristic; Obj = obj; }
public static BeatSaberSong GetSongFromFolder(string directory) { try { //"excuse me this is not a schema change" ~lolPants //...after saying that beatsaver will stop accepting "info.dat" for uploading in the near future monkaHMMMMMMM JSONNode mainNode = GetNodeFromFile(directory + "/Info.dat"); if (mainNode == null) { //Virgin "info.dat" VS chad "Info.dat" mainNode = GetNodeFromFile(directory + "/info.dat"); if (mainNode == null) { return(null); } } BeatSaberSong song = new BeatSaberSong(directory, mainNode); song.editor = $"{Application.productName}/{Application.version}"; JSONNode.Enumerator nodeEnum = mainNode.GetEnumerator(); while (nodeEnum.MoveNext()) { string key = nodeEnum.Current.Key; JSONNode node = nodeEnum.Current.Value; switch (key) { case "_songName": song.songName = node.Value; break; case "_songSubName": song.songSubName = node.Value; break; case "_songAuthorName": song.songAuthorName = node.Value; break; case "_levelAuthorName": song.levelAuthorName = node.Value; break; case "_beatsPerMinute": song.beatsPerMinute = node.AsFloat; break; case "_songTimeOffset": song.songTimeOffset = node.AsFloat; break; case "_previewStartTime": song.previewStartTime = node.AsFloat; break; case "_previewDuration": song.previewDuration = node.AsFloat; break; case "_shuffle": song.shuffle = node.AsFloat; break; case "_shufflePeriod": song.shufflePeriod = node.AsFloat; break; case "_coverImageFilename": song.coverImageFilename = node.Value; break; case "_songFilename": song.songFilename = node.Value; break; case "_environmentName": song.environmentName = node.Value; break; //Because there is only one option, I wont load from file. //case "_allDirectionsEnvironmentName": song.allDirectionsEnvironmentName = node.Value; break; case "_customData": song.customData = node; if (!song.customData["_contributors"].IsNull) { foreach (JSONNode contributor in song.customData["_contributors"]) { song.contributors.Add(new MapContributor(contributor)); } } break; case "_difficultyBeatmapSets": foreach (JSONNode n in node) { DifficultyBeatmapSet set = new DifficultyBeatmapSet(); set.beatmapCharacteristicName = n["_beatmapCharacteristicName"]; foreach (JSONNode d in n["_difficultyBeatmaps"]) { DifficultyBeatmap beatmap = new DifficultyBeatmap(set) { difficulty = d["_difficulty"].Value, difficultyRank = d["_difficultyRank"].AsInt, noteJumpMovementSpeed = d["_noteJumpMovementSpeed"].AsFloat, noteJumpStartBeatOffset = d["_noteJumpStartBeatOffset"].AsFloat, customData = d["_customData"], }; if (d["_customData"]["_colorLeft"] != null) { beatmap.colorLeft = d["_customData"]["_colorLeft"].AsObject.ReadColor(); } if (d["_customData"]["_colorRight"] != null) { beatmap.colorRight = d["_customData"]["_colorRight"].AsObject.ReadColor(); } if (d["_customData"]["_envColorLeft"] != null) { beatmap.envColorLeft = d["_customData"]["_envColorLeft"].AsObject.ReadColor(); } else if (d["_customData"]["_colorLeft"] != null) { beatmap.envColorLeft = beatmap.colorLeft; } if (d["_customData"]["_envColorRight"] != null) { beatmap.envColorRight = d["_customData"]["_envColorRight"].AsObject.ReadColor(); } else if (d["_customData"]["_colorRight"] != null) { beatmap.envColorRight = beatmap.colorRight; } if (d["_customData"]["_obstacleColor"] != null) { beatmap.obstacleColor = d["_customData"]["_obstacleColor"].AsObject.ReadColor(); } beatmap.UpdateName(d["_beatmapFilename"]); set.difficultyBeatmaps.Add(beatmap); } set.difficultyBeatmaps = set.difficultyBeatmaps.OrderBy(x => x.difficultyRank).ToList(); song.difficultyBeatmapSets.Add(set); } song.difficultyBeatmapSets = song.difficultyBeatmapSets.OrderBy(x => SongInfoEditUI.CharacteristicDropdownToBeatmapName.IndexOf(x.beatmapCharacteristicName)).ToList(); break; } } return(song); } catch (Exception e) { Debug.LogError(e); return(null); } }
public DifficultyBeatmap(DifficultyBeatmapSet beatmapSet) { parentBeatmapSet = beatmapSet; }
public static BeatSaberSong GetSongFromFolder(string directory) { try { JSONNode mainNode = GetNodeFromFile(directory + "/info.dat"); if (mainNode == null) { return(null); } BeatSaberSong song = new BeatSaberSong(directory, mainNode); List <DifficultyBeatmapSet> difficultyDataList = new List <DifficultyBeatmapSet>(); JSONNode.Enumerator nodeEnum = mainNode.GetEnumerator(); while (nodeEnum.MoveNext()) { string key = nodeEnum.Current.Key; JSONNode node = nodeEnum.Current.Value; switch (key) { case "_songName": song.songName = node.Value; break; case "_songSubName": song.songSubName = node.Value; break; case "_songAuthorName": song.songAuthorName = node.Value; break; case "_levelAuthorName": song.levelAuthorName = node.Value; break; case "_beatsPerMinute": song.beatsPerMinute = node.AsFloat; break; case "_songTimeOffset": song.songTimeOffset = node.AsFloat; break; case "_previewStartTime": song.previewStartTime = node.AsFloat; break; case "_previewDuration": song.previewDuration = node.AsFloat; break; case "_shuffle": song.shuffle = node.AsFloat; break; case "_shufflePeriod": song.shufflePeriod = node.AsFloat; break; case "_coverImageFilename": song.coverImageFilename = node.Value; break; case "_songFilename": song.songFilename = node.Value; break; case "_environmentName": song.environmentName = node.Value; break; case "_customData": song.customData = node; break; case "_difficultyBeatmapSets": foreach (JSONNode n in node) { DifficultyBeatmapSet set = new DifficultyBeatmapSet(); set.beatmapCharacteristicName = n["_beatmapCharacteristicName"]; foreach (JSONNode d in n["_difficultyBeatmaps"]) { DifficultyBeatmap beatmap = new DifficultyBeatmap(set) { difficulty = d["_difficulty"].Value, difficultyRank = d["_difficultyRank"].AsInt, noteJumpMovementSpeed = d["_noteJumpMovementSpeed"].AsFloat, noteJumpStartBeatOffset = d["_noteJumpStartBeatOffset"].AsFloat, customData = d["_customData"], }; if (d["_customData"]["_colorLeft"] != null) { beatmap.colorLeft = GetColorFromJSONNode(d["_customData"]["_colorLeft"]); } if (d["_customData"]["_colorRight"] != null) { beatmap.colorRight = GetColorFromJSONNode(d["_customData"]["_colorRight"]); } beatmap.UpdateName(d["_beatmapFilename"]); set.difficultyBeatmaps.Add(beatmap); } //Debug.Log("Found difficulty data for " + difficultyData.jsonPath); difficultyDataList.Add(set); } break; } } song.difficultyBeatmapSets = difficultyDataList; return(song); } catch (Exception e) { Debug.LogError(e); return(null); } }