public bool LoadAudicaFile(bool loadRecent = false, string filePath = null) { inTimingMode = false; SetOffset(0); if (audicaLoaded) { Export(); } if (loadRecent) { audicaFile = null; DeleteAllTargets(); audicaFile = AudicaHandler.LoadAudicaFile(PlayerPrefs.GetString("recentFile", null)); if (audicaFile == null) { return(false); } } else if (filePath != null) { audicaFile = null; DeleteAllTargets(); audicaFile = AudicaHandler.LoadAudicaFile(filePath); PlayerPrefs.SetString("recentFile", audicaFile.filepath); } else { string[] paths = StandaloneFileBrowser.OpenFilePanel("Audica File (Not OST)", Path.Combine(Application.persistentDataPath), "audica", false); if (paths.Length == 0) { return(false); } audicaFile = null; DeleteAllTargets(); audicaFile = AudicaHandler.LoadAudicaFile(paths[0]); PlayerPrefs.SetString("recentFile", paths[0]); } desc = audicaFile.desc; // Get song BPM if (audicaFile.song_mid != null) { float oneMinuteInMicroseconds = 60000000f; var midiBpm = -1; foreach (var tempo in audicaFile.song_mid.GetTempoMap().Tempo) { // TODO: Multi-bpm support :( // Debug.Log($"FOUND TEMPO EVENT: {tempo}, BPM: {tempo.Value.BeatsPerMinute}"); midiBpm = (int)Math.Round(oneMinuteInMicroseconds / tempo.Value.MicrosecondsPerQuarterNote); } if (midiBpm != desc.tempo && midiBpm != -1) { // TODO: in-scene dialog box :/ //if (EditorUtility.DisplayDialog("BPM mismatch", //"Detected different BPM values in midi and song.desc. NotReaper does not currently support multi-bpm tracks.", // $"Use midi ({midiBpm})", $"Use song.desc ({desc.tempo})")) { desc.tempo = midiBpm; //} } } //Update our discord presence nrDiscordPresence.UpdatePresenceSongName(desc.title); //Loads all the sounds. StartCoroutine(GetAudioClip($"file://{Application.dataPath}/.cache/{audicaFile.desc.cachedMainSong}.ogg")); StartCoroutine(LoadLeftSustain($"file://{Application.dataPath}/.cache/{audicaFile.desc.cachedSustainSongLeft}.ogg")); StartCoroutine(LoadRightSustain($"file://{Application.dataPath}/.cache/{audicaFile.desc.cachedSustainSongRight}.ogg")); //foreach (Cue cue in audicaFile.diffs.expert.cues) { //AddTarget(cue); //} //Difficulty manager loads stuff now audicaLoaded = true; difficultyManager.LoadHighestDifficulty(); //Disable timing window buttons so users don't mess stuff up. applyButtonTiming.interactable = false; generateAudicaButton.interactable = false; loadAudioFileTiming.interactable = false; //Loaded successfully NotificationShower.AddNotifToQueue(new NRNotification("Map loaded successfully!")); NotificationShower.AddNotifToQueue(new NRNotification("Hold F1 to view shortcuts")); return(true); }
public bool LoadAudicaFile(bool loadRecent = false, string filePath = null) { inTimingMode = false; if (audicaLoaded) { Export(); } DeleteAllTargets(); audicaFile = null; if (loadRecent) { audicaFile = AudicaHandler.LoadAudicaFile(PlayerPrefs.GetString("recentFile", null)); if (audicaFile == null) { return(false); } } else if (filePath != null) { audicaFile = AudicaHandler.LoadAudicaFile(filePath); PlayerPrefs.SetString("recentFile", audicaFile.filepath); } else { string[] paths = StandaloneFileBrowser.OpenFilePanel("Audica File (Not OST)", Path.Combine(Application.persistentDataPath), "audica", false); if (paths.Length == 0) { return(false); } audicaFile = AudicaHandler.LoadAudicaFile(paths[0]); PlayerPrefs.SetString("recentFile", paths[0]); } //SetOffset(0); desc = audicaFile.desc; //Update our discord presence nrDiscordPresence.UpdatePresenceSongName(desc.title); //Loads all the sounds. StartCoroutine(GetAudioClip($"file://{Application.dataPath}/.cache/{audicaFile.desc.cachedMainSong}.ogg")); StartCoroutine(LoadLeftSustain($"file://{Application.dataPath}/.cache/{audicaFile.desc.cachedSustainSongLeft}.ogg")); StartCoroutine(LoadRightSustain($"file://{Application.dataPath}/.cache/{audicaFile.desc.cachedSustainSongRight}.ogg")); //foreach (Cue cue in audicaFile.diffs.expert.cues) { //AddTarget(cue); //} //Difficulty manager loads stuff now audicaLoaded = true; difficultyManager.LoadHighestDifficulty(); //Disable timing window buttons so users don't mess stuff up. applyButtonTiming.interactable = false; generateAudicaButton.interactable = false; loadAudioFileTiming.interactable = false; //Loaded successfully NotificationShower.AddNotifToQueue(new NRNotification("Map loaded successfully!")); return(true); }