Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string dir = Application.StartupPath + "/Songs/";

            AddMessage("Starting...", Color.DarkGreen);

            foreach (string s in Directory.GetDirectories(dir))
            {
                if (File.Exists(s + "/info.json"))
                {
                    saveLoc = s;
                    AddMessage("Found info.JSON file at " + s, Color.DarkGreen);
                    string newDir = @"" + s;
                    songTwelveNoteInfo = new BeatSaberInfo();
                    songTwelveNoteInfo = LoadsongData(newDir + "/info.json");

                    setPendingInfo();

                    foreach (BeatSaberInfoDifficultyLevels Difficultyinfo in songTwelveNoteInfo.difficultyLevels)
                    {
                        AddMessage("Swapping colors for " + Difficultyinfo.difficulty + " level.", Color.DarkGreen);
                        var noteInfoRead           = File.ReadAllText(s + "/" + Difficultyinfo.jsonPath);
                        BeatSaberNoteInfo noteInfo = JsonConvert.DeserializeObject <BeatSaberNoteInfo>(noteInfoRead);

                        foreach (BeatSaberNoteData noteDataInfo in noteInfo._notes)
                        {
                            if (noteDataInfo._type == Hand.red)
                            {
                                noteDataInfo._type = Hand.blue;
                            }
                            else if (noteDataInfo._type == Hand.blue)
                            {
                                noteDataInfo._type = Hand.red;
                            }
                        }

                        CreateNotesFile(noteInfo, Difficultyinfo);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void CreateNotesFile(BeatSaberNoteInfo chart, BeatSaberInfoDifficultyLevels dif)
        {
            BeatSaberNoteInfo _data = new BeatSaberNoteInfo()
            {
                _version        = chart._version,
                _beatsPerMinute = chart._beatsPerMinute,
                _beatsPerBar    = chart._beatsPerBar,
                _noteJumpSpeed  = chart._noteJumpSpeed,
                _shuffle        = chart._shuffle,
                _shufflePeriod  = chart._shufflePeriod,
                _events         = chart._events,
                _notes          = chart._notes,
                _obstacles      = chart._obstacles
            };

            string json = JsonConvert.SerializeObject(_data, Formatting.Indented);

            if (!System.IO.File.Exists(@"" + saveLoc + "\\" + dif.jsonPath))
            {
                using (StreamWriter w = File.AppendText(@"" + saveLoc + "\\" + dif.jsonPath))
                {
                    w.WriteLine(json);
                }

                AddMessage("Swap Complete for " + dif.difficulty, Color.DarkGreen);
            }
            else
            {
                File.Delete(@"" + saveLoc + "\\" + dif.jsonPath);

                using (StreamWriter w = File.AppendText(@"" + saveLoc + "\\" + dif.jsonPath))
                {
                    w.WriteLine(json);
                }

                AddMessage("Swap Complete for " + dif.difficulty, Color.DarkGreen);
            }
        }