Example #1
0
 public Note(Note note)
 {
     this.position = note.position;
     this.type     = note.type;
     this.next     = note.next;
     this.prev     = note.prev;
 }
Example #2
0
 public Note(NotePosition position, NoteTypes type, NotePosition next, NotePosition prev)
 {
     this.position = position;
     this.type     = type;
     this.next     = next;
     this.prev     = prev;
 }
Example #3
0
        List <Note> GetAllNoteEventsInRange(float start, float end,
                                            SortedList <NotePosition, Note> events)
        {
            List <Note>  notesInRange = new List <Note>();
            NotePosition startSearch  = new NotePosition(start, -2);
            NotePosition endSearch    = new NotePosition(end, -1);

            events.Add(startSearch, null);
            events.Add(endSearch, null);
            int indexStart = events.IndexOfKey(startSearch);
            int indexEnd   = events.IndexOfKey(endSearch);

            IList <Note> notes    = events.Values;
            int          numNotes = events.Count;

            for (int i = (indexStart + 1) % numNotes; i != indexEnd; i = (i + 1) % numNotes)
            {
                notesInRange.Add(notes[i]);
            }

            events.Remove(startSearch);
            events.Remove(endSearch);

            return(notesInRange);
        }
Example #4
0
 public static Vector3 NoteToCanvasPosition(NotePosition notePosition)
 {
     return(new Vector3(
                SamplesToCanvasPositionX(notePosition.ToSamples(Audio.Source.clip.frequency, EditData.BPM.Value)),
                BlockNumToCanvasPositionY(notePosition.block) * NoteCanvas.ScaleFactor.Value,
                0));
 }
        public static Note AddNote([NotNull] this Bar bar, Guid id, int row, NotePosition column)
        {
            if (row < 0 || row >= bar.GetNumberOfGrids())
            {
                throw new ArgumentOutOfRangeException(nameof(row), row, null);
            }

            if (column == NotePosition.Default)
            {
                throw new ArgumentOutOfRangeException(nameof(column), column, null);
            }

            if (bar.Notes.Any(n => n.Basic.IndexInGrid == row && n.Basic.FinishPosition == column))
            {
                throw new InvalidOperationException($"A note exists at row {row}, column {column}.");
            }

            var note = new Note(bar, id);

            bar.Notes.Add(note);

            bar.Basic.Score.Project.UsedNoteIDs.Add(id);
            // IndexInGrid must be set before calling FixSyncWhenAdded.
            note.Basic.IndexInGrid   = row;
            note.Basic.StartPosition = note.Basic.FinishPosition = column;

            note.FixSyncWhenAdded();

            bar.Notes.Sort(Note.TimingThenPositionComparison);

            bar.Basic.Score.InformNoteCountChanged();

            return(note);
        }
        public Candidates GetLeftCandidates(NoteDirection direction, NotePosition position)
        {
            switch (direction)
            {
            case NoteDirection.Up:
                return(GetLeftCandidatesForUp(position));

            case NoteDirection.UpRight:
                return(new Candidates());

            case NoteDirection.Right:
                return(GetLeftCandidatesForRight(position));

            case NoteDirection.DownRight:
                return(new Candidates());

            case NoteDirection.Down:
                return(GetLeftCandidatesForDown(position));

            case NoteDirection.DownLeft:
                return(new Candidates());

            case NoteDirection.Left:
                return(GetLeftCandidatesForLeft(position));

            case NoteDirection.UpLeft:
                return(new Candidates());
            }

            return(new Candidates());
        }
Example #7
0
 public Note(NotePosition position, NoteTypes type, NotePosition next, NotePosition prev)
 {
     this.position = position;
     this.type = type;
     this.next = next;
     this.prev = prev;
 }
Example #8
0
 public Note(Note note)
 {
     this.position = note.position;
     this.type = note.type;
     this.next = note.next;
     this.prev = note.prev;
 }
