Dummy beatmap has dummy ruleset

This commit is contained in:
Dean Herbert 2017-07-19 09:59:47 +09:00
parent f168ee660c
commit 632d2e8ba5
3 changed files with 34 additions and 3 deletions
osu.Game

View File

@ -5,7 +5,12 @@ using System.Collections.Generic;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Textures;
using osu.Game.Database;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
namespace osu.Game.Beatmaps
{
@ -24,6 +29,7 @@ namespace osu.Game.Beatmaps
},
BeatmapSet = new BeatmapSetInfo(),
Difficulty = new BeatmapDifficulty(),
Ruleset = new DummyRulesetInfo()
})
{
this.game = game;
@ -37,5 +43,31 @@ namespace osu.Game.Beatmaps
protected override Texture GetBackground() => game.Textures.Get(@"Backgrounds/bg4");
protected override Track GetTrack() => new TrackVirtual();
private class DummyRulesetInfo : RulesetInfo
{
public override Ruleset CreateInstance() => new DummyRuleset();
private class DummyRuleset : Ruleset
{
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset)
{
throw new System.NotImplementedException();
}
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => null;
public override ScoreProcessor CreateScoreProcessor()
{
throw new System.NotImplementedException();
}
public override string Description => "dummy";
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new List<KeyCounter>();
}
}
}
}

View File

@ -21,6 +21,6 @@ namespace osu.Game.Database
[Indexed]
public bool Available { get; set; }
public Ruleset CreateInstance() => (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo));
public virtual Ruleset CreateInstance() => (Ruleset)Activator.CreateInstance(Type.GetType(InstantiationInfo));
}
}

View File

@ -120,8 +120,7 @@ namespace osu.Game.Screens.Select
}));
//get statistics from the current ruleset.
if (beatmapInfo.Ruleset != null)
labels.AddRange(beatmapInfo.Ruleset.CreateInstance().GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
labels.AddRange(beatmapInfo.Ruleset.CreateInstance().GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
}
PixelSnapping = true;