private static int Main([NotNull, ItemNotNull] string[] args) { if (args.Length == 0) { Console.Error.WriteLine(HelpText); return(0); } var inputFile = Path.GetFullPath(args[0]); string outputScoreFile; if (args.Length >= 2) { outputScoreFile = args[1]; } else { var fi = new FileInfo(inputFile); var name = fi.FullName; outputScoreFile = name.Substring(0, name.Length - fi.Extension.Length) + ".txt"; } string outputScenarioFile; if (args.Length >= 3) { outputScenarioFile = args[2]; } else { var fi = new FileInfo(inputFile); var name = fi.FullName; outputScenarioFile = name.Substring(0, name.Length - fi.Extension.Length) + "_scenario.txt"; } var format = new SimpleScoreFormat(); SourceScore sourceScore; using (var fileStream = File.Open(inputFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (var reader = format.CreateReader()) { var sourceOptions = new ReadSourceOptions(); sourceScore = reader.ReadSourceScore(fileStream, fileStream.Name, sourceOptions); } } for (var i = 1; i < sourceScore.Conductors.Length; ++i) { ScorePreprocessor.FixNoteTickInfo(sourceScore.Conductors[i], sourceScore); } foreach (var sourceNote in sourceScore.Notes) { ScorePreprocessor.FixNoteTickInfo(sourceNote, sourceScore); } using (var fileStream = File.Open(outputScoreFile, FileMode.Create, FileAccess.Write, FileShare.Write)) { using (var writer = new StreamWriter(fileStream, Utf8WithoutBom)) { WriteScore.Write(sourceScore, writer); } } using (var fileStream = File.Open(outputScenarioFile, FileMode.Create, FileAccess.Write, FileShare.Write)) { using (var writer = new StreamWriter(fileStream, Utf8WithoutBom)) { WriteScenario.Write(sourceScore, writer); } } return(0); }
private static void WriteEventNote([NotNull] this TextWriter writer, [NotNull] SourceScore sourceScore, [NotNull, ItemNotNull] SourceNote[] notes, int index, TrackType trackType) { writer.WriteLine($" [{index}]"); var sourceNote = notes[index]; writer.WriteLine(" EventNoteData data"); // MLTD: "offset > 0" means music is AFTER the beatmap // MilliSim: "offset > 0" means music is BEFORE the beatmap var absTime = ScoreCompileHelper.TicksToSeconds(sourceNote.Ticks, sourceScore.Conductors); writer.WriteLine(" double absTime = "+ absTime.ToString(CultureInfo.InvariantCulture)); writer.WriteLine(" UInt8 selected = 0"); writer.WriteLine(" SInt64 tick = "+ (sourceNote.Ticks / (NoteBase.TicksPerBeat / 8)).ToString()); if (sourceNote.Type < 0) { writer.WriteLine(" int measure = "+ sourceNote.Measure.ToString()); writer.WriteLine(" int beat = "+ sourceNote.Beat.ToString()); writer.WriteLine(" int track = -1"); } else { writer.WriteLine(" int measure = 0"); writer.WriteLine(" int beat = 0"); var tracks = MltdHelper.GetTrackIndicesFromTrackType(trackType); writer.WriteLine(" int track = "+ tracks[sourceNote.TrackIndex].ToString()); } writer.WriteLine(" int type = "+ ((int)MltdHelper.GetMltdNoteType(sourceNote)).ToString()); writer.WriteLine(" float startPosx = "+ sourceNote.StartX.ToString(CultureInfo.InvariantCulture)); writer.WriteLine(" float endPosx = "+ sourceNote.EndX.ToString(CultureInfo.InvariantCulture)); writer.WriteLine(" float speed = "+ sourceNote.Speed.ToString(CultureInfo.InvariantCulture)); if (sourceNote.FollowingNotes != null && sourceNote.FollowingNotes.Length > 0) { var duration = (int)((sourceNote.FollowingNotes[sourceNote.FollowingNotes.Length - 1].Ticks - sourceNote.Ticks) / (NoteBase.TicksPerBeat / 8)); writer.WriteLine(" int duration = "+ duration.ToString()); } else { writer.WriteLine(" int duration = 0"); } writer.WritePolyPoints(sourceNote, sourceNote.FollowingNotes); if (sourceNote.FollowingNotes != null && sourceNote.FollowingNotes.Length > 0) { writer.WriteLine(" int endType = "+ ((int)sourceNote.FollowingNotes[sourceNote.FollowingNotes.Length - 1].FlickDirection).ToString()); } else { writer.WriteLine(" int endType = 0"); } if (sourceNote.Type < 0) { writer.WriteLine(" double leadTime = 0"); } else { // TODO: What is this "magic number"? const double someConstant = 198.3471011848414; var bpm = ScorePreprocessor.GetCurrentBpm(sourceNote.Ticks, sourceScore.Conductors); var leadTime = someConstant / bpm; // TODO: Another guess... Didn't look too carefully inside speed variated notes. leadTime /= sourceNote.Speed; writer.WriteLine(" double leadTime = "+ leadTime.ToString(CultureInfo.InvariantCulture)); } }
private static void WriteNotes([NotNull] this TextWriter writer, [NotNull] SourceScore score, [NotNull] ScenarioScrObj template) { var notes = score.Notes; var noteList = new List <EventScenarioData>(); var specialNote = notes.FirstOrDefault(n => n.Type == NoteType.Special); // Mofify time: the tap buttons animation before the special note (the big round note) if (specialNote != null) { noteList.AddRange(template.scenario); var animNote = noteList.Find(n => n.type == ScenarioNoteType.BeginTapButtonsAnimation); if (animNote != null) { var specialNoteTime = ScoreCompileHelper.TicksToSeconds(specialNote.Ticks, score.Conductors); animNote.absTime = specialNoteTime - 0.5f; animNote.tick = ScorePreprocessor.SecondsToTicks(animNote.absTime, score.Conductors); } // Modify time: second tap buttons appearing time (the one that is after the special note) var reappearNote = notes.FirstOrDefault(n => n.Ticks > specialNote.Ticks); if (reappearNote != null && animNote != null) { var reaNote = noteList.Where(n => n.type == ScenarioNoteType.ShowTapButtons).Skip(1).FirstOrDefault(); if (reaNote != null) { var reappearNoteTime = ScoreCompileHelper.TicksToSeconds(reappearNote.Ticks, score.Conductors); reaNote.absTime = reappearNoteTime - 0.8f; reaNote.tick = ScorePreprocessor.SecondsToTicks(reaNote.absTime, score.Conductors); } } } noteList.Sort((n1, n2) => { var t = n1.tick.CompareTo(n2.tick); if (t != 0) { return(t); } t = ((int)n1.type).CompareTo((int)n2.type); if (t != 0) { return(t); } t = n1.idol.CompareTo(n2.idol); if (t != 0) { return(t); } return(n1.track.CompareTo(n2.track)); }); writer.Write(@"EventScenarioData scenario Array Array int size = " ); writer.WriteLine(noteList.Count.ToString()); for (var i = 0; i < noteList.Count; ++i) { var sn = noteList[i]; writer.WriteLine(" [{0}]", i.ToString()); writer.WriteScenarioNote(2, "data", sn); } }