mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 04:23:14 +08:00
Provide Autoplay mod in Ruleset.
This commit is contained in:
parent
44fd0eb78b
commit
eb9972581e
@ -83,6 +83,8 @@ namespace osu.Game.Rulesets.Catch
|
||||
}
|
||||
}
|
||||
|
||||
public override Mod GetAutoplayMod() => new ModAutoplay();
|
||||
|
||||
public override string Description => "osu!catch";
|
||||
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_fruits_o;
|
||||
|
@ -104,6 +104,8 @@ namespace osu.Game.Rulesets.Mania
|
||||
}
|
||||
}
|
||||
|
||||
public override Mod GetAutoplayMod() => new ModAutoplay();
|
||||
|
||||
public override string Description => "osu!mania";
|
||||
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mania_o;
|
||||
|
@ -104,6 +104,8 @@ namespace osu.Game.Rulesets.Osu
|
||||
}
|
||||
}
|
||||
|
||||
public override Mod GetAutoplayMod() => new OsuModAutoplay();
|
||||
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_osu_o;
|
||||
|
||||
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new OsuDifficultyCalculator(beatmap);
|
||||
|
@ -83,6 +83,8 @@ namespace osu.Game.Rulesets.Taiko
|
||||
}
|
||||
}
|
||||
|
||||
public override Mod GetAutoplayMod() => new TaikoModAutoplay();
|
||||
|
||||
public override string Description => "osu!taiko";
|
||||
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_taiko_o;
|
||||
|
@ -60,6 +60,8 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { };
|
||||
|
||||
public override Mod GetAutoplayMod() => new ModAutoplay();
|
||||
|
||||
public override HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap, bool isForCurrentRuleset)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
@ -18,6 +18,8 @@ namespace osu.Game.Rulesets
|
||||
|
||||
public abstract IEnumerable<Mod> GetModsFor(ModType type);
|
||||
|
||||
public abstract Mod GetAutoplayMod();
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to create a hit renderer for a beatmap
|
||||
/// </summary>
|
||||
|
@ -114,32 +114,18 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
originalMods = modSelect.SelectedMods.Value;
|
||||
if (state?.Keyboard.ControlPressed == true)
|
||||
if (findAutoMod(originalMods) == null)
|
||||
{
|
||||
var auto = findAutoMod(Ruleset.Value.CreateInstance().GetModsFor(ModType.Special));
|
||||
if (auto != null)
|
||||
modSelect.SelectedMods.Value = originalMods.Concat(new[] { auto });
|
||||
}
|
||||
{
|
||||
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
|
||||
var autoType = auto.GetType();
|
||||
|
||||
if (originalMods.All(m => m.GetType() != autoType))
|
||||
modSelect.SelectedMods.Value = originalMods.Concat(new[] { auto });
|
||||
}
|
||||
|
||||
Beatmap.Value.Track.Looping = false;
|
||||
Beatmap.Disabled = true;
|
||||
|
||||
LoadComponentAsync(player = new PlayerLoader(new Player()), l => Push(player));
|
||||
}
|
||||
|
||||
private Mod findAutoMod(IEnumerable<Mod> mods)
|
||||
{
|
||||
foreach (var mod in mods)
|
||||
{
|
||||
if (mod is ModAutoplay) return mod;
|
||||
var multimod = mod as MultiMod;
|
||||
if (multimod != null)
|
||||
{
|
||||
var find = findAutoMod(multimod.Mods);
|
||||
if (find != null) return find;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user