mirror of
https://github.com/osukey/osukey.git
synced 2025-06-10 13:58:01 +09:00
Introduce concept of HitObjectParsers, fix tests and stop using reflection (unreliable due to lazy loading).
This commit is contained in:
parent
0011d7f720
commit
d3f810f72f
@ -10,6 +10,11 @@ using osu.Framework.Desktop.Platform;
|
|||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game;
|
using osu.Game;
|
||||||
using osu.Game.IPC;
|
using osu.Game.IPC;
|
||||||
|
using osu.Game.Modes;
|
||||||
|
using osu.Game.Modes.Catch;
|
||||||
|
using osu.Game.Modes.Mania;
|
||||||
|
using osu.Game.Modes.Osu;
|
||||||
|
using osu.Game.Modes.Taiko;
|
||||||
|
|
||||||
namespace osu.Desktop
|
namespace osu.Desktop
|
||||||
{
|
{
|
||||||
@ -31,6 +36,11 @@ namespace osu.Desktop
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Ruleset.Register(new OsuRuleset());
|
||||||
|
Ruleset.Register(new TaikoRuleset());
|
||||||
|
Ruleset.Register(new ManiaRuleset());
|
||||||
|
Ruleset.Register(new CatchRuleset());
|
||||||
|
|
||||||
BaseGame osu = new OsuGame(args);
|
BaseGame osu = new OsuGame(args);
|
||||||
host.Add(osu);
|
host.Add(osu);
|
||||||
host.Run();
|
host.Run();
|
||||||
|
@ -134,6 +134,18 @@
|
|||||||
<Project>{c92a607b-1fdd-4954-9f92-03ff547d9080}</Project>
|
<Project>{c92a607b-1fdd-4954-9f92-03ff547d9080}</Project>
|
||||||
<Name>osu.Game.Modes.Osu</Name>
|
<Name>osu.Game.Modes.Osu</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\osu.Game.Modes.Catch\osu.Game.Modes.Catch.csproj">
|
||||||
|
<Project>{58f6c80c-1253-4a0e-a465-b8c85ebeadf3}</Project>
|
||||||
|
<Name>osu.Game.Modes.Catch</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\osu.Game.Modes.Mania\osu.Game.Modes.Mania.csproj">
|
||||||
|
<Project>{48f4582b-7687-4621-9cbe-5c24197cb536}</Project>
|
||||||
|
<Name>osu.Game.Modes.Mania</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\osu.Game.Modes.Taiko\osu.Game.Modes.Taiko.csproj">
|
||||||
|
<Project>{f167e17a-7de6-4af5-b920-a5112296c695}</Project>
|
||||||
|
<Name>osu.Game.Modes.Taiko</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\osu.Game\osu.Game.csproj">
|
<ProjectReference Include="..\osu.Game\osu.Game.csproj">
|
||||||
<Project>{0d3fbf8a-7464-4cf7-8c90-3e7886df2d4d}</Project>
|
<Project>{0d3fbf8a-7464-4cf7-8c90-3e7886df2d4d}</Project>
|
||||||
<Name>osu.Game</Name>
|
<Name>osu.Game</Name>
|
||||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Modes.Osu.Objects
|
|||||||
public Vector2 Position { get; set; }
|
public Vector2 Position { get; set; }
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
private enum HitObjectType
|
internal enum HitObjectType
|
||||||
{
|
{
|
||||||
Circle = 1,
|
Circle = 1,
|
||||||
Slider = 2,
|
Slider = 2,
|
||||||
@ -25,35 +25,5 @@ namespace osu.Game.Modes.Osu.Objects
|
|||||||
Hold = 128,
|
Hold = 128,
|
||||||
ManiaLong = 128,
|
ManiaLong = 128,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OsuBaseHit Parse(string val)
|
|
||||||
{
|
|
||||||
string[] split = val.Split(',');
|
|
||||||
var type = (HitObjectType)int.Parse(split[3]);
|
|
||||||
bool combo = type.HasFlag(HitObjectType.NewCombo);
|
|
||||||
type &= (HitObjectType)0xF;
|
|
||||||
type &= ~HitObjectType.NewCombo;
|
|
||||||
OsuBaseHit result;
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case HitObjectType.Circle:
|
|
||||||
result = new Circle();
|
|
||||||
break;
|
|
||||||
case HitObjectType.Slider:
|
|
||||||
result = new Slider();
|
|
||||||
break;
|
|
||||||
case HitObjectType.Spinner:
|
|
||||||
result = new Spinner();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new InvalidOperationException($@"Unknown hit object type {type}");
|
|
||||||
}
|
|
||||||
result.Position = new Vector2(int.Parse(split[0]), int.Parse(split[1]));
|
|
||||||
result.StartTime = double.Parse(split[2]);
|
|
||||||
result.Sample = new HitSampleInfo { Type = (SampleType)int.Parse(split[4]) };
|
|
||||||
result.NewCombo = combo;
|
|
||||||
// TODO: "addition" field
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
45
osu.Game.Mode.Osu/Objects/OsuHitObjectParser.cs
Normal file
45
osu.Game.Mode.Osu/Objects/OsuHitObjectParser.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using osu.Game.Beatmaps.Samples;
|
||||||
|
using osu.Game.Modes.Objects;
|
||||||
|
using OpenTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Modes.Osu.Objects
|
||||||
|
{
|
||||||
|
public class OsuHitObjectParser : HitObjectParser
|
||||||
|
{
|
||||||
|
public override HitObject Parse(string text)
|
||||||
|
{
|
||||||
|
string[] split = text.Split(',');
|
||||||
|
var type = (OsuBaseHit.HitObjectType)int.Parse(split[3]);
|
||||||
|
bool combo = type.HasFlag(OsuBaseHit.HitObjectType.NewCombo);
|
||||||
|
type &= (OsuBaseHit.HitObjectType)0xF;
|
||||||
|
type &= ~OsuBaseHit.HitObjectType.NewCombo;
|
||||||
|
OsuBaseHit result;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case OsuBaseHit.HitObjectType.Circle:
|
||||||
|
result = new Circle();
|
||||||
|
break;
|
||||||
|
case OsuBaseHit.HitObjectType.Slider:
|
||||||
|
result = new Slider();
|
||||||
|
break;
|
||||||
|
case OsuBaseHit.HitObjectType.Spinner:
|
||||||
|
result = new Spinner();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//throw new InvalidOperationException($@"Unknown hit object type {type}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
result.Position = new Vector2(int.Parse(split[0]), int.Parse(split[1]));
|
||||||
|
result.StartTime = double.Parse(split[2]);
|
||||||
|
result.Sample = new HitSampleInfo { Type = (SampleType)int.Parse(split[4]) };
|
||||||
|
result.NewCombo = combo;
|
||||||
|
// TODO: "addition" field
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
|
using osu.Game.Modes.Osu.Objects;
|
||||||
using osu.Game.Modes.Osu.UI;
|
using osu.Game.Modes.Osu.UI;
|
||||||
using osu.Game.Modes.UI;
|
using osu.Game.Modes.UI;
|
||||||
|
|
||||||
@ -13,5 +14,7 @@ namespace osu.Game.Modes.Osu
|
|||||||
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();
|
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();
|
||||||
|
|
||||||
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new UI.OsuHitRenderer { Objects = objects };
|
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new UI.OsuHitRenderer { Objects = objects };
|
||||||
|
|
||||||
|
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Objects\OsuHitObjectParser.cs" />
|
||||||
<Compile Include="UI\OsuComboCounter.cs" />
|
<Compile Include="UI\OsuComboCounter.cs" />
|
||||||
<Compile Include="UI\OsuHitRenderer.cs" />
|
<Compile Include="UI\OsuHitRenderer.cs" />
|
||||||
<Compile Include="UI\OsuPlayfield.cs" />
|
<Compile Include="UI\OsuPlayfield.cs" />
|
||||||
|
@ -4,15 +4,18 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Modes.Catch.UI;
|
using osu.Game.Modes.Catch.UI;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
|
using osu.Game.Modes.Osu.Objects;
|
||||||
using osu.Game.Modes.Osu.UI;
|
using osu.Game.Modes.Osu.UI;
|
||||||
using osu.Game.Modes.UI;
|
using osu.Game.Modes.UI;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Catch
|
namespace osu.Game.Modes.Catch
|
||||||
{
|
{
|
||||||
class CatchRuleset : Ruleset
|
public class CatchRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();
|
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();
|
||||||
|
|
||||||
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new CatchHitRenderer { Objects = objects };
|
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new CatchHitRenderer { Objects = objects };
|
||||||
|
|
||||||
|
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,15 +5,18 @@ using System.Collections.Generic;
|
|||||||
using osu.Game.Modes.Mania.UI;
|
using osu.Game.Modes.Mania.UI;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
using osu.Game.Modes.Osu;
|
using osu.Game.Modes.Osu;
|
||||||
|
using osu.Game.Modes.Osu.Objects;
|
||||||
using osu.Game.Modes.Osu.UI;
|
using osu.Game.Modes.Osu.UI;
|
||||||
using osu.Game.Modes.UI;
|
using osu.Game.Modes.UI;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Mania
|
namespace osu.Game.Modes.Mania
|
||||||
{
|
{
|
||||||
class ManiaRuleset : Ruleset
|
public class ManiaRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();
|
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();
|
||||||
|
|
||||||
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new ManiaHitRenderer { Objects = objects };
|
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new ManiaHitRenderer { Objects = objects };
|
||||||
|
|
||||||
|
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,19 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
|
using osu.Game.Modes.Osu.Objects;
|
||||||
using osu.Game.Modes.Osu.UI;
|
using osu.Game.Modes.Osu.UI;
|
||||||
using osu.Game.Modes.Taiko.UI;
|
using osu.Game.Modes.Taiko.UI;
|
||||||
using osu.Game.Modes.UI;
|
using osu.Game.Modes.UI;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Taiko
|
namespace osu.Game.Modes.Taiko
|
||||||
{
|
{
|
||||||
class TaikoRuleset : Ruleset
|
public class TaikoRuleset : Ruleset
|
||||||
{
|
{
|
||||||
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();
|
public override ScoreOverlay CreateScoreOverlay() => new OsuScoreOverlay();
|
||||||
|
|
||||||
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new TaikoHitRenderer { Objects = objects };
|
public override HitRenderer CreateHitRendererWith(List<HitObject> objects) => new TaikoHitRenderer { Objects = objects };
|
||||||
|
|
||||||
|
public override HitObjectParser CreateHitObjectParser() => new OsuHitObjectParser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Beatmaps.Formats;
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osu.Game.Beatmaps.Samples;
|
using osu.Game.Beatmaps.Samples;
|
||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
|
using osu.Game.Modes.Osu;
|
||||||
using osu.Game.Modes.Osu.Objects;
|
using osu.Game.Modes.Osu.Objects;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
@ -20,6 +21,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
OsuLegacyDecoder.Register();
|
OsuLegacyDecoder.Register();
|
||||||
|
Ruleset.Register(new OsuRuleset());
|
||||||
}
|
}
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDecodeMetadata()
|
public void TestDecodeMetadata()
|
||||||
|
@ -9,6 +9,10 @@ using osu.Framework.Platform;
|
|||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.IPC;
|
using osu.Game.IPC;
|
||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
|
using osu.Game.Modes.Catch;
|
||||||
|
using osu.Game.Modes.Mania;
|
||||||
|
using osu.Game.Modes.Osu;
|
||||||
|
using osu.Game.Modes.Taiko;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Beatmaps.IO
|
namespace osu.Game.Tests.Beatmaps.IO
|
||||||
@ -21,6 +25,10 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
[OneTimeSetUp]
|
[OneTimeSetUp]
|
||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
|
Ruleset.Register(new OsuRuleset());
|
||||||
|
Ruleset.Register(new TaikoRuleset());
|
||||||
|
Ruleset.Register(new ManiaRuleset());
|
||||||
|
Ruleset.Register(new CatchRuleset());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Game.Beatmaps.IO;
|
using osu.Game.Beatmaps.IO;
|
||||||
|
using osu.Game.Modes;
|
||||||
|
using osu.Game.Modes.Osu;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Beatmaps.IO
|
namespace osu.Game.Tests.Beatmaps.IO
|
||||||
@ -13,8 +15,9 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
public void SetUp()
|
public void SetUp()
|
||||||
{
|
{
|
||||||
OszArchiveReader.Register();
|
OszArchiveReader.Register();
|
||||||
|
Ruleset.Register(new OsuRuleset());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestReadBeatmaps()
|
public void TestReadBeatmaps()
|
||||||
{
|
{
|
||||||
|
@ -70,6 +70,18 @@
|
|||||||
<Project>{c92a607b-1fdd-4954-9f92-03ff547d9080}</Project>
|
<Project>{c92a607b-1fdd-4954-9f92-03ff547d9080}</Project>
|
||||||
<Name>osu.Game.Modes.Osu</Name>
|
<Name>osu.Game.Modes.Osu</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\osu.Game.Modes.Catch\osu.Game.Modes.Catch.csproj">
|
||||||
|
<Project>{58f6c80c-1253-4a0e-a465-b8c85ebeadf3}</Project>
|
||||||
|
<Name>osu.Game.Modes.Catch</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\osu.Game.Modes.Mania\osu.Game.Modes.Mania.csproj">
|
||||||
|
<Project>{48f4582b-7687-4621-9cbe-5c24197cb536}</Project>
|
||||||
|
<Name>osu.Game.Modes.Mania</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\osu.Game.Modes.Taiko\osu.Game.Modes.Taiko.csproj">
|
||||||
|
<Project>{f167e17a-7de6-4af5-b920-a5112296c695}</Project>
|
||||||
|
<Name>osu.Game.Modes.Taiko</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\osu.Game\osu.Game.csproj">
|
<ProjectReference Include="..\osu.Game\osu.Game.csproj">
|
||||||
<Project>{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}</Project>
|
<Project>{0D3FBF8A-7464-4CF7-8C90-3E7886DF2D4D}</Project>
|
||||||
<Name>osu.Game</Name>
|
<Name>osu.Game</Name>
|
||||||
|
@ -48,6 +48,8 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
new Color4(121,9,13, 255),
|
new Color4(121,9,13, 255),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (colours.Count == 0) return;
|
||||||
|
|
||||||
int i = -1;
|
int i = -1;
|
||||||
|
|
||||||
foreach (HitObject h in b.HitObjects)
|
foreach (HitObject h in b.HitObjects)
|
||||||
|
@ -221,7 +221,9 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
BaseDifficulty = new BaseDifficulty(),
|
BaseDifficulty = new BaseDifficulty(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HitObjectParser parser = null;
|
||||||
|
|
||||||
var section = Section.None;
|
var section = Section.None;
|
||||||
string line;
|
string line;
|
||||||
while (true)
|
while (true)
|
||||||
@ -233,14 +235,14 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
continue;
|
continue;
|
||||||
if (line.StartsWith(@"osu file format v"))
|
if (line.StartsWith(@"osu file format v"))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (line.StartsWith(@"[") && line.EndsWith(@"]"))
|
if (line.StartsWith(@"[") && line.EndsWith(@"]"))
|
||||||
{
|
{
|
||||||
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
|
if (!Enum.TryParse(line.Substring(1, line.Length - 2), out section))
|
||||||
throw new InvalidDataException($@"Unknown osu section {line}");
|
throw new InvalidDataException($@"Unknown osu section {line}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string val = line, key = null;
|
string val = line, key = null;
|
||||||
if (section != Section.Events && section != Section.TimingPoints && section != Section.HitObjects)
|
if (section != Section.Events && section != Section.TimingPoints && section != Section.HitObjects)
|
||||||
{
|
{
|
||||||
@ -251,6 +253,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
case Section.General:
|
case Section.General:
|
||||||
handleGeneral(beatmap, key, val);
|
handleGeneral(beatmap, key, val);
|
||||||
|
parser = Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).CreateHitObjectParser();
|
||||||
break;
|
break;
|
||||||
case Section.Editor:
|
case Section.Editor:
|
||||||
handleEditor(beatmap, key, val);
|
handleEditor(beatmap, key, val);
|
||||||
@ -271,13 +274,13 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
handleColours(beatmap, key, val);
|
handleColours(beatmap, key, val);
|
||||||
break;
|
break;
|
||||||
case Section.HitObjects:
|
case Section.HitObjects:
|
||||||
var h = HitObject.Parse(beatmap.BeatmapInfo.Mode, val);
|
var obj = parser?.Parse(val);
|
||||||
if (h != null)
|
if (obj != null)
|
||||||
beatmap.HitObjects.Add(h);
|
beatmap.HitObjects.Add(obj);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return beatmap;
|
return beatmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,17 +21,5 @@ namespace osu.Game.Modes.Objects
|
|||||||
public double Duration => EndTime - StartTime;
|
public double Duration => EndTime - StartTime;
|
||||||
|
|
||||||
public HitSampleInfo Sample;
|
public HitSampleInfo Sample;
|
||||||
|
|
||||||
public static HitObject Parse(PlayMode mode, string val)
|
|
||||||
{
|
|
||||||
//TODO: move to modular HitObjectParser system rather than static parsing. (https://github.com/ppy/osu/pull/60/files#r83135780)
|
|
||||||
switch (mode)
|
|
||||||
{
|
|
||||||
case PlayMode.Osu:
|
|
||||||
return null; //return OsuBaseHit.Parse(val);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
osu.Game/Modes/Objects/HitObjectParser.cs
Normal file
16
osu.Game/Modes/Objects/HitObjectParser.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
//Copyright (c) 2007-2016 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 System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace osu.Game.Modes.Objects
|
||||||
|
{
|
||||||
|
public abstract class HitObjectParser
|
||||||
|
{
|
||||||
|
public abstract HitObject Parse(string text);
|
||||||
|
}
|
||||||
|
}
|
@ -13,17 +13,19 @@ namespace osu.Game.Modes
|
|||||||
{
|
{
|
||||||
public abstract class Ruleset
|
public abstract class Ruleset
|
||||||
{
|
{
|
||||||
|
private static List<Type> availableRulesets = new List<Type>();
|
||||||
|
|
||||||
public abstract ScoreOverlay CreateScoreOverlay();
|
public abstract ScoreOverlay CreateScoreOverlay();
|
||||||
|
|
||||||
public abstract HitRenderer CreateHitRendererWith(List<HitObject> objects);
|
public abstract HitRenderer CreateHitRendererWith(List<HitObject> objects);
|
||||||
|
|
||||||
|
public abstract HitObjectParser CreateHitObjectParser();
|
||||||
|
|
||||||
|
public static void Register(Ruleset ruleset) => availableRulesets.Add(ruleset.GetType());
|
||||||
|
|
||||||
public static Ruleset GetRuleset(PlayMode mode)
|
public static Ruleset GetRuleset(PlayMode mode)
|
||||||
{
|
{
|
||||||
Type type = AppDomain.CurrentDomain
|
Type type = availableRulesets.FirstOrDefault(t => t.Name == $@"{mode}Ruleset");
|
||||||
.GetAssemblies()
|
|
||||||
.Where(a => a.FullName.Contains($@"osu.Game.Modes.{mode}"))
|
|
||||||
.SelectMany(a => a.GetTypes())
|
|
||||||
.FirstOrDefault(t => t.Name == $@"{mode}Ruleset");
|
|
||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -63,6 +63,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Modes\Objects\HitObjectParser.cs" />
|
||||||
<Compile Include="Overlays\DragBar.cs" />
|
<Compile Include="Overlays\DragBar.cs" />
|
||||||
<Compile Include="Overlays\MusicController.cs" />
|
<Compile Include="Overlays\MusicController.cs" />
|
||||||
<Compile Include="Beatmaps\Beatmap.cs" />
|
<Compile Include="Beatmaps\Beatmap.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user