Exemplo n.º 1
0
        public void TestDecodeBeatmapEditor()
        {
            var decoder = new LegacyBeatmapDecoder();

            using (var resStream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
                using (var stream = new StreamReader(resStream))
                {
                    var beatmapInfo = decoder.Decode(stream).BeatmapInfo;

                    int[] expectedBookmarks =
                    {
                        11505,   22054,  32604,  43153,  53703,  64252,  74802, 85351,
                        95901,  106450, 116999, 119637, 130186, 140735, 151285,
                        161834, 164471, 175020, 185570, 196119, 206669, 209306
                    };
                    Assert.AreEqual(expectedBookmarks.Length, beatmapInfo.Bookmarks.Length);
                    for (int i = 0; i < expectedBookmarks.Length; i++)
                    {
                        Assert.AreEqual(expectedBookmarks[i], beatmapInfo.Bookmarks[i]);
                    }
                    Assert.AreEqual(1.8, beatmapInfo.DistanceSpacing);
                    Assert.AreEqual(4, beatmapInfo.BeatDivisor);
                    Assert.AreEqual(4, beatmapInfo.GridSize);
                    Assert.AreEqual(2, beatmapInfo.TimelineZoom);
                }
        }
Exemplo n.º 2
0
        public void TestDecodeOverlappingTimingPoints()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = TestResources.OpenResource("overlapping-control-points.osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var controlPoints = decoder.Decode(stream).ControlPointInfo;

                    Assert.That(controlPoints.DifficultyPointAt(500).SpeedMultiplier, Is.EqualTo(1.5).Within(0.1));
                    Assert.That(controlPoints.DifficultyPointAt(1500).SpeedMultiplier, Is.EqualTo(1.5).Within(0.1));
                    Assert.That(controlPoints.DifficultyPointAt(2500).SpeedMultiplier, Is.EqualTo(0.75).Within(0.1));
                    Assert.That(controlPoints.DifficultyPointAt(3500).SpeedMultiplier, Is.EqualTo(1.5).Within(0.1));

                    Assert.That(controlPoints.EffectPointAt(500).KiaiMode, Is.True);
                    Assert.That(controlPoints.EffectPointAt(1500).KiaiMode, Is.True);
                    Assert.That(controlPoints.EffectPointAt(2500).KiaiMode, Is.False);
                    Assert.That(controlPoints.EffectPointAt(3500).KiaiMode, Is.True);

                    Assert.That(controlPoints.SamplePointAt(500).SampleBank, Is.EqualTo("drum"));
                    Assert.That(controlPoints.SamplePointAt(1500).SampleBank, Is.EqualTo("drum"));
                    Assert.That(controlPoints.SamplePointAt(2500).SampleBank, Is.EqualTo("normal"));
                    Assert.That(controlPoints.SamplePointAt(3500).SampleBank, Is.EqualTo("drum"));

                    Assert.That(controlPoints.TimingPointAt(500).BeatLength, Is.EqualTo(500).Within(0.1));
                    Assert.That(controlPoints.TimingPointAt(1500).BeatLength, Is.EqualTo(500).Within(0.1));
                    Assert.That(controlPoints.TimingPointAt(2500).BeatLength, Is.EqualTo(250).Within(0.1));
                    Assert.That(controlPoints.TimingPointAt(3500).BeatLength, Is.EqualTo(500).Within(0.1));
                }
        }
Exemplo n.º 3
0
        public void TestDecodeBeatmapHitObjects()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
                using (var stream = new StreamReader(resStream))
                {
                    var hitObjects = decoder.Decode(stream).HitObjects;

                    var curveData    = hitObjects[0] as IHasCurve;
                    var positionData = hitObjects[0] as IHasPosition;

                    Assert.IsNotNull(positionData);
                    Assert.IsNotNull(curveData);
                    Assert.AreEqual(new Vector2(192, 168), positionData.Position);
                    Assert.AreEqual(956, hitObjects[0].StartTime);
                    Assert.IsTrue(hitObjects[0].Samples.Any(s => s.Name == SampleInfo.HIT_NORMAL));

                    positionData = hitObjects[1] as IHasPosition;

                    Assert.IsNotNull(positionData);
                    Assert.AreEqual(new Vector2(304, 56), positionData.Position);
                    Assert.AreEqual(1285, hitObjects[1].StartTime);
                    Assert.IsTrue(hitObjects[1].Samples.Any(s => s.Name == SampleInfo.HIT_CLAP));
                }
        }
