Esempio n. 1
0
        private static double CalculateTimingPeriodBetweenNotes(List <DelesteBeatmapEntry> entries, DelesteBasicNote currentBasicFlickNote, DelesteBasicNote lastBasicFlickNote, int fullLength)
        {
            double timeDiff;
            double timePerBeat;
            DelesteBeatmapEntry entry;

            if (currentBasicFlickNote.Entry.MeasureIndex != lastBasicFlickNote.Entry.MeasureIndex)
            {
                var startIndex = entries.IndexOf(lastBasicFlickNote.Entry);
                var endIndex   = entries.IndexOf(currentBasicFlickNote.Entry, startIndex + 1);

                entry       = lastBasicFlickNote.Entry;
                timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM);
                timeDiff    = timePerBeat * entry.Signature * (1 - (float)lastBasicFlickNote.IndexInMeasure / lastBasicFlickNote.Entry.FullLength);
                for (var i = startIndex + 1; i < endIndex; ++i)
                {
                    entry = entries[i];
                    if (entry.IsCommand)
                    {
                        continue;
                    }
                    timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM);
                    timeDiff   += timePerBeat * entry.Signature;
                }
                entry       = currentBasicFlickNote.Entry;
                timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM);
                timeDiff   += timePerBeat * entry.Signature * ((float)currentBasicFlickNote.IndexInMeasure / fullLength);
            }
            else
            {
                entry       = currentBasicFlickNote.Entry;
                timePerBeat = DirectorHelper.BpmToSeconds(entry.BPM);
                timeDiff    = timePerBeat * entry.Signature * ((float)currentBasicFlickNote.IndexInMeasure / fullLength - (float)lastBasicFlickNote.IndexInMeasure / lastBasicFlickNote.Entry.FullLength);
            }
            return(timeDiff);
        }
Esempio n. 2
0
        public static DelesteBeatmapEntry ReadEntry(Project temporaryProject, string line, int entryCounter, List <DelesteBasicNote> noteCache, List <string> warnings, ref bool hasErrors)
        {
            line = line.ToLowerInvariant();
            if (line.StartsWithOfGroup(Constants.BeatmapCommands))
            {
                line = line.Substring(0, line.IndexOf(' '));
                var warning = string.Format(Resources.DelesteCommandIsNotYetSupportedPromptTemplate, entryCounter, line);
                warnings.Add(warning);
                return(null);
            }

            DelesteBeatmapEntry entry;
            var isCommand = HandleCommands(line, temporaryProject, out entry);

            if (isCommand)
            {
                return(entry);
            }
            if (line.Length < 2 || !char.IsNumber(line, 1))
            {
                // Not a beatmap entry. May be metadata.
                return(null);
            }

            if (line.IndexOf('.') >= 0)
            {
                hasErrors = true;
                var warning = Resources.DelesteTxtFormat2IsNotSupportedPrompt;
                warnings.Add(warning);
                return(null);
            }

            // #gid,mid:types&indices:sp[:fp]
            var colonStringValues = line.Substring(1).Split(':');
            var commaStringValues = colonStringValues[0].Split(',');
            var noteDistribution  = colonStringValues[1];
            var standardNoteCount = noteDistribution.Count(ch => ch != '0');

            // Abbreviated format (1, 2) & full format
            // #0,000:2
            // #0,000:2222:1234
            // #0,001:2222:3333:3333
            var    groupNumberString = commaStringValues[0];
            var    measureIndexString = commaStringValues[1];
            string finishPositions, startPositions;

            switch (colonStringValues.Length)
            {
            case 2:
                startPositions = finishPositions = new string('3', standardNoteCount);
                break;

            case 3:
                startPositions = finishPositions = colonStringValues[2];
                break;

            default:
                startPositions  = colonStringValues[2];
                finishPositions = colonStringValues[3];
                break;
            }
            noteCache.Clear();

            var measureIndex = Convert.ToInt32(measureIndexString);

            if (standardNoteCount != startPositions.Length || startPositions.Length != finishPositions.Length)
            {
                var warning = string.Format(Resources.DelesteNoteCountInconsistentPromptTemplate, entryCounter, measureIndex, standardNoteCount, startPositions.Length, finishPositions.Length);
                warnings.Add(warning);
                return(null);
            }
            entry              = new DelesteBeatmapEntry();
            entry.GroupID      = Convert.ToInt32(groupNumberString);
            entry.MeasureIndex = measureIndex;
            entry.FullLength   = noteDistribution.Length;
            int i = -1, j = -1;

            foreach (var ch in noteDistribution)
            {
                ++j;
                if (ch == '0')
                {
                    continue;
                }
                ++i;
                var note = new DelesteBasicNote(entry);
                note.IndexInMeasure = j;
                note.Type           = (DelesteNoteType)(ch - '0');
                note.StartPosition  = (NotePosition)(startPositions[i] - '0');
                note.FinishPosition = (NotePosition)(finishPositions[i] - '0');
                noteCache.Add(note);
            }
            entry.Notes = noteCache.ToArray();
            return(entry);
        }