Ejemplo n.º 1
0
        public bool AddLine(int startBeat)
        {
            int insPos = FindPreviousLine(startBeat);

            //Check for actual notes (startbeat may be lower than first note)
            while (insPos >= 0 && _Lines[insPos].NoteCount > 0 && _Lines[insPos].FirstNoteBeat > startBeat)
            {
                insPos--;
            }
            CSongLine line = new CSongLine {
                StartBeat = startBeat
            };

            if (insPos >= 0)
            {
                CSongLine prevLine = _Lines[insPos];
                //We already have a line break here
                if (prevLine.StartBeat == startBeat && (prevLine.NoteCount == 0 || prevLine.FirstNoteBeat == startBeat))
                {
                    return(false);
                }
                //Maybe we have to split the previous line
                while (prevLine.NoteCount > 0 && prevLine.LastNote.StartBeat >= startBeat)
                {
                    //throw new Exception("This should not happen on song loading!");
                    line.AddNote(prevLine.LastNote);
                    prevLine.DeleteNote(prevLine.NoteCount - 1);
                }
            }
            _Lines.Insert(insPos + 1, line);
            return(true);
        }