Exemplo n.º 4
0
        public void TestDecodeBeatmapGeneral()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var beatmap     = decoder.Decode(stream);
                    var beatmapInfo = beatmap.BeatmapInfo;
                    var metadata    = beatmap.Metadata;

                    Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", metadata.AudioFile);
                    Assert.AreEqual(0, beatmapInfo.AudioLeadIn);
                    Assert.AreEqual(164471, metadata.PreviewTime);
                    Assert.AreEqual(0.7f, beatmapInfo.StackLeniency);
                    Assert.IsTrue(beatmapInfo.Ruleset.OnlineID == 0);
                    Assert.IsFalse(beatmapInfo.LetterboxInBreaks);
                    Assert.IsFalse(beatmapInfo.SpecialStyle);
                    Assert.IsFalse(beatmapInfo.WidescreenStoryboard);
                    Assert.IsFalse(beatmapInfo.SamplesMatchPlaybackRate);
                    Assert.AreEqual(CountdownType.None, beatmapInfo.Countdown);
                    Assert.AreEqual(0, beatmapInfo.CountdownOffset);
                }
        }
Exemplo n.º 5
0
        private static Beatmap GrabBeatmap(Stream beatmapFile)
        {
            var beatmapDecoder = new LegacyBeatmapDecoder();
            var beatmap        = beatmapDecoder.Decode(new LineBufferedReader(beatmapFile));

            beatmapFile.Close();

            return(beatmap);
        }
        public void TestInvalidEventStillPasses()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var badResStream = TestResources.OpenResource("invalid-events.osu"))
                using (var badStream = new LineBufferedReader(badResStream))
                {
                    Assert.DoesNotThrow(() => decoder.Decode(badStream));
                }
        }
Exemplo n.º 7
0
        public void TestDecodeHitObjectNullAdditionBank()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = Resource.OpenResource("hitobject-no-addition-bank.osu"))
                using (var stream = new StreamReader(resStream))
                {
                    var hitObjects = decoder.Decode(stream).HitObjects;

                    Assert.AreEqual(hitObjects[0].Samples[0].Bank, hitObjects[0].Samples[1].Bank);
                }
        }
Exemplo n.º 8
0
        public void TestTimingPointResetsSpeedMultiplier()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = TestResources.OpenResource("timingpoint-speedmultiplier-reset.osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var controlPoints = decoder.Decode(stream).ControlPointInfo;

                    Assert.That(controlPoints.DifficultyPointAt(0).SpeedMultiplier, Is.EqualTo(0.5).Within(0.1));
                    Assert.That(controlPoints.DifficultyPointAt(2000).SpeedMultiplier, Is.EqualTo(1).Within(0.1));
                }
        }
Exemplo n.º 9
0
        public void TestDecodeControlPointDifficultyChange()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = TestResources.OpenResource("controlpoint-difficulty-multiplier.osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var controlPointInfo = decoder.Decode(stream).ControlPointInfo;

                    Assert.That(controlPointInfo.DifficultyPointAt(5).SpeedMultiplier, Is.EqualTo(1));
                    Assert.That(controlPointInfo.DifficultyPointAt(1000).SpeedMultiplier, Is.EqualTo(10));
                    Assert.That(controlPointInfo.DifficultyPointAt(2000).SpeedMultiplier, Is.EqualTo(1.8518518518518519d));
                    Assert.That(controlPointInfo.DifficultyPointAt(3000).SpeedMultiplier, Is.EqualTo(0.5));
                }
        }
