示例#1
0
        /// <summary>
        /// Choose a command
        /// </summary>
        /// <param name="input">The users input.</param>
        public static void ChooseCommand(string input, ListDescriptor list, NoteDescriptor note)
        {
            if (string.IsNullOrEmpty(input))
            {
                Print.Color("red", "You must enter a command.");
                Index(list, note);
            }
            else
            {
                switch (input)
                {
                case "view all":
                    ViewAll(list);
                    Index(list, note);
                    break;

                case "create note":
                    Create(note.ListId);
                    Index(list, note);
                    break;

                case "help":
                    Command.HelpCommand.ShowListCommands();
                    Index(list, note);
                    break;

                default:
                    Navigate(input, list, note);
                    break;
                }
            }
        }
示例#2
0
        public CustomNote(string fileName)
        {
            FileName = fileName;

            if (fileName != "DefaultNotes")
            {
                AssetBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, fileName));
                GameObject note = AssetBundle.LoadAsset <GameObject>("assets/_customnote.prefab");

                //Descriptor = note.GetComponent<NoteDescriptor>();
                //Descriptor.Icon = Descriptor.Icon ?? Utils.GetDefaultCustomIcon();

                NoteLeft     = note.transform.Find("NoteLeft").gameObject;
                NoteRight    = note.transform.Find("NoteRight").gameObject;
                NoteDotLeft  = note.transform.Find("NoteDotLeft")?.gameObject;
                NoteDotRight = note.transform.Find("NoteDotRight")?.gameObject;
                NoteBomb     = note.transform.Find("NoteBomb")?.gameObject;
            }
            else
            {
                Descriptor = new NoteDescriptor
                {
                    AuthorName  = "Beat Saber",
                    NoteName    = "Default",
                    Description = "This is the default notes. (No preview available)",
                    Icon        = Utils.GetDefaultIcon()
                };
            }
        }
示例#3
0
    public void LoadMusicScore(string path)
    {
        musicScore = new List <NoteDescriptor>();

        StreamReader file = new StreamReader(Application.persistentDataPath + "/" + path);

        //TextAsset t = Resources.Load(path) as TextAsset;
        //var arrayString = t.text.Split('\n');

        NoteDescriptor n;
        //foreach (var line in arrayString)
        string line = file.ReadLine();

        while (line != null)
        {
            if (line[0] == '#')
            {
                continue;
            }
            string[] parts = line.Split(',');
            switch (parts[0])
            {
            case "N":
                n = new NoteDescriptor(NoteType.Normal, float.Parse(parts[1]), float.Parse(parts[2]));
                musicScore.Add(n);
                break;

            case "R":
                n = new NoteDescriptor(NoteType.Rotate, float.Parse(parts[1]), float.Parse(parts[2]));
                musicScore.Add(n);
                break;

            case "L":
                n = new NoteDescriptor(NoteType.Long, float.Parse(parts[1]), float.Parse(parts[2]), float.Parse(parts[3]));
                musicScore.Add(n);
                break;

            case "S":
                n = new NoteDescriptor(NoteType.Special, float.Parse(parts[1]), float.Parse(parts[2]));
                musicScore.Add(n);
                break;

            case "X":
                n = new NoteDescriptor(NoteType.EndRotate, float.Parse(parts[1]));
                musicScore.Add(n);
                break;

            default:
                Debug.LogError("Unrecognized note description.");
                break;
            }

            line = file.ReadLine();
        }

        file.Close();
    }
示例#4
0
        /// <summary>
        /// Display the information about a specified note.
        /// </summary>
        /// <param name="note">The note in focus.</param>
        public static void Index(ListDescriptor list, NoteDescriptor note)
        {
            System.Console.WriteLine(">>> >>> Welcome to note: [" + note.NoteId + "]");

            System.Console.WriteLine(">>> >>> Type 'help' for a list of available commands!");
            System.Console.WriteLine(">>> >>> Please enter a command...");

            ChooseCommand(System.Console.ReadLine(), list, note);;
        }
