1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Repurpose Flat{File -> }WorkingBeatmap

This commit is contained in:
Bartłomiej Dach 2023-08-12 00:49:39 +02:00
parent 896cbb0ba0
commit 37361cd683
No known key found for this signature in database
2 changed files with 11 additions and 10 deletions

View File

@ -75,7 +75,7 @@ namespace osu.Desktop.LegacyIpc
case LegacyIpcDifficultyCalculationRequest req: case LegacyIpcDifficultyCalculationRequest req:
try try
{ {
WorkingBeatmap beatmap = new FlatFileWorkingBeatmap(req.BeatmapFile); WorkingBeatmap beatmap = new FlatWorkingBeatmap(req.BeatmapFile);
var ruleset = beatmap.BeatmapInfo.Ruleset.CreateInstance(); var ruleset = beatmap.BeatmapInfo.Ruleset.CreateInstance();
Mod[] mods = ruleset.ConvertFromLegacyMods((LegacyMods)req.Mods).ToArray(); Mod[] mods = ruleset.ConvertFromLegacyMods((LegacyMods)req.Mods).ToArray();

View File

@ -12,25 +12,26 @@ using osu.Game.Skinning;
namespace osu.Game.Beatmaps namespace osu.Game.Beatmaps
{ {
/// <summary> /// <summary>
/// A <see cref="WorkingBeatmap"/> which can be constructed directly from a .osu file, providing an implementation for /// A <see cref="WorkingBeatmap"/> which can be constructed directly from an .osu file (via <see cref="FlatWorkingBeatmap(string, int?)"/>)
/// or an <see cref="IBeatmap"/> instance (via <see cref="FlatWorkingBeatmap(IBeatmap)"/>,
/// providing an implementation for
/// <see cref="WorkingBeatmap.GetPlayableBeatmap(osu.Game.Rulesets.IRulesetInfo,System.Collections.Generic.IReadOnlyList{osu.Game.Rulesets.Mods.Mod})"/>. /// <see cref="WorkingBeatmap.GetPlayableBeatmap(osu.Game.Rulesets.IRulesetInfo,System.Collections.Generic.IReadOnlyList{osu.Game.Rulesets.Mods.Mod})"/>.
/// </summary> /// </summary>
public class FlatFileWorkingBeatmap : WorkingBeatmap public class FlatWorkingBeatmap : WorkingBeatmap
{ {
private readonly Beatmap beatmap; private readonly IBeatmap beatmap;
public FlatFileWorkingBeatmap(string file, int? beatmapId = null) public FlatWorkingBeatmap(string file, int? beatmapId = null)
: this(readFromFile(file), beatmapId) : this(readFromFile(file))
{ {
if (beatmapId.HasValue)
beatmap.BeatmapInfo.OnlineID = beatmapId.Value;
} }
private FlatFileWorkingBeatmap(Beatmap beatmap, int? beatmapId = null) public FlatWorkingBeatmap(IBeatmap beatmap)
: base(beatmap.BeatmapInfo, null) : base(beatmap.BeatmapInfo, null)
{ {
this.beatmap = beatmap; this.beatmap = beatmap;
if (beatmapId.HasValue)
beatmap.BeatmapInfo.OnlineID = beatmapId.Value;
} }
private static Beatmap readFromFile(string filename) private static Beatmap readFromFile(string filename)