Exemplo n.º 10
0
        public void TestDecodeBeatmapDifficulty()
        {
            var decoder = new LegacyBeatmapDecoder();

            using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var difficulty = decoder.Decode(stream).BeatmapInfo.BaseDifficulty;

                    Assert.AreEqual(6.5f, difficulty.DrainRate);
                    Assert.AreEqual(4, difficulty.CircleSize);
                    Assert.AreEqual(8, difficulty.OverallDifficulty);
                    Assert.AreEqual(9, difficulty.ApproachRate);
                    Assert.AreEqual(1.8, difficulty.SliderMultiplier);
                    Assert.AreEqual(2, difficulty.SliderTickRate);
                }
        }
Exemplo n.º 11
0
        public void TestDecodeHitObjectCustomSampleBank()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = Resource.OpenResource("hitobject-custom-samplebank.osu"))
                using (var stream = new StreamReader(resStream))
                {
                    var hitObjects = decoder.Decode(stream).HitObjects;

                    Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
                    Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
                    Assert.AreEqual("normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
                }

            SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
        }
Exemplo n.º 12
0
        public void TestDecodeSliderSamples()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = Resource.OpenResource("slider-samples.osu"))
                using (var stream = new StreamReader(resStream))
                {
                    var hitObjects = decoder.Decode(stream).HitObjects;

                    var slider1 = (ConvertSlider)hitObjects[0];

                    Assert.AreEqual(1, slider1.NodeSamples[0].Count);
                    Assert.AreEqual(SampleInfo.HIT_NORMAL, slider1.NodeSamples[0][0].Name);
                    Assert.AreEqual(1, slider1.NodeSamples[1].Count);
                    Assert.AreEqual(SampleInfo.HIT_NORMAL, slider1.NodeSamples[1][0].Name);
                    Assert.AreEqual(1, slider1.NodeSamples[2].Count);
                    Assert.AreEqual(SampleInfo.HIT_NORMAL, slider1.NodeSamples[2][0].Name);

                    var slider2 = (ConvertSlider)hitObjects[1];

                    Assert.AreEqual(2, slider2.NodeSamples[0].Count);
                    Assert.AreEqual(SampleInfo.HIT_NORMAL, slider2.NodeSamples[0][0].Name);
                    Assert.AreEqual(SampleInfo.HIT_CLAP, slider2.NodeSamples[0][1].Name);
                    Assert.AreEqual(2, slider2.NodeSamples[1].Count);
                    Assert.AreEqual(SampleInfo.HIT_NORMAL, slider2.NodeSamples[1][0].Name);
                    Assert.AreEqual(SampleInfo.HIT_CLAP, slider2.NodeSamples[1][1].Name);
                    Assert.AreEqual(2, slider2.NodeSamples[2].Count);
                    Assert.AreEqual(SampleInfo.HIT_NORMAL, slider2.NodeSamples[2][0].Name);
                    Assert.AreEqual(SampleInfo.HIT_CLAP, slider2.NodeSamples[2][1].Name);

                    var slider3 = (ConvertSlider)hitObjects[2];

                    Assert.AreEqual(2, slider3.NodeSamples[0].Count);
                    Assert.AreEqual(SampleInfo.HIT_NORMAL, slider3.NodeSamples[0][0].Name);
                    Assert.AreEqual(SampleInfo.HIT_WHISTLE, slider3.NodeSamples[0][1].Name);
                    Assert.AreEqual(1, slider3.NodeSamples[1].Count);
                    Assert.AreEqual(SampleInfo.HIT_NORMAL, slider3.NodeSamples[1][0].Name);
                    Assert.AreEqual(2, slider3.NodeSamples[2].Count);
                    Assert.AreEqual(SampleInfo.HIT_NORMAL, slider3.NodeSamples[2][0].Name);
                    Assert.AreEqual(SampleInfo.HIT_CLAP, slider3.NodeSamples[2][1].Name);
                }
        }
Exemplo n.º 13
0
        public void TestDecodeControlPointCustomSampleBank()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = TestResources.OpenResource("controlpoint-custom-samplebank.osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var hitObjects = decoder.Decode(stream).HitObjects;

                    Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
                    Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
                    Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
                    Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First());

                    // The control point at the end time of the slider should be applied
                    Assert.AreEqual("Gameplay/soft-hitnormal8", getTestableSampleInfo(hitObjects[4]).LookupNames.First());
                }