示例#5
0
        public CustomNote(string fileName)
        {
            FileName = fileName;

            if (fileName != "DefaultNotes")
            {
                try
                {
                    AssetBundle = AssetBundle.LoadFromFile(Path.Combine(Plugin.PluginAssetPath, fileName));
                    GameObject note = AssetBundle.LoadAsset <GameObject>("assets/_customnote.prefab");

                    Descriptor      = note.GetComponent <NoteDescriptor>();
                    Descriptor.Icon = Descriptor.Icon ?? Utils.GetDefaultCustomIcon();

                    NoteLeft  = note.transform.Find("NoteLeft").gameObject;
                    NoteRight = note.transform.Find("NoteRight").gameObject;
                    Transform NoteDotLeftTransform  = note.transform.Find("NoteDotLeft");
                    Transform NoteDotRightTransform = note.transform.Find("NoteDotRight");
                    NoteDotLeft  = NoteDotLeftTransform != null ? NoteDotLeftTransform.gameObject : NoteLeft;
                    NoteDotRight = NoteDotRightTransform != null ? NoteDotRightTransform.gameObject : NoteRight;
                    NoteBomb     = note.transform.Find("NoteBomb")?.gameObject;
                }
                catch (Exception ex)
                {
                    Logger.log.Warn($"Something went wrong getting the AssetBundle for '{FileName}'!");
                    Logger.log.Warn(ex);

                    Descriptor = new NoteDescriptor
                    {
                        NoteName   = "Invalid Note (Delete it!)",
                        AuthorName = FileName,
                        Icon       = Utils.GetErrorIcon()
                    };

                    ErrorMessage = $"File: '{fileName}'" +
                                   "\n\nThis file failed to load." +
                                   "\n\nThis may have been caused by having duplicated files," +
                                   " another note with the same name already exists or that the custom note is simply just broken." +
                                   "\n\nThe best thing is probably just to delete it!";

                    FileName = "DefaultNotes";
                }
            }
            else
            {
                Descriptor = new NoteDescriptor
                {
                    AuthorName  = "Beat Saber",
                    NoteName    = "Default",
                    Description = "This is the default notes. (No preview available)",
                    Icon        = Utils.GetDefaultIcon()
                };
            }
        }
示例#6
0
    void CreateNote(NoteDescriptor n)
    {
        switch (n.noteType)
        {
        case NoteType.Normal:
            // create a normal note at the center
            GameObject go   = Instantiate(singleNotePrefab) as GameObject;
            SingleNote note = go.GetComponent <SingleNote>();
            note.noteType   = NoteType.Normal;
            note.startTime  = currTime;
            note.arriveTime = n.arriveTime;
            note.angle_deg  = n.angle_deg;
            note.velocity   = ringRad / flyTime;
            note.time       = n.arriveTime;
            queues[(int)n.angle_deg / deg_perqueue].Enqueue(note);
            break;

        case NoteType.Long:
            go = Instantiate(longNotePrefab) as GameObject;
            LongNote ln = go.GetComponent <LongNote>();
            ln.noteType       = NoteType.Long;
            ln.startTime      = currTime;
            ln.headArriveTime = n.arriveTime;
            ln.tailArriveTime = n.endTime;
            ln.angle_deg      = n.angle_deg;
            ln.velocity       = ringRad / flyTime;
            ln.time           = n.arriveTime;
            queues[(int)n.angle_deg / deg_perqueue].Enqueue(ln);
            break;

        case NoteType.Special:
            go = Instantiate(specialNotePrefab) as GameObject;
            go.transform.parent = null;
            SpecialNote sn = go.GetComponent <SpecialNote>();
            sn.noteType   = NoteType.Special;
            sn.startTime  = currTime;
            sn.arriveTime = n.arriveTime;
            sn.angle_deg  = n.angle_deg;
            sn.velocity   = ringRad / flyTime;
            sn.time       = n.arriveTime;
            queues[(int)n.angle_deg / deg_perqueue].Enqueue(sn);
            break;

        default:
            break;
        }
    }
示例#7
0
 /// <summary>
 /// Navigate around the notes view.
 /// </summary>
 /// <param name="input"></param>
 public static void Navigate(string input, ListDescriptor list, NoteDescriptor note)
 {
     if (input.Contains("view") && !input.Contains("view all") && !string.IsNullOrEmpty(input))
     {
         try
         {
             var listTitle = input.Split("view ")[1].Trim();
             ListController.Display(listTitle);
         }
         catch (Exception e)
         {
             Print.Color("red", e.ToString());
             Print.Color("red", "Please specify which list to navigate to.");
         }
     }
     Index(list, note);
 }
