Esempio n. 1
0
        private void ParseFile()
        {
            using (var reader = StepmaniaFileReaderFactory.CreateReader(FilePath))
            {
                while (reader.ReadNextTag(out SmFileAttribute tag))
                {
                    if (reader.State == ReaderState.ReadingChartMetadata)
                    {
                        var stepData = reader.ReadStepchartMetadata();

                        ChartMetadata.Add(stepData);

                        reader.SkipTagValue();
                    }
                    else
                    {
                        var value = reader.ReadTagValue();

                        if (!_attributes.ContainsKey(tag))
                        {
                            _attributes.Add(tag, value);
                        }
                    }
                }
            }
        }
        private static string GenerateLightsChart(string file, StepMetadata referenceData)
        {
            using (var reader = StepmaniaFileReaderFactory.CreateReader(file))
            {
                while (reader.ReadNextTag(out SmFileAttribute tag))
                {
                    if (reader.State != ReaderState.ReadingChartMetadata)
                    {
                        continue;
                    }

                    var stepData = reader.ReadStepchartMetadata();

                    if (stepData.PlayStyle == referenceData.PlayStyle && stepData.Difficulty == referenceData.Difficulty)
                    {
                        return(GenerateLightsChart(reader));
                    }
                }
            }

            throw new Exception($"Could not find note data to reference in {file}");
        }
Esempio n. 3
0
        public static LightChartHoldState VerifyLightChartHolds(string smFilePath)
        {
            var holdState = LightChartHoldState.HoldingNone;

            void VerifyHoldState(string line, int column, int measure)
            {
                if (line[column] == HOLD_BEGIN || line[column] == ROLL_BEGIN)
                {
                    if (!holdState.HasFlag(HoldStateMap[column]))
                    {
                        holdState |= HoldStateMap[column];
                    }
                    else
                    {
                        throw new Exception($"Parser encountered HOLD_BEGIN on column {column} (note: {line[column]}, measure: {measure}) when hold state was already holding.\n{Path.GetFullPath(smFilePath)}");
                    }
                }
                else if (line[column] == HOLD_END)
                {
                    if (holdState.HasFlag(HoldStateMap[column]))
                    {
                        holdState &= ~HoldStateMap[column];
                    }
                    else
                    {
                        throw new Exception($"Parser encountered HOLD_END on column {column} (note: {line[column]}, measure: {measure}) when hold state was not holding.\n{Path.GetFullPath(smFilePath)}");
                    }
                }
            }

            using (var reader = StepmaniaFileReaderFactory.CreateReader(smFilePath))
            {
                while (reader.ReadNextTag(out SmFileAttribute tag))
                {
                    if (tag != SmFileAttribute.NOTES)
                    {
                        continue;
                    }

                    var stepData = reader.ReadStepchartMetadata();

                    if (stepData.PlayStyle == PlayStyle.Lights && stepData.Difficulty == SongDifficulty.Easy)
                    {
                        int measureNumber = 1;
                        while (reader.IsParsingNoteData)
                        {
                            var measure = reader.ReadMeasure();

                            foreach (string line in measure)
                            {
                                VerifyHoldState(line, MARQUEE_LEFT, measureNumber);
                                VerifyHoldState(line, MARQUEE_UP, measureNumber);
                                VerifyHoldState(line, MARQUEE_DOWN, measureNumber);
                                VerifyHoldState(line, MARQUEE_RIGHT, measureNumber);
                                VerifyHoldState(line, BASS_LEFT, measureNumber);
                                VerifyHoldState(line, BASS_RIGHT, measureNumber);
                            }

                            measureNumber++;
                        }

                        break;
                    }
                }
            }

            return(holdState);
        }