1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

Add bindable mods and autoplay support.

This commit is contained in:
Dean Herbert 2017-03-06 14:52:37 +09:00
parent 1ea21daa91
commit 76ef8c1a6c
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
5 changed files with 32 additions and 9 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.IO;
using osu.Framework.Audio.Track;
using osu.Framework.Configuration;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps.Formats;
using osu.Game.Beatmaps.IO;
@ -26,6 +27,8 @@ namespace osu.Game.Beatmaps
public PlayMode PlayMode => beatmap?.BeatmapInfo?.Mode > PlayMode.Osu ? beatmap.BeatmapInfo.Mode : PreferredPlayMode ?? PlayMode.Osu;
public readonly Bindable<Mod[]> Mods = new Bindable<Mod[]>();
public readonly bool WithStoryboard;
protected abstract ArchiveReader GetReader();

View File

@ -4,6 +4,8 @@
using System;
using System.ComponentModel;
using osu.Game.Graphics;
using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
namespace osu.Game.Modes
{
@ -41,6 +43,12 @@ namespace osu.Game.Modes
/// The mods this mod cannot be enabled with.
/// </summary>
public abstract Mods[] DisablesMods { get; }
/// <summary>
/// Direct access to the Player before load has run.
/// </summary>
/// <param name="player"></param>
public virtual void PlayerLoading(Player player) { }
}
public class MultiMod : Mod
@ -150,6 +158,12 @@ namespace osu.Game.Modes
public override double ScoreMultiplier => 0;
public override bool Ranked => false;
public override Mods[] DisablesMods => new Mods[] { Mods.Relax, Mods.Autopilot, Mods.SpunOut, Mods.SuddenDeath, Mods.Perfect };
public override void PlayerLoading(Player player)
{
base.PlayerLoading(player);
player.ReplayInputHandler = Ruleset.GetRuleset(player.Beatmap.PlayMode).CreateAutoplayScore(player.Beatmap.Beatmap)?.Replay?.GetInputHandler();
}
}
public abstract class ModPerfect : ModSuddenDeath

View File

@ -17,6 +17,7 @@ using osu.Game.Configuration;
using osu.Framework.Configuration;
using System;
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using OpenTK.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transforms;
@ -66,6 +67,17 @@ namespace osu.Game.Screens.Play
[BackgroundDependencyLoader]
private void load(AudioManager audio, BeatmapDatabase beatmaps, OsuGameBase game, OsuConfigManager config)
{
var beatmap = Beatmap.Beatmap;
if (beatmap.BeatmapInfo?.Mode > PlayMode.Osu)
{
//we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor.
Exit();
return;
}
Beatmap.Mods.Value.ForEach(m => m.PlayerLoading(this));
dimLevel = config.GetBindable<int>(OsuConfig.DimLevel);
mouseWheelDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableWheel);
@ -102,15 +114,6 @@ namespace osu.Game.Screens.Play
sourceClock.Reset();
});
var beatmap = Beatmap.Beatmap;
if (beatmap.BeatmapInfo?.Mode > PlayMode.Osu)
{
//we only support osu! mode for now because the hitobject parsing is crappy and needs a refactor.
Exit();
return;
}
ruleset = Ruleset.GetRuleset(Beatmap.PlayMode);
scoreOverlay = ruleset.CreateScoreOverlay();

View File

@ -8,6 +8,7 @@ using osu.Game.Configuration;
using System.Linq;
using osu.Framework.Input.Handlers;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Input.Handlers;
using OpenTK.Input;
using KeyboardState = osu.Framework.Input.KeyboardState;

View File

@ -337,6 +337,8 @@ namespace osu.Game.Screens.Select
{
base.OnBeatmapChanged(beatmap);
beatmap.Mods.BindTo(modSelect.SelectedMods);
//todo: change background in selectionChanged instead; support per-difficulty backgrounds.
changeBackground(beatmap);
carousel.SelectBeatmap(beatmap?.BeatmapInfo);