示例#8
0
        public CustomNote(byte[] noteObject, string name)
        {
            if (noteObject != null)
            {
                try
                {
                    AssetBundle = AssetBundle.LoadFromMemory(noteObject);
                    GameObject note = AssetBundle.LoadAsset <GameObject>("assets/_customnote.prefab");
                    FileName = $@"internalResource\{name}";

                    Descriptor      = note.GetComponent <NoteDescriptor>();
                    Descriptor.Icon = Descriptor.Icon ?? Utils.GetDefaultCustomIcon();

                    NoteLeft     = note.transform.Find("NoteLeft").gameObject;
                    NoteRight    = note.transform.Find("NoteRight").gameObject;
                    NoteDotLeft  = note.transform.Find("NoteDotLeft")?.gameObject;
                    NoteDotRight = note.transform.Find("NoteDotRight")?.gameObject;
                    NoteBomb     = note.transform.Find("NoteBomb")?.gameObject;
                }
                catch (Exception ex)
                {
                    Logger.log.Warn($"Something went wrong getting the AssetBundle from a resource!");
                    Logger.log.Warn(ex);

                    Descriptor = new NoteDescriptor
                    {
                        NoteName   = "Internal Error (Report it!)",
                        AuthorName = FileName,
                        Icon       = Utils.GetErrorIcon()
                    };
                    ErrorMessage = $@"File: 'internalResource\\{name}'" +
                                   "\n\nAn internal asset has failed to load." +
                                   "\n\nThis shouldn't have happened and should be reported!" +
                                   " Remember to include the log related to this incident.";

                    FileName = "DefaultNotes";
                }
            }
            else
            {
                throw new ArgumentNullException("noteObject cannot be null for the constructor!");
            }
        }
示例#9
0
        /// <summary>
        /// Reads a note by Id.
        /// </summary>
        /// <param name="id">The id of the note to view.</param>
        public static NoteDescriptor ReadNoteDetailsById(int id)
        {
            using var context = new Context();

            var note = context.Notes
                       .FirstOrDefault(l => l.NoteId == id && l.Archived == false);

            if (note == null)
            {
                return(new NoteDescriptor());
            }

            var noteDescriptor = new NoteDescriptor()
            {
                NoteId          = note.NoteId,
                Content         = note.Content,
                CreatedDateTime = note.CreatedDateTime
            };

            return(noteDescriptor);
        }
示例#10
0
    private int CalculateAdditionScrollSpace(NoteDescriptor note, int extraSpace = 0)
    {
        int additionalSpace = 253 + extraSpace;
        int labelHeight     = 22;

        if (string.IsNullOrEmpty(note.NoteName))
        {
            additionalSpace += labelHeight;
        }

        if (string.IsNullOrEmpty(note.AuthorName))
        {
            additionalSpace += labelHeight;
        }

        if (!note.transform.Find("NoteLeft"))
        {
            additionalSpace += labelHeight;
        }

        if (!note.transform.Find("NoteRight"))
        {
            additionalSpace += labelHeight;
        }

        if (note.DisableBaseNoteArrows)
        {
            if (!note.transform.Find("NoteDotLeft"))
            {
                additionalSpace += labelHeight;
            }

            if (!note.transform.Find("NoteDotRight"))
            {
                additionalSpace += labelHeight;
            }
        }

        return(additionalSpace);
    }