Exemplo n.º 14
0
        public void TestDecodeBeatmapEvents()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var beatmap    = decoder.Decode(stream);
                    var metadata   = beatmap.Metadata;
                    var breakPoint = beatmap.Breaks[0];

                    Assert.AreEqual("machinetop_background.jpg", metadata.BackgroundFile);
                    Assert.AreEqual(122474, breakPoint.StartTime);
                    Assert.AreEqual(140135, breakPoint.EndTime);
                    Assert.IsTrue(breakPoint.HasEffect);
                }
        }
        public void TestDecodeHitObjectFileSamples()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = TestResources.OpenResource("hitobject-file-samples.osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var hitObjects = decoder.Decode(stream).HitObjects;

                    Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
                    Assert.AreEqual("hit_2.wav", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
                    Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
                    Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[3]).LookupNames.First());
                    Assert.AreEqual(70, getTestableSampleInfo(hitObjects[3]).Volume);
                }

            HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
        }
Exemplo n.º 16
0
        public void TestDecodeBeatmapComboOffsetsCatch()
        {
            var decoder = new LegacyBeatmapDecoder();

            using (var resStream = TestResources.OpenResource("hitobject-combo-offset.osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var beatmap = decoder.Decode(stream);

                    var converted = new CatchBeatmapConverter(beatmap, new CatchRuleset()).Convert();
                    new CatchBeatmapProcessor(converted).PreProcess();
                    new CatchBeatmapProcessor(converted).PostProcess();

                    Assert.AreEqual(4, ((IHasComboInformation)converted.HitObjects.ElementAt(0)).ComboIndexWithOffsets);
                    Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(2)).ComboIndexWithOffsets);
                    Assert.AreEqual(5, ((IHasComboInformation)converted.HitObjects.ElementAt(4)).ComboIndexWithOffsets);
                    Assert.AreEqual(6, ((IHasComboInformation)converted.HitObjects.ElementAt(6)).ComboIndexWithOffsets);
                    Assert.AreEqual(11, ((IHasComboInformation)converted.HitObjects.ElementAt(8)).ComboIndexWithOffsets);
                    Assert.AreEqual(14, ((IHasComboInformation)converted.HitObjects.ElementAt(11)).ComboIndexWithOffsets);
                }
        }
Exemplo n.º 17
0
        public void TestDecodeCustomHitObjectSamples()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = Resource.OpenResource("custom-hitobject-samples.osu"))
                using (var stream = new StreamReader(resStream))
                {
                    var hitObjects = decoder.Decode(stream).HitObjects;

                    Assert.AreEqual("hit_1.wav", hitObjects[0].Samples[0].LookupNames.First());
                    Assert.AreEqual("hit_2.wav", hitObjects[1].Samples[0].LookupNames.First());
                    Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
                    Assert.AreEqual("hit_1.wav", hitObjects[3].Samples[0].LookupNames.First());
                }

            SampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(new SampleInfo {
                Name = "hitnormal"
            });
        }
Exemplo n.º 18
0
        public void TestDecodeBeatmapMetadata()
        {
            var decoder = new LegacyBeatmapDecoder();

            using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var beatmap     = decoder.Decode(stream);
                    var beatmapInfo = beatmap.BeatmapInfo;
                    var metadata    = beatmap.Metadata;

                    Assert.AreEqual("Renatus", metadata.Title);
                    Assert.AreEqual("Renatus", metadata.TitleUnicode);
                    Assert.AreEqual("Soleily", metadata.Artist);
                    Assert.AreEqual("Soleily", metadata.ArtistUnicode);
                    Assert.AreEqual("Gamu", metadata.AuthorString);
                    Assert.AreEqual("Insane", beatmapInfo.Version);
                    Assert.AreEqual(string.Empty, metadata.Source);
                    Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", metadata.Tags);
                    Assert.AreEqual(557821, beatmapInfo.OnlineBeatmapID);
                    Assert.AreEqual(241526, beatmapInfo.BeatmapSet.OnlineBeatmapSetID);
                }
        }
