private static void WriteConductor([NotNull] this TextWriter writer, [NotNull] SourceScore sourceScore, int index) { writer.WriteLine($" [{index}]"); var conductor = sourceScore.Conductors[index]; writer.WriteLine(" EventConductorData data"); var absTime = ScoreCompileHelper.TicksToSeconds(conductor.Ticks, sourceScore.Conductors); writer.WriteLine(" double absTime = "+ absTime.ToString(CultureInfo.InvariantCulture)); writer.WriteLine(" UInt8 selected = 0"); writer.WriteLine(" SInt64 tick = "+ conductor.Ticks.ToString()); writer.WriteLine(" int measure = "+ conductor.Measure.ToString()); writer.WriteLine(" int beat = "+ conductor.Beat.ToString()); writer.WriteLine(" int track = 0"); writer.WriteLine(" double tempo = "+ conductor.Tempo.ToString(CultureInfo.InvariantCulture)); writer.WriteLine(" int tsigNumerator = "+ conductor.SignatureNumerator.ToString()); writer.WriteLine(" int tsigDenominator = "+ conductor.SignatureDenominator.ToString()); writer.WriteLine(" string marker = \"\""); }
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); } }