示例#11
0
        public CustomNote(string fileName)
        {
            FileName = fileName;

            if (fileName != "DefaultNotes")
            {
                try
                {
                    AssetBundle = AssetBundle.LoadFromFile(Path.Combine(Plugin.PluginAssetPath, fileName));
                    GameObject note = AssetBundle.LoadAsset <GameObject>("assets/_customnote.prefab");

                    Descriptor      = note.GetComponent <NoteDescriptor>();
                    Descriptor.Icon = Descriptor.Icon ?? Utils.GetDefaultCustomIcon();

                    NoteLeft  = note.transform.Find("NoteLeft").gameObject;
                    NoteRight = note.transform.Find("NoteRight").gameObject;
                    Transform NoteDotLeftTransform  = note.transform.Find("NoteDotLeft");
                    Transform NoteDotRightTransform = note.transform.Find("NoteDotRight");
                    NoteDotLeft  = NoteDotLeftTransform != null ? NoteDotLeftTransform.gameObject : NoteLeft;
                    NoteDotRight = NoteDotRightTransform != null ? NoteDotRightTransform.gameObject : NoteRight;
                    NoteBomb     = note.transform.Find("NoteBomb")?.gameObject;

                    // burst slider stuff
                    Transform BurstSliderLeftTransform = note.transform.Find("BurstSliderLeft");
                    if (BurstSliderLeftTransform == null)
                    {
                        BurstSliderLeft = new GameObject();
                        GameObject innerBurstSliderLeft = UnityEngine.Object.Instantiate(NoteDotLeft);
                        innerBurstSliderLeft.transform.SetParent(BurstSliderLeft.transform);
                        innerBurstSliderLeft.transform.localPosition = Vector3.zero;
                        innerBurstSliderLeft.transform.localScale    = new Vector3(
                            innerBurstSliderLeft.transform.localScale.x,
                            innerBurstSliderLeft.transform.localScale.y / 4,
                            innerBurstSliderLeft.transform.localScale.z);
                        BurstSliderLeft.SetActive(false);
                    }
                    else
                    {
                        BurstSliderLeft = BurstSliderLeftTransform.gameObject;
                    }

                    Transform BurstSliderRightTransform = note.transform.Find("BurstSliderRight");
                    if (BurstSliderRightTransform == null)
                    {
                        BurstSliderRight = new GameObject();
                        GameObject innerBurstSliderRight = UnityEngine.Object.Instantiate(NoteDotRight);
                        innerBurstSliderRight.transform.SetParent(BurstSliderRight.transform);
                        innerBurstSliderRight.transform.localPosition = Vector3.zero;
                        innerBurstSliderRight.transform.localScale    = new Vector3(
                            innerBurstSliderRight.transform.localScale.x,
                            innerBurstSliderRight.transform.localScale.y / 4,
                            innerBurstSliderRight.transform.localScale.z);
                        BurstSliderRight.SetActive(false);
                    }
                    else
                    {
                        BurstSliderRight = BurstSliderRightTransform.gameObject;
                    }

                    // burst slider head stuff
                    Transform BurstSliderHeadLeftTransform     = note.transform.Find("BurstSliderHeadLeft");
                    Transform BurstSliderHeadRightTransform    = note.transform.Find("BurstSliderHeadRight");
                    Transform BurstSliderHeadDotLeftTransform  = note.transform.Find("BurstSliderHeadDotLeft");
                    Transform BurstSliderHeadDotRightTransform = note.transform.Find("BurstSliderHeadDotRight");
                    BurstSliderHeadLeft     = BurstSliderHeadLeftTransform != null ? BurstSliderHeadLeftTransform.gameObject : NoteLeft;
                    BurstSliderHeadRight    = BurstSliderHeadRightTransform != null ? BurstSliderHeadRightTransform.gameObject : NoteRight;
                    BurstSliderHeadDotLeft  = BurstSliderHeadDotLeftTransform != null ? BurstSliderHeadDotLeftTransform.gameObject : BurstSliderHeadLeftTransform != null ? BurstSliderHeadLeftTransform.gameObject : NoteDotLeft;
                    BurstSliderHeadDotRight = BurstSliderHeadDotRightTransform != null ? BurstSliderHeadDotRightTransform.gameObject : BurstSliderHeadRightTransform != null ? BurstSliderHeadRightTransform.gameObject : NoteDotRight;
                }
                catch (Exception ex)
                {
                    Logger.log.Warn($"Something went wrong getting the AssetBundle for '{FileName}'!");
                    Logger.log.Warn(ex);

                    Descriptor = new NoteDescriptor
                    {
                        NoteName   = "Invalid Note (Delete it!)",
                        AuthorName = FileName,
                        Icon       = Utils.GetErrorIcon()
                    };

                    ErrorMessage = $"File: '{fileName}'" +
                                   "\n\nThis file failed to load." +
                                   "\n\nThis may have been caused by having duplicated files," +
                                   " another note with the same name already exists or that the custom note is simply just broken." +
                                   "\n\nThe best thing is probably just to delete it!";

                    FileName = "DefaultNotes";
                }
            }
            else
            {
                Descriptor = new NoteDescriptor
                {
                    AuthorName  = "Beat Saber",
                    NoteName    = "Default",
                    Description = "This is the default notes. (No preview available)",
                    Icon        = Utils.GetDefaultIcon()
                };
            }
        }
