Merge remote-tracking branch 'upstream/master' into general-fixes

# Conflicts:
#	osu.Game/Modes/UI/HitRenderer.cs
This commit is contained in:
Dean Herbert
2017-03-14 16:15:26 +09:00
34 changed files with 182 additions and 111 deletions

View File

@ -0,0 +1,23 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Modes.Objects;
using osu.Game.Modes.UI;
namespace osu.Game.Modes.Mods
{
/// <summary>
/// An interface for mods that are applied to a HitRenderer.
/// </summary>
/// <typeparam name="TObject">The type of HitObject the HitRenderer contains.</typeparam>
public interface IApplicableMod<TObject>
where TObject : HitObject
{
/// <summary>
/// Applies the mod to a HitRenderer.
/// </summary>
/// <param name="hitRenderer">The HitRenderer to apply the mod to.</param>
void Apply(HitRenderer<TObject> hitRenderer);
}
}

View File

@ -1,11 +1,13 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Screens.Play;
using osu.Game.Modes.Objects;
using osu.Game.Modes.UI;
using System;
namespace osu.Game.Modes
namespace osu.Game.Modes.Mods
{
/// <summary>
/// The base class for gameplay modifiers.
@ -41,12 +43,6 @@ namespace osu.Game.Modes
/// The mods this mod cannot be enabled with.
/// </summary>
public virtual Type[] IncompatibleMods => new Type[] { };
/// <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
@ -151,11 +147,16 @@ namespace osu.Game.Modes
public override string Description => "Watch a perfect automated play through the song";
public override double ScoreMultiplier => 0;
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) };
}
public override void PlayerLoading(Player player)
public abstract class ModAutoplay<T> : ModAutoplay, IApplicableMod<T>
where T : HitObject
{
protected abstract Score CreateReplayScore(Beatmap<T> beatmap);
public void Apply(HitRenderer<T> hitRenderer)
{
base.PlayerLoading(player);
player.ReplayInputHandler = Ruleset.GetRuleset(player.Beatmap.PlayMode).CreateAutoplayScore(player.Beatmap.Beatmap)?.Replay?.GetInputHandler();
hitRenderer.InputManager.ReplayInputHandler = CreateReplayScore(hitRenderer.Beatmap)?.Replay?.GetInputHandler();
}
}
@ -170,11 +171,4 @@ namespace osu.Game.Modes
public override string Name => "Cinema";
public override FontAwesome Icon => FontAwesome.fa_osu_mod_cinema;
}
public enum ModType
{
DifficultyReduction,
DifficultyIncrease,
Special,
}
}

View File

@ -0,0 +1,12 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Modes.Mods
{
public enum ModType
{
DifficultyReduction,
DifficultyIncrease,
Special,
}
}

View File

@ -3,6 +3,7 @@
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects;
using osu.Game.Modes.UI;
using osu.Game.Screens.Play;
@ -31,7 +32,7 @@ namespace osu.Game.Modes
public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0);
public abstract HitRenderer CreateHitRendererWith(Beatmap beatmap);
public abstract HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap);
public abstract HitObjectParser CreateHitObjectParser();
@ -47,8 +48,6 @@ namespace osu.Game.Modes
public abstract IEnumerable<KeyCounter> CreateGameplayKeys();
public virtual Score CreateAutoplayScore(Beatmap beatmap) => null;
public static Ruleset GetRuleset(PlayMode mode)
{
Type type;

View File

@ -1,11 +1,11 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Modes.Mods;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Screens.Play;
@ -22,10 +22,13 @@ namespace osu.Game.Modes.UI
internal readonly PlayerInputManager InputManager = new PlayerInputManager();
/// <summary>
/// A function to convert coordinates from gamefield to screen space.
/// </summary>
public abstract Func<Vector2, Vector2> MapPlayfieldToScreenSpace { get; }
protected readonly KeyConversionInputManager KeyConversionInputManager;
protected HitRenderer()
{
KeyConversionInputManager = CreateKeyConversionInputManager();
KeyConversionInputManager.RelativeSizeAxes = Axes.Both;
}
/// <summary>
/// Whether all the HitObjects have been judged.
@ -39,51 +42,48 @@ namespace osu.Game.Modes.UI
if (AllObjectsJudged)
OnAllJudged?.Invoke();
}
protected virtual KeyConversionInputManager CreateKeyConversionInputManager() => new KeyConversionInputManager();
}
public abstract class HitRenderer<TObject> : HitRenderer
where TObject : HitObject
{
internal readonly KeyConversionInputManager KeyConversionInputManager;
public override Func<Vector2, Vector2> MapPlayfieldToScreenSpace => Playfield.ScaledContent.ToScreenSpace;
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
public Beatmap<TObject> Beatmap;
protected override Container<Drawable> Content => content;
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
protected Playfield<TObject> Playfield;
protected Beatmap<TObject> Beatmap;
private Container content;
protected HitRenderer(Beatmap beatmap)
protected HitRenderer(WorkingBeatmap beatmap)
{
Beatmap = CreateBeatmapConverter().Convert(beatmap);
Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap);
applyMods(beatmap.Mods.Value);
RelativeSizeAxes = Axes.Both;
KeyConversionInputManager = CreateKeyConversionInputManager();
KeyConversionInputManager.RelativeSizeAxes = Axes.Both;
KeyConversionInputManager.Add(Playfield = CreatePlayfield());
InputManager.Add(content = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new[]
{
KeyConversionInputManager
}
Children = new[] { KeyConversionInputManager }
});
AddInternal(InputManager);
}
[BackgroundDependencyLoader]
private void load()
{
loadObjects();
if (InputManager?.ReplayInputHandler != null)
InputManager.ReplayInputHandler.ToScreenSpace = Playfield.ScaledContent.ToScreenSpace;
}
private void loadObjects()
@ -103,11 +103,19 @@ namespace osu.Game.Modes.UI
Playfield.PostProcess();
}
private void applyMods(IEnumerable<Mod> mods)
{
if (mods == null)
return;
foreach (var mod in mods.OfType<IApplicableMod<TObject>>())
mod.Apply(this);
}
private void onJudgement(DrawableHitObject<TObject> o, JudgementInfo j) => TriggerOnJudgement(j);
protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
protected abstract Playfield<TObject> CreatePlayfield();
protected abstract IBeatmapConverter<TObject> CreateBeatmapConverter();
protected virtual KeyConversionInputManager CreateKeyConversionInputManager() => new KeyConversionInputManager();
}
}