Exemplo n.º 19
0
        public void TestDecodeBeatmapTimingPoints()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
                using (var stream = new StreamReader(resStream))
                {
                    var beatmap       = decoder.Decode(stream);
                    var controlPoints = beatmap.ControlPointInfo;

                    Assert.AreEqual(4, controlPoints.TimingPoints.Count);
                    var timingPoint = controlPoints.TimingPoints[0];
                    Assert.AreEqual(956, timingPoint.Time);
                    Assert.AreEqual(329.67032967033d, timingPoint.BeatLength);
                    Assert.AreEqual(TimeSignatures.SimpleQuadruple, timingPoint.TimeSignature);

                    Assert.AreEqual(5, controlPoints.DifficultyPoints.Count);
                    var difficultyPoint = controlPoints.DifficultyPoints[0];
                    Assert.AreEqual(116999, difficultyPoint.Time);
                    Assert.AreEqual(0.75000000000000189d, difficultyPoint.SpeedMultiplier);

                    Assert.AreEqual(34, controlPoints.SamplePoints.Count);
                    var soundPoint = controlPoints.SamplePoints[0];
                    Assert.AreEqual(956, soundPoint.Time);
                    Assert.AreEqual("soft", soundPoint.SampleBank);
                    Assert.AreEqual(60, soundPoint.SampleVolume);

                    Assert.AreEqual(8, controlPoints.EffectPoints.Count);
                    var effectPoint = controlPoints.EffectPoints[0];
                    Assert.AreEqual(53703, effectPoint.Time);
                    Assert.IsTrue(effectPoint.KiaiMode);
                    Assert.IsFalse(effectPoint.OmitFirstBarLine);
                }
        }
Exemplo n.º 20
0
        public void TestDecodeBeatmapTimingPoints()
        {
            var decoder = new LegacyBeatmapDecoder {
                ApplyOffsets = false
            };

            using (var resStream = TestResources.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
                using (var stream = new LineBufferedReader(resStream))
                {
                    var beatmap       = decoder.Decode(stream);
                    var controlPoints = beatmap.ControlPointInfo;

                    Assert.AreEqual(4, controlPoints.TimingPoints.Count);
                    Assert.AreEqual(5, controlPoints.DifficultyPoints.Count);
                    Assert.AreEqual(34, controlPoints.SamplePoints.Count);
                    Assert.AreEqual(8, controlPoints.EffectPoints.Count);

                    var timingPoint = controlPoints.TimingPointAt(0);
                    Assert.AreEqual(956, timingPoint.Time);
                    Assert.AreEqual(329.67032967033, timingPoint.BeatLength);
                    Assert.AreEqual(TimeSignatures.SimpleQuadruple, timingPoint.TimeSignature);

                    timingPoint = controlPoints.TimingPointAt(48428);
                    Assert.AreEqual(956, timingPoint.Time);
                    Assert.AreEqual(329.67032967033d, timingPoint.BeatLength);
                    Assert.AreEqual(TimeSignatures.SimpleQuadruple, timingPoint.TimeSignature);

                    timingPoint = controlPoints.TimingPointAt(119637);
                    Assert.AreEqual(119637, timingPoint.Time);
                    Assert.AreEqual(659.340659340659, timingPoint.BeatLength);
                    Assert.AreEqual(TimeSignatures.SimpleQuadruple, timingPoint.TimeSignature);

                    var difficultyPoint = controlPoints.DifficultyPointAt(0);
                    Assert.AreEqual(0, difficultyPoint.Time);
                    Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);

                    difficultyPoint = controlPoints.DifficultyPointAt(48428);
                    Assert.AreEqual(0, difficultyPoint.Time);
                    Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);

                    difficultyPoint = controlPoints.DifficultyPointAt(116999);
                    Assert.AreEqual(116999, difficultyPoint.Time);
                    Assert.AreEqual(0.75, difficultyPoint.SpeedMultiplier, 0.1);

                    var soundPoint = controlPoints.SamplePointAt(0);
                    Assert.AreEqual(956, soundPoint.Time);
                    Assert.AreEqual("soft", soundPoint.SampleBank);
                    Assert.AreEqual(60, soundPoint.SampleVolume);

                    soundPoint = controlPoints.SamplePointAt(53373);
                    Assert.AreEqual(53373, soundPoint.Time);
                    Assert.AreEqual("soft", soundPoint.SampleBank);
                    Assert.AreEqual(60, soundPoint.SampleVolume);

                    soundPoint = controlPoints.SamplePointAt(119637);
                    Assert.AreEqual(119637, soundPoint.Time);
                    Assert.AreEqual("soft", soundPoint.SampleBank);
                    Assert.AreEqual(80, soundPoint.SampleVolume);

                    var effectPoint = controlPoints.EffectPointAt(0);
                    Assert.AreEqual(0, effectPoint.Time);
                    Assert.IsFalse(effectPoint.KiaiMode);
                    Assert.IsFalse(effectPoint.OmitFirstBarLine);

                    effectPoint = controlPoints.EffectPointAt(53703);
                    Assert.AreEqual(53703, effectPoint.Time);
                    Assert.IsTrue(effectPoint.KiaiMode);
                    Assert.IsFalse(effectPoint.OmitFirstBarLine);

                    effectPoint = controlPoints.EffectPointAt(119637);
                    Assert.AreEqual(95901, effectPoint.Time);
                    Assert.IsFalse(effectPoint.KiaiMode);
                    Assert.IsFalse(effectPoint.OmitFirstBarLine);
                }
        }
