private bool LoadTimelineDiff(CueFile cueFile, bool save = true) { if (save) { timeline.Export(); } timeline.DeleteAllTargets(); timeline.RemoveAllRepeaters(); foreach (Cue cue in cueFile.cues) { timeline.AddTargetFromAction(timeline.GetTargetDataForCue(cue)); } if (cueFile.NRCueData != null) { if (cueFile.NRCueData.pathBuilderNoteData.Count == cueFile.NRCueData.pathBuilderNoteCues.Count) { for (int i = 0; i < cueFile.NRCueData.pathBuilderNoteCues.Count; ++i) { var data = timeline.GetTargetDataForCue(cueFile.NRCueData.pathBuilderNoteCues[i]); data.pathBuilderData = cueFile.NRCueData.pathBuilderNoteData[i]; data.pathBuilderData.parentNotes.Add(data); //Recalculate the notes, and remove any identical enties that would have been loaded through the cues ChainBuilder.CalculateChainNotes(data); foreach (TargetData genData in data.pathBuilderData.generatedNotes) { var foundData = timeline.FindTargetData(genData.time, genData.behavior, genData.handType); if (foundData != null) { timeline.DeleteTargetFromAction(foundData); } } timeline.AddTargetFromAction(data); //Generate the notes, so the song is complete ChainBuilder.GenerateChainNotes(data); } } if (Timeline.audioLoaded) { foreach (var section in cueFile.NRCueData.repeaterSections) { timeline.AddRepeaterSectionFromAction(section); } } else { timeline.loadRepeaterSectionAfterAudio = cueFile.NRCueData.repeaterSections; } } return(true); }
private void OnBeatLengthChanged(QNT_Duration newBeatLength) { if (!data.supportsBeatLength) { return; } if (data.behavior == TargetBehavior.NR_Pathbuilder) { ChainBuilder.GenerateChainNotes(data); } }
public void ExportAsCues() { //Pick folder //string prevDir = PlayerPrefs.GetString("recentDirCues", ""); string diff; switch (DifficultyManager.I.loadedIndex) { case 0: diff = "Expert"; break; case 1: diff = "Advanced"; break; case 2: diff = "Standard"; break; default: diff = "Easy"; break; } string fileName = Path.GetFileName(Timeline.audicaFile.filepath)?.Replace(".audica", ""); fileName = fileName + "_NRExport-" + diff + ".cues"; string path; if (!String.IsNullOrEmpty(NRSettings.config.cuesSavePath)) { path = Path.Combine(NRSettings.config.cuesSavePath, fileName); } else { path = StandaloneFileBrowser.SaveFilePanel("Find community_maps/maps folder in Audica folder", Path.Combine(Application.dataPath, @"../"), fileName, "cues"); if (String.IsNullOrEmpty(path)) { return; } NRSettings.config.cuesSavePath = Path.GetDirectoryName(path); NRSettings.SaveSettingsJson(); } //Ensure all chains are generated List <TargetData> nonGeneratedNotes = new List <TargetData>(); foreach (Target note in Timeline.instance.notes) { if (note.data.behavior == TargetBehavior.NR_Pathbuilder && note.data.pathBuilderData.createdNotes == false) { nonGeneratedNotes.Add(note.data); } } foreach (var data in nonGeneratedNotes) { ChainBuilder.GenerateChainNotes(data); } CueFile export = new CueFile(); export.cues = new List <Cue>(); export.NRCueData = new NRCueData(); foreach (Target target in Timeline.orderedNotes) { if (target.data.beatLength == 0) { target.data.beatLength = Constants.SixteenthNoteDuration; } if (target.data.behavior == TargetBehavior.Metronome) { continue; } var cue = NotePosCalc.ToCue(target, Timeline.offset); if (target.data.behavior == TargetBehavior.NR_Pathbuilder) { export.NRCueData.pathBuilderNoteCues.Add(cue); export.NRCueData.pathBuilderNoteData.Add(target.data.pathBuilderData); continue; } export.cues.Add(cue); } File.WriteAllText(path, JsonUtility.ToJson(export)); NotificationShower.Queue(new NRNotification("Saved cues!")); }