Example #9
0
 public Vector3 NoteToScreenPosition(NotePosition notePosition)
 {
     return(new Vector3(
                SamplesToScreenPositionX(notePosition.ToSamples(Audio.clip.frequency)),
                BlockNumToScreenPositionY(notePosition.block) * CanvasScaleFactor.Value,
                0));
 }
    public Note(string label, NotePosition position, int sourceId)
    {
        ArgumentValidator.NotNull(() => label);

        Label    = label;
        Position = position;
        SourceId = sourceId;
    }
        public static float GetNoteXPosition(Graphics context, NotePosition startPosition, NotePosition finishPosition, float timeTransformed)
        {
            var clientSize = context.Bounds;
            var endPos     = Definitions.AvatarCenterXEndPositions[(int)finishPosition - 1] * clientSize.Width;
            var startPos   = Definitions.AvatarCenterXStartPositions[(int)startPosition - 1] * clientSize.Width;

            return(endPos - (endPos - startPos) * NoteXTransform(timeTransformed));
        }
Example #12
0
 protected RectangleF GetRectFromNotePosition(NotePosition pos)
 {
     return(new RectangleF(
                (MeasurementProfile.UnitLaneWidth + MeasurementProfile.BorderThickness) * pos.LaneIndex + MeasurementProfile.BorderThickness,
                GetYPositionFromTick(pos.Tick) - MeasurementProfile.ShortNoteHeight / 2,
                (MeasurementProfile.UnitLaneWidth + MeasurementProfile.BorderThickness) * pos.Width - MeasurementProfile.BorderThickness,
                MeasurementProfile.ShortNoteHeight
                ));
 }
Example #13
0
        public static float GetNoteXPosition(RenderContext context, NotePosition finishPosition, float timeTransformed)
        {
            var clientSize           = context.ClientSize;
            var endPos               = Definitions.AvatarCenterXEndPositions[(int)finishPosition - 1] * clientSize.Width;
            var displayStartPosition = finishPosition;
            var startPos             = Definitions.AvatarCenterXStartPositions[(int)displayStartPosition - 1] * clientSize.Width;

            return(endPos - (endPos - startPos) * NoteXTransform(timeTransformed));
        }
Example #14
0
        public static float GetNoteXPosition(RenderParams renderParams, NotePosition finishPosition, NotePosition startPosition, float timeTransformed)
        {
            var clientSize           = renderParams.ClientSize;
            var endPos               = AvatarCenterXEndPositions[(int)finishPosition - 1] * clientSize.Width;
            var displayStartPosition = renderParams.IsPreview ? startPosition : finishPosition;
            var startPos             = AvatarCenterXStartPositions[(int)displayStartPosition - 1] * clientSize.Width;

            return(endPos - (endPos - startPos) * NoteXTransform(timeTransformed));
        }
Example #15
0
 /// <summary>
 /// Renders a note.
 /// </summary>
 /// <param name="position">The position of the note.</param>
 /// <param name="participant">Optional participant. The position is relative to this participant.</param>
 /// <param name="note">The text of the note.</param>
 /// <param name="style">Optional of note. Default <see cref="NoteStyle.Normal"/>.</param>
 /// <param name="color">Optional backgrond color.</param>
 /// <param name="alignWithPrevious">Optional alignment with the previous note. Default <c>false</c>.</param>
 /// <exception cref="ArgumentNullException"><paramref name="stringBuilder"/> is <c>null</c>.</exception>
 public static void Note(this StringBuilder stringBuilder, NotePosition position, string participant, string note, NoteStyle style = NoteStyle.Normal, Color color = null, bool alignWithPrevious = false)
 {
     stringBuilder.NoteBase(position, participant, style, color, alignWithPrevious);
     stringBuilder.Append(Constant.Space);
     stringBuilder.Append(Constant.Colon);
     stringBuilder.Append(Constant.Space);
     stringBuilder.Append(note.Replace("\n", "\\n"));
     stringBuilder.AppendNewLine();
 }
Example #16
0
 public Note(Note note)
 {
     this.position   = note.position;
     this.type       = note.type;
     this.next       = note.next;
     this.prev       = note.prev;
     this.attributes = note.attributes;
     this.direction  = note.direction;
 }
Example #17
0
 void RemoveNote(NotePosition notePosition)
 {
     if (model.NoteObjects.ContainsKey(notePosition))
     {
         var noteObject = model.NoteObjects[notePosition];
         model.NoteObjects.Remove(notePosition);
         DestroyObject(noteObject.gameObject);
     }
 }
 internal ScoreEditorHitTestResult(Point location, ScoreEditorHitRegion hitRegion, Bar bar, Note note, int row, NotePosition column)
 {
     Location  = location;
     HitRegion = hitRegion;
     Bar       = bar;
     Note      = note;
     Row       = row;
     Column    = column;
 }
