mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 12:37:45 +08:00
Add static RulesetStore
to LegacyBeatmapDecoder
This commit is contained in:
parent
0138f22c8d
commit
13086541f0
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
@ -37,6 +38,15 @@ namespace osu.Game.Beatmaps.Formats
|
||||
LegacyStoryboardDecoder.Register();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register dependencies for use with static decoder classes.
|
||||
/// </summary>
|
||||
/// <param name="rulesets">A store containing all available rulesets (used by <see cref="LegacyBeatmapDecoder"/>).</param>
|
||||
public static void RegisterDependencies(RulesetStore rulesets)
|
||||
{
|
||||
LegacyBeatmapDecoder.RulesetStore = rulesets;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a <see cref="Decoder"/> to parse a <see cref="Beatmap"/>.
|
||||
/// </summary>
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions;
|
||||
@ -11,12 +12,15 @@ using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects.Legacy;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
public class LegacyBeatmapDecoder : LegacyDecoder<Beatmap>
|
||||
{
|
||||
protected internal static RulesetStore RulesetStore;
|
||||
|
||||
private Beatmap beatmap;
|
||||
|
||||
private ConvertHitObjectParser parser;
|
||||
@ -40,6 +44,9 @@ namespace osu.Game.Beatmaps.Formats
|
||||
public LegacyBeatmapDecoder(int version = LATEST_VERSION)
|
||||
: base(version)
|
||||
{
|
||||
if (RulesetStore == null)
|
||||
throw new InvalidOperationException($"Call {nameof(Decoder)}.{nameof(RegisterDependencies)} before using {nameof(LegacyBeatmapDecoder)}.");
|
||||
|
||||
// BeatmapVersion 4 and lower had an incorrect offset (stable has this set as 24ms off)
|
||||
offset = FormatVersion < 5 ? 24 : 0;
|
||||
}
|
||||
@ -158,7 +165,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
case @"Mode":
|
||||
int rulesetID = Parsing.ParseInt(pair.Value);
|
||||
|
||||
beatmap.BeatmapInfo.RulesetID = rulesetID;
|
||||
beatmap.BeatmapInfo.Ruleset = RulesetStore.GetRuleset(rulesetID) ?? throw new ArgumentException("Ruleset is not available locally.");
|
||||
|
||||
switch (rulesetID)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user