Remove all generic judgements.

This commit is contained in:
smoogipooo
2017-09-06 18:05:51 +09:00
parent e85d511645
commit 0cc443e618
30 changed files with 137 additions and 208 deletions

View File

@ -16,9 +16,7 @@ namespace osu.Game.Rulesets.Judgements
/// <summary>
/// A drawable object which visualises the hit result of a <see cref="Judgements.Judgement"/>.
/// </summary>
/// <typeparam name="TJudgement">The type of judgement to visualise.</typeparam>
public class DrawableJudgement<TJudgement> : Container
where TJudgement : Judgement
public class DrawableJudgement : Container
{
protected readonly Judgement Judgement;

View File

@ -32,24 +32,12 @@ namespace osu.Game.Rulesets.Objects.Drawables
public abstract class DrawableHitObject<TObject> : DrawableHitObject
where TObject : HitObject
{
public new readonly TObject HitObject;
protected DrawableHitObject(TObject hitObject)
: base(hitObject)
{
HitObject = hitObject;
}
}
public abstract class DrawableHitObject<TObject, TJudgement> : DrawableHitObject<TObject>
where TObject : HitObject
where TJudgement : Judgement
{
public event Action<DrawableHitObject, Judgement> OnJudgement;
public override bool HandleInput => Interactive;
public new readonly TObject HitObject;
public override bool HandleInput => Interactive;
public bool Interactive = true;
/// <summary>
@ -65,6 +53,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
protected DrawableHitObject(TObject hitObject)
: base(hitObject)
{
HitObject = hitObject;
}
private ArmedState state;
@ -202,13 +191,13 @@ namespace osu.Game.Rulesets.Objects.Drawables
}
}
private List<DrawableHitObject<TObject, TJudgement>> nestedHitObjects;
protected IEnumerable<DrawableHitObject<TObject, TJudgement>> NestedHitObjects => nestedHitObjects;
private List<DrawableHitObject<TObject>> nestedHitObjects;
protected IEnumerable<DrawableHitObject<TObject>> NestedHitObjects => nestedHitObjects;
protected virtual void AddNested(DrawableHitObject<TObject, TJudgement> h)
protected virtual void AddNested(DrawableHitObject<TObject> h)
{
if (nestedHitObjects == null)
nestedHitObjects = new List<DrawableHitObject<TObject, TJudgement>>();
nestedHitObjects = new List<DrawableHitObject<TObject>>();
h.OnJudgement += (d, j) => OnJudgement?.Invoke(d, j);
nestedHitObjects.Add(h);

View File

@ -3,19 +3,17 @@
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Objects.Drawables
{
/// <summary>
/// A basic class that overrides <see cref="DrawableHitObject{TObject, TJudgement}"/> and implements <see cref="IScrollingHitObject"/>.
/// A basic class that overrides <see cref="DrawableHitObject{TObject}"/> and implements <see cref="IScrollingHitObject"/>.
/// This object does not need to have its <see cref="Drawable.RelativePositionAxes"/> set to be able to scroll, as this will
/// will be set by the scrolling container that contains it.
/// </summary>
public abstract class DrawableScrollingHitObject<TObject, TJudgement> : DrawableHitObject<TObject, TJudgement>, IScrollingHitObject
public abstract class DrawableScrollingHitObject<TObject> : DrawableHitObject<TObject>, IScrollingHitObject
where TObject : HitObject
where TJudgement : Judgement
{
public BindableDouble LifetimeOffset { get; } = new BindableDouble();
@ -57,7 +55,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
set { lifetimeEnd = value; }
}
protected override void AddNested(DrawableHitObject<TObject, TJudgement> h)
protected override void AddNested(DrawableHitObject<TObject> h)
{
var scrollingHitObject = h as IScrollingHitObject;
scrollingHitObject?.LifetimeOffset.BindTo(LifetimeOffset);

View File

@ -135,9 +135,8 @@ namespace osu.Game.Rulesets.Scoring
}
}
public abstract class ScoreProcessor<TObject, TJudgement> : ScoreProcessor
public abstract class ScoreProcessor<TObject> : ScoreProcessor
where TObject : HitObject
where TJudgement : Judgement
{
/// <summary>
/// All judgements held by this ScoreProcessor.
@ -150,7 +149,7 @@ namespace osu.Game.Rulesets.Scoring
{
}
protected ScoreProcessor(RulesetContainer<TObject, TJudgement> rulesetContainer)
protected ScoreProcessor(RulesetContainer<TObject> rulesetContainer)
{
Judgements.Capacity = rulesetContainer.Beatmap.HitObjects.Count;

View File

@ -14,9 +14,8 @@ using System.Linq;
namespace osu.Game.Rulesets.UI
{
public abstract class Playfield<TObject, TJudgement> : Container
public abstract class Playfield<TObject> : Container
where TObject : HitObject
where TJudgement : Judgement
{
/// <summary>
/// The HitObjects contained in this Playfield.
@ -70,7 +69,7 @@ namespace osu.Game.Rulesets.UI
public override Axes RelativeSizeAxes
{
get { return Axes.Both; }
set { throw new InvalidOperationException($@"{nameof(Playfield<TObject, TJudgement>)}'s {nameof(RelativeSizeAxes)} should never be changed from {Axes.Both}"); }
set { throw new InvalidOperationException($@"{nameof(Playfield<TObject>)}'s {nameof(RelativeSizeAxes)} should never be changed from {Axes.Both}"); }
}
/// <summary>
@ -82,18 +81,19 @@ namespace osu.Game.Rulesets.UI
/// Adds a DrawableHitObject to this Playfield.
/// </summary>
/// <param name="h">The DrawableHitObject to add.</param>
public virtual void Add(DrawableHitObject<TObject, TJudgement> h) => HitObjects.Add(h);
public virtual void Add(DrawableHitObject<TObject> h) => HitObjects.Add(h);
/// <summary>
/// Remove a DrawableHitObject from this Playfield.
/// </summary>
/// <param name="h">The DrawableHitObject to remove.</param>
public virtual void Remove(DrawableHitObject<TObject, TJudgement> h) => HitObjects.Remove(h);
public virtual void Remove(DrawableHitObject<TObject> h) => HitObjects.Remove(h);
/// <summary>
/// Triggered when an object's Judgement is updated.
/// Triggered when a new <see cref="Judgement"/> occurs on a <see cref="DrawableHitObject"/>.
/// </summary>
/// <param name="judgedObject">The object that Judgement has been updated for.</param>
/// <param name="judgedObject">The object that <paramref name="judgement"/> occured for.</param>
/// <param name="judgement">The <see cref="Judgement"/> that occurred.</param>
public virtual void OnJudgement(DrawableHitObject judgedObject, Judgement judgement) { }
public class HitObjectContainer : CompositeDrawable

View File

@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.UI
/// <summary>
/// Base RulesetContainer. Doesn't hold objects.
/// <para>
/// Should not be derived - derive <see cref="RulesetContainer{TObject,TJudgement}"/> instead.
/// Should not be derived - derive <see cref="RulesetContainer{TObject}"/> instead.
/// </para>
/// </summary>
public abstract class RulesetContainer : Container
@ -35,7 +35,7 @@ namespace osu.Game.Rulesets.UI
public event Action OnAllJudged;
/// <summary>
/// Whether to apply adjustments to the child <see cref="Playfield{TObject,TJudgement}"/> based on our own size.
/// Whether to apply adjustments to the child <see cref="Playfield{TObject}"/> based on our own size.
/// </summary>
public bool AspectAdjust = true;
@ -119,13 +119,15 @@ namespace osu.Game.Rulesets.UI
/// RulesetContainer that applies conversion to Beatmaps. Does not contain a Playfield
/// and does not load drawable hit objects.
/// <para>
/// Should not be derived - derive <see cref="RulesetContainer{TObject,TJudgement}"/> instead.
/// Should not be derived - derive <see cref="RulesetContainer{TObject}"/> instead.
/// </para>
/// </summary>
/// <typeparam name="TObject">The type of HitObject contained by this RulesetContainer.</typeparam>
public abstract class RulesetContainer<TObject> : RulesetContainer
where TObject : HitObject
{
public event Action<Judgement> OnJudgement;
/// <summary>
/// The Beatmap
/// </summary>
@ -151,6 +153,20 @@ namespace osu.Game.Rulesets.UI
/// </summary>
protected readonly bool IsForCurrentRuleset;
public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor;
protected override bool AllObjectsJudged => drawableObjects.All(h => h.AllJudged);
/// <summary>
/// The playfield.
/// </summary>
public Playfield<TObject> Playfield { get; private set; }
protected override Container<Drawable> Content => content;
private Container content;
private readonly List<DrawableHitObject<TObject>> drawableObjects = new List<DrawableHitObject<TObject>>();
/// <summary>
/// Whether to assume the beatmap passed into this <see cref="RulesetContainer{TObject}"/> is for the current ruleset.
/// Creates a hit renderer for a beatmap.
@ -158,7 +174,7 @@ namespace osu.Game.Rulesets.UI
/// <param name="ruleset">The ruleset being repesented.</param>
/// <param name="workingBeatmap">The beatmap to create the hit renderer for.</param>
/// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param>
internal RulesetContainer(Ruleset ruleset, WorkingBeatmap workingBeatmap, bool isForCurrentRuleset)
protected RulesetContainer(Ruleset ruleset, WorkingBeatmap workingBeatmap, bool isForCurrentRuleset)
: base(ruleset)
{
Debug.Assert(workingBeatmap != null, "RulesetContainer initialized with a null beatmap.");
@ -194,74 +210,6 @@ namespace osu.Game.Rulesets.UI
applyMods(Mods);
}
/// <summary>
/// Applies the active mods to this RulesetContainer.
/// </summary>
/// <param name="mods"></param>
private void applyMods(IEnumerable<Mod> mods)
{
if (mods == null)
return;
foreach (var mod in mods.OfType<IApplicableMod<TObject>>())
mod.ApplyToRulesetContainer(this);
}
/// <summary>
/// Creates a processor to perform post-processing operations
/// on HitObjects in converted Beatmaps.
/// </summary>
/// <returns>The Beatmap processor.</returns>
protected virtual BeatmapProcessor<TObject> CreateBeatmapProcessor() => new BeatmapProcessor<TObject>();
/// <summary>
/// Creates a converter to convert Beatmap to a specific mode.
/// </summary>
/// <returns>The Beatmap converter.</returns>
protected abstract BeatmapConverter<TObject> CreateBeatmapConverter();
}
/// <summary>
/// A derivable RulesetContainer that manages the Playfield and HitObjects.
/// </summary>
/// <typeparam name="TObject">The type of HitObject contained by this RulesetContainer.</typeparam>
/// <typeparam name="TJudgement">The type of Judgement of DrawableHitObjects contained by this RulesetContainer.</typeparam>
public abstract class RulesetContainer<TObject, TJudgement> : RulesetContainer<TObject>
where TObject : HitObject
where TJudgement : Judgement
{
public event Action<Judgement> OnJudgement;
public sealed override bool ProvidingUserCursor => !HasReplayLoaded && Playfield.ProvidingUserCursor;
/// <summary>
/// All the converted hit objects contained by this hit renderer.
/// </summary>
public new IEnumerable<TObject> Objects => Beatmap.HitObjects;
protected override bool AllObjectsJudged => drawableObjects.All(h => h.AllJudged);
/// <summary>
/// The playfield.
/// </summary>
public Playfield<TObject, TJudgement> Playfield { get; private set; }
protected override Container<Drawable> Content => content;
private Container content;
private readonly List<DrawableHitObject<TObject, TJudgement>> drawableObjects = new List<DrawableHitObject<TObject, TJudgement>>();
/// <summary>
/// Creates a hit renderer for a beatmap.
/// </summary>
/// <param name="ruleset">The ruleset being repesented.</param>
/// <param name="beatmap">The beatmap to create the hit renderer for.</param>
/// <param name="isForCurrentRuleset">Whether to assume the beatmap is for the current ruleset.</param>
protected RulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap, bool isForCurrentRuleset)
: base(ruleset, beatmap, isForCurrentRuleset)
{
}
[BackgroundDependencyLoader]
private void load()
{
@ -276,6 +224,19 @@ namespace osu.Game.Rulesets.UI
loadObjects();
}
/// <summary>
/// Applies the active mods to this RulesetContainer.
/// </summary>
/// <param name="mods"></param>
private void applyMods(IEnumerable<Mod> mods)
{
if (mods == null)
return;
foreach (var mod in mods.OfType<IApplicableMod<TObject>>())
mod.ApplyToRulesetContainer(this);
}
public override void SetReplay(Replay replay)
{
base.SetReplay(replay);
@ -320,23 +281,36 @@ namespace osu.Game.Rulesets.UI
}
/// <summary>
/// In some cases we want to apply changes to the relative size of our contained <see cref="Playfield{TObject, TJudgement}"/> based on custom conditions.
/// Creates a processor to perform post-processing operations
/// on HitObjects in converted Beatmaps.
/// </summary>
/// <returns>The Beatmap processor.</returns>
protected virtual BeatmapProcessor<TObject> CreateBeatmapProcessor() => new BeatmapProcessor<TObject>();
/// <summary>
/// In some cases we want to apply changes to the relative size of our contained <see cref="Playfield{TObject}"/> based on custom conditions.
/// </summary>
/// <returns></returns>
protected virtual Vector2 GetPlayfieldAspectAdjust() => new Vector2(0.75f); //a sane default
/// <summary>
/// Creates a converter to convert Beatmap to a specific mode.
/// </summary>
/// <returns>The Beatmap converter.</returns>
protected abstract BeatmapConverter<TObject> CreateBeatmapConverter();
/// <summary>
/// Creates a DrawableHitObject from a HitObject.
/// </summary>
/// <param name="h">The HitObject to make drawable.</param>
/// <returns>The DrawableHitObject.</returns>
protected abstract DrawableHitObject<TObject, TJudgement> GetVisualRepresentation(TObject h);
protected abstract DrawableHitObject<TObject> GetVisualRepresentation(TObject h);
/// <summary>
/// Creates a Playfield.
/// </summary>
/// <returns>The Playfield.</returns>
protected abstract Playfield<TObject, TJudgement> CreatePlayfield();
protected abstract Playfield<TObject> CreatePlayfield();
}
/// <summary>
@ -344,11 +318,9 @@ namespace osu.Game.Rulesets.UI
/// </summary>
/// <typeparam name="TPlayfield">The type of Playfield contained by this RulesetContainer.</typeparam>
/// <typeparam name="TObject">The type of HitObject contained by this RulesetContainer.</typeparam>
/// <typeparam name="TJudgement">The type of Judgement of DrawableHitObjects contained by this RulesetContainer.</typeparam>
public abstract class RulesetContainer<TPlayfield, TObject, TJudgement> : RulesetContainer<TObject, TJudgement>
public abstract class RulesetContainer<TPlayfield, TObject> : RulesetContainer<TObject>
where TObject : HitObject
where TJudgement : Judgement
where TPlayfield : Playfield<TObject, TJudgement>
where TPlayfield : Playfield<TObject>
{
/// <summary>
/// The playfield.

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Timing;
@ -19,11 +18,10 @@ using osu.Game.Rulesets.Timing;
namespace osu.Game.Rulesets.UI
{
/// <summary>
/// A type of <see cref="Playfield{TObject, TJudgement}"/> specialized towards scrolling <see cref="DrawableHitObject"/>s.
/// A type of <see cref="Playfield{TObject}"/> specialized towards scrolling <see cref="DrawableHitObject"/>s.
/// </summary>
public class ScrollingPlayfield<TObject, TJudgement> : Playfield<TObject, TJudgement>
public class ScrollingPlayfield<TObject> : Playfield<TObject>
where TObject : HitObject
where TJudgement : Judgement
{
/// <summary>
/// The default span of time visible by the length of the scrolling axes.
@ -65,7 +63,7 @@ namespace osu.Game.Rulesets.UI
public new readonly ScrollingHitObjectContainer HitObjects;
/// <summary>
/// Creates a new <see cref="ScrollingPlayfield{TObject, TJudgement}"/>.
/// Creates a new <see cref="ScrollingPlayfield{TObject}"/>.
/// </summary>
/// <param name="scrollingAxes">The axes on which <see cref="DrawableHitObject"/>s in this container should scroll.</param>
/// <param name="customWidth">Whether we want our internal coordinate system to be scaled to a specified width</param>
@ -77,21 +75,21 @@ namespace osu.Game.Rulesets.UI
HitObjects.Reversed.BindTo(Reversed);
}
private List<ScrollingPlayfield<TObject, TJudgement>> nestedPlayfields;
private List<ScrollingPlayfield<TObject>> nestedPlayfields;
/// <summary>
/// All the <see cref="ScrollingPlayfield{TObject, TJudgement}"/>s nested inside this playfield.
/// All the <see cref="ScrollingPlayfield{TObject}"/>s nested inside this playfield.
/// </summary>
public IEnumerable<ScrollingPlayfield<TObject, TJudgement>> NestedPlayfields => nestedPlayfields;
public IEnumerable<ScrollingPlayfield<TObject>> NestedPlayfields => nestedPlayfields;
/// <summary>
/// Adds a <see cref="ScrollingPlayfield{TObject, TJudgement}"/> to this playfield. The nested <see cref="ScrollingPlayfield{TObject, TJudgement}"/>
/// Adds a <see cref="ScrollingPlayfield{TObject}"/> to this playfield. The nested <see cref="ScrollingPlayfield{TObject}"/>
/// will be given all of the same speed adjustments as this playfield.
/// </summary>
/// <param name="otherPlayfield">The <see cref="ScrollingPlayfield{TObject, TJudgement}"/> to add.</param>
protected void AddNested(ScrollingPlayfield<TObject, TJudgement> otherPlayfield)
/// <param name="otherPlayfield">The <see cref="ScrollingPlayfield{TObject}"/> to add.</param>
protected void AddNested(ScrollingPlayfield<TObject> otherPlayfield)
{
if (nestedPlayfields == null)
nestedPlayfields = new List<ScrollingPlayfield<TObject, TJudgement>>();
nestedPlayfields = new List<ScrollingPlayfield<TObject>>();
nestedPlayfields.Add(otherPlayfield);
}
@ -119,7 +117,7 @@ namespace osu.Game.Rulesets.UI
this.TransformTo(this.PopulateTransform(new TransformVisibleTimeRange(), newTimeRange, duration, easing));
}
private class TransformVisibleTimeRange : Transform<double, ScrollingPlayfield<TObject, TJudgement>>
private class TransformVisibleTimeRange : Transform<double, ScrollingPlayfield<TObject>>
{
private double valueAt(double time)
{
@ -131,8 +129,8 @@ namespace osu.Game.Rulesets.UI
public override string TargetMember => "VisibleTimeRange.Value";
protected override void Apply(ScrollingPlayfield<TObject, TJudgement> d, double time) => d.VisibleTimeRange.Value = valueAt(time);
protected override void ReadIntoStartValue(ScrollingPlayfield<TObject, TJudgement> d) => StartValue = d.VisibleTimeRange.Value;
protected override void Apply(ScrollingPlayfield<TObject> d, double time) => d.VisibleTimeRange.Value = valueAt(time);
protected override void ReadIntoStartValue(ScrollingPlayfield<TObject> d) => StartValue = d.VisibleTimeRange.Value;
}
/// <summary>

View File

@ -9,7 +9,6 @@ using osu.Framework.Lists;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Timing;
@ -17,17 +16,16 @@ using osu.Game.Rulesets.Timing;
namespace osu.Game.Rulesets.UI
{
/// <summary>
/// A type of <see cref="RulesetContainer{TPlayfield,TObject,TJudgement}"/> that supports a <see cref="ScrollingPlayfield{TObject, TJudgement}"/>.
/// <see cref="HitObject"/>s inside this <see cref="RulesetContainer{TPlayfield,TObject,TJudgement}"/> will scroll within the playfield.
/// A type of <see cref="RulesetContainer{TPlayfield,TObject}"/> that supports a <see cref="ScrollingPlayfield{TObject}"/>.
/// <see cref="HitObject"/>s inside this <see cref="RulesetContainer{TPlayfield,TObject}"/> will scroll within the playfield.
/// </summary>
public abstract class ScrollingRulesetContainer<TPlayfield, TObject, TJudgement> : RulesetContainer<TPlayfield, TObject, TJudgement>
public abstract class ScrollingRulesetContainer<TPlayfield, TObject> : RulesetContainer<TPlayfield, TObject>
where TObject : HitObject
where TJudgement : Judgement
where TPlayfield : ScrollingPlayfield<TObject, TJudgement>
where TPlayfield : ScrollingPlayfield<TObject>
{
/// <summary>
/// Provides the default <see cref="MultiplierControlPoint"/>s that adjust the scrolling rate of <see cref="HitObject"/>s
/// inside this <see cref="RulesetContainer{TPlayfield,TObject,TJudgement}"/>.
/// inside this <see cref="RulesetContainer{TPlayfield,TObject}"/>.
/// </summary>
/// <returns></returns>
protected readonly SortedList<MultiplierControlPoint> DefaultControlPoints = new SortedList<MultiplierControlPoint>(Comparer<MultiplierControlPoint>.Default);
@ -88,7 +86,7 @@ namespace osu.Game.Rulesets.UI
DefaultControlPoints.ForEach(c => applySpeedAdjustment(c, Playfield));
}
private void applySpeedAdjustment(MultiplierControlPoint controlPoint, ScrollingPlayfield<TObject, TJudgement> playfield)
private void applySpeedAdjustment(MultiplierControlPoint controlPoint, ScrollingPlayfield<TObject> playfield)
{
playfield.HitObjects.AddSpeedAdjustment(CreateSpeedAdjustmentContainer(controlPoint));
playfield.NestedPlayfields.ForEach(p => applySpeedAdjustment(controlPoint, p));