mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 14:12:54 +08:00
Merge pull request #467 from smoogipooo/beatmap_conversion
Beatmap conversion
This commit is contained in:
commit
c76a495d3d
21
osu.Game.Modes.Catch/Beatmaps/CatchBeatmapConverter.cs
Normal file
21
osu.Game.Modes.Catch/Beatmaps/CatchBeatmapConverter.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// 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 osu.Game.Modes.Catch.Objects;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace osu.Game.Modes.Catch.Beatmaps
|
||||||
|
{
|
||||||
|
internal class CatchBeatmapConverter : IBeatmapConverter<CatchBaseHit>
|
||||||
|
{
|
||||||
|
public Beatmap<CatchBaseHit> Convert(Beatmap original)
|
||||||
|
{
|
||||||
|
return new Beatmap<CatchBaseHit>(original)
|
||||||
|
{
|
||||||
|
HitObjects = new List<CatchBaseHit>() // Todo: Convert HitObjects
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,26 +2,23 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Modes.Catch.Beatmaps;
|
||||||
using osu.Game.Modes.Catch.Objects;
|
using osu.Game.Modes.Catch.Objects;
|
||||||
using osu.Game.Modes.Objects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Catch
|
namespace osu.Game.Modes.Catch
|
||||||
{
|
{
|
||||||
public class CatchDifficultyCalculator : DifficultyCalculator<CatchBaseHit>
|
public class CatchDifficultyCalculator : DifficultyCalculator<CatchBaseHit>
|
||||||
{
|
{
|
||||||
protected override PlayMode PlayMode => PlayMode.Catch;
|
|
||||||
|
|
||||||
public CatchDifficultyCalculator(Beatmap beatmap) : base(beatmap)
|
public CatchDifficultyCalculator(Beatmap beatmap) : base(beatmap)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override HitObjectConverter<CatchBaseHit> Converter => new CatchConverter();
|
protected override double CalculateInternal(Dictionary<string, string> categoryDifficulty)
|
||||||
|
|
||||||
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IBeatmapConverter<CatchBaseHit> CreateBeatmapConverter() => new CatchBeatmapConverter();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,8 +2,8 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Modes.Catch.Beatmaps;
|
||||||
using osu.Game.Modes.Catch.Objects;
|
using osu.Game.Modes.Catch.Objects;
|
||||||
using osu.Game.Modes.Objects;
|
|
||||||
using osu.Game.Modes.Objects.Drawables;
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
using osu.Game.Modes.UI;
|
using osu.Game.Modes.UI;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ namespace osu.Game.Modes.Catch.UI
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override HitObjectConverter<CatchBaseHit> Converter => new CatchConverter();
|
protected override IBeatmapConverter<CatchBaseHit> CreateBeatmapConverter() => new CatchBeatmapConverter();
|
||||||
|
|
||||||
protected override Playfield<CatchBaseHit> CreatePlayfield() => new CatchPlayfield();
|
protected override Playfield<CatchBaseHit> CreatePlayfield() => new CatchPlayfield();
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Beatmaps\CatchBeatmapConverter.cs" />
|
||||||
<Compile Include="CatchDifficultyCalculator.cs" />
|
<Compile Include="CatchDifficultyCalculator.cs" />
|
||||||
<Compile Include="Objects\CatchBaseHit.cs" />
|
<Compile Include="Objects\CatchBaseHit.cs" />
|
||||||
<Compile Include="Objects\CatchConverter.cs" />
|
<Compile Include="Objects\CatchConverter.cs" />
|
||||||
|
21
osu.Game.Modes.Mania/Beatmaps/ManiaBeatmapConverter.cs
Normal file
21
osu.Game.Modes.Mania/Beatmaps/ManiaBeatmapConverter.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// 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 osu.Game.Modes.Mania.Objects;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace osu.Game.Modes.Mania.Beatmaps
|
||||||
|
{
|
||||||
|
internal class ManiaBeatmapConverter : IBeatmapConverter<ManiaBaseHit>
|
||||||
|
{
|
||||||
|
public Beatmap<ManiaBaseHit> Convert(Beatmap original)
|
||||||
|
{
|
||||||
|
return new Beatmap<ManiaBaseHit>(original)
|
||||||
|
{
|
||||||
|
HitObjects = new List<ManiaBaseHit>() // Todo: Implement
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,29 +2,24 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Modes.Mania.Beatmaps;
|
||||||
using osu.Game.Modes.Mania.Objects;
|
using osu.Game.Modes.Mania.Objects;
|
||||||
using osu.Game.Modes.Objects;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Mania
|
namespace osu.Game.Modes.Mania
|
||||||
{
|
{
|
||||||
public class ManiaDifficultyCalculator : DifficultyCalculator<ManiaBaseHit>
|
public class ManiaDifficultyCalculator : DifficultyCalculator<ManiaBaseHit>
|
||||||
{
|
{
|
||||||
protected override PlayMode PlayMode => PlayMode.Mania;
|
public ManiaDifficultyCalculator(Beatmap beatmap)
|
||||||
|
: base(beatmap)
|
||||||
private int columns;
|
|
||||||
|
|
||||||
public ManiaDifficultyCalculator(Beatmap beatmap, int columns = 5) : base(beatmap)
|
|
||||||
{
|
{
|
||||||
this.columns = columns;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override HitObjectConverter<ManiaBaseHit> Converter => new ManiaConverter(columns);
|
protected override double CalculateInternal(Dictionary<string, string> categoryDifficulty)
|
||||||
|
|
||||||
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IBeatmapConverter<ManiaBaseHit> CreateBeatmapConverter() => new ManiaBeatmapConverter();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,8 +2,8 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Modes.Mania.Beatmaps;
|
||||||
using osu.Game.Modes.Mania.Objects;
|
using osu.Game.Modes.Mania.Objects;
|
||||||
using osu.Game.Modes.Objects;
|
|
||||||
using osu.Game.Modes.Objects.Drawables;
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
using osu.Game.Modes.UI;
|
using osu.Game.Modes.UI;
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ namespace osu.Game.Modes.Mania.UI
|
|||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override HitObjectConverter<ManiaBaseHit> Converter => new ManiaConverter(columns);
|
protected override IBeatmapConverter<ManiaBaseHit> CreateBeatmapConverter() => new ManiaBeatmapConverter();
|
||||||
|
|
||||||
protected override Playfield<ManiaBaseHit> CreatePlayfield() => new ManiaPlayfield(columns);
|
protected override Playfield<ManiaBaseHit> CreatePlayfield() => new ManiaPlayfield(columns);
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Beatmaps\ManiaBeatmapConverter.cs" />
|
||||||
<Compile Include="ManiaDifficultyCalculator.cs" />
|
<Compile Include="ManiaDifficultyCalculator.cs" />
|
||||||
<Compile Include="Objects\Drawable\DrawableNote.cs" />
|
<Compile Include="Objects\Drawable\DrawableNote.cs" />
|
||||||
<Compile Include="Objects\HoldNote.cs" />
|
<Compile Include="Objects\HoldNote.cs" />
|
||||||
@ -85,6 +86,7 @@
|
|||||||
<None Include="OpenTK.dll.config" />
|
<None Include="OpenTK.dll.config" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
@ -1,35 +1,45 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// 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.Beatmaps;
|
|
||||||
using osu.Game.Modes.Osu.Objects.Drawables;
|
|
||||||
using OpenTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Modes.Osu.Objects
|
using OpenTK;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Modes.Objects;
|
||||||
|
using osu.Game.Modes.Osu.Objects;
|
||||||
|
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace osu.Game.Modes.Osu.Beatmaps
|
||||||
{
|
{
|
||||||
public class OsuHitObjectConverter : HitObjectConverter<OsuHitObject>
|
internal class OsuBeatmapConverter : IBeatmapConverter<OsuHitObject>
|
||||||
{
|
{
|
||||||
public override List<OsuHitObject> Convert(Beatmap beatmap)
|
public Beatmap<OsuHitObject> Convert(Beatmap original)
|
||||||
{
|
{
|
||||||
List<OsuHitObject> output = new List<OsuHitObject>();
|
return new Beatmap<OsuHitObject>(original)
|
||||||
|
{
|
||||||
|
HitObjects = convertHitObject(original.HitObjects, original.BeatmapInfo?.StackLeniency ?? 0.7f)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<OsuHitObject> convertHitObject(List<HitObject> hitObjects, float stackLeniency)
|
||||||
|
{
|
||||||
|
List<OsuHitObject> converted = new List<OsuHitObject>();
|
||||||
|
|
||||||
int combo = 0;
|
int combo = 0;
|
||||||
foreach (HitObject h in beatmap.HitObjects)
|
foreach (HitObject h in hitObjects)
|
||||||
{
|
{
|
||||||
if (h.NewCombo) combo = 0;
|
if (h.NewCombo) combo = 0;
|
||||||
|
|
||||||
h.ComboIndex = combo++;
|
h.ComboIndex = combo++;
|
||||||
output.Add(h as OsuHitObject);
|
converted.Add(h as OsuHitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateStacking(output, beatmap.BeatmapInfo?.StackLeniency ?? 0.7f);
|
updateStacking(converted, stackLeniency);
|
||||||
|
|
||||||
return output;
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateStacking(List<OsuHitObject> hitObjects, float stackLeniency, int startIndex = 0, int endIndex = -1)
|
private void updateStacking(List<OsuHitObject> hitObjects, float stackLeniency, int startIndex = 0, int endIndex = -1)
|
||||||
{
|
{
|
||||||
if (endIndex == -1)
|
if (endIndex == -1)
|
||||||
endIndex = hitObjects.Count - 1;
|
endIndex = hitObjects.Count - 1;
|
||||||
@ -171,6 +181,5 @@ namespace osu.Game.Modes.Osu.Objects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,10 +2,10 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Modes.Osu.Beatmaps;
|
||||||
using osu.Game.Modes.Osu.Objects;
|
using osu.Game.Modes.Osu.Objects;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Modes.Objects;
|
|
||||||
|
|
||||||
namespace osu.Game.Modes.Osu
|
namespace osu.Game.Modes.Osu
|
||||||
{
|
{
|
||||||
@ -14,8 +14,6 @@ namespace osu.Game.Modes.Osu
|
|||||||
private const double star_scaling_factor = 0.0675;
|
private const double star_scaling_factor = 0.0675;
|
||||||
private const double extreme_scaling_factor = 0.5;
|
private const double extreme_scaling_factor = 0.5;
|
||||||
|
|
||||||
protected override PlayMode PlayMode => PlayMode.Osu;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// HitObjects are stored as a member variable.
|
/// HitObjects are stored as a member variable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -25,8 +23,6 @@ namespace osu.Game.Modes.Osu
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override HitObjectConverter<OsuHitObject> Converter => new OsuHitObjectConverter();
|
|
||||||
|
|
||||||
protected override void PreprocessHitObjects()
|
protected override void PreprocessHitObjects()
|
||||||
{
|
{
|
||||||
foreach (var h in Objects)
|
foreach (var h in Objects)
|
||||||
@ -34,7 +30,7 @@ namespace osu.Game.Modes.Osu
|
|||||||
((Slider)h).Curve.Calculate();
|
((Slider)h).Curve.Calculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
|
protected override double CalculateInternal(Dictionary<string, string> categoryDifficulty)
|
||||||
{
|
{
|
||||||
// Fill our custom DifficultyHitObject class, that carries additional information
|
// Fill our custom DifficultyHitObject class, that carries additional information
|
||||||
DifficultyHitObjects.Clear();
|
DifficultyHitObjects.Clear();
|
||||||
@ -184,6 +180,8 @@ namespace osu.Game.Modes.Osu
|
|||||||
return difficulty;
|
return difficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IBeatmapConverter<OsuHitObject> CreateBeatmapConverter() => new OsuBeatmapConverter();
|
||||||
|
|
||||||
// Those values are used as array indices. Be careful when changing them!
|
// Those values are used as array indices. Be careful when changing them!
|
||||||
public enum DifficultyType
|
public enum DifficultyType
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Modes.Objects;
|
|
||||||
using osu.Game.Modes.Objects.Drawables;
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
|
using osu.Game.Modes.Osu.Beatmaps;
|
||||||
using osu.Game.Modes.Osu.Objects;
|
using osu.Game.Modes.Osu.Objects;
|
||||||
using osu.Game.Modes.Osu.Objects.Drawables;
|
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||||
using osu.Game.Modes.UI;
|
using osu.Game.Modes.UI;
|
||||||
@ -17,7 +17,7 @@ namespace osu.Game.Modes.Osu.UI
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override HitObjectConverter<OsuHitObject> Converter => new OsuHitObjectConverter();
|
protected override IBeatmapConverter<OsuHitObject> CreateBeatmapConverter() => new OsuBeatmapConverter();
|
||||||
|
|
||||||
protected override Playfield<OsuHitObject> CreatePlayfield() => new OsuPlayfield();
|
protected override Playfield<OsuHitObject> CreatePlayfield() => new OsuPlayfield();
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Beatmaps\OsuBeatmapConverter.cs" />
|
||||||
<Compile Include="Objects\BezierApproximator.cs" />
|
<Compile Include="Objects\BezierApproximator.cs" />
|
||||||
<Compile Include="Objects\CircularArcApproximator.cs" />
|
<Compile Include="Objects\CircularArcApproximator.cs" />
|
||||||
<Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" />
|
<Compile Include="Objects\Drawables\DrawableOsuHitObject.cs" />
|
||||||
@ -80,7 +81,6 @@
|
|||||||
<Compile Include="Objects\HitCircle.cs" />
|
<Compile Include="Objects\HitCircle.cs" />
|
||||||
<Compile Include="Objects\Drawables\DrawableHitCircle.cs" />
|
<Compile Include="Objects\Drawables\DrawableHitCircle.cs" />
|
||||||
<Compile Include="Objects\OsuHitObject.cs" />
|
<Compile Include="Objects\OsuHitObject.cs" />
|
||||||
<Compile Include="Objects\OsuHitObjectConverter.cs" />
|
|
||||||
<Compile Include="Objects\Slider.cs" />
|
<Compile Include="Objects\Slider.cs" />
|
||||||
<Compile Include="Objects\Spinner.cs" />
|
<Compile Include="Objects\Spinner.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
20
osu.Game.Modes.Taiko/Beatmaps/TaikoBeatmapConverter.cs
Normal file
20
osu.Game.Modes.Taiko/Beatmaps/TaikoBeatmapConverter.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// 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 osu.Game.Modes.Taiko.Objects;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace osu.Game.Modes.Taiko.Beatmaps
|
||||||
|
{
|
||||||
|
internal class TaikoBeatmapConverter : IBeatmapConverter<TaikoBaseHit>
|
||||||
|
{
|
||||||
|
public Beatmap<TaikoBaseHit> Convert(Beatmap original)
|
||||||
|
{
|
||||||
|
return new Beatmap<TaikoBaseHit>(original)
|
||||||
|
{
|
||||||
|
HitObjects = new List<TaikoBaseHit>() // Todo: Implement
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,26 +2,23 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Taiko.Beatmaps;
|
||||||
using osu.Game.Modes.Taiko.Objects;
|
using osu.Game.Modes.Taiko.Objects;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Taiko
|
namespace osu.Game.Modes.Taiko
|
||||||
{
|
{
|
||||||
public class TaikoDifficultyCalculator : DifficultyCalculator<TaikoBaseHit>
|
public class TaikoDifficultyCalculator : DifficultyCalculator<TaikoBaseHit>
|
||||||
{
|
{
|
||||||
protected override PlayMode PlayMode => PlayMode.Taiko;
|
|
||||||
|
|
||||||
public TaikoDifficultyCalculator(Beatmap beatmap) : base(beatmap)
|
public TaikoDifficultyCalculator(Beatmap beatmap) : base(beatmap)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override HitObjectConverter<TaikoBaseHit> Converter => new TaikoConverter();
|
protected override double CalculateInternal(Dictionary<string, string> categoryDifficulty)
|
||||||
|
|
||||||
protected override double CalculateInternal(Dictionary<String, String> categoryDifficulty)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IBeatmapConverter<TaikoBaseHit> CreateBeatmapConverter() => new TaikoBeatmapConverter();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,8 +2,8 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Modes.Objects;
|
|
||||||
using osu.Game.Modes.Objects.Drawables;
|
using osu.Game.Modes.Objects.Drawables;
|
||||||
|
using osu.Game.Modes.Taiko.Beatmaps;
|
||||||
using osu.Game.Modes.Taiko.Objects;
|
using osu.Game.Modes.Taiko.Objects;
|
||||||
using osu.Game.Modes.UI;
|
using osu.Game.Modes.UI;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ namespace osu.Game.Modes.Taiko.UI
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override HitObjectConverter<TaikoBaseHit> Converter => new TaikoConverter();
|
protected override IBeatmapConverter<TaikoBaseHit> CreateBeatmapConverter() => new TaikoBeatmapConverter();
|
||||||
|
|
||||||
protected override Playfield<TaikoBaseHit> CreatePlayfield() => new TaikoPlayfield();
|
protected override Playfield<TaikoBaseHit> CreatePlayfield() => new TaikoPlayfield();
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Beatmaps\TaikoBeatmapConverter.cs" />
|
||||||
<Compile Include="TaikoDifficultyCalculator.cs" />
|
<Compile Include="TaikoDifficultyCalculator.cs" />
|
||||||
<Compile Include="Objects\Drawable\DrawableTaikoHit.cs" />
|
<Compile Include="Objects\Drawable\DrawableTaikoHit.cs" />
|
||||||
<Compile Include="Objects\TaikoBaseHit.cs" />
|
<Compile Include="Objects\TaikoBaseHit.cs" />
|
||||||
|
@ -1,23 +1,44 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Modes.Objects;
|
|
||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
|
using osu.Game.Modes.Objects;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
public class Beatmap
|
/// <summary>
|
||||||
|
/// A Beatmap containing converted HitObjects.
|
||||||
|
/// </summary>
|
||||||
|
public class Beatmap<T>
|
||||||
|
where T : HitObject
|
||||||
{
|
{
|
||||||
public BeatmapInfo BeatmapInfo { get; set; }
|
public BeatmapInfo BeatmapInfo;
|
||||||
|
public List<ControlPoint> ControlPoints;
|
||||||
|
public List<Color4> ComboColors;
|
||||||
|
|
||||||
public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
|
public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
|
||||||
public List<HitObject> HitObjects { get; set; }
|
|
||||||
public List<ControlPoint> ControlPoints { get; set; }
|
/// <summary>
|
||||||
public List<Color4> ComboColors { get; set; }
|
/// The HitObjects this Beatmap contains.
|
||||||
|
/// </summary>
|
||||||
|
public List<T> HitObjects;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new beatmap.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="original">The original beatmap to use the parameters of.</param>
|
||||||
|
public Beatmap(Beatmap original = null)
|
||||||
|
{
|
||||||
|
BeatmapInfo = original?.BeatmapInfo;
|
||||||
|
ControlPoints = original?.ControlPoints;
|
||||||
|
ComboColors = original?.ComboColors;
|
||||||
|
}
|
||||||
|
|
||||||
public double BPMMaximum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength;
|
public double BPMMaximum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength;
|
||||||
public double BPMMinimum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength;
|
public double BPMMinimum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderByDescending(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength;
|
||||||
public double BPMMode => BPMAt(ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time);
|
public double BPMMode => BPMAt(ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time);
|
||||||
@ -58,7 +79,17 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
return timingPoint ?? ControlPoint.Default;
|
return timingPoint ?? ControlPoint.Default;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A Beatmap containing un-converted HitObjects.
|
||||||
|
/// </summary>
|
||||||
|
public class Beatmap : Beatmap<HitObject>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates the star difficulty for this Beatmap.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The star difficulty.</returns>
|
||||||
public double CalculateStarDifficulty() => Ruleset.GetRuleset(BeatmapInfo.Mode).CreateDifficultyCalculator(this).Calculate();
|
public double CalculateStarDifficulty() => Ruleset.GetRuleset(BeatmapInfo.Mode).CreateDifficultyCalculator(this).Calculate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Game.Modes;
|
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
public abstract class DifficultyCalculator
|
public abstract class DifficultyCalculator
|
||||||
{
|
{
|
||||||
protected abstract PlayMode PlayMode { get; }
|
|
||||||
|
|
||||||
protected double TimeRate = 1;
|
protected double TimeRate = 1;
|
||||||
|
|
||||||
protected abstract double CalculateInternal(Dictionary<String, String> categoryDifficulty);
|
protected abstract double CalculateInternal(Dictionary<string, string> categoryDifficulty);
|
||||||
|
|
||||||
private void loadTiming()
|
private void loadTiming()
|
||||||
{
|
{
|
||||||
@ -35,16 +31,16 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
protected List<T> Objects;
|
protected List<T> Objects;
|
||||||
|
|
||||||
protected abstract HitObjectConverter<T> Converter { get; }
|
|
||||||
|
|
||||||
protected DifficultyCalculator(Beatmap beatmap)
|
protected DifficultyCalculator(Beatmap beatmap)
|
||||||
{
|
{
|
||||||
Objects = Converter.Convert(beatmap);
|
Objects = CreateBeatmapConverter().Convert(beatmap).HitObjects;
|
||||||
PreprocessHitObjects();
|
PreprocessHitObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void PreprocessHitObjects()
|
protected virtual void PreprocessHitObjects()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract IBeatmapConverter<T> CreateBeatmapConverter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
osu.Game/Beatmaps/IBeatmapCoverter.cs
Normal file
12
osu.Game/Beatmaps/IBeatmapCoverter.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// 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.Modes.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Beatmaps
|
||||||
|
{
|
||||||
|
public interface IBeatmapConverter<T> where T : HitObject
|
||||||
|
{
|
||||||
|
Beatmap<T> Convert(Beatmap original);
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Game.Beatmaps.Samples;
|
using osu.Game.Beatmaps.Samples;
|
||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
using SQLite.Net.Attributes;
|
using SQLite.Net.Attributes;
|
||||||
using SQLiteNetExtensions.Attributes;
|
using SQLiteNetExtensions.Attributes;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Database
|
namespace osu.Game.Database
|
||||||
{
|
{
|
||||||
|
@ -32,16 +32,6 @@ namespace osu.Game.Modes.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract bool AllObjectsJudged { get; }
|
protected abstract bool AllObjectsJudged { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The beatmap this HitRenderer is initialized with.
|
|
||||||
/// </summary>
|
|
||||||
protected readonly Beatmap Beatmap;
|
|
||||||
|
|
||||||
protected HitRenderer(Beatmap beatmap)
|
|
||||||
{
|
|
||||||
Beatmap = beatmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void TriggerOnJudgement(JudgementInfo j)
|
protected void TriggerOnJudgement(JudgementInfo j)
|
||||||
{
|
{
|
||||||
OnJudgement?.Invoke(j);
|
OnJudgement?.Invoke(j);
|
||||||
@ -57,19 +47,18 @@ namespace osu.Game.Modes.UI
|
|||||||
public override Func<Vector2, Vector2> MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace;
|
public override Func<Vector2, Vector2> MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace;
|
||||||
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
|
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
|
||||||
|
|
||||||
protected abstract HitObjectConverter<TObject> Converter { get; }
|
|
||||||
protected virtual List<TObject> Convert(Beatmap beatmap) => Converter.Convert(beatmap);
|
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
|
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
|
||||||
|
|
||||||
protected Playfield<TObject> Playfield;
|
protected Playfield<TObject> Playfield;
|
||||||
|
protected Beatmap<TObject> Beatmap;
|
||||||
|
|
||||||
private Container content;
|
private Container content;
|
||||||
|
|
||||||
protected HitRenderer(Beatmap beatmap)
|
protected HitRenderer(Beatmap beatmap)
|
||||||
: base(beatmap)
|
|
||||||
{
|
{
|
||||||
|
Beatmap = CreateBeatmapConverter().Convert(beatmap);
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
InputManager.Add(content = new Container
|
InputManager.Add(content = new Container
|
||||||
@ -93,7 +82,7 @@ namespace osu.Game.Modes.UI
|
|||||||
|
|
||||||
private void loadObjects()
|
private void loadObjects()
|
||||||
{
|
{
|
||||||
foreach (TObject h in Convert(Beatmap))
|
foreach (TObject h in Beatmap.HitObjects)
|
||||||
{
|
{
|
||||||
DrawableHitObject<TObject> drawableObject = GetVisualRepresentation(h);
|
DrawableHitObject<TObject> drawableObject = GetVisualRepresentation(h);
|
||||||
|
|
||||||
@ -112,5 +101,6 @@ namespace osu.Game.Modes.UI
|
|||||||
|
|
||||||
protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
|
protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
|
||||||
protected abstract Playfield<TObject> CreatePlayfield();
|
protected abstract Playfield<TObject> CreatePlayfield();
|
||||||
|
protected abstract IBeatmapConverter<TObject> CreateBeatmapConverter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
||||||
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
|
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
|
||||||
|
<Compile Include="Beatmaps\IBeatmapCoverter.cs" />
|
||||||
<Compile Include="Database\ScoreDatabase.cs" />
|
<Compile Include="Database\ScoreDatabase.cs" />
|
||||||
<Compile Include="Graphics\Backgrounds\Triangles.cs" />
|
<Compile Include="Graphics\Backgrounds\Triangles.cs" />
|
||||||
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
|
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user