Example #19
0
            public override bool Equals(object obj)
            {
                if (obj == null || !(obj is NotePosition))
                {
                    return(false);
                }
                NotePosition other = (NotePosition)obj;

                return(StartTick == other.StartTick && StartLaneIndex == other.StartLaneIndex && StartWidth == other.StartWidth);
            }
Example #20
0
            public override bool Equals(object obj)
            {
                if (obj == null || !(obj is NotePosition))
                {
                    return(false);
                }
                NotePosition other = (NotePosition)obj;

                return(TickOffset == other.TickOffset && LaneIndexOffset == other.LaneIndexOffset && WidthChange == other.WidthChange);
            }
Example #21
0
        protected void AddSortedNoteEvents(Note note)
        {
            sortedNoteOns.Add(NoteOnPosition(note), note);
            NotePosition offPosition = NoteOffPosition(note);

            if (!sortedNoteOffs.ContainsKey(offPosition))
            {
                sortedNoteOffs.Add(offPosition, note);
            }
        }
Example #22
0
            public override bool Equals(object obj)
            {
                if (obj == null || !(obj is NotePosition))
                {
                    return(false);
                }
                NotePosition other = (NotePosition)obj;

                return(Tick == other.Tick && LaneIndex == other.LaneIndex);
            }
Example #23
0
        /// <summary>
        /// Renders the start of a multiline rectangle note.
        /// </summary>
        /// <param name="position">The position of the note.</param>
        /// <param name="participant">Optional participant. The position is relative to this participant.</param>
        /// <param name="color">Optional backgrond color.</param>
        /// <param name="alignWithPrevious">Optional alignment with the previous note. Default <c>false</c>.</param>
        /// <exception cref="ArgumentNullException"><paramref name="stringBuilder"/> is <c>null</c>.</exception>
        public static void StartRNote(this StringBuilder stringBuilder, NotePosition position, string participant = null, Color color = null, bool alignWithPrevious = false)
        {
            if (stringBuilder is null)
            {
                throw new ArgumentNullException(nameof(stringBuilder));
            }

            stringBuilder.NoteBase(position, participant, NoteStyle.Box, color, alignWithPrevious);
            stringBuilder.AppendNewLine();
        }
        public NotePosition GetSelectedNextLongNote(NotePosition current, Func <NoteObject, NotePosition> accessor)
        {
            while (EditData.Notes.ContainsKey(current))
            {
                if (selectedNoteObjects.ContainsKey(current))
                {
                    return(current);
                }

                current = accessor(EditData.Notes[current]);
            }

            return(NotePosition.None);
        }
Example #25
0
    public override bool Equals(object obj)
    {
        if (!(obj is NotePosition))
        {
            return(false);
        }

        NotePosition target = (NotePosition)obj;

        return(
            BPM == target.BPM &&
            Mathf.Approximately((float)num / LPB, (float)target.num / target.LPB) &&
            block == target.block);
    }
        public Note RemoveNoteAt(Bar bar, int row, NotePosition column)
        {
            var score = CurrentScore;

            if (score == null)
            {
                return(null);
            }
            if (!score.Bars.Contains(bar))
            {
                throw new ArgumentException("Assigned bar is not in current score.", nameof(bar));
            }
            var note = bar.Notes.FirstOrDefault(n => n.Basic.IndexInGrid == row && n.Basic.FinishPosition == column);

            return(note == null ? null : bar.RemoveNote(note));
        }
Example #27
0
        /// <summary>
        /// Base for rendering a note.
        /// </summary>
        /// <param name="position">The position of the note.</param>
        /// <param name="participant">Optional participant. The position is relative to this participant.</param>
        /// <param name="style">Optional style of note. Default <see cref="NoteStyle.Normal"/>.</param>
        /// <param name="color">Optional backgrond color.</param>
        /// <param name="alignWithPrevious">Optional alignment with the previous note. Default <c>false</c>.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="stringBuilder"/> is <c>null</c>.</exception>
        internal static void NoteBase(this StringBuilder stringBuilder, NotePosition position, string participant = null, NoteStyle style = NoteStyle.Normal, Color color = null, bool alignWithPrevious = false)
        {
            if (stringBuilder is null)
            {
                throw new ArgumentNullException(nameof(stringBuilder));
            }

            if (alignWithPrevious)
            {
                stringBuilder.Append(Constant.AlignNote);
                stringBuilder.Append(Constant.Space);
            }

            switch (style)
            {
            case NoteStyle.Hexagonal:
                stringBuilder.Append(Constant.NoteHexagon);
                break;

            case NoteStyle.Box:
                stringBuilder.Append(Constant.NoteBox);
                break;
            }

            stringBuilder.Append(Constant.Note);
            stringBuilder.Append(Constant.Space);
            stringBuilder.Append(position.ToString().ToLowerInvariant());

            if (!string.IsNullOrWhiteSpace(participant))
            {
                if (position != NotePosition.Over)
                {
                    stringBuilder.Append(Constant.Space);
                    stringBuilder.Append(Constant.Of);
                }

                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(participant);
            }

            if (color is not null && color.ToString() != string.Empty)
            {
                stringBuilder.Append(Constant.Space);
                stringBuilder.Append(color);
            }
        }
