コード例 #1
0
ファイル: SMWriterBase.cs プロジェクト: PerryAsleep/Fumen
        protected static bool TryGetChartType(Chart chart, out SMCommon.ChartType chartType)
        {
            // If the Chart's Type is already a supported ChartType, use that.
            if (SMCommon.TryGetChartType(chart.Type, out chartType))
            {
                return(true);
            }

            // Otherwise infer the ChartType from the number of inputs and players
            chartType = SMCommon.ChartType.dance_single;
            if (chart.NumPlayers == 1)
            {
                if (chart.NumInputs <= 3)
                {
                    chartType = SMCommon.ChartType.dance_threepanel;
                    return(true);
                }
                if (chart.NumInputs == 4)
                {
                    chartType = SMCommon.ChartType.dance_single;
                    return(true);
                }
                if (chart.NumInputs <= 6)
                {
                    chartType = SMCommon.ChartType.dance_solo;
                    return(true);
                }
                if (chart.NumInputs <= 8)
                {
                    chartType = SMCommon.ChartType.dance_double;
                    return(true);
                }
            }
            if (chart.NumPlayers == 2)
            {
                if (chart.NumInputs <= 8)
                {
                    chartType = SMCommon.ChartType.dance_routine;
                    return(true);
                }
            }

            return(false);
        }
コード例 #2
0
        public override bool Parse(MSDFile.Value value)
        {
            // Only consider this line if it matches this property name.
            if (!ParseFirstParameter(value, out var type))
            {
                return(false);
            }

            Chart.Type = type;

            // Parse chart type and set number of players and inputs.
            if (!SMCommon.TryGetChartType(Chart.Type, out var smChartType))
            {
                Chart.Type = null;
                Logger?.Error($"{PropertyName}: Failed to parse {SMCommon.TagStepsType} value '{smChartType}'. This chart will be ignored.");
                return(true);
            }
            Chart.NumPlayers = SMCommon.Properties[(int)smChartType].NumPlayers;
            Chart.NumInputs  = SMCommon.Properties[(int)smChartType].NumInputs;

            Chart.Extras.AddSourceExtra(SMCommon.TagStepsType, Chart.Type, true);

            return(true);
        }
コード例 #3
0
        public override bool Parse(MSDFile.Value value)
        {
            // Only consider this line if it matches this property name.
            if (!DoesValueMatchProperty(value))
            {
                return(false);
            }

            if (value.Params.Count < 7)
            {
                Logger?.Warn($"{PropertyName}: Expected at least 7 parameters. Found {value.Params.Count}. Ignoring all note data.");
                return(true);
            }

            var chart = new Chart
            {
                Type           = value.Params[1]?.Trim(SMCommon.SMAllWhiteSpace) ?? "",
                Description    = value.Params[2]?.Trim(SMCommon.SMAllWhiteSpace) ?? "",
                DifficultyType = value.Params[3]?.Trim(SMCommon.SMAllWhiteSpace) ?? ""
            };

            chart.Layers.Add(new Layer());

            // Record whether this chart was written under NOTES or NOTES2.
            chart.Extras.AddSourceExtra(SMCommon.TagFumenNotesType, PropertyName, true);

            // Parse the chart information before measure data.
            var chartDifficultyRatingStr = value.Params[4]?.Trim(SMCommon.SMAllWhiteSpace) ?? "";
            var chartRadarValuesStr      = value.Params[5]?.Trim(SMCommon.SMAllWhiteSpace) ?? "";

            // Parse the difficulty rating as a number.
            if (int.TryParse(chartDifficultyRatingStr, out var difficultyRatingInt))
            {
                chart.DifficultyRating = (double)difficultyRatingInt;
            }

            // Parse the radar values into a list.
            var radarValues    = new List <double>();
            var radarValuesStr = chartRadarValuesStr.Split(',');

            foreach (var radarValueStr in radarValuesStr)
            {
                if (double.TryParse(radarValueStr, out var d))
                {
                    radarValues.Add(d);
                }
            }
            chart.Extras.AddSourceExtra(SMCommon.TagRadarValues, radarValues, true);

            // Parse chart type and set number of players and inputs.
            if (!SMCommon.TryGetChartType(chart.Type, out var smChartType))
            {
                Logger?.Error($"{PropertyName}: Failed to parse {SMCommon.TagStepsType} value '{chart.Type}'. This chart will be ignored.");
                return(true);
            }
            chart.NumPlayers = SMCommon.Properties[(int)smChartType].NumPlayers;
            chart.NumInputs  = SMCommon.Properties[(int)smChartType].NumInputs;

            // Add a 4/4 time signature
            chart.Layers[0].Events.Add(new TimeSignature(new Fraction(SMCommon.NumBeatsPerMeasure, SMCommon.NumBeatsPerMeasure))
            {
                Position = new MetricPosition()
            });

            // Parse the notes.
            if (!ParseNotes(chart, value.Params[6] ?? ""))
            {
                return(true);
            }

            Song.Charts.Add(chart);

            return(true);
        }