public static IEnumerator BmsToLanotalium(string BmsChartPath, bool Overwrite) { BmsChartManaged bmsChartManaged = new BmsChartManaged(BmsChartPath); LanotaChartManaged lanotaChartManaged = BmsToLanota(bmsChartManaged); Directory.CreateDirectory(bmsChartManaged.BmsChartFolder + "/Lanota"); string Chart = lanotaChartManaged.ToString(); File.WriteAllText(bmsChartManaged.BmsChartFolder + "/Lanota/Lanota_" + bmsChartManaged.BmsChartFileName + ".txt", Chart); if (!File.Exists(bmsChartManaged.BmsChartFolder + "/Lanota/" + bmsChartManaged.NativeBmsChart.Title + ".wav") || Overwrite) { Bms.Audio.FullAudioClipData fullAudioClipData = new Bms.Audio.FullAudioClipData(); yield return(WaitForTask(bmsChartManaged.ProduceFullAudioClipDataAsync(fullAudioClipData))); yield return(WaitForTask(fullAudioClipData.WriteDataToWavAsync(bmsChartManaged.BmsChartFolder + "/Lanota/" + bmsChartManaged.NativeBmsChart.Title + ".wav"))); } if (File.Exists(bmsChartManaged.BmsChartFolder + "/" + bmsChartManaged.StageFile)) { File.Copy(bmsChartManaged.BmsChartFolder + "/" + bmsChartManaged.StageFile, bmsChartManaged.BmsChartFolder + "/Lanota/background.png", true); } Lanota.Lanotalium.Project.LanotaliumProject lanotaliumProject = new Lanota.Lanotalium.Project.LanotaliumProject { Name = bmsChartManaged.NativeBmsChart.Title, Designer = bmsChartManaged.NativeBmsChart.Artist, MusicPath = bmsChartManaged.BmsChartFolder + "/Lanota/" + bmsChartManaged.NativeBmsChart.Title + ".wav", ChartPath = bmsChartManaged.BmsChartFolder + "/Lanota/Lanota_" + bmsChartManaged.BmsChartFileName + ".txt", BGA0Path = bmsChartManaged.BmsChartFolder + "/Lanota/background.png" }; File.WriteAllText(bmsChartManaged.BmsChartFolder + "/Lanota/Lap_" + bmsChartManaged.BmsChartFileName + ".lap", JsonConvert.SerializeObject(lanotaliumProject)); }
public static ChartConvertTask BmsToLanotaliumAsync(string BmsChartPath, bool Overwrite) { ChartConvertTask task = new ChartConvertTask(); task.Task = Task.Run(() => { BmsChartManaged bmsChartManaged = new BmsChartManaged(BmsChartPath); LanotaChartManaged lanotaChartManaged = BmsToLanota(bmsChartManaged); Directory.CreateDirectory(bmsChartManaged.BmsChartFolder + "/Lanota"); string Chart = lanotaChartManaged.ToString(); File.WriteAllText(bmsChartManaged.BmsChartFolder + "/Lanota/Lanota_" + bmsChartManaged.BmsChartFileName + ".txt", Chart); task.Percent = 1; if (!File.Exists(bmsChartManaged.BmsChartFolder + "/Lanota/" + bmsChartManaged.NativeBmsChart.Title + ".wav") || Overwrite) { Bms.Audio.FullAudioClipData fullAudioClipData = new Bms.Audio.FullAudioClipData(); Task AudioTask = bmsChartManaged.ProduceFullAudioClipDataAsync(fullAudioClipData); while (!AudioTask.IsCompleted) { task.Percent = 1 + fullAudioClipData.Percent * 0.95f; } if (AudioTask.Exception != null) { throw AudioTask.Exception; } Task WriteAudioTask = fullAudioClipData.WriteDataToWavAsync(bmsChartManaged.BmsChartFolder + "/Lanota/" + bmsChartManaged.NativeBmsChart.Title + ".wav"); while (!WriteAudioTask.IsCompleted) { } if (WriteAudioTask.Exception != null) { throw WriteAudioTask.Exception; } } task.Percent = 96; if (File.Exists(bmsChartManaged.BmsChartFolder + "/" + bmsChartManaged.StageFile)) { File.Copy(bmsChartManaged.BmsChartFolder + "/" + bmsChartManaged.StageFile, bmsChartManaged.BmsChartFolder + "/Lanota/background.png", true); } Lanota.Lanotalium.Project.LanotaliumProject lanotaliumProject = new Lanota.Lanotalium.Project.LanotaliumProject { Name = bmsChartManaged.NativeBmsChart.Title, Designer = bmsChartManaged.NativeBmsChart.Artist, MusicPath = bmsChartManaged.BmsChartFolder + "/Lanota/" + bmsChartManaged.NativeBmsChart.Title + ".wav", ChartPath = bmsChartManaged.BmsChartFolder + "/Lanota/Lanota_" + bmsChartManaged.BmsChartFileName + ".txt", BGA0Path = bmsChartManaged.BmsChartFolder + "/Lanota/background.png" }; File.WriteAllText(bmsChartManaged.BmsChartFolder + "/Lanota/Lap_" + bmsChartManaged.BmsChartFileName + ".lap", JsonConvert.SerializeObject(lanotaliumProject)); task.LapPath = bmsChartManaged.BmsChartFolder + "/Lanota/Lap_" + bmsChartManaged.BmsChartFileName + ".lap"; task.Percent = 100; }); return(task); }