mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 10:02:59 +08:00
Merge pull request #471 from smoogipooo/beatmap_conversion
Beatmap conversion
This commit is contained in:
commit
c51e97e8cc
@ -1,40 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Osu.Objects;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Modes.Catch.Objects
|
||||
{
|
||||
internal class CatchConverter : HitObjectConverter<CatchBaseHit>
|
||||
{
|
||||
public override List<CatchBaseHit> Convert(Beatmap beatmap)
|
||||
{
|
||||
List<CatchBaseHit> output = new List<CatchBaseHit>();
|
||||
|
||||
foreach (HitObject i in beatmap.HitObjects)
|
||||
{
|
||||
CatchBaseHit h = i as CatchBaseHit;
|
||||
|
||||
if (h == null)
|
||||
{
|
||||
OsuHitObject o = i as OsuHitObject;
|
||||
|
||||
if (o == null) throw new HitObjectConvertException(@"Catch", i);
|
||||
|
||||
h = new Fruit
|
||||
{
|
||||
StartTime = o.StartTime,
|
||||
Position = o.Position.X,
|
||||
};
|
||||
}
|
||||
|
||||
output.Add(h);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
@ -50,7 +50,6 @@
|
||||
<Compile Include="Beatmaps\CatchBeatmapConverter.cs" />
|
||||
<Compile Include="CatchDifficultyCalculator.cs" />
|
||||
<Compile Include="Objects\CatchBaseHit.cs" />
|
||||
<Compile Include="Objects\CatchConverter.cs" />
|
||||
<Compile Include="Objects\Drawable\DrawableFruit.cs" />
|
||||
<Compile Include="Objects\Droplet.cs" />
|
||||
<Compile Include="Objects\Fruit.cs" />
|
||||
|
@ -1,48 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Osu.Objects;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Modes.Mania.Objects
|
||||
{
|
||||
internal class ManiaConverter : HitObjectConverter<ManiaBaseHit>
|
||||
{
|
||||
private readonly int columns;
|
||||
|
||||
public ManiaConverter(int columns)
|
||||
{
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
public override List<ManiaBaseHit> Convert(Beatmap beatmap)
|
||||
{
|
||||
List<ManiaBaseHit> output = new List<ManiaBaseHit>();
|
||||
|
||||
foreach (HitObject i in beatmap.HitObjects)
|
||||
{
|
||||
ManiaBaseHit h = i as ManiaBaseHit;
|
||||
|
||||
if (h == null)
|
||||
{
|
||||
OsuHitObject o = i as OsuHitObject;
|
||||
|
||||
if (o == null) throw new HitObjectConvertException(@"Mania", i);
|
||||
|
||||
h = new Note
|
||||
{
|
||||
StartTime = o.StartTime,
|
||||
Column = (int)Math.Round(o.Position.X / 512 * columns)
|
||||
};
|
||||
}
|
||||
|
||||
output.Add(h);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
@ -52,7 +52,6 @@
|
||||
<Compile Include="Objects\Drawable\DrawableNote.cs" />
|
||||
<Compile Include="Objects\HoldNote.cs" />
|
||||
<Compile Include="Objects\ManiaBaseHit.cs" />
|
||||
<Compile Include="Objects\ManiaConverter.cs" />
|
||||
<Compile Include="Objects\Note.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UI\ManiaHitRenderer.cs" />
|
||||
|
@ -1,39 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Osu.Objects;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Modes.Taiko.Objects
|
||||
{
|
||||
internal class TaikoConverter : HitObjectConverter<TaikoBaseHit>
|
||||
{
|
||||
public override List<TaikoBaseHit> Convert(Beatmap beatmap)
|
||||
{
|
||||
List<TaikoBaseHit> output = new List<TaikoBaseHit>();
|
||||
|
||||
foreach (HitObject i in beatmap.HitObjects)
|
||||
{
|
||||
TaikoBaseHit h = i as TaikoBaseHit;
|
||||
|
||||
if (h == null)
|
||||
{
|
||||
OsuHitObject o = i as OsuHitObject;
|
||||
|
||||
if (o == null) throw new HitObjectConvertException(@"Taiko", i);
|
||||
|
||||
h = new TaikoBaseHit
|
||||
{
|
||||
StartTime = o.StartTime,
|
||||
};
|
||||
}
|
||||
|
||||
output.Add(h);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
@ -51,7 +51,6 @@
|
||||
<Compile Include="TaikoDifficultyCalculator.cs" />
|
||||
<Compile Include="Objects\Drawable\DrawableTaikoHit.cs" />
|
||||
<Compile Include="Objects\TaikoBaseHit.cs" />
|
||||
<Compile Include="Objects\TaikoConverter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UI\TaikoHitRenderer.cs" />
|
||||
<Compile Include="UI\TaikoPlayfield.cs" />
|
||||
|
@ -1,25 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Modes.Objects
|
||||
{
|
||||
public abstract class HitObjectConverter<T>
|
||||
where T : HitObject
|
||||
{
|
||||
public abstract List<T> Convert(Beatmap beatmap);
|
||||
}
|
||||
|
||||
public class HitObjectConvertException : Exception
|
||||
{
|
||||
public HitObject Input { get; }
|
||||
public HitObjectConvertException(string modeName, HitObject input)
|
||||
: base($@"Can't convert from {input.GetType().Name} to {modeName} HitObject!")
|
||||
{
|
||||
Input = input;
|
||||
}
|
||||
}
|
||||
}
|
@ -114,7 +114,6 @@
|
||||
<Compile Include="Beatmaps\Drawables\Panel.cs" />
|
||||
<Compile Include="Modes\Objects\Drawables\DrawableHitObject.cs" />
|
||||
<Compile Include="Modes\Objects\HitObject.cs" />
|
||||
<Compile Include="Modes\Objects\HitObjectConverter.cs" />
|
||||
<Compile Include="Beatmaps\Samples\HitSampleInfo.cs" />
|
||||
<Compile Include="Beatmaps\Samples\SampleBank.cs" />
|
||||
<Compile Include="Beatmaps\Samples\SampleInfo.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user