mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Merge remote-tracking branch 'upstream/master' into tab-control
This commit is contained in:
@ -19,7 +19,13 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
public BeatmapInfo BeatmapInfo;
|
||||
public List<ControlPoint> ControlPoints;
|
||||
public List<Color4> ComboColors;
|
||||
public readonly List<Color4> ComboColors = new List<Color4>
|
||||
{
|
||||
new Color4(17, 136, 170, 255),
|
||||
new Color4(102, 136, 0, 255),
|
||||
new Color4(204, 102, 0, 255),
|
||||
new Color4(121, 9, 13, 255)
|
||||
};
|
||||
|
||||
public BeatmapMetadata Metadata => BeatmapInfo?.Metadata ?? BeatmapInfo?.BeatmapSet?.Metadata;
|
||||
|
||||
@ -34,9 +40,9 @@ namespace osu.Game.Beatmaps
|
||||
/// <param name="original">The original beatmap to use the parameters of.</param>
|
||||
public Beatmap(Beatmap original = null)
|
||||
{
|
||||
BeatmapInfo = original?.BeatmapInfo;
|
||||
ControlPoints = original?.ControlPoints;
|
||||
ComboColors = original?.ComboColors;
|
||||
BeatmapInfo = original?.BeatmapInfo ?? BeatmapInfo;
|
||||
ControlPoints = original?.ControlPoints ?? ControlPoints;
|
||||
ComboColors = original?.ComboColors ?? ComboColors;
|
||||
}
|
||||
|
||||
public double BPMMaximum => 60000 / (ControlPoints?.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).FirstOrDefault() ?? ControlPoint.Default).BeatLength;
|
||||
|
@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using osu.Game.Modes.Objects;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Database;
|
||||
|
||||
@ -31,9 +30,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
public virtual Beatmap Decode(TextReader stream)
|
||||
{
|
||||
Beatmap b = ParseFile(stream);
|
||||
Process(b);
|
||||
return b;
|
||||
return ParseFile(stream);
|
||||
}
|
||||
|
||||
public virtual void Decode(TextReader stream, Beatmap beatmap)
|
||||
@ -41,20 +38,12 @@ namespace osu.Game.Beatmaps.Formats
|
||||
ParseFile(stream, beatmap);
|
||||
}
|
||||
|
||||
public virtual Beatmap Process(Beatmap beatmap)
|
||||
{
|
||||
ApplyColours(beatmap);
|
||||
|
||||
return beatmap;
|
||||
}
|
||||
|
||||
protected virtual Beatmap ParseFile(TextReader stream)
|
||||
{
|
||||
var beatmap = new Beatmap
|
||||
{
|
||||
HitObjects = new List<HitObject>(),
|
||||
ControlPoints = new List<ControlPoint>(),
|
||||
ComboColors = new List<Color4>(),
|
||||
BeatmapInfo = new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata(),
|
||||
@ -65,25 +54,5 @@ namespace osu.Game.Beatmaps.Formats
|
||||
return beatmap;
|
||||
}
|
||||
protected abstract void ParseFile(TextReader stream, Beatmap beatmap);
|
||||
|
||||
public virtual void ApplyColours(Beatmap b)
|
||||
{
|
||||
List<Color4> colours = b.ComboColors ?? new List<Color4> {
|
||||
new Color4(17, 136, 170, 255),
|
||||
new Color4(102, 136, 0, 255),
|
||||
new Color4(204, 102, 0, 255),
|
||||
new Color4(121, 9, 13, 255),
|
||||
};
|
||||
|
||||
if (colours.Count == 0) return;
|
||||
|
||||
int i = -1;
|
||||
|
||||
foreach (HitObject h in b.HitObjects)
|
||||
{
|
||||
if (h.NewCombo || i == -1) i = (i + 1) % colours.Count;
|
||||
h.Colour = colours[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,14 +212,23 @@ namespace osu.Game.Beatmaps.Formats
|
||||
beatmap.ControlPoints.Add(cp);
|
||||
}
|
||||
|
||||
private void handleColours(Beatmap beatmap, string key, string val)
|
||||
private void handleColours(Beatmap beatmap, string key, string val, ref bool hasCustomColours)
|
||||
{
|
||||
string[] split = val.Split(',');
|
||||
|
||||
if (split.Length != 3)
|
||||
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B): {val}");
|
||||
|
||||
byte r, g, b;
|
||||
if (!byte.TryParse(split[0], out r) || !byte.TryParse(split[1], out g) || !byte.TryParse(split[2], out b))
|
||||
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
|
||||
|
||||
if (!hasCustomColours)
|
||||
{
|
||||
beatmap.ComboColors.Clear();
|
||||
hasCustomColours = true;
|
||||
}
|
||||
|
||||
// Note: the combo index specified in the beatmap is discarded
|
||||
if (key.StartsWith(@"Combo"))
|
||||
{
|
||||
@ -237,6 +246,8 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
HitObjectParser parser = null;
|
||||
|
||||
bool hasCustomColours = false;
|
||||
|
||||
var section = Section.None;
|
||||
while (true)
|
||||
{
|
||||
@ -265,7 +276,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
case Section.General:
|
||||
handleGeneral(beatmap, key, val);
|
||||
parser = Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).CreateHitObjectParser();
|
||||
parser = new LegacyHitObjectParser();
|
||||
break;
|
||||
case Section.Editor:
|
||||
handleEditor(beatmap, key, val);
|
||||
@ -283,16 +294,14 @@ namespace osu.Game.Beatmaps.Formats
|
||||
handleTimingPoints(beatmap, val);
|
||||
break;
|
||||
case Section.Colours:
|
||||
handleColours(beatmap, key, val);
|
||||
handleColours(beatmap, key, val, ref hasCustomColours);
|
||||
break;
|
||||
case Section.HitObjects:
|
||||
var obj = parser?.Parse(val);
|
||||
|
||||
if (obj != null)
|
||||
{
|
||||
obj.SetDefaultsFromBeatmap(beatmap);
|
||||
beatmap.HitObjects.Add(obj);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,17 @@ using osu.Game.Modes.Objects;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a Beatmap for another mode.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of HitObject stored in the Beatmap.</typeparam>
|
||||
public interface IBeatmapConverter<T> where T : HitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts a Beatmap to another mode.
|
||||
/// </summary>
|
||||
/// <param name="original">The original Beatmap.</param>
|
||||
/// <returns>The converted Beatmap.</returns>
|
||||
Beatmap<T> Convert(Beatmap original);
|
||||
}
|
||||
}
|
||||
|
31
osu.Game/Beatmaps/IBeatmapProcessor.cs
Normal file
31
osu.Game/Beatmaps/IBeatmapProcessor.cs
Normal file
@ -0,0 +1,31 @@
|
||||
// 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;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
/// <summary>
|
||||
/// Processes a post-converted Beatmap.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of HitObject contained in the Beatmap.</typeparam>
|
||||
public interface IBeatmapProcessor<T>
|
||||
where T : HitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets default values for a HitObject.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The HitObject to set default values for.</param>
|
||||
/// <param name="beatmap">The Beatmap to extract the default values from.</param>
|
||||
void SetDefaults(T hitObject, Beatmap<T> beatmap);
|
||||
|
||||
/// <summary>
|
||||
/// Post-processes a Beatmap to add mode-specific components that aren't added during conversion.
|
||||
/// <para>
|
||||
/// An example of such a usage is for combo colours.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The Beatmap to process.</param>
|
||||
void PostProcess(Beatmap<T> beatmap);
|
||||
}
|
||||
}
|
14
osu.Game/Modes/Judgements/JudgementInfo.cs
Normal file
14
osu.Game/Modes/Judgements/JudgementInfo.cs
Normal file
@ -0,0 +1,14 @@
|
||||
// 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.Drawables;
|
||||
|
||||
namespace osu.Game.Modes.Judgements
|
||||
{
|
||||
public class JudgementInfo
|
||||
{
|
||||
public ulong? ComboAtHit;
|
||||
public HitResult? Result;
|
||||
public double TimeOffset;
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
// 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;
|
||||
|
||||
|
150
osu.Game/Modes/Objects/BezierApproximator.cs
Normal file
150
osu.Game/Modes/Objects/BezierApproximator.cs
Normal file
@ -0,0 +1,150 @@
|
||||
// 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.Collections.Generic;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Objects
|
||||
{
|
||||
public class BezierApproximator
|
||||
{
|
||||
private int count;
|
||||
private List<Vector2> controlPoints;
|
||||
private Vector2[] subdivisionBuffer1;
|
||||
private Vector2[] subdivisionBuffer2;
|
||||
|
||||
private const float tolerance = 0.25f;
|
||||
private const float tolerance_sq = tolerance * tolerance;
|
||||
|
||||
public BezierApproximator(List<Vector2> controlPoints)
|
||||
{
|
||||
this.controlPoints = controlPoints;
|
||||
count = controlPoints.Count;
|
||||
|
||||
subdivisionBuffer1 = new Vector2[count];
|
||||
subdivisionBuffer2 = new Vector2[count * 2 - 1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make sure the 2nd order derivative (approximated using finite elements) is within tolerable bounds.
|
||||
/// NOTE: The 2nd order derivative of a 2d curve represents its curvature, so intuitively this function
|
||||
/// checks (as the name suggests) whether our approximation is _locally_ "flat". More curvy parts
|
||||
/// need to have a denser approximation to be more "flat".
|
||||
/// </summary>
|
||||
/// <param name="controlPoints">The control points to check for flatness.</param>
|
||||
/// <returns>Whether the control points are flat enough.</returns>
|
||||
private static bool isFlatEnough(Vector2[] controlPoints)
|
||||
{
|
||||
for (int i = 1; i < controlPoints.Length - 1; i++)
|
||||
if ((controlPoints[i - 1] - 2 * controlPoints[i] + controlPoints[i + 1]).LengthSquared > tolerance_sq * 4)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Subdivides n control points representing a bezier curve into 2 sets of n control points, each
|
||||
/// describing a bezier curve equivalent to a half of the original curve. Effectively this splits
|
||||
/// the original curve into 2 curves which result in the original curve when pieced back together.
|
||||
/// </summary>
|
||||
/// <param name="controlPoints">The control points to split.</param>
|
||||
/// <param name="l">Output: The control points corresponding to the left half of the curve.</param>
|
||||
/// <param name="r">Output: The control points corresponding to the right half of the curve.</param>
|
||||
private void subdivide(Vector2[] controlPoints, Vector2[] l, Vector2[] r)
|
||||
{
|
||||
Vector2[] midpoints = subdivisionBuffer1;
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
midpoints[i] = controlPoints[i];
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
l[i] = midpoints[0];
|
||||
r[count - i - 1] = midpoints[count - i - 1];
|
||||
|
||||
for (int j = 0; j < count - i - 1; j++)
|
||||
midpoints[j] = (midpoints[j] + midpoints[j + 1]) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This uses <a href="https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm">De Casteljau's algorithm</a> to obtain an optimal
|
||||
/// piecewise-linear approximation of the bezier curve with the same amount of points as there are control points.
|
||||
/// </summary>
|
||||
/// <param name="controlPoints">The control points describing the bezier curve to be approximated.</param>
|
||||
/// <param name="output">The points representing the resulting piecewise-linear approximation.</param>
|
||||
private void approximate(Vector2[] controlPoints, List<Vector2> output)
|
||||
{
|
||||
Vector2[] l = subdivisionBuffer2;
|
||||
Vector2[] r = subdivisionBuffer1;
|
||||
|
||||
subdivide(controlPoints, l, r);
|
||||
|
||||
for (int i = 0; i < count - 1; ++i)
|
||||
l[count + i] = r[i + 1];
|
||||
|
||||
output.Add(controlPoints[0]);
|
||||
for (int i = 1; i < count - 1; ++i)
|
||||
{
|
||||
int index = 2 * i;
|
||||
Vector2 p = 0.25f * (l[index - 1] + 2 * l[index] + l[index + 1]);
|
||||
output.Add(p);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a piecewise-linear approximation of a bezier curve, by adaptively repeatedly subdividing
|
||||
/// the control points until their approximation error vanishes below a given threshold.
|
||||
/// </summary>
|
||||
/// <returns>A list of vectors representing the piecewise-linear approximation.</returns>
|
||||
public List<Vector2> CreateBezier()
|
||||
{
|
||||
List<Vector2> output = new List<Vector2>();
|
||||
|
||||
if (count == 0)
|
||||
return output;
|
||||
|
||||
Stack<Vector2[]> toFlatten = new Stack<Vector2[]>();
|
||||
Stack<Vector2[]> freeBuffers = new Stack<Vector2[]>();
|
||||
|
||||
// "toFlatten" contains all the curves which are not yet approximated well enough.
|
||||
// We use a stack to emulate recursion without the risk of running into a stack overflow.
|
||||
// (More specifically, we iteratively and adaptively refine our curve with a
|
||||
// <a href="https://en.wikipedia.org/wiki/Depth-first_search">Depth-first search</a>
|
||||
// over the tree resulting from the subdivisions we make.)
|
||||
toFlatten.Push(controlPoints.ToArray());
|
||||
|
||||
Vector2[] leftChild = subdivisionBuffer2;
|
||||
|
||||
while (toFlatten.Count > 0)
|
||||
{
|
||||
Vector2[] parent = toFlatten.Pop();
|
||||
if (isFlatEnough(parent))
|
||||
{
|
||||
// If the control points we currently operate on are sufficiently "flat", we use
|
||||
// an extension to De Casteljau's algorithm to obtain a piecewise-linear approximation
|
||||
// of the bezier curve represented by our control points, consisting of the same amount
|
||||
// of points as there are control points.
|
||||
approximate(parent, output);
|
||||
freeBuffers.Push(parent);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we do not yet have a sufficiently "flat" (in other words, detailed) approximation we keep
|
||||
// subdividing the curve we are currently operating on.
|
||||
Vector2[] rightChild = freeBuffers.Count > 0 ? freeBuffers.Pop() : new Vector2[count];
|
||||
subdivide(parent, leftChild, rightChild);
|
||||
|
||||
// We re-use the buffer of the parent for one of the children, so that we save one allocation per iteration.
|
||||
for (int i = 0; i < count; ++i)
|
||||
parent[i] = leftChild[i];
|
||||
|
||||
toFlatten.Push(rightChild);
|
||||
toFlatten.Push(parent);
|
||||
}
|
||||
|
||||
output.Add(controlPoints[count - 1]);
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
99
osu.Game/Modes/Objects/CircularArcApproximator.cs
Normal file
99
osu.Game/Modes/Objects/CircularArcApproximator.cs
Normal file
@ -0,0 +1,99 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using osu.Framework.MathUtils;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Objects
|
||||
{
|
||||
public class CircularArcApproximator
|
||||
{
|
||||
private Vector2 a;
|
||||
private Vector2 b;
|
||||
private Vector2 c;
|
||||
|
||||
private int amountPoints;
|
||||
|
||||
private const float tolerance = 0.1f;
|
||||
|
||||
public CircularArcApproximator(Vector2 a, Vector2 b, Vector2 c)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a piecewise-linear approximation of a circular arc curve.
|
||||
/// </summary>
|
||||
/// <returns>A list of vectors representing the piecewise-linear approximation.</returns>
|
||||
public List<Vector2> CreateArc()
|
||||
{
|
||||
float aSq = (b - c).LengthSquared;
|
||||
float bSq = (a - c).LengthSquared;
|
||||
float cSq = (a - b).LengthSquared;
|
||||
|
||||
// If we have a degenerate triangle where a side-length is almost zero, then give up and fall
|
||||
// back to a more numerically stable method.
|
||||
if (Precision.AlmostEquals(aSq, 0) || Precision.AlmostEquals(bSq, 0) || Precision.AlmostEquals(cSq, 0))
|
||||
return new List<Vector2>();
|
||||
|
||||
float s = aSq * (bSq + cSq - aSq);
|
||||
float t = bSq * (aSq + cSq - bSq);
|
||||
float u = cSq * (aSq + bSq - cSq);
|
||||
|
||||
float sum = s + t + u;
|
||||
|
||||
// If we have a degenerate triangle with an almost-zero size, then give up and fall
|
||||
// back to a more numerically stable method.
|
||||
if (Precision.AlmostEquals(sum, 0))
|
||||
return new List<Vector2>();
|
||||
|
||||
Vector2 centre = (s * a + t * b + u * c) / sum;
|
||||
Vector2 dA = a - centre;
|
||||
Vector2 dC = c - centre;
|
||||
|
||||
float r = dA.Length;
|
||||
|
||||
double thetaStart = Math.Atan2(dA.Y, dA.X);
|
||||
double thetaEnd = Math.Atan2(dC.Y, dC.X);
|
||||
|
||||
while (thetaEnd < thetaStart)
|
||||
thetaEnd += 2 * Math.PI;
|
||||
|
||||
double dir = 1;
|
||||
double thetaRange = thetaEnd - thetaStart;
|
||||
|
||||
// Decide in which direction to draw the circle, depending on which side of
|
||||
// AC B lies.
|
||||
Vector2 orthoAtoC = c - a;
|
||||
orthoAtoC = new Vector2(orthoAtoC.Y, -orthoAtoC.X);
|
||||
if (Vector2.Dot(orthoAtoC, b - a) < 0)
|
||||
{
|
||||
dir = -dir;
|
||||
thetaRange = 2 * Math.PI - thetaRange;
|
||||
}
|
||||
|
||||
// We select the amount of points for the approximation by requiring the discrete curvature
|
||||
// to be smaller than the provided tolerance. The exact angle required to meet the tolerance
|
||||
// is: 2 * Math.Acos(1 - TOLERANCE / r)
|
||||
// The special case is required for extremely short sliders where the radius is smaller than
|
||||
// the tolerance. This is a pathological rather than a realistic case.
|
||||
amountPoints = 2 * r <= tolerance ? 2 : Math.Max(2, (int)Math.Ceiling(thetaRange / (2 * Math.Acos(1 - tolerance / r))));
|
||||
|
||||
List<Vector2> output = new List<Vector2>(amountPoints);
|
||||
|
||||
for (int i = 0; i < amountPoints; ++i)
|
||||
{
|
||||
double fract = (double)i / (amountPoints - 1);
|
||||
double theta = thetaStart + dir * fract * thetaRange;
|
||||
Vector2 o = new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * r;
|
||||
output.Add(centre + o);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
49
osu.Game/Modes/Objects/CurvedHitObject.cs
Normal file
49
osu.Game/Modes/Objects/CurvedHitObject.cs
Normal file
@ -0,0 +1,49 @@
|
||||
// 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.Game.Modes.Objects.Types;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Modes.Objects
|
||||
{
|
||||
public class CurvedHitObject : HitObject, IHasCurve
|
||||
{
|
||||
public SliderCurve Curve { get; } = new SliderCurve();
|
||||
|
||||
public int RepeatCount { get; set; } = 1;
|
||||
|
||||
public double EndTime => 0;
|
||||
public double Duration => 0;
|
||||
|
||||
public List<Vector2> ControlPoints
|
||||
{
|
||||
get { return Curve.ControlPoints; }
|
||||
set { Curve.ControlPoints = value; }
|
||||
}
|
||||
|
||||
public CurveType CurveType
|
||||
{
|
||||
get { return Curve.CurveType; }
|
||||
set { Curve.CurveType = value; }
|
||||
}
|
||||
|
||||
public double Distance
|
||||
{
|
||||
get { return Curve.Distance; }
|
||||
set { Curve.Distance = value; }
|
||||
}
|
||||
|
||||
public Vector2 PositionAt(double progress) => Curve.PositionAt(ProgressAt(progress));
|
||||
|
||||
public double ProgressAt(double progress)
|
||||
{
|
||||
var p = progress * RepeatCount % 1;
|
||||
if (RepeatAt(progress) % 2 == 1)
|
||||
p = 1 - p;
|
||||
return p;
|
||||
}
|
||||
|
||||
public int RepeatAt(double progress) => (int)(progress * RepeatCount);
|
||||
}
|
||||
}
|
12
osu.Game/Modes/Objects/Drawables/ArmedState.cs
Normal file
12
osu.Game/Modes/Objects/Drawables/ArmedState.cs
Normal 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.Objects.Drawables
|
||||
{
|
||||
public enum ArmedState
|
||||
{
|
||||
Idle,
|
||||
Hit,
|
||||
Miss
|
||||
}
|
||||
}
|
@ -3,26 +3,27 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using OpenTK;
|
||||
using osu.Game.Modes.Judgements;
|
||||
using Container = osu.Framework.Graphics.Containers.Container;
|
||||
using osu.Game.Modes.Objects.Types;
|
||||
|
||||
namespace osu.Game.Modes.Objects.Drawables
|
||||
{
|
||||
public abstract class DrawableHitObject : Container, IStateful<ArmedState>
|
||||
public abstract class DrawableHitObject<TJudgement> : Container, IStateful<ArmedState>
|
||||
where TJudgement : JudgementInfo
|
||||
{
|
||||
public override bool HandleInput => Interactive;
|
||||
|
||||
public bool Interactive = true;
|
||||
|
||||
public JudgementInfo Judgement;
|
||||
public TJudgement Judgement;
|
||||
|
||||
protected abstract JudgementInfo CreateJudgementInfo();
|
||||
protected abstract TJudgement CreateJudgementInfo();
|
||||
|
||||
protected abstract void UpdateState(ArmedState state);
|
||||
|
||||
@ -67,14 +68,15 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class DrawableHitObject<HitObjectType> : DrawableHitObject
|
||||
where HitObjectType : HitObject
|
||||
public abstract class DrawableHitObject<TObject, TJudgement> : DrawableHitObject<TJudgement>
|
||||
where TObject : HitObject
|
||||
where TJudgement : JudgementInfo
|
||||
{
|
||||
public event Action<DrawableHitObject<HitObjectType>, JudgementInfo> OnJudgement;
|
||||
public event Action<DrawableHitObject<TObject, TJudgement>> OnJudgement;
|
||||
|
||||
public HitObjectType HitObject;
|
||||
public TObject HitObject;
|
||||
|
||||
protected DrawableHitObject(HitObjectType hitObject)
|
||||
protected DrawableHitObject(TObject hitObject)
|
||||
{
|
||||
HitObject = hitObject;
|
||||
}
|
||||
@ -88,7 +90,9 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
if (Judgement.Result != null)
|
||||
return false;
|
||||
|
||||
Judgement.TimeOffset = Time.Current - HitObject.EndTime;
|
||||
double endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
|
||||
|
||||
Judgement.TimeOffset = Time.Current - endTime;
|
||||
|
||||
CheckJudgement(userTriggered);
|
||||
|
||||
@ -105,7 +109,7 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
break;
|
||||
}
|
||||
|
||||
OnJudgement?.Invoke(this, Judgement);
|
||||
OnJudgement?.Invoke(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -138,44 +142,17 @@ namespace osu.Game.Modes.Objects.Drawables
|
||||
Sample = audio.Sample.Get($@"Gameplay/{sampleSet.ToString().ToLower()}-hit{type.ToString().ToLower()}");
|
||||
}
|
||||
|
||||
private List<DrawableHitObject<HitObjectType>> nestedHitObjects;
|
||||
private List<DrawableHitObject<TObject, TJudgement>> nestedHitObjects;
|
||||
|
||||
protected IEnumerable<DrawableHitObject<HitObjectType>> NestedHitObjects => nestedHitObjects;
|
||||
protected IEnumerable<DrawableHitObject<TObject, TJudgement>> NestedHitObjects => nestedHitObjects;
|
||||
|
||||
protected void AddNested(DrawableHitObject<HitObjectType> h)
|
||||
protected void AddNested(DrawableHitObject<TObject, TJudgement> h)
|
||||
{
|
||||
if (nestedHitObjects == null)
|
||||
nestedHitObjects = new List<DrawableHitObject<HitObjectType>>();
|
||||
nestedHitObjects = new List<DrawableHitObject<TObject, TJudgement>>();
|
||||
|
||||
h.OnJudgement += (d, j) => { OnJudgement?.Invoke(d, j); } ;
|
||||
h.OnJudgement += d => OnJudgement?.Invoke(d);
|
||||
nestedHitObjects.Add(h);
|
||||
}
|
||||
}
|
||||
|
||||
public enum ArmedState
|
||||
{
|
||||
Idle,
|
||||
Hit,
|
||||
Miss
|
||||
}
|
||||
|
||||
public class PositionalJudgementInfo : JudgementInfo
|
||||
{
|
||||
public Vector2 PositionOffset;
|
||||
}
|
||||
|
||||
public class JudgementInfo
|
||||
{
|
||||
public ulong? ComboAtHit;
|
||||
public HitResult? Result;
|
||||
public double TimeOffset;
|
||||
}
|
||||
|
||||
public enum HitResult
|
||||
{
|
||||
[Description(@"Miss")]
|
||||
Miss,
|
||||
[Description(@"Hit")]
|
||||
Hit,
|
||||
}
|
||||
}
|
||||
|
15
osu.Game/Modes/Objects/Drawables/HitResult.cs
Normal file
15
osu.Game/Modes/Objects/Drawables/HitResult.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// 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.ComponentModel;
|
||||
|
||||
namespace osu.Game.Modes.Objects.Drawables
|
||||
{
|
||||
public enum HitResult
|
||||
{
|
||||
[Description(@"Miss")]
|
||||
Miss,
|
||||
[Description(@"Hit")]
|
||||
Hit,
|
||||
}
|
||||
}
|
@ -1,30 +1,26 @@
|
||||
// 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.Beatmaps;
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Modes.Objects
|
||||
{
|
||||
/// <summary>
|
||||
/// A hitobject describes a point in a beatmap
|
||||
/// A HitObject describes an object in a Beatmap.
|
||||
/// <para>
|
||||
/// HitObjects may contain more properties for which you should be checking through the IHas* types.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public abstract class HitObject
|
||||
public class HitObject
|
||||
{
|
||||
public double StartTime;
|
||||
public virtual double EndTime => StartTime;
|
||||
/// <summary>
|
||||
/// The time at which the HitObject starts.
|
||||
/// </summary>
|
||||
public double StartTime { get; set; }
|
||||
|
||||
public bool NewCombo { get; set; }
|
||||
|
||||
public Color4 Colour = new Color4(17, 136, 170, 255);
|
||||
|
||||
public double Duration => EndTime - StartTime;
|
||||
|
||||
public HitSampleInfo Sample;
|
||||
|
||||
public int ComboIndex;
|
||||
|
||||
public virtual void SetDefaultsFromBeatmap(Beatmap beatmap) { }
|
||||
/// <summary>
|
||||
/// The sample to be played when this HitObject is hit.
|
||||
/// </summary>
|
||||
public HitSampleInfo Sample { get; set; }
|
||||
}
|
||||
}
|
||||
|
18
osu.Game/Modes/Objects/Legacy/LegacyHit.cs
Normal file
18
osu.Game/Modes/Objects/Legacy/LegacyHit.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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.Types;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Objects.Legacy
|
||||
{
|
||||
/// <summary>
|
||||
/// Legacy Hit-type, used for parsing Beatmaps.
|
||||
/// </summary>
|
||||
public sealed class LegacyHit : HitObject, IHasPosition, IHasCombo
|
||||
{
|
||||
public Vector2 Position { get; set; }
|
||||
|
||||
public bool NewCombo { get; set; }
|
||||
}
|
||||
}
|
18
osu.Game/Modes/Objects/Legacy/LegacyHitObjectType.cs
Normal file
18
osu.Game/Modes/Objects/Legacy/LegacyHitObjectType.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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;
|
||||
|
||||
namespace osu.Game.Modes.Objects.Legacy
|
||||
{
|
||||
[Flags]
|
||||
public enum LegacyHitObjectType
|
||||
{
|
||||
Circle = 1 << 0,
|
||||
Slider = 1 << 1,
|
||||
NewCombo = 1 << 2,
|
||||
Spinner = 1 << 3,
|
||||
ColourHax = 112,
|
||||
Hold = 1 << 7
|
||||
}
|
||||
}
|
18
osu.Game/Modes/Objects/Legacy/LegacyHold.cs
Normal file
18
osu.Game/Modes/Objects/Legacy/LegacyHold.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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.Game.Modes.Objects.Types;
|
||||
|
||||
namespace osu.Game.Modes.Objects.Legacy
|
||||
{
|
||||
/// <summary>
|
||||
/// Legacy Hold-type, used for parsing "specials" in beatmaps.
|
||||
/// </summary>
|
||||
public sealed class LegacyHold : HitObject, IHasPosition, IHasCombo, IHasHold
|
||||
{
|
||||
public Vector2 Position { get; set; }
|
||||
|
||||
public bool NewCombo { get; set; }
|
||||
}
|
||||
}
|
18
osu.Game/Modes/Objects/Legacy/LegacySlider.cs
Normal file
18
osu.Game/Modes/Objects/Legacy/LegacySlider.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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.Types;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Objects.Legacy
|
||||
{
|
||||
/// <summary>
|
||||
/// Legacy Slider-type, used for parsing Beatmaps.
|
||||
/// </summary>
|
||||
public sealed class LegacySlider : CurvedHitObject, IHasPosition, IHasCombo
|
||||
{
|
||||
public Vector2 Position { get; set; }
|
||||
|
||||
public bool NewCombo { get; set; }
|
||||
}
|
||||
}
|
17
osu.Game/Modes/Objects/Legacy/LegacySpinner.cs
Normal file
17
osu.Game/Modes/Objects/Legacy/LegacySpinner.cs
Normal file
@ -0,0 +1,17 @@
|
||||
// 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.Types;
|
||||
|
||||
namespace osu.Game.Modes.Objects.Legacy
|
||||
{
|
||||
/// <summary>
|
||||
/// Legacy Spinner-type, used for parsing Beatmaps.
|
||||
/// </summary>
|
||||
internal class LegacySpinner : HitObject, IHasEndTime
|
||||
{
|
||||
public double EndTime { get; set; }
|
||||
|
||||
public double Duration => EndTime - StartTime;
|
||||
}
|
||||
}
|
119
osu.Game/Modes/Objects/LegacyHitObjectParser.cs
Normal file
119
osu.Game/Modes/Objects/LegacyHitObjectParser.cs
Normal file
@ -0,0 +1,119 @@
|
||||
// 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.Game.Beatmaps.Samples;
|
||||
using osu.Game.Modes.Objects.Types;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using osu.Game.Modes.Objects.Legacy;
|
||||
|
||||
namespace osu.Game.Modes.Objects
|
||||
{
|
||||
internal class LegacyHitObjectParser : HitObjectParser
|
||||
{
|
||||
public override HitObject Parse(string text)
|
||||
{
|
||||
string[] split = text.Split(',');
|
||||
var type = (LegacyHitObjectType)int.Parse(split[3]) & ~LegacyHitObjectType.ColourHax;
|
||||
bool combo = type.HasFlag(LegacyHitObjectType.NewCombo);
|
||||
type &= ~LegacyHitObjectType.NewCombo;
|
||||
|
||||
HitObject result;
|
||||
|
||||
if ((type & LegacyHitObjectType.Circle) > 0)
|
||||
{
|
||||
result = new LegacyHit
|
||||
{
|
||||
Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])),
|
||||
NewCombo = combo
|
||||
};
|
||||
}
|
||||
else if ((type & LegacyHitObjectType.Slider) > 0)
|
||||
{
|
||||
CurveType curveType = CurveType.Catmull;
|
||||
double length = 0;
|
||||
List<Vector2> points = new List<Vector2> { new Vector2(int.Parse(split[0]), int.Parse(split[1])) };
|
||||
|
||||
string[] pointsplit = split[5].Split('|');
|
||||
foreach (string t in pointsplit)
|
||||
{
|
||||
if (t.Length == 1)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case @"C":
|
||||
curveType = CurveType.Catmull;
|
||||
break;
|
||||
case @"B":
|
||||
curveType = CurveType.Bezier;
|
||||
break;
|
||||
case @"L":
|
||||
curveType = CurveType.Linear;
|
||||
break;
|
||||
case @"P":
|
||||
curveType = CurveType.PerfectCurve;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
string[] temp = t.Split(':');
|
||||
Vector2 v = new Vector2(
|
||||
(int)Convert.ToDouble(temp[0], CultureInfo.InvariantCulture),
|
||||
(int)Convert.ToDouble(temp[1], CultureInfo.InvariantCulture)
|
||||
);
|
||||
points.Add(v);
|
||||
}
|
||||
|
||||
int repeatCount = Convert.ToInt32(split[6], CultureInfo.InvariantCulture);
|
||||
|
||||
if (repeatCount > 9000)
|
||||
throw new ArgumentOutOfRangeException(nameof(repeatCount), @"Repeat count is way too high");
|
||||
|
||||
if (split.Length > 7)
|
||||
length = Convert.ToDouble(split[7], CultureInfo.InvariantCulture);
|
||||
|
||||
result = new LegacySlider
|
||||
{
|
||||
ControlPoints = points,
|
||||
Distance = length,
|
||||
CurveType = curveType,
|
||||
RepeatCount = repeatCount,
|
||||
Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])),
|
||||
NewCombo = combo
|
||||
};
|
||||
}
|
||||
else if ((type & LegacyHitObjectType.Spinner) > 0)
|
||||
{
|
||||
result = new LegacySpinner
|
||||
{
|
||||
EndTime = Convert.ToDouble(split[5], CultureInfo.InvariantCulture)
|
||||
};
|
||||
}
|
||||
else if ((type & LegacyHitObjectType.Hold) > 0)
|
||||
{
|
||||
// Note: Hold is generated by BMS converts
|
||||
result = new LegacyHold
|
||||
{
|
||||
Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])),
|
||||
NewCombo = combo
|
||||
};
|
||||
}
|
||||
else
|
||||
throw new InvalidOperationException($@"Unknown hit object type {type}");
|
||||
|
||||
result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture);
|
||||
result.Sample = new HitSampleInfo
|
||||
{
|
||||
Type = (SampleType)int.Parse(split[4]),
|
||||
Set = SampleSet.Soft,
|
||||
};
|
||||
|
||||
// TODO: "addition" field
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
// 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.Objects
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns null HitObjects but at least allows us to run.
|
||||
/// </summary>
|
||||
public class NullHitObjectParser : HitObjectParser
|
||||
{
|
||||
public override HitObject Parse(string text) => null;
|
||||
}
|
||||
}
|
203
osu.Game/Modes/Objects/SliderCurve.cs
Normal file
203
osu.Game/Modes/Objects/SliderCurve.cs
Normal file
@ -0,0 +1,203 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Modes.Objects.Types;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Objects
|
||||
{
|
||||
public class SliderCurve
|
||||
{
|
||||
public double Distance;
|
||||
|
||||
public List<Vector2> ControlPoints;
|
||||
|
||||
public CurveType CurveType = CurveType.PerfectCurve;
|
||||
|
||||
public Vector2 Offset;
|
||||
|
||||
private List<Vector2> calculatedPath = new List<Vector2>();
|
||||
private List<double> cumulativeLength = new List<double>();
|
||||
|
||||
private List<Vector2> calculateSubpath(List<Vector2> subControlPoints)
|
||||
{
|
||||
switch (CurveType)
|
||||
{
|
||||
case CurveType.Linear:
|
||||
return subControlPoints;
|
||||
case CurveType.PerfectCurve:
|
||||
//we can only use CircularArc iff we have exactly three control points and no dissection.
|
||||
if (ControlPoints.Count != 3 || subControlPoints.Count != 3)
|
||||
break;
|
||||
|
||||
// Here we have exactly 3 control points. Attempt to fit a circular arc.
|
||||
List<Vector2> subpath = new CircularArcApproximator(subControlPoints[0], subControlPoints[1], subControlPoints[2]).CreateArc();
|
||||
|
||||
// If for some reason a circular arc could not be fit to the 3 given points, fall back to a numerically stable bezier approximation.
|
||||
if (subpath.Count == 0)
|
||||
break;
|
||||
|
||||
return subpath;
|
||||
}
|
||||
|
||||
return new BezierApproximator(subControlPoints).CreateBezier();
|
||||
}
|
||||
|
||||
private void calculatePath()
|
||||
{
|
||||
calculatedPath.Clear();
|
||||
|
||||
// Sliders may consist of various subpaths separated by two consecutive vertices
|
||||
// with the same position. The following loop parses these subpaths and computes
|
||||
// their shape independently, consecutively appending them to calculatedPath.
|
||||
List<Vector2> subControlPoints = new List<Vector2>();
|
||||
for (int i = 0; i < ControlPoints.Count; ++i)
|
||||
{
|
||||
subControlPoints.Add(ControlPoints[i]);
|
||||
if (i == ControlPoints.Count - 1 || ControlPoints[i] == ControlPoints[i + 1])
|
||||
{
|
||||
List<Vector2> subpath = calculateSubpath(subControlPoints);
|
||||
foreach (Vector2 t in subpath)
|
||||
if (calculatedPath.Count == 0 || calculatedPath.Last() != t)
|
||||
calculatedPath.Add(t);
|
||||
|
||||
subControlPoints.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateCumulativeLengthAndTrimPath()
|
||||
{
|
||||
double l = 0;
|
||||
|
||||
cumulativeLength.Clear();
|
||||
cumulativeLength.Add(l);
|
||||
|
||||
for (int i = 0; i < calculatedPath.Count - 1; ++i)
|
||||
{
|
||||
Vector2 diff = calculatedPath[i + 1] - calculatedPath[i];
|
||||
double d = diff.Length;
|
||||
|
||||
// Shorten slider curves that are too long compared to what's
|
||||
// in the .osu file.
|
||||
if (Distance - l < d)
|
||||
{
|
||||
calculatedPath[i + 1] = calculatedPath[i] + diff * (float)((Distance - l) / d);
|
||||
calculatedPath.RemoveRange(i + 2, calculatedPath.Count - 2 - i);
|
||||
|
||||
l = Distance;
|
||||
cumulativeLength.Add(l);
|
||||
break;
|
||||
}
|
||||
|
||||
l += d;
|
||||
cumulativeLength.Add(l);
|
||||
}
|
||||
|
||||
//TODO: Figure out if the following code is needed in some cases. Judging by the map
|
||||
// "Transform" http://osu.ppy.sh/s/484689 it seems like we should _not_ be doing this.
|
||||
// Lengthen slider curves that are too short compared to what's
|
||||
// in the .osu file.
|
||||
/*if (l < Length && calculatedPath.Count > 1)
|
||||
{
|
||||
Vector2 diff = calculatedPath[calculatedPath.Count - 1] - calculatedPath[calculatedPath.Count - 2];
|
||||
double d = diff.Length;
|
||||
|
||||
if (d <= 0)
|
||||
return;
|
||||
|
||||
calculatedPath[calculatedPath.Count - 1] += diff * (float)((Length - l) / d);
|
||||
cumulativeLength[calculatedPath.Count - 1] = Length;
|
||||
}*/
|
||||
}
|
||||
|
||||
public void Calculate()
|
||||
{
|
||||
calculatePath();
|
||||
calculateCumulativeLengthAndTrimPath();
|
||||
}
|
||||
|
||||
private int indexOfDistance(double d)
|
||||
{
|
||||
int i = cumulativeLength.BinarySearch(d);
|
||||
if (i < 0) i = ~i;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private double progressToDistance(double progress)
|
||||
{
|
||||
return MathHelper.Clamp(progress, 0, 1) * Distance;
|
||||
}
|
||||
|
||||
private Vector2 interpolateVertices(int i, double d)
|
||||
{
|
||||
if (calculatedPath.Count == 0)
|
||||
return Vector2.Zero;
|
||||
|
||||
if (i <= 0)
|
||||
return calculatedPath.First();
|
||||
else if (i >= calculatedPath.Count)
|
||||
return calculatedPath.Last();
|
||||
|
||||
Vector2 p0 = calculatedPath[i - 1];
|
||||
Vector2 p1 = calculatedPath[i];
|
||||
|
||||
double d0 = cumulativeLength[i - 1];
|
||||
double d1 = cumulativeLength[i];
|
||||
|
||||
// Avoid division by and almost-zero number in case two points are extremely close to each other.
|
||||
if (Precision.AlmostEquals(d0, d1))
|
||||
return p0;
|
||||
|
||||
double w = (d - d0) / (d1 - d0);
|
||||
return p0 + (p1 - p0) * (float)w;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the slider curve until a given progress that ranges from 0 (beginning of the slider)
|
||||
/// to 1 (end of the slider) and stores the generated path in the given list.
|
||||
/// </summary>
|
||||
/// <param name="path">The list to be filled with the computed curve.</param>
|
||||
/// <param name="p0">Start progress. Ranges from 0 (beginning of the slider) to 1 (end of the slider).</param>
|
||||
/// <param name="p1">End progress. Ranges from 0 (beginning of the slider) to 1 (end of the slider).</param>
|
||||
public void GetPathToProgress(List<Vector2> path, double p0, double p1)
|
||||
{
|
||||
if (calculatedPath.Count == 0 && ControlPoints.Count > 0)
|
||||
Calculate();
|
||||
|
||||
double d0 = progressToDistance(p0);
|
||||
double d1 = progressToDistance(p1);
|
||||
|
||||
path.Clear();
|
||||
|
||||
int i = 0;
|
||||
for (; i < calculatedPath.Count && cumulativeLength[i] < d0; ++i) { }
|
||||
|
||||
path.Add(interpolateVertices(i, d0) + Offset);
|
||||
|
||||
for (; i < calculatedPath.Count && cumulativeLength[i] <= d1; ++i)
|
||||
path.Add(calculatedPath[i] + Offset);
|
||||
|
||||
path.Add(interpolateVertices(i, d1) + Offset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Computes the position on the slider at a given progress that ranges from 0 (beginning of the curve)
|
||||
/// to 1 (end of the curve).
|
||||
/// </summary>
|
||||
/// <param name="progress">Ranges from 0 (beginning of the curve) to 1 (end of the curve).</param>
|
||||
/// <returns></returns>
|
||||
public Vector2 PositionAt(double progress)
|
||||
{
|
||||
if (calculatedPath.Count == 0 && ControlPoints.Count > 0)
|
||||
Calculate();
|
||||
|
||||
double d = progressToDistance(progress);
|
||||
return interpolateVertices(indexOfDistance(d), d) + Offset;
|
||||
}
|
||||
}
|
||||
}
|
13
osu.Game/Modes/Objects/Types/CurveType.cs
Normal file
13
osu.Game/Modes/Objects/Types/CurveType.cs
Normal file
@ -0,0 +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
|
||||
|
||||
namespace osu.Game.Modes.Objects.Types
|
||||
{
|
||||
public enum CurveType
|
||||
{
|
||||
Catmull,
|
||||
Bezier,
|
||||
Linear,
|
||||
PerfectCurve
|
||||
}
|
||||
}
|
16
osu.Game/Modes/Objects/Types/IHasCombo.cs
Normal file
16
osu.Game/Modes/Objects/Types/IHasCombo.cs
Normal file
@ -0,0 +1,16 @@
|
||||
// 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.Objects.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitObject that is part of a combo.
|
||||
/// </summary>
|
||||
public interface IHasCombo
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the HitObject starts a new combo.
|
||||
/// </summary>
|
||||
bool NewCombo { get; }
|
||||
}
|
||||
}
|
52
osu.Game/Modes/Objects/Types/IHasCurve.cs
Normal file
52
osu.Game/Modes/Objects/Types/IHasCurve.cs
Normal file
@ -0,0 +1,52 @@
|
||||
// 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.Collections.Generic;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Objects.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitObject that has a curve.
|
||||
/// </summary>
|
||||
public interface IHasCurve : IHasDistance, IHasRepeats
|
||||
{
|
||||
/// <summary>
|
||||
/// The curve.
|
||||
/// </summary>
|
||||
SliderCurve Curve { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The control points that shape the curve.
|
||||
/// </summary>
|
||||
List<Vector2> ControlPoints { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of curve.
|
||||
/// </summary>
|
||||
CurveType CurveType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Computes the position on the curve at a given progress, accounting for repeat logic.
|
||||
/// <para>
|
||||
/// Ranges from [0, 1] where 0 is the beginning of the curve and 1 is the end of the curve.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="progress">[0, 1] where 0 is the beginning of the curve and 1 is the end of the curve.</param>
|
||||
Vector2 PositionAt(double progress);
|
||||
|
||||
/// <summary>
|
||||
/// Finds the progress along the curve, accounting for repeat logic.
|
||||
/// </summary>
|
||||
/// <param name="progress">[0, 1] where 0 is the beginning of the curve and 1 is the end of the curve.</param>
|
||||
/// <returns>[0, 1] where 0 is the beginning of the curve and 1 is the end of the curve.</returns>
|
||||
double ProgressAt(double progress);
|
||||
|
||||
/// <summary>
|
||||
/// Determines which repeat of the curve the progress point is on.
|
||||
/// </summary>
|
||||
/// <param name="progress">[0, 1] where 0 is the beginning of the curve and 1 is the end of the curve.</param>
|
||||
/// <returns>[0, RepeatCount] where 0 is the first run.</returns>
|
||||
int RepeatAt(double progress);
|
||||
}
|
||||
}
|
16
osu.Game/Modes/Objects/Types/IHasDistance.cs
Normal file
16
osu.Game/Modes/Objects/Types/IHasDistance.cs
Normal file
@ -0,0 +1,16 @@
|
||||
// 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.Objects.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitObject that has a positional length.
|
||||
/// </summary>
|
||||
public interface IHasDistance : IHasEndTime
|
||||
{
|
||||
/// <summary>
|
||||
/// The positional length of the HitObject.
|
||||
/// </summary>
|
||||
double Distance { get; }
|
||||
}
|
||||
}
|
21
osu.Game/Modes/Objects/Types/IHasEndTime.cs
Normal file
21
osu.Game/Modes/Objects/Types/IHasEndTime.cs
Normal file
@ -0,0 +1,21 @@
|
||||
// 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.Objects.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitObject that ends at a different time than its start time.
|
||||
/// </summary>
|
||||
public interface IHasEndTime
|
||||
{
|
||||
/// <summary>
|
||||
/// The time at which the HitObject ends.
|
||||
/// </summary>
|
||||
double EndTime { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The duration of the HitObject.
|
||||
/// </summary>
|
||||
double Duration { get; }
|
||||
}
|
||||
}
|
12
osu.Game/Modes/Objects/Types/IHasHold.cs
Normal file
12
osu.Game/Modes/Objects/Types/IHasHold.cs
Normal 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.Objects.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A special type of HitObject, mostly used for legacy conversion of "holds".
|
||||
/// </summary>
|
||||
public interface IHasHold
|
||||
{
|
||||
}
|
||||
}
|
18
osu.Game/Modes/Objects/Types/IHasPosition.cs
Normal file
18
osu.Game/Modes/Objects/Types/IHasPosition.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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;
|
||||
|
||||
namespace osu.Game.Modes.Objects.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitObject that has a starting position.
|
||||
/// </summary>
|
||||
public interface IHasPosition
|
||||
{
|
||||
/// <summary>
|
||||
/// The starting position of the HitObject.
|
||||
/// </summary>
|
||||
Vector2 Position { get; }
|
||||
}
|
||||
}
|
16
osu.Game/Modes/Objects/Types/IHasRepeats.cs
Normal file
16
osu.Game/Modes/Objects/Types/IHasRepeats.cs
Normal file
@ -0,0 +1,16 @@
|
||||
// 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.Objects.Types
|
||||
{
|
||||
/// <summary>
|
||||
/// A HitObject that spans some length.
|
||||
/// </summary>
|
||||
public interface IHasRepeats : IHasEndTime
|
||||
{
|
||||
/// <summary>
|
||||
/// The amount of times the HitObject repeats.
|
||||
/// </summary>
|
||||
int RepeatCount { get; }
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@
|
||||
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;
|
||||
using System;
|
||||
@ -34,8 +33,6 @@ namespace osu.Game.Modes
|
||||
|
||||
public abstract HitRenderer CreateHitRendererWith(WorkingBeatmap beatmap);
|
||||
|
||||
public abstract HitObjectParser CreateHitObjectParser();
|
||||
|
||||
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);
|
||||
|
||||
public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
|
||||
|
@ -2,9 +2,9 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes.Judgements;
|
||||
|
||||
namespace osu.Game.Modes
|
||||
{
|
||||
|
@ -5,25 +5,51 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Modes.Judgements;
|
||||
using osu.Game.Modes.Mods;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using osu.Game.Screens.Play;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Modes.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// Base HitRenderer. Doesn't hold objects.
|
||||
/// <para>
|
||||
/// Should not be derived - derive <see cref="HitRenderer{TObject, TJudgement}"/> instead.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public abstract class HitRenderer : Container
|
||||
{
|
||||
/// <summary>
|
||||
/// The event that's fired when a hit object is judged.
|
||||
/// </summary>
|
||||
public event Action<JudgementInfo> OnJudgement;
|
||||
|
||||
/// <summary>
|
||||
/// The event that's fired when all hit objects have been judged.
|
||||
/// </summary>
|
||||
public event Action OnAllJudged;
|
||||
|
||||
/// <summary>
|
||||
/// The input manager for this HitRenderer.
|
||||
/// </summary>
|
||||
internal readonly PlayerInputManager InputManager = new PlayerInputManager();
|
||||
|
||||
/// <summary>
|
||||
/// The key conversion input manager for this HitRenderer.
|
||||
/// </summary>
|
||||
protected readonly KeyConversionInputManager KeyConversionInputManager;
|
||||
|
||||
/// <summary>
|
||||
/// Whether all the HitObjects have been judged.
|
||||
/// </summary>
|
||||
protected abstract bool AllObjectsJudged { get; }
|
||||
|
||||
protected HitRenderer()
|
||||
{
|
||||
KeyConversionInputManager = CreateKeyConversionInputManager();
|
||||
@ -31,10 +57,9 @@ namespace osu.Game.Modes.UI
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether all the HitObjects have been judged.
|
||||
/// Triggers a judgement for further processing.
|
||||
/// </summary>
|
||||
protected abstract bool AllObjectsJudged { get; }
|
||||
|
||||
/// <param name="j">The judgement to trigger.</param>
|
||||
protected void TriggerOnJudgement(JudgementInfo j)
|
||||
{
|
||||
OnJudgement?.Invoke(j);
|
||||
@ -43,29 +68,92 @@ namespace osu.Game.Modes.UI
|
||||
OnAllJudged?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a key conversion input manager.
|
||||
/// </summary>
|
||||
/// <returns>The input manager.</returns>
|
||||
protected virtual KeyConversionInputManager CreateKeyConversionInputManager() => new KeyConversionInputManager();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HitRenderer 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="HitRenderer{TObject, TJudgement}"/> instead.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">The type of HitObject contained by this HitRenderer.</typeparam>
|
||||
public abstract class HitRenderer<TObject> : HitRenderer
|
||||
where TObject : HitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The Beatmap
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
private Container content;
|
||||
|
||||
protected HitRenderer(WorkingBeatmap beatmap)
|
||||
{
|
||||
Debug.Assert(beatmap != null, "HitRenderer initialized with a null beatmap.");
|
||||
|
||||
// Convert + process the beatmap
|
||||
Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap);
|
||||
Beatmap.HitObjects.ForEach(h => CreateBeatmapProcessor().SetDefaults(h, Beatmap));
|
||||
CreateBeatmapProcessor().PostProcess(Beatmap);
|
||||
|
||||
applyMods(beatmap.Mods.Value);
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the active mods to this HitRenderer.
|
||||
/// </summary>
|
||||
/// <param name="mods"></param>
|
||||
private void applyMods(IEnumerable<Mod> mods)
|
||||
{
|
||||
if (mods == null)
|
||||
return;
|
||||
|
||||
foreach (var mod in mods.OfType<IApplicableMod<TObject>>())
|
||||
mod.Apply(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a converter to convert Beatmap to a specific mode.
|
||||
/// </summary>
|
||||
/// <returns>The Beatmap converter.</returns>
|
||||
protected abstract IBeatmapConverter<TObject> CreateBeatmapConverter();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a processor to perform post-processing operations
|
||||
/// on HitObjects in converted Beatmaps.
|
||||
/// </summary>
|
||||
/// <returns>The Beatmap processor.</returns>
|
||||
protected abstract IBeatmapProcessor<TObject> CreateBeatmapProcessor();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A derivable HitRenderer that manages the Playfield and HitObjects.
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">The type of HitObject contained by this HitRenderer.</typeparam>
|
||||
/// <typeparam name="TJudgement">The type of Judgement of DrawableHitObjects contained by this HitRenderer.</typeparam>
|
||||
public abstract class HitRenderer<TObject, TJudgement> : HitRenderer<TObject>
|
||||
where TObject : HitObject
|
||||
where TJudgement : JudgementInfo
|
||||
{
|
||||
protected override Container<Drawable> Content => content;
|
||||
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
|
||||
|
||||
/// <summary>
|
||||
/// The playfield.
|
||||
/// </summary>
|
||||
protected Playfield<TObject, TJudgement> Playfield;
|
||||
|
||||
private Container content;
|
||||
|
||||
protected HitRenderer(WorkingBeatmap beatmap)
|
||||
: base(beatmap)
|
||||
{
|
||||
KeyConversionInputManager.Add(Playfield = CreatePlayfield());
|
||||
|
||||
InputManager.Add(content = new Container
|
||||
@ -90,7 +178,7 @@ namespace osu.Game.Modes.UI
|
||||
{
|
||||
foreach (TObject h in Beatmap.HitObjects)
|
||||
{
|
||||
DrawableHitObject<TObject> drawableObject = GetVisualRepresentation(h);
|
||||
var drawableObject = GetVisualRepresentation(h);
|
||||
|
||||
if (drawableObject == null)
|
||||
continue;
|
||||
@ -103,19 +191,27 @@ namespace osu.Game.Modes.UI
|
||||
Playfield.PostProcess();
|
||||
}
|
||||
|
||||
private void applyMods(IEnumerable<Mod> mods)
|
||||
/// <summary>
|
||||
/// Triggered when an object's Judgement is updated.
|
||||
/// </summary>
|
||||
/// <param name="judgedObject">The object that Judgement has been updated for.</param>
|
||||
private void onJudgement(DrawableHitObject<TObject, TJudgement> judgedObject)
|
||||
{
|
||||
if (mods == null)
|
||||
return;
|
||||
|
||||
foreach (var mod in mods.OfType<IApplicableMod<TObject>>())
|
||||
mod.Apply(this);
|
||||
TriggerOnJudgement(judgedObject.Judgement);
|
||||
Playfield.OnJudgement(judgedObject);
|
||||
}
|
||||
|
||||
private void onJudgement(DrawableHitObject<TObject> o, JudgementInfo j) => TriggerOnJudgement(j);
|
||||
/// <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);
|
||||
protected abstract Playfield<TObject> CreatePlayfield();
|
||||
protected abstract IBeatmapConverter<TObject> CreateBeatmapConverter();
|
||||
/// <summary>
|
||||
/// Creates a Playfield.
|
||||
/// </summary>
|
||||
/// <returns>The Playfield.</returns>
|
||||
protected abstract Playfield<TObject, TJudgement> CreatePlayfield();
|
||||
}
|
||||
}
|
||||
|
@ -6,22 +6,23 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Objects.Drawables;
|
||||
using OpenTK;
|
||||
using osu.Game.Modes.Judgements;
|
||||
|
||||
namespace osu.Game.Modes.UI
|
||||
{
|
||||
public abstract class Playfield<T> : Container
|
||||
where T : HitObject
|
||||
public abstract class Playfield<TObject, TJudgement> : Container
|
||||
where TObject : HitObject
|
||||
where TJudgement : JudgementInfo
|
||||
{
|
||||
public HitObjectContainer<DrawableHitObject<T>> HitObjects;
|
||||
|
||||
public virtual void Add(DrawableHitObject<T> h) => HitObjects.Add(h);
|
||||
/// <summary>
|
||||
/// The HitObjects contained in this Playfield.
|
||||
/// </summary>
|
||||
public HitObjectContainer<DrawableHitObject<TObject, TJudgement>> HitObjects;
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
internal Container<Drawable> ScaledContent;
|
||||
|
||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
private Container<Drawable> content;
|
||||
|
||||
/// <summary>
|
||||
@ -43,15 +44,28 @@ namespace osu.Game.Modes.UI
|
||||
}
|
||||
});
|
||||
|
||||
Add(HitObjects = new HitObjectContainer<DrawableHitObject<T>>
|
||||
Add(HitObjects = new HitObjectContainer<DrawableHitObject<TObject, TJudgement>>
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
});
|
||||
}
|
||||
|
||||
public virtual void PostProcess()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Performs post-processing tasks (if any) after all DrawableHitObjects are loaded into this Playfield.
|
||||
/// </summary>
|
||||
public virtual void PostProcess() { }
|
||||
|
||||
/// <summary>
|
||||
/// 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);
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when an object's Judgement is updated.
|
||||
/// </summary>
|
||||
/// <param name="judgedObject">The object that Judgement has been updated for.</param>
|
||||
public virtual void OnJudgement(DrawableHitObject<TObject, TJudgement> judgedObject) { }
|
||||
|
||||
private class ScaledContainer : Container
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
// 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 OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
|
@ -21,6 +21,8 @@ using osu.Game.Database;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Modes;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Modes.Objects.Types;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -90,11 +92,14 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
if (beatmap.Beatmap != null)
|
||||
{
|
||||
HitObject lastObject = beatmap.Beatmap.HitObjects.LastOrDefault();
|
||||
double endTime = (lastObject as IHasEndTime)?.EndTime ?? lastObject?.StartTime ?? 0;
|
||||
|
||||
labels.Add(new InfoLabel(new BeatmapStatistic
|
||||
{
|
||||
Name = "Length",
|
||||
Icon = FontAwesome.fa_clock_o,
|
||||
Content = beatmap.Beatmap.HitObjects.Count == 0 ? "-" : TimeSpan.FromMilliseconds(beatmap.Beatmap.HitObjects.Last().EndTime - beatmap.Beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"),
|
||||
Content = beatmap.Beatmap.HitObjects.Count == 0 ? "-" : TimeSpan.FromMilliseconds(endTime - beatmap.Beatmap.HitObjects.First().StartTime).ToString(@"m\:ss"),
|
||||
}));
|
||||
|
||||
labels.Add(new InfoLabel(new BeatmapStatistic
|
||||
|
@ -74,6 +74,7 @@
|
||||
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
||||
<Compile Include="Beatmaps\DifficultyCalculator.cs" />
|
||||
<Compile Include="Beatmaps\IBeatmapCoverter.cs" />
|
||||
<Compile Include="Beatmaps\IBeatmapProcessor.cs" />
|
||||
<Compile Include="Database\ScoreDatabase.cs" />
|
||||
<Compile Include="Graphics\Backgrounds\Triangles.cs" />
|
||||
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
|
||||
@ -98,9 +99,29 @@
|
||||
<Compile Include="Modes\LegacyReplay.cs" />
|
||||
<Compile Include="Modes\Mods\IApplicableMod.cs" />
|
||||
<Compile Include="Modes\Mods\ModType.cs" />
|
||||
<Compile Include="Modes\Objects\Drawables\ArmedState.cs" />
|
||||
<Compile Include="Modes\Objects\Drawables\HitResult.cs" />
|
||||
<Compile Include="Modes\Objects\BezierApproximator.cs" />
|
||||
<Compile Include="Modes\Objects\CircularArcApproximator.cs" />
|
||||
<Compile Include="Modes\Objects\CurvedHitObject.cs" />
|
||||
<Compile Include="Modes\Objects\Legacy\LegacyHit.cs" />
|
||||
<Compile Include="Modes\Objects\LegacyHitObjectParser.cs" />
|
||||
<Compile Include="Modes\Objects\Legacy\LegacyHold.cs" />
|
||||
<Compile Include="Modes\Objects\Legacy\LegacySlider.cs" />
|
||||
<Compile Include="Modes\Objects\Legacy\LegacySpinner.cs" />
|
||||
<Compile Include="Modes\Objects\SliderCurve.cs" />
|
||||
<Compile Include="Modes\Objects\Types\CurveType.cs" />
|
||||
<Compile Include="Modes\Objects\Drawables\IDrawableHitObjectWithProxiedApproach.cs" />
|
||||
<Compile Include="Modes\Judgements\JudgementInfo.cs" />
|
||||
<Compile Include="Modes\Objects\HitObjectParser.cs" />
|
||||
<Compile Include="Modes\Objects\NullHitObjectParser.cs" />
|
||||
<Compile Include="Modes\Objects\Types\IHasCombo.cs" />
|
||||
<Compile Include="Modes\Objects\Types\IHasEndTime.cs" />
|
||||
<Compile Include="Modes\Objects\Types\IHasDistance.cs" />
|
||||
<Compile Include="Modes\Objects\Types\IHasCurve.cs" />
|
||||
<Compile Include="Modes\Objects\Types\IHasRepeats.cs" />
|
||||
<Compile Include="Modes\Objects\Types\IHasPosition.cs" />
|
||||
<Compile Include="Modes\Objects\Types\IHasHold.cs" />
|
||||
<Compile Include="Modes\Objects\Legacy\LegacyHitObjectType.cs" />
|
||||
<Compile Include="Modes\Replay.cs" />
|
||||
<Compile Include="Modes\Score.cs" />
|
||||
<Compile Include="Modes\ScoreProcesssor.cs" />
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
Reference in New Issue
Block a user