Exemplo n.º 21
0
        static int Main(string[] args)
        {
            if (args == null)
            {
                Console.Write("Missing arguments: [inputMap.osu] [outputMap] {forceKeys}\n");
                return(1);
            }

            LegacyBeatmapDecoder legacyBeatmapDecoder = new LegacyBeatmapDecoder();
            IBeatmap             beatmap = null;


            try
            {
                using (StreamReader sr = new StreamReader(args[0]))
                {
                    try
                    {
                        beatmap = legacyBeatmapDecoder.Decode(sr);
                    }
                    catch (Exception e)
                    {
                        Console.Write("Could not convert input file:\n" + e);
                        return(1);
                    }
                }
            }
            catch (Exception e)
            {
                Console.Write("Could not read input file:\n" + e);
            }

            if (beatmap == null)
            {
                Console.Write("Failed");
                return(1);
            }

            IBeatmap convertedBeatmap = null;
            ManiaBeatmapConverter maniaBeatmapConverter = null;

            try
            {
                beatmap.BeatmapInfo.Ruleset = new OsuRuleset().RulesetInfo;
                maniaBeatmapConverter       = new ManiaBeatmapConverter(beatmap);

                // Third argument is optionnal and can force TargetColumns
                if (args.Length > 2)
                {
                    maniaBeatmapConverter.TargetColumns = Int32.Parse(args[2]);
                }

                convertedBeatmap = maniaBeatmapConverter.Convert();
            } catch (Exception e)
            {
                Console.Write("Could not convert input file:\n" + e);
                return(1);
            }

            int columns = maniaBeatmapConverter.TargetColumns;

            using (StreamWriter writer = new StreamWriter(args[1]))
            {
                writer.Write("[Difficulty]\n");
                writer.Write("CircleSize: " + columns + "\n");

                writer.Write("[HitObjects]\n");
                String current = "";
                foreach (ManiaHitObject maniaHitObject in convertedBeatmap.HitObjects)
                {
                    int columnPosition = (((maniaHitObject.Column) * (512 / columns)) + (256 / columns));
                    switch (maniaHitObject.GetType().Name)
                    {
                    case "Note":
                        current = columnPosition + ",192," + maniaHitObject.StartTime.ToString().Split(",")[0].Split(".")[0] + ",1,0,0:0:0:0:0\n";
                        break;

                    case "HoldNote":
                        current = columnPosition + ",192," + maniaHitObject.StartTime.ToString().Split(",")[0].Split(".")[0] + ",128,0," + (maniaHitObject as HoldNote).EndTime.ToString().Split(",")[0].Split(".")[0] + ":0:0:0:0\n";
                        break;
                    }
                    writer.Write(current);
                }
            }

            return(0);
        }