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); } } } }
void setPendingInfo() { BeatSaberInfo _data = new BeatSaberInfo() { songName = songTwelveNoteInfo.songName + " (Swapped Cube Colors)", songSubName = songTwelveNoteInfo.songSubName + " (Swapped Cube Colors)", authorName = songTwelveNoteInfo.authorName, beatsPerMinute = songTwelveNoteInfo.beatsPerMinute, previewStartTime = songTwelveNoteInfo.previewStartTime, previewDuration = songTwelveNoteInfo.previewDuration, coverImagePath = songTwelveNoteInfo.coverImagePath, environmentName = songTwelveNoteInfo.environmentName, difficultyLevels = songTwelveNoteInfo.difficultyLevels }; string json = JsonConvert.SerializeObject(_data, Formatting.Indented); if (!System.IO.File.Exists(@"" + saveLoc + "\\info.JSON")) { using (StreamWriter w = File.AppendText(@"" + saveLoc + "\\info.JSON")) { w.WriteLine(json); } AddMessage("Created new info.JSON file.", Color.DarkGreen); } else { File.Delete(@"" + saveLoc + "\\info.JSON"); using (StreamWriter w = File.AppendText(@"" + saveLoc + "\\info.JSON")) { w.WriteLine(json); } AddMessage("Created new info.JSON file.", Color.DarkGreen); } }