예제 #1
0
        IEnumerator WaitForUserColors()
        {
            while (!NRSettings.isLoaded)
            {
                yield return(new WaitForSeconds(0.1f));
            }

            selectedTool = EditorTool.None;
            SelectMode(EditorMode.Compose);
            SelectTool(EditorTool.Standard);
            SelectHand(TargetHandType.Left);
            SelectVelocity(UITargetVelocity.Standard);

            NotificationShower.AddNotifToQueue(new NRNotification("Welcome to NotReaper!", 3f));

            pauseMenu.LoadUIColors();
            pauseMenu.OpenPauseMenu();

            soundSelect.LoadUIColors();

            timeline.UpdateUIColors();

            FigureOutIsInUI();

            StartCoroutine(LoadBGImage("file://" + NRSettings.config.bgImagePath));
        }
예제 #2
0
 public void RemoveComment()
 {
     if (loadedContainer.comments.Contains(currentComment))
     {
         loadedContainer.comments.Remove(currentComment);
         NotificationShower.Queue($"Removed comment", NRNotifType.Success);
     }
     else
     {
         NotificationShower.Queue($"Comment doesn't exist", NRNotifType.Fail);
     }
 }
예제 #3
0
        public void Load()
        {
            string reviewDirectory = Path.Combine(Directory.GetParent(Application.dataPath).ToString(), "reviews");
            string path            = StandaloneFileBrowser.OpenFilePanel("Select review file", reviewDirectory, ".review", false).FirstOrDefault();

            if (File.Exists(path) && path.Contains(".review"))
            {
                LoadContainer(path);
            }
            else
            {
                NotificationShower.Queue($"Review file doesn't exist", NRNotifType.Fail);
            }
        }
예제 #4
0
        public void Export()
        {
            string dirpath = Application.persistentDataPath;

            CueFile export = new CueFile();

            export.cues = new List <Cue>();

            foreach (Target target in orderedNotes)
            {
                if (target.data.beatLength == 0)
                {
                    target.data.beatLength = 120;
                }

                if (target.data.behavior == TargetBehavior.Metronome)
                {
                    continue;
                }
                export.cues.Add(NotePosCalc.ToCue(target, offset, false));
            }

            switch (difficultyManager.loadedIndex)
            {
            case 0:
                audicaFile.diffs.expert = export;
                break;

            case 1:
                audicaFile.diffs.advanced = export;
                break;

            case 2:
                audicaFile.diffs.moderate = export;
                break;

            case 3:
                audicaFile.diffs.beginner = export;
                break;
            }

            audicaFile.desc = desc;


            AudicaExporter.ExportToAudicaFile(audicaFile);

            NotificationShower.AddNotifToQueue(new NRNotification("Map saved successfully!"));
        }
예제 #5
0
        public void SetAutoVolume() // Compare to normalized and set song volume in moggsong to match OST
        {
            string retMessage = string.Empty;

            UnityEngine.Debug.Log("Start auto song volume");
            ffmpeg.StartInfo.RedirectStandardError = true;
            ffmpeg.StartInfo.Arguments             =
                String.Format("-i \"{0}\" -filter:a volumedetect -f null /dev/null", loadedSong);
            ffmpeg.Start();
            retMessage = ffmpeg.StandardError.ReadToEnd();
            ffmpeg.WaitForExit();
            ffmpeg.Close();

            var outputFile = Path.Combine(Application.streamingAssetsPath, "Ogg2Audica", "audioOutput.txt");

            File.Delete(outputFile);
            File.WriteAllText(outputFile, retMessage);

            string max_volume = string.Empty; // Pulling max_volume line

            foreach (var line in File.ReadLines(outputFile))
            {
                if (line.Contains("max_volume:"))
                {
                    max_volume = line;
                }
            }
            string normalized_db = max_volume.Split(' ')[4]; // Grab only the number

            float foundVolume = float.Parse(normalized_db);  // Crappy maths

            if (foundVolume > 0)
            {
                foundVolume = foundVolume * -1;
            }
            else if (foundVolume < 0)
            {
                foundVolume = Mathf.Abs(foundVolume);
            }
            moggSongVolume = foundVolume - Mathf.Abs(moggSongVolume);

            NotificationShower.Queue(new NRNotification("Mogg volume set to " + moggSongVolume.ToString("n2")));
            UnityEngine.Debug.Log("Moggsong volume set to " + moggSongVolume.ToString("n2"));
            UnityEngine.Debug.Log("End auto song volume");
        }
예제 #6
0
        /// <summary>
        /// Creates a review comment using selected notes and text fields.
        /// </summary>
        public void CreateComment()
        {
            var selectedCues = new List <Cue>();

            foreach (Target target in Timeline.instance.selectedNotes)
            {
                selectedCues.Add(target.ToCue());
            }

            var comment = new ReviewComment(selectedCues.ToArray(),
                                            descriptionField.text,
                                            (CommentType)int.Parse(commentTypeGroup.ActiveToggles().FirstOrDefault().name));

            loadedContainer.comments.Add(comment);

            string targetPlural = selectedCues.Count == 1 ? "target" : "targets";

            NotificationShower.Queue($"Added comment for {selectedCues.Count} {targetPlural}", NRNotifType.Success);
        }
예제 #7
0
        private void SetUserColors()
        {
            selectedTool = EditorTool.None;
            SelectMode(EditorMode.Compose);
            SelectTool(EditorTool.Standard);
            SelectHand(TargetHandType.Left);
            SelectVelocity(UITargetVelocity.Standard);

            NotificationShower.AddNotifToQueue(new NRNotification("Welcome to NotReaper!", 3f));
            pauseMenu.OpenPauseMenu();

            shortcutMenu.LoadUIColors();
            soundSelect.LoadUIColors();
            timeline.UpdateUIColors();

            FigureOutIsInUI();
            StartCoroutine(LoadBGImage("file://" + NRSettings.config.bgImagePath));

            nrDiscordPresence.InitPresence();
        }
예제 #8
0
 void LoadContainer(string path)
 {
     if (File.Exists(path))
     {
         var container = ReviewContainer.Read(path);
         if (VerifyReview(container))
         {
             loadedContainer = container;
             NotificationShower.Queue($"Loaded {loadedContainer.reviewAuthor}'s review", NRNotifType.Success);
         }
         else
         {
             NotificationShower.Queue("This review was made for a different song.", NRNotifType.Fail);
         }
     }
     else
     {
         loadedContainer = new ReviewContainer();
     }
 }
예제 #9
0
        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);
        }
예제 #10
0
    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!"));
    }
예제 #11
0
 public void Export()
 {
     loadedContainer.Export();
     OpenReviewFolder();
     NotificationShower.Queue($"Successfully exported review", NRNotifType.Success);
 }
예제 #12
0
        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);
        }