Пример #1
0
        public static Tuple <InfoJson, List <DifficultyJson> > ConvertInfo(InfoDat infoDat, string folderPath)
        {
            List <DifficultyJson> diffJsons = new List <DifficultyJson>();
            InfoJson info = new InfoJson
            {
                songName              = $"{infoDat._songName}{(string.IsNullOrWhiteSpace(infoDat._songSubName) ? "" : $" {infoDat._songSubName}")}",
                songSubName           = infoDat._songAuthorName,
                authorName            = infoDat._levelAuthorName,
                beatsPerMinute        = infoDat._beatsPerMinute,
                previewStartTime      = infoDat._previewStartTime,
                previewDuration       = infoDat._previewDuration,
                coverImagePath        = infoDat._coverImageFilename,
                environmentName       = infoDat._environmentName,
                customEnvironment     = infoDat._customData?._customEnvironment ?? "",
                customEnvironmentHash = infoDat._customData?._customEnvironmentHash ?? ""
            };

            if (infoDat._customData != null)
            {
                foreach (var contrib in infoDat._customData._contributors) // Contributors
                {
                    info.contributors.Add(new InfoJson.Contributor
                    {
                        role     = contrib._role,
                        name     = contrib._name,
                        iconPath = contrib._iconPath
                    });
                }
            }

            foreach (var set in infoDat._difficultyBeatmapSets) // Difficulty Sets
            {
                foreach (var diff in set._difficultyBeatmaps)   // Actual Difficulties
                {
                    var diffLevel = new InfoJson.DifficultyLevel
                    {
                        difficulty      = diff._difficulty,
                        difficultyRank  = ConvertDifficultyRank(diff._difficultyRank),
                        audioPath       = infoDat._songFilename.Replace(".egg", ".ogg"),
                        jsonPath        = diff._beatmapFilename.Replace(".dat", ".json"),
                        offset          = diff._customData?._editorOffset ?? 0,
                        oldOffset       = diff._customData?._editorOldOffset ?? 0,
                        characteristic  = GetNewCharacteristic(set._beatmapCharacteristicName),
                        difficultyLabel = diff._customData?._difficultyLabel ?? ""
                    };
                    info.difficultyLevels.Add(diffLevel);

                    diffJsons.Add(ConvertDifficulty(infoDat, diff,
                                                    JsonConvert.DeserializeObject <DifficultyDat>(File.ReadAllText(Path.Combine(folderPath, diff._beatmapFilename)))));
                }
            }

            return(new Tuple <InfoJson, List <DifficultyJson> >(info, diffJsons));
        }
Пример #2
0
 public static DifficultyJson ConvertDifficulty(InfoDat infoDat, InfoDat.DifficultyBeatmap diffBeatmap, DifficultyDat diffDat)
 {
     return(new DifficultyJson
     {
         _beatsPerMinute = infoDat._beatsPerMinute,
         _noteJumpSpeed = diffBeatmap._noteJumpMovementSpeed,
         _noteJumpStartBeatOffset = diffBeatmap._noteJumpStartBeatOffset,
         _shuffle = infoDat._shuffle,
         _shufflePeriod = infoDat._shufflePeriod,
         _warnings = diffBeatmap._customData?._warnings,
         _information = diffBeatmap._customData?._information,
         _suggestions = diffBeatmap._customData?._suggestions,
         _requirements = diffBeatmap._customData?._requirements,
         _events = diffDat._events,
         _notes = diffDat._notes,
         _obstacles = diffDat._obstacles,
         _BPMChanges = diffDat._BPMChanges,
         _bookmarks = diffDat._bookmarks,
         FileName = diffBeatmap._beatmapFilename.Replace(".dat", ".json")
     });
 }