Example #28
0
        public string GenerateScoreNoteElement(ScoreNote pScoreNote)
        {
            var result = string.Format(
                "\t<ScoreNote Beat=\"{0}\" Tick=\"{1}\" NoteId=\"{2}\" Duration=\"{3}\"",
                pScoreNote.Beat, pScoreNote.Tick, pScoreNote.NoteId, pScoreNote.DurationInTicks);

            if (pScoreNote is GuitarScoreNote)
            {
                NotePosition notePosition = ((GuitarScoreNote)pScoreNote).DefaultNotePosition;

                result += string.Format(" String=\"{0}\" Fret=\"{1}\" RemarkOrChordName=\"{2}\"", notePosition.String, notePosition.Fret, pScoreNote.RemarkOrChordName);
            }

            result += "/>";

            return(result);
        }
        public Note AddNoteAt(Bar bar, int row, NotePosition column)
        {
            var score = CurrentScore;

            if (score == null)
            {
                return(null);
            }
            if (!score.Bars.Contains(bar))
            {
                throw new ArgumentException("Assigned bar is not in current score.", nameof(bar));
            }
            var note = bar.AddNote(row, column);

            if (NoteStartPosition != NotePosition.Default)
            {
                note.Basic.StartPosition = NoteStartPosition;
            }
            return(note);
        }
 public ScoreNote AddScoreNote(ScoreBar scoreBar, int row, NotePosition position)
 {
     return(AddScoreNote(scoreBar, row, (int)position - 1, null));
 }
        /// <summary>
        /// Loads uNote's editor preferences.
        /// </summary>
        public static void Load()
        {
            //Note, we also assign default values here, if no key is found.

            displayNotesInScene = UnfinityEditorPrefs.GetBool("uNote_displayNotesInScene", true);
            notePositionInScene = (NotePosition)UnfinityEditorPrefs.GetInt("uNote_notePositionInScene",
                                                        (int)NotePosition.Top); //Cast our int to a NotePosition value.

            forceCompactMode = UnfinityEditorPrefs.GetBool("uNote_forceCompactMode", false);
            createInEditMode = UnfinityEditorPrefs.GetBool("uNote_createInEditMode", false);
            displayParentNotes = UnfinityEditorPrefs.GetBool("uNote_displayParentNotes", false);
            onlySearchFirstParent = UnfinityEditorPrefs.GetBool("uNote_onlySearchFirstParent", true);
        }
 private static void ChangeNoteStartPositionTo(IEnumerable <ScoreNote> scoreNotes, NotePosition startPosition)
 {
     foreach (var scoreNote in scoreNotes)
     {
         var note = scoreNote.Note;
         // A rule: in a hold pair, the latter one always follows the trail of the former one.
         if (note.IsHoldStart)
         {
             note.HoldTarget.StartPosition = note.StartPosition = startPosition;
         }
         else if (note.IsHoldEnd)
         {
             note.StartPosition = note.HoldTarget.StartPosition;
         }
         else
         {
             note.StartPosition = startPosition;
         }
     }
 }
Example #33
0
 public Note(NotePosition position, NoteTypes type)
 {
     this.position = position;
     this.type = type;
 }
 private ScoreNote AddScoreNote(ScoreBar scoreBar, int row, NotePosition column, Note dataTemplate)
 {
     return(AddScoreNote(scoreBar, row, (int)column - 1, dataTemplate));
 }
Example #35
0
 public Note(NotePosition position)
 {
     this.position = position;
 }