示例#12
0
        public CustomNote(byte[] noteObject, string name)
        {
            if (noteObject != null)
            {
                try
                {
                    AssetBundle = AssetBundle.LoadFromMemory(noteObject);
                    GameObject note = AssetBundle.LoadAsset <GameObject>("assets/_customnote.prefab");
                    FileName = $@"internalResource\{name}";

                    Descriptor      = note.GetComponent <NoteDescriptor>();
                    Descriptor.Icon = Descriptor.Icon ?? Utils.GetDefaultCustomIcon();

                    NoteLeft     = note.transform.Find("NoteLeft").gameObject;
                    NoteRight    = note.transform.Find("NoteRight").gameObject;
                    NoteDotLeft  = note.transform.Find("NoteDotLeft")?.gameObject;
                    NoteDotRight = note.transform.Find("NoteDotRight")?.gameObject;
                    NoteBomb     = note.transform.Find("NoteBomb")?.gameObject;

                    // burst slider stuff
                    Transform BurstSliderLeftTransform = note.transform.Find("BurstSliderLeft");
                    if (BurstSliderLeftTransform == null)
                    {
                        BurstSliderLeft = new GameObject();
                        GameObject innerBurstSliderLeft = UnityEngine.Object.Instantiate(NoteDotLeft);
                        innerBurstSliderLeft.transform.SetParent(BurstSliderLeft.transform);
                        innerBurstSliderLeft.transform.localPosition = Vector3.zero;
                        innerBurstSliderLeft.transform.localScale    = new Vector3(
                            innerBurstSliderLeft.transform.localScale.x,
                            innerBurstSliderLeft.transform.localScale.y / 4,
                            innerBurstSliderLeft.transform.localScale.z);
                        BurstSliderLeft.SetActive(false);
                    }
                    else
                    {
                        BurstSliderLeft = BurstSliderLeftTransform.gameObject;
                    }

                    Transform BurstSliderRightTransform = note.transform.Find("BurstSliderRight");
                    if (BurstSliderRightTransform == null)
                    {
                        BurstSliderRight = new GameObject();
                        GameObject innerBurstSliderRight = UnityEngine.Object.Instantiate(NoteDotRight);
                        innerBurstSliderRight.transform.SetParent(BurstSliderRight.transform);
                        innerBurstSliderRight.transform.localPosition = Vector3.zero;
                        innerBurstSliderRight.transform.localScale    = new Vector3(
                            innerBurstSliderRight.transform.localScale.x,
                            innerBurstSliderRight.transform.localScale.y / 4,
                            innerBurstSliderRight.transform.localScale.z);
                        BurstSliderRight.SetActive(false);
                    }
                    else
                    {
                        BurstSliderRight = BurstSliderRightTransform.gameObject;
                    }

                    // burst slider head stuff
                    Transform BurstSliderHeadLeftTransform     = note.transform.Find("BurstSliderHeadLeft");
                    Transform BurstSliderHeadRightTransform    = note.transform.Find("BurstSliderHeadRight");
                    Transform BurstSliderHeadDotLeftTransform  = note.transform.Find("BurstSliderHeadDotLeft");
                    Transform BurstSliderHeadDotRightTransform = note.transform.Find("BurstSliderHeadDotRight");
                    BurstSliderHeadLeft     = BurstSliderHeadLeftTransform != null ? BurstSliderHeadLeftTransform.gameObject : NoteLeft;
                    BurstSliderHeadRight    = BurstSliderHeadRightTransform != null ? BurstSliderHeadRightTransform.gameObject : NoteRight;
                    BurstSliderHeadDotLeft  = BurstSliderHeadDotLeftTransform != null ? BurstSliderHeadDotLeftTransform.gameObject : BurstSliderHeadLeftTransform != null ? BurstSliderHeadLeftTransform.gameObject : NoteDotLeft;
                    BurstSliderHeadDotRight = BurstSliderHeadDotRightTransform != null ? BurstSliderHeadDotRightTransform.gameObject : BurstSliderHeadRightTransform != null ? BurstSliderHeadRightTransform.gameObject : NoteDotRight;
                }
                catch (Exception ex)
                {
                    Logger.log.Warn($"Something went wrong getting the AssetBundle from a resource!");
                    Logger.log.Warn(ex);

                    Descriptor = new NoteDescriptor
                    {
                        NoteName   = "Internal Error (Report it!)",
                        AuthorName = FileName,
                        Icon       = Utils.GetErrorIcon()
                    };
                    ErrorMessage = $@"File: 'internalResource\\{name}'" +
                                   "\n\nAn internal asset has failed to load." +
                                   "\n\nThis shouldn't have happened and should be reported!" +
                                   " Remember to include the log related to this incident.";

                    FileName = "DefaultNotes";
                }
            }
            else
            {
                throw new ArgumentNullException("noteObject cannot be null for the constructor!");
            }
        }