コード例 #1
0
        public static BeatSaberJSONClass LoadFromDisk(string path, string fileName)
        {
            Debug.LogWarning("Loading map from disk - " + path + fileName);
            StringBuilder builder = new StringBuilder();
            StreamReader  reader  = new StreamReader(path + fileName);
            string        line;

            while ((line = reader.ReadLine()) != null)
            {
                builder.AppendLine(line);
            }
            reader.Close();
            BeatSaberJSONClass beatSaberMap = new BeatSaberJSONClass();

            BeatSaberJSONClass.LevelJSON loadedMapData = JsonUtility.FromJson <BeatSaberJSONClass.LevelJSON>(builder.ToString());
            beatSaberMap.level = loadedMapData;

            builder = new StringBuilder();
            reader  = new StreamReader(path + "info.json");
            while ((line = reader.ReadLine()) != null)
            {
                builder.AppendLine(line);
            }
            reader.Close();
            BeatSaberJSONClass.InfoJSON infoJSON =
                JsonUtility.FromJson <BeatSaberJSONClass.InfoJSON>(builder.ToString());
            beatSaberMap.info = infoJSON;

            return(beatSaberMap);
        }
コード例 #2
0
        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);
        }