1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Merge branch 'master' into add-password-support

This commit is contained in:
smoogipoo 2021-07-19 22:23:09 +09:00
commit b7c2d6b1ab
107 changed files with 2125 additions and 397 deletions

View File

@ -3,6 +3,7 @@ M:System.Object.Equals(System.Object)~System.Boolean;Don't use object.Equals. Us
M:System.ValueType.Equals(System.Object)~System.Boolean;Don't use object.Equals(Fallbacks to ValueType). Use IEquatable<T> or EqualityComparer<T>.Default instead.
M:System.Nullable`1.Equals(System.Object)~System.Boolean;Use == instead.
T:System.IComparable;Don't use non-generic IComparable. Use generic version instead.
T:SixLabors.ImageSharp.IDeepCloneable`1;Use osu.Game.Utils.IDeepCloneable<T> instead.
M:osu.Framework.Graphics.Sprites.SpriteText.#ctor;Use OsuSpriteText.
M:osu.Framework.Bindables.IBindableList`1.GetBoundCopy();Fails on iOS. Use manual ctor + BindTo instead. (see https://github.com/mono/mono/issues/19900)
T:Microsoft.EntityFrameworkCore.Internal.EnumerableExtensions;Don't use internal extension methods.

View File

@ -23,7 +23,7 @@ We are accepting bug reports (please report with as much detail as possible and
- Detailed release changelogs are available on the [official osu! site](https://osu.ppy.sh/home/changelog/lazer).
- You can learn more about our approach to [project management](https://github.com/ppy/osu/wiki/Project-management).
- Read peppy's [latest blog post](https://blog.ppy.sh/a-definitive-lazer-faq/) exploring where the project is currently and the roadmap going forward.
- Read peppy's [blog post](https://blog.ppy.sh/a-definitive-lazer-faq/) exploring where the project is currently and the roadmap going forward.
## Running osu!

View File

@ -6,7 +6,7 @@
<Description>A free-to-win rhythm game. Rhythm is just a *click* away!</Description>
<AssemblyName>osu!</AssemblyName>
<Title>osu!</Title>
<Product>osu!</Product>
<Product>osu!(lazer)</Product>
<ApplicationIcon>lazer.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>0.0.0</Version>

View File

@ -0,0 +1,288 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Utils;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
namespace osu.Game.Rulesets.Catch.Tests
{
[TestFixture]
public class JuiceStreamPathTest
{
[TestCase(1e3, true, false)]
// When the coordinates are large, the slope invariant fails within the specified absolute allowance due to the floating-number precision.
[TestCase(1e9, false, false)]
// Using discrete values sometimes discover more edge cases.
[TestCase(10, true, true)]
public void TestRandomInsertSetPosition(double scale, bool checkSlope, bool integralValues)
{
var rng = new Random(1);
var path = new JuiceStreamPath();
for (int iteration = 0; iteration < 100000; iteration++)
{
if (rng.Next(10) == 0)
path.Clear();
int vertexCount = path.Vertices.Count;
switch (rng.Next(2))
{
case 0:
{
double distance = rng.NextDouble() * scale * 2 - scale;
if (integralValues)
distance = Math.Round(distance);
float oldX = path.PositionAtDistance(distance);
int index = path.InsertVertex(distance);
Assert.That(path.Vertices.Count, Is.EqualTo(vertexCount + 1));
Assert.That(path.Vertices[index].Distance, Is.EqualTo(distance));
Assert.That(path.Vertices[index].X, Is.EqualTo(oldX));
break;
}
case 1:
{
int index = rng.Next(path.Vertices.Count);
double distance = path.Vertices[index].Distance;
float newX = (float)(rng.NextDouble() * scale * 2 - scale);
if (integralValues)
newX = MathF.Round(newX);
path.SetVertexPosition(index, newX);
Assert.That(path.Vertices.Count, Is.EqualTo(vertexCount));
Assert.That(path.Vertices[index].Distance, Is.EqualTo(distance));
Assert.That(path.Vertices[index].X, Is.EqualTo(newX));
break;
}
}
assertInvariants(path.Vertices, checkSlope);
}
}
[Test]
public void TestRemoveVertices()
{
var path = new JuiceStreamPath();
path.Add(10, 5);
path.Add(20, -5);
int removeCount = path.RemoveVertices((v, i) => v.Distance == 10 && i == 1);
Assert.That(removeCount, Is.EqualTo(1));
Assert.That(path.Vertices, Is.EqualTo(new[]
{
new JuiceStreamPathVertex(0, 0),
new JuiceStreamPathVertex(20, -5)
}));
removeCount = path.RemoveVertices((_, i) => i == 0);
Assert.That(removeCount, Is.EqualTo(1));
Assert.That(path.Vertices, Is.EqualTo(new[]
{
new JuiceStreamPathVertex(20, -5)
}));
removeCount = path.RemoveVertices((_, i) => true);
Assert.That(removeCount, Is.EqualTo(1));
Assert.That(path.Vertices, Is.EqualTo(new[]
{
new JuiceStreamPathVertex()
}));
}
[Test]
public void TestResampleVertices()
{
var path = new JuiceStreamPath();
path.Add(-100, -10);
path.Add(100, 50);
path.ResampleVertices(new double[]
{
-50,
0,
70,
120
});
Assert.That(path.Vertices, Is.EqualTo(new[]
{
new JuiceStreamPathVertex(-100, -10),
new JuiceStreamPathVertex(-50, -5),
new JuiceStreamPathVertex(0, 0),
new JuiceStreamPathVertex(70, 35),
new JuiceStreamPathVertex(100, 50),
new JuiceStreamPathVertex(100, 50),
}));
path.Clear();
path.SetVertexPosition(0, 10);
path.ResampleVertices(Array.Empty<double>());
Assert.That(path.Vertices, Is.EqualTo(new[]
{
new JuiceStreamPathVertex(0, 10)
}));
}
[Test]
public void TestRandomConvertFromSliderPath()
{
var rng = new Random(1);
var path = new JuiceStreamPath();
var sliderPath = new SliderPath();
for (int iteration = 0; iteration < 10000; iteration++)
{
sliderPath.ControlPoints.Clear();
do
{
int start = sliderPath.ControlPoints.Count;
do
{
float x = (float)(rng.NextDouble() * 1e3);
float y = (float)(rng.NextDouble() * 1e3);
sliderPath.ControlPoints.Add(new PathControlPoint(new Vector2(x, y)));
} while (rng.Next(2) != 0);
int length = sliderPath.ControlPoints.Count - start + 1;
sliderPath.ControlPoints[start].Type.Value = length <= 2 ? PathType.Linear : length == 3 ? PathType.PerfectCurve : PathType.Bezier;
} while (rng.Next(3) != 0);
if (rng.Next(5) == 0)
sliderPath.ExpectedDistance.Value = rng.NextDouble() * 3e3;
else
sliderPath.ExpectedDistance.Value = null;
path.ConvertFromSliderPath(sliderPath);
Assert.That(path.Vertices[0].Distance, Is.EqualTo(0));
Assert.That(path.Distance, Is.EqualTo(sliderPath.Distance).Within(1e-3));
assertInvariants(path.Vertices, true);
double[] sampleDistances = Enumerable.Range(0, 10)
.Select(_ => rng.NextDouble() * sliderPath.Distance)
.ToArray();
foreach (double distance in sampleDistances)
{
float expected = sliderPath.PositionAt(distance / sliderPath.Distance).X;
Assert.That(path.PositionAtDistance(distance), Is.EqualTo(expected).Within(1e-3));
}
path.ResampleVertices(sampleDistances);
assertInvariants(path.Vertices, true);
foreach (double distance in sampleDistances)
{
float expected = sliderPath.PositionAt(distance / sliderPath.Distance).X;
Assert.That(path.PositionAtDistance(distance), Is.EqualTo(expected).Within(1e-3));
}
}
}
[Test]
public void TestRandomConvertToSliderPath()
{
var rng = new Random(1);
var path = new JuiceStreamPath();
var sliderPath = new SliderPath();
for (int iteration = 0; iteration < 10000; iteration++)
{
path.Clear();
do
{
double distance = rng.NextDouble() * 1e3;
float x = (float)(rng.NextDouble() * 1e3);
path.Add(distance, x);
} while (rng.Next(5) != 0);
float sliderStartY = (float)(rng.NextDouble() * JuiceStreamPath.OSU_PLAYFIELD_HEIGHT);
path.ConvertToSliderPath(sliderPath, sliderStartY);
Assert.That(sliderPath.Distance, Is.EqualTo(path.Distance).Within(1e-3));
Assert.That(sliderPath.ControlPoints[0].Position.Value.X, Is.EqualTo(path.Vertices[0].X));
assertInvariants(path.Vertices, true);
foreach (var point in sliderPath.ControlPoints)
{
Assert.That(point.Type.Value, Is.EqualTo(PathType.Linear).Or.Null);
Assert.That(sliderStartY + point.Position.Value.Y, Is.InRange(0, JuiceStreamPath.OSU_PLAYFIELD_HEIGHT));
}
for (int i = 0; i < 10; i++)
{
double distance = rng.NextDouble() * path.Distance;
float expected = path.PositionAtDistance(distance);
Assert.That(sliderPath.PositionAt(distance / sliderPath.Distance).X, Is.EqualTo(expected).Within(1e-3));
}
}
}
[Test]
public void TestInvalidation()
{
var path = new JuiceStreamPath();
Assert.That(path.InvalidationID, Is.EqualTo(1));
int previousId = path.InvalidationID;
path.InsertVertex(10);
checkNewId();
path.SetVertexPosition(1, 5);
checkNewId();
path.Add(20, 0);
checkNewId();
path.RemoveVertices((v, _) => v.Distance == 20);
checkNewId();
path.ResampleVertices(new double[] { 5, 10, 15 });
checkNewId();
path.Clear();
checkNewId();
path.ConvertFromSliderPath(new SliderPath());
checkNewId();
void checkNewId()
{
Assert.That(path.InvalidationID, Is.Not.EqualTo(previousId));
previousId = path.InvalidationID;
}
}
private void assertInvariants(IReadOnlyList<JuiceStreamPathVertex> vertices, bool checkSlope)
{
Assert.That(vertices, Is.Not.Empty);
for (int i = 0; i < vertices.Count; i++)
{
Assert.That(double.IsFinite(vertices[i].Distance));
Assert.That(float.IsFinite(vertices[i].X));
}
for (int i = 1; i < vertices.Count; i++)
{
Assert.That(vertices[i].Distance, Is.GreaterThanOrEqualTo(vertices[i - 1].Distance));
if (!checkSlope) continue;
float xDiff = Math.Abs(vertices[i].X - vertices[i - 1].X);
double distanceDiff = vertices[i].Distance - vertices[i - 1].Distance;
Assert.That(xDiff, Is.LessThanOrEqualTo(distanceDiff).Within(Precision.FLOAT_EPSILON));
}
}
}
}

View File

@ -23,7 +23,8 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
protected override IEnumerable<CatchHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap, CancellationToken cancellationToken)
{
var positionData = obj as IHasXPosition;
var xPositionData = obj as IHasXPosition;
var yPositionData = obj as IHasYPosition;
var comboData = obj as IHasCombo;
switch (obj)
@ -36,10 +37,11 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
Path = curveData.Path,
NodeSamples = curveData.NodeSamples,
RepeatCount = curveData.RepeatCount,
X = positionData?.X ?? 0,
X = xPositionData?.X ?? 0,
NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0,
LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0
LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0,
LegacyConvertedY = yPositionData?.Y ?? CatchHitObject.DEFAULT_LEGACY_CONVERT_Y
}.Yield();
case IHasDuration endTime:
@ -59,7 +61,8 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
Samples = obj.Samples,
NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0,
X = positionData?.X ?? 0
X = xPositionData?.X ?? 0,
LegacyConvertedY = yPositionData?.Y ?? CatchHitObject.DEFAULT_LEGACY_CONVERT_Y
}.Yield();
}
}

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
@ -33,11 +32,11 @@ namespace osu.Game.Rulesets.Catch.Difficulty
{
mods = Score.Mods;
fruitsHit = Score.Statistics.GetOrDefault(HitResult.Great);
ticksHit = Score.Statistics.GetOrDefault(HitResult.LargeTickHit);
tinyTicksHit = Score.Statistics.GetOrDefault(HitResult.SmallTickHit);
tinyTicksMissed = Score.Statistics.GetOrDefault(HitResult.SmallTickMiss);
misses = Score.Statistics.GetOrDefault(HitResult.Miss);
fruitsHit = Score.Statistics.GetValueOrDefault(HitResult.Great);
ticksHit = Score.Statistics.GetValueOrDefault(HitResult.LargeTickHit);
tinyTicksHit = Score.Statistics.GetValueOrDefault(HitResult.SmallTickHit);
tinyTicksMissed = Score.Statistics.GetValueOrDefault(HitResult.SmallTickMiss);
misses = Score.Statistics.GetValueOrDefault(HitResult.Miss);
// We are heavily relying on aim in catch the beat
double value = Math.Pow(5.0 * Math.Max(1.0, Attributes.StarRating / 0.0049) - 4.0, 2.0) / 100000.0;

View File

@ -19,9 +19,8 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints
{
get
{
float x = HitObject.OriginalX;
float y = HitObjectContainer.PositionAtTime(HitObject.StartTime);
return HitObjectContainer.ToScreenSpace(new Vector2(x, y + HitObjectContainer.DrawHeight));
Vector2 position = CatchHitObjectUtils.GetStartPosition(HitObjectContainer, HitObject);
return HitObjectContainer.ToScreenSpace(position + new Vector2(0, HitObjectContainer.DrawHeight));
}
}

View File

@ -1,14 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Skinning.Default;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;
namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
@ -28,10 +26,8 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
Colour = osuColour.Yellow;
}
public void UpdateFrom(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject hitObject, [CanBeNull] CatchHitObject parent = null)
public void UpdateFrom(CatchHitObject hitObject)
{
X = hitObject.EffectiveX - (parent?.OriginalX ?? 0);
Y = hitObjectContainer.PositionAtTime(hitObject.StartTime, parent?.StartTime ?? hitObjectContainer.Time.Current);
Scale = new Vector2(hitObject.Scale);
}
}

View File

@ -20,12 +20,6 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
Anchor = Anchor.BottomLeft;
}
public void UpdatePositionFrom(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject parentHitObject)
{
X = parentHitObject.OriginalX;
Y = hitObjectContainer.PositionAtTime(parentHitObject.StartTime);
}
public void UpdateNestedObjectsFrom(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject parentHitObject)
{
nestedHitObjects.Clear();
@ -43,7 +37,8 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
{
var hitObject = nestedHitObjects[i];
var outline = (FruitOutline)InternalChildren[i];
outline.UpdateFrom(hitObjectContainer, hitObject, parentHitObject);
outline.Position = CatchHitObjectUtils.GetStartPosition(hitObjectContainer, hitObject) - Position;
outline.UpdateFrom(hitObject);
outline.Scale *= hitObject is Droplet ? 0.5f : 1;
}
}

View File

@ -33,12 +33,6 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints.Components
};
}
public void UpdatePositionFrom(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject hitObject)
{
X = hitObject.OriginalX;
Y = hitObjectContainer.PositionAtTime(hitObject.StartTime);
}
public void UpdatePathFrom(ScrollingHitObjectContainer hitObjectContainer, JuiceStream hitObject)
{
double distanceToYFactor = -hitObjectContainer.LengthAtTime(hitObject.StartTime, hitObject.StartTime + 1 / hitObject.Velocity);

View File

@ -29,7 +29,8 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints
{
base.Update();
outline.UpdateFrom(HitObjectContainer, HitObject);
outline.Position = CatchHitObjectUtils.GetStartPosition(HitObjectContainer, HitObject);
outline.UpdateFrom(HitObject);
}
protected override bool OnMouseDown(MouseDownEvent e)

View File

@ -20,8 +20,10 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints
{
base.Update();
if (IsSelected)
outline.UpdateFrom(HitObjectContainer, HitObject);
if (!IsSelected) return;
outline.Position = CatchHitObjectUtils.GetStartPosition(HitObjectContainer, HitObject);
outline.UpdateFrom(HitObject);
}
}
}

View File

@ -49,8 +49,7 @@ namespace osu.Game.Rulesets.Catch.Edit.Blueprints
if (!IsSelected) return;
scrollingPath.UpdatePositionFrom(HitObjectContainer, HitObject);
nestedOutlineContainer.UpdatePositionFrom(HitObjectContainer, HitObject);
nestedOutlineContainer.Position = scrollingPath.Position = CatchHitObjectUtils.GetStartPosition(HitObjectContainer, HitObject);
if (pathCache.IsValid) return;

View File

@ -0,0 +1,24 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.UI.Scrolling;
using osuTK;
namespace osu.Game.Rulesets.Catch.Edit
{
/// <summary>
/// Utility functions used by the editor.
/// </summary>
public static class CatchHitObjectUtils
{
/// <summary>
/// Get the position of the hit object in the playfield based on <see cref="CatchHitObject.OriginalX"/> and <see cref="HitObject.StartTime"/>.
/// </summary>
public static Vector2 GetStartPosition(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject hitObject)
{
return new Vector2(hitObject.OriginalX, hitObjectContainer.PositionAtTime(hitObject.StartTime));
}
}
}

View File

@ -9,10 +9,11 @@ using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
using osuTK;
namespace osu.Game.Rulesets.Catch.Objects
{
public abstract class CatchHitObject : HitObject, IHasXPosition, IHasComboInformation
public abstract class CatchHitObject : HitObject, IHasPosition, IHasComboInformation
{
public const float OBJECT_RADIUS = 64;
@ -31,8 +32,6 @@ namespace osu.Game.Rulesets.Catch.Objects
set => OriginalXBindable.Value = value;
}
float IHasXPosition.X => OriginalXBindable.Value;
public readonly Bindable<float> XOffsetBindable = new Bindable<float>();
/// <summary>
@ -131,5 +130,24 @@ namespace osu.Game.Rulesets.Catch.Objects
}
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
#region Hit object conversion
// The half of the height of the osu! playfield.
public const float DEFAULT_LEGACY_CONVERT_Y = 192;
/// <summary>
/// The Y position of the hit object is not used in the normal osu!catch gameplay.
/// It is preserved to maximize the backward compatibility with the legacy editor, in which the mappers use the Y position to organize the patterns.
/// </summary>
public float LegacyConvertedY { get; set; } = DEFAULT_LEGACY_CONVERT_Y;
float IHasXPosition.X => OriginalX;
float IHasYPosition.Y => LegacyConvertedY;
Vector2 IHasPosition.Position => new Vector2(OriginalX, LegacyConvertedY);
#endregion
}
}

View File

@ -0,0 +1,340 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Utils;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
#nullable enable
namespace osu.Game.Rulesets.Catch.Objects
{
/// <summary>
/// Represents the path of a juice stream.
/// <para>
/// A <see cref="JuiceStream"/> holds a legacy <see cref="SliderPath"/> as the representation of the path.
/// However, the <see cref="SliderPath"/> representation is difficult to work with.
/// This <see cref="JuiceStreamPath"/> represents the path in a more convenient way, a polyline connecting list of <see cref="JuiceStreamPathVertex"/>s.
/// </para>
/// <para>
/// The path can be regarded as a function from the closed interval <c>[Vertices[0].Distance, Vertices[^1].Distance]</c> to the x position, given by <see cref="PositionAtDistance"/>.
/// To ensure the path is convertible to a <see cref="SliderPath"/>, the slope of the function must not be more than <c>1</c> everywhere,
/// and this slope condition is always maintained as an invariant.
/// </para>
/// </summary>
public class JuiceStreamPath
{
/// <summary>
/// The height of legacy osu!standard playfield.
/// The sliders converted by <see cref="ConvertToSliderPath"/> are vertically contained in this height.
/// </summary>
internal const float OSU_PLAYFIELD_HEIGHT = 384;
/// <summary>
/// The list of vertices of the path, which is represented as a polyline connecting the vertices.
/// </summary>
public IReadOnlyList<JuiceStreamPathVertex> Vertices => vertices;
/// <summary>
/// The current version number.
/// This starts from <c>1</c> and incremented whenever this <see cref="JuiceStreamPath"/> is modified.
/// </summary>
public int InvalidationID { get; private set; } = 1;
/// <summary>
/// The difference between first vertex's <see cref="JuiceStreamPathVertex.Distance"/> and last vertex's <see cref="JuiceStreamPathVertex.Distance"/>.
/// </summary>
public double Distance => vertices[^1].Distance - vertices[0].Distance;
/// <remarks>
/// This list should always be non-empty.
/// </remarks>
private readonly List<JuiceStreamPathVertex> vertices = new List<JuiceStreamPathVertex>
{
new JuiceStreamPathVertex()
};
/// <summary>
/// Compute the x-position of the path at the given <paramref name="distance"/>.
/// </summary>
/// <remarks>
/// When the given distance is outside of the path, the x position at the corresponding endpoint is returned,
/// </remarks>
public float PositionAtDistance(double distance)
{
int index = vertexIndexAtDistance(distance);
return positionAtDistance(distance, index);
}
/// <summary>
/// Remove all vertices of this path, then add a new vertex <c>(0, 0)</c>.
/// </summary>
public void Clear()
{
vertices.Clear();
vertices.Add(new JuiceStreamPathVertex());
invalidate();
}
/// <summary>
/// Insert a vertex at given <paramref name="distance"/>.
/// The <see cref="PositionAtDistance"/> is used as the position of the new vertex.
/// Thus, the set of points of the path is not changed (up to floating-point precision).
/// </summary>
/// <returns>The index of the new vertex.</returns>
public int InsertVertex(double distance)
{
if (!double.IsFinite(distance))
throw new ArgumentOutOfRangeException(nameof(distance));
int index = vertexIndexAtDistance(distance);
float x = positionAtDistance(distance, index);
vertices.Insert(index, new JuiceStreamPathVertex(distance, x));
invalidate();
return index;
}
/// <summary>
/// Move the vertex of given <paramref name="index"/> to the given position <paramref name="newX"/>.
/// When the distances between vertices are too small for the new vertex positions, the adjacent vertices are moved towards <paramref name="newX"/>.
/// </summary>
public void SetVertexPosition(int index, float newX)
{
if (index < 0 || index >= vertices.Count)
throw new ArgumentOutOfRangeException(nameof(index));
if (!float.IsFinite(newX))
throw new ArgumentOutOfRangeException(nameof(newX));
var newVertex = new JuiceStreamPathVertex(vertices[index].Distance, newX);
for (int i = index - 1; i >= 0 && !canConnect(vertices[i], newVertex); i--)
{
float clampedX = clampToConnectablePosition(newVertex, vertices[i]);
vertices[i] = new JuiceStreamPathVertex(vertices[i].Distance, clampedX);
}
for (int i = index + 1; i < vertices.Count; i++)
{
float clampedX = clampToConnectablePosition(newVertex, vertices[i]);
vertices[i] = new JuiceStreamPathVertex(vertices[i].Distance, clampedX);
}
vertices[index] = newVertex;
invalidate();
}
/// <summary>
/// Add a new vertex at given <paramref name="distance"/> and position.
/// Adjacent vertices are moved when necessary in the same way as <see cref="SetVertexPosition"/>.
/// </summary>
public void Add(double distance, float x)
{
int index = InsertVertex(distance);
SetVertexPosition(index, x);
}
/// <summary>
/// Remove all vertices that satisfy the given <paramref name="predicate"/>.
/// </summary>
/// <remarks>
/// If all vertices are removed, a new vertex <c>(0, 0)</c> is added.
/// </remarks>
/// <param name="predicate">The predicate to determine whether a vertex should be removed given the vertex and its index in the path.</param>
/// <returns>The number of removed vertices.</returns>
public int RemoveVertices(Func<JuiceStreamPathVertex, int, bool> predicate)
{
int index = 0;
int removeCount = vertices.RemoveAll(vertex => predicate(vertex, index++));
if (vertices.Count == 0)
vertices.Add(new JuiceStreamPathVertex());
if (removeCount != 0)
invalidate();
return removeCount;
}
/// <summary>
/// Recreate this path by using difference set of vertices at given distances.
/// In addition to the given <paramref name="sampleDistances"/>, the first vertex and the last vertex are always added to the new path.
/// New vertices use the positions on the original path. Thus, <see cref="PositionAtDistance"/>s at <paramref name="sampleDistances"/> are preserved.
/// </summary>
public void ResampleVertices(IEnumerable<double> sampleDistances)
{
var sampledVertices = new List<JuiceStreamPathVertex>();
foreach (double distance in sampleDistances)
{
if (!double.IsFinite(distance))
throw new ArgumentOutOfRangeException(nameof(sampleDistances));
double clampedDistance = Math.Clamp(distance, vertices[0].Distance, vertices[^1].Distance);
float x = PositionAtDistance(clampedDistance);
sampledVertices.Add(new JuiceStreamPathVertex(clampedDistance, x));
}
sampledVertices.Sort();
// The first vertex and the last vertex are always used in the result.
vertices.RemoveRange(1, vertices.Count - (vertices.Count == 1 ? 1 : 2));
vertices.InsertRange(1, sampledVertices);
invalidate();
}
/// <summary>
/// Convert a <see cref="SliderPath"/> to list of vertices and write the result to this <see cref="JuiceStreamPath"/>.
/// </summary>
/// <remarks>
/// Duplicated vertices are automatically removed.
/// </remarks>
public void ConvertFromSliderPath(SliderPath sliderPath)
{
var sliderPathVertices = new List<Vector2>();
sliderPath.GetPathToProgress(sliderPathVertices, 0, 1);
double distance = 0;
vertices.Clear();
vertices.Add(new JuiceStreamPathVertex(0, sliderPathVertices.FirstOrDefault().X));
for (int i = 1; i < sliderPathVertices.Count; i++)
{
distance += Vector2.Distance(sliderPathVertices[i - 1], sliderPathVertices[i]);
if (!Precision.AlmostEquals(vertices[^1].Distance, distance))
vertices.Add(new JuiceStreamPathVertex(distance, sliderPathVertices[i].X));
}
invalidate();
}
/// <summary>
/// Convert the path of this <see cref="JuiceStreamPath"/> to a <see cref="SliderPath"/> and write the result to <paramref name="sliderPath"/>.
/// The resulting slider is "folded" to make it vertically contained in the playfield `(0..<see cref="OSU_PLAYFIELD_HEIGHT"/>)` assuming the slider start position is <paramref name="sliderStartY"/>.
/// </summary>
public void ConvertToSliderPath(SliderPath sliderPath, float sliderStartY)
{
const float margin = 1;
// Note: these two variables and `sliderPath` are modified by the local functions.
double currentDistance = 0;
Vector2 lastPosition = new Vector2(vertices[0].X, 0);
sliderPath.ControlPoints.Clear();
sliderPath.ControlPoints.Add(new PathControlPoint(lastPosition));
for (int i = 1; i < vertices.Count; i++)
{
sliderPath.ControlPoints[^1].Type.Value = PathType.Linear;
float deltaX = vertices[i].X - lastPosition.X;
double length = vertices[i].Distance - currentDistance;
// Should satisfy `deltaX^2 + deltaY^2 = length^2`.
// By invariants, the expression inside the `sqrt` is (almost) non-negative.
double deltaY = Math.Sqrt(Math.Max(0, length * length - (double)deltaX * deltaX));
// When `deltaY` is small, one segment is always enough.
// This case is handled separately to prevent divide-by-zero.
if (deltaY <= OSU_PLAYFIELD_HEIGHT / 2 - margin)
{
float nextX = vertices[i].X;
float nextY = (float)(lastPosition.Y + getYDirection() * deltaY);
addControlPoint(nextX, nextY);
continue;
}
// When `deltaY` is large or when the slider velocity is fast, the segment must be partitioned to subsegments to stay in bounds.
for (double currentProgress = 0; currentProgress < deltaY;)
{
double nextProgress = Math.Min(currentProgress + getMaxDeltaY(), deltaY);
float nextX = (float)(vertices[i - 1].X + nextProgress / deltaY * deltaX);
float nextY = (float)(lastPosition.Y + getYDirection() * (nextProgress - currentProgress));
addControlPoint(nextX, nextY);
currentProgress = nextProgress;
}
}
int getYDirection()
{
float lastSliderY = sliderStartY + lastPosition.Y;
return lastSliderY < OSU_PLAYFIELD_HEIGHT / 2 ? 1 : -1;
}
float getMaxDeltaY()
{
float lastSliderY = sliderStartY + lastPosition.Y;
return Math.Max(lastSliderY, OSU_PLAYFIELD_HEIGHT - lastSliderY) - margin;
}
void addControlPoint(float nextX, float nextY)
{
Vector2 nextPosition = new Vector2(nextX, nextY);
sliderPath.ControlPoints.Add(new PathControlPoint(nextPosition));
currentDistance += Vector2.Distance(lastPosition, nextPosition);
lastPosition = nextPosition;
}
}
/// <summary>
/// Find the index at which a new vertex with <paramref name="distance"/> can be inserted.
/// </summary>
private int vertexIndexAtDistance(double distance)
{
// The position of `(distance, Infinity)` is uniquely determined because infinite positions are not allowed.
int i = vertices.BinarySearch(new JuiceStreamPathVertex(distance, float.PositiveInfinity));
return i < 0 ? ~i : i;
}
/// <summary>
/// Compute the position at the given <paramref name="distance"/>, assuming <paramref name="index"/> is the vertex index returned by <see cref="vertexIndexAtDistance"/>.
/// </summary>
private float positionAtDistance(double distance, int index)
{
if (index <= 0)
return vertices[0].X;
if (index >= vertices.Count)
return vertices[^1].X;
double length = vertices[index].Distance - vertices[index - 1].Distance;
if (Precision.AlmostEquals(length, 0))
return vertices[index].X;
float deltaX = vertices[index].X - vertices[index - 1].X;
return (float)(vertices[index - 1].X + deltaX * ((distance - vertices[index - 1].Distance) / length));
}
/// <summary>
/// Check the two vertices can connected directly while satisfying the slope condition.
/// </summary>
private bool canConnect(JuiceStreamPathVertex vertex1, JuiceStreamPathVertex vertex2, float allowance = 0)
{
double xDistance = Math.Abs((double)vertex2.X - vertex1.X);
float length = (float)Math.Abs(vertex2.Distance - vertex1.Distance);
return xDistance <= length + allowance;
}
/// <summary>
/// Move the position of <paramref name="movableVertex"/> towards the position of <paramref name="fixedVertex"/>
/// until the vertex pair satisfies the condition <see cref="canConnect"/>.
/// </summary>
/// <returns>The resulting position of <paramref name="movableVertex"/>.</returns>
private float clampToConnectablePosition(JuiceStreamPathVertex fixedVertex, JuiceStreamPathVertex movableVertex)
{
float length = (float)Math.Abs(movableVertex.Distance - fixedVertex.Distance);
return Math.Clamp(movableVertex.X, fixedVertex.X - length, fixedVertex.X + length);
}
private void invalidate() => InvalidationID++;
}
}

View File

@ -0,0 +1,33 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
#nullable enable
namespace osu.Game.Rulesets.Catch.Objects
{
/// <summary>
/// A vertex of a <see cref="JuiceStreamPath"/>.
/// </summary>
public readonly struct JuiceStreamPathVertex : IComparable<JuiceStreamPathVertex>
{
public readonly double Distance;
public readonly float X;
public JuiceStreamPathVertex(double distance, float x)
{
Distance = distance;
X = x;
}
public int CompareTo(JuiceStreamPathVertex other)
{
int c = Distance.CompareTo(other.Distance);
return c != 0 ? c : X.CompareTo(other.X);
}
public override string ToString() => $"({Distance}, {X})";
}
}

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
@ -37,12 +36,12 @@ namespace osu.Game.Rulesets.Mania.Difficulty
{
mods = Score.Mods;
scaledScore = Score.TotalScore;
countPerfect = Score.Statistics.GetOrDefault(HitResult.Perfect);
countGreat = Score.Statistics.GetOrDefault(HitResult.Great);
countGood = Score.Statistics.GetOrDefault(HitResult.Good);
countOk = Score.Statistics.GetOrDefault(HitResult.Ok);
countMeh = Score.Statistics.GetOrDefault(HitResult.Meh);
countMiss = Score.Statistics.GetOrDefault(HitResult.Miss);
countPerfect = Score.Statistics.GetValueOrDefault(HitResult.Perfect);
countGreat = Score.Statistics.GetValueOrDefault(HitResult.Great);
countGood = Score.Statistics.GetValueOrDefault(HitResult.Good);
countOk = Score.Statistics.GetValueOrDefault(HitResult.Ok);
countMeh = Score.Statistics.GetValueOrDefault(HitResult.Meh);
countMiss = Score.Statistics.GetValueOrDefault(HitResult.Miss);
IEnumerable<Mod> scoreIncreaseMods = Ruleset.GetModsFor(ModType.DifficultyIncrease);

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Mania
{
public class ManiaSettingsSubsection : RulesetSettingsSubsection
{
protected override string Header => "osu!mania";
protected override LocalisableString Header => "osu!mania";
public ManiaSettingsSubsection(ManiaRuleset ruleset)
: base(ruleset)

View File

@ -22,6 +22,10 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
// Leaving the default (10s) makes hitobjects not appear, as this offset is used for the initial state transforms.
// Calculated as DrawableManiaRuleset.MAX_TIME_RANGE + some additional allowance for velocity < 1.
protected override double InitialLifetimeOffset => 30000;
[Resolved(canBeNull: true)]
private ManiaPlayfield playfield { get; set; }

View File

@ -33,12 +33,12 @@ namespace osu.Game.Rulesets.Mania.UI
/// <summary>
/// The minimum time range. This occurs at a <see cref="relativeTimeRange"/> of 40.
/// </summary>
public const double MIN_TIME_RANGE = 340;
public const double MIN_TIME_RANGE = 290;
/// <summary>
/// The maximum time range. This occurs at a <see cref="relativeTimeRange"/> of 1.
/// </summary>
public const double MAX_TIME_RANGE = 13720;
public const double MAX_TIME_RANGE = 11485;
protected new ManiaPlayfield Playfield => (ManiaPlayfield)base.Playfield;
@ -67,7 +67,7 @@ namespace osu.Game.Rulesets.Mania.UI
protected override ScrollVisualisationMethod VisualisationMethod => scrollMethod;
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
private readonly Bindable<double> configTimeRange = new BindableDouble();
private readonly BindableDouble configTimeRange = new BindableDouble();
// Stores the current speed adjustment active in gameplay.
private readonly Track speedAdjustmentTrack = new TrackVirtual(0);
@ -103,6 +103,8 @@ namespace osu.Game.Rulesets.Mania.UI
configDirection.BindValueChanged(direction => Direction.Value = (ScrollingDirection)direction.NewValue, true);
Config.BindWith(ManiaRulesetSetting.ScrollTime, configTimeRange);
TimeRange.MinValue = configTimeRange.MinValue;
TimeRange.MaxValue = configTimeRange.MaxValue;
}
protected override void AdjustScrollSpeed(int amount)

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Mods;
@ -36,10 +35,10 @@ namespace osu.Game.Rulesets.Osu.Difficulty
mods = Score.Mods;
accuracy = Score.Accuracy;
scoreMaxCombo = Score.MaxCombo;
countGreat = Score.Statistics.GetOrDefault(HitResult.Great);
countOk = Score.Statistics.GetOrDefault(HitResult.Ok);
countMeh = Score.Statistics.GetOrDefault(HitResult.Meh);
countMiss = Score.Statistics.GetOrDefault(HitResult.Miss);
countGreat = Score.Statistics.GetValueOrDefault(HitResult.Great);
countOk = Score.Statistics.GetValueOrDefault(HitResult.Ok);
countMeh = Score.Statistics.GetValueOrDefault(HitResult.Meh);
countMiss = Score.Statistics.GetValueOrDefault(HitResult.Miss);
// Custom multipliers for NoFail and SpunOut.
double multiplier = 1.12; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things
@ -98,11 +97,13 @@ namespace osu.Game.Rulesets.Osu.Difficulty
double approachRateFactor = 0.0;
if (Attributes.ApproachRate > 10.33)
approachRateFactor += 0.4 * (Attributes.ApproachRate - 10.33);
approachRateFactor = Attributes.ApproachRate - 10.33;
else if (Attributes.ApproachRate < 8.0)
approachRateFactor += 0.01 * (8.0 - Attributes.ApproachRate);
approachRateFactor = 0.025 * (8.0 - Attributes.ApproachRate);
aimValue *= 1.0 + Math.Min(approachRateFactor, approachRateFactor * (totalHits / 1000.0));
double approachRateTotalHitsFactor = 1.0 / (1.0 + Math.Exp(-(0.007 * (totalHits - 400))));
aimValue *= 1.0 + (0.03 + 0.37 * approachRateTotalHitsFactor) * approachRateFactor;
// We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR.
if (mods.Any(h => h is OsuModHidden))
@ -145,9 +146,11 @@ namespace osu.Game.Rulesets.Osu.Difficulty
double approachRateFactor = 0.0;
if (Attributes.ApproachRate > 10.33)
approachRateFactor += 0.4 * (Attributes.ApproachRate - 10.33);
approachRateFactor = Attributes.ApproachRate - 10.33;
speedValue *= 1.0 + Math.Min(approachRateFactor, approachRateFactor * (totalHits / 1000.0));
double approachRateTotalHitsFactor = 1.0 / (1.0 + Math.Exp(-(0.007 * (totalHits - 400))));
speedValue *= 1.0 + (0.03 + 0.37 * approachRateTotalHitsFactor) * approachRateFactor;
if (mods.Any(m => m is OsuModHidden))
speedValue *= 1.0 + 0.04 * (12.0 - Attributes.ApproachRate);

View File

@ -1,13 +1,43 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Timing;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.Osu.Utils;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModTarget : Mod
public class OsuModTarget : ModWithVisibilityAdjustment, IApplicableToDrawableRuleset<OsuHitObject>,
IApplicableToHealthProcessor, IApplicableToDifficulty, IApplicableFailOverride,
IHasSeed, IHidesApproachCircles
{
public override string Name => "Target";
public override string Acronym => "TP";
@ -15,5 +45,510 @@ namespace osu.Game.Rulesets.Osu.Mods
public override IconUsage? Icon => OsuIcon.ModTarget;
public override string Description => @"Practice keeping up with the beat of the song.";
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles) };
[SettingSource("Seed", "Use a custom seed instead of a random one", SettingControlType = typeof(SettingsNumberBox))]
public Bindable<int?> Seed { get; } = new Bindable<int?>
{
Default = null,
Value = null
};
#region Constants
/// <summary>
/// Jump distance for circles in the last combo
/// </summary>
private const float max_base_distance = 333f;
/// <summary>
/// The maximum allowed jump distance after multipliers are applied
/// </summary>
private const float distance_cap = 380f;
// The distances from the hit objects to the borders of the playfield they start to "turn around" and curve towards the middle.
// The closer the hit objects draw to the border, the sharper the turn
private const byte border_distance_x = 192;
private const byte border_distance_y = 144;
/// <summary>
/// The extent of rotation towards playfield centre when a circle is near the edge
/// </summary>
private const float edge_rotation_multiplier = 0.75f;
/// <summary>
/// Number of recent circles to check for overlap
/// </summary>
private const int overlap_check_count = 5;
/// <summary>
/// Duration of the undimming animation
/// </summary>
private const double undim_duration = 96;
/// <summary>
/// Acceptable difference for timing comparisons
/// </summary>
private const double timing_precision = 1;
#endregion
#region Private Fields
private ControlPointInfo controlPointInfo;
private List<OsuHitObject> originalHitObjects;
private Random rng;
#endregion
#region Sudden Death (IApplicableFailOverride)
public bool PerformFail() => true;
public bool RestartOnFail => false;
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
{
// Sudden death
healthProcessor.FailConditions += (_, result)
=> result.Type.AffectsCombo()
&& !result.IsHit;
}
#endregion
#region Reduce AR (IApplicableToDifficulty)
public void ReadFromDifficulty(BeatmapDifficulty difficulty)
{
}
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
// Decrease AR to increase preempt time
difficulty.ApproachRate *= 0.5f;
}
#endregion
#region Circle Transforms (ModWithVisibilityAdjustment)
protected override void ApplyIncreasedVisibilityState(DrawableHitObject drawable, ArmedState state)
{
}
protected override void ApplyNormalVisibilityState(DrawableHitObject drawable, ArmedState state)
{
if (!(drawable is DrawableHitCircle circle)) return;
double startTime = circle.HitObject.StartTime;
double preempt = circle.HitObject.TimePreempt;
using (circle.BeginAbsoluteSequence(startTime - preempt))
{
// initial state
circle.ScaleTo(0.5f)
.FadeColour(OsuColour.Gray(0.5f));
// scale to final size
circle.ScaleTo(1f, preempt);
// Remove approach circles
circle.ApproachCircle.Hide();
}
using (circle.BeginAbsoluteSequence(startTime - controlPointInfo.TimingPointAt(startTime).BeatLength - undim_duration))
circle.FadeColour(Color4.White, undim_duration);
}
#endregion
#region Beatmap Generation (IApplicableToBeatmap)
public override void ApplyToBeatmap(IBeatmap beatmap)
{
Seed.Value ??= RNG.Next();
rng = new Random(Seed.Value.Value);
var osuBeatmap = (OsuBeatmap)beatmap;
if (osuBeatmap.HitObjects.Count == 0) return;
controlPointInfo = osuBeatmap.ControlPointInfo;
originalHitObjects = osuBeatmap.HitObjects.OrderBy(x => x.StartTime).ToList();
var hitObjects = generateBeats(osuBeatmap)
.Select(beat =>
{
var newCircle = new HitCircle();
newCircle.ApplyDefaults(controlPointInfo, osuBeatmap.BeatmapInfo.BaseDifficulty);
newCircle.StartTime = beat;
return (OsuHitObject)newCircle;
}).ToList();
addHitSamples(hitObjects);
fixComboInfo(hitObjects);
randomizeCirclePos(hitObjects);
osuBeatmap.HitObjects = hitObjects;
base.ApplyToBeatmap(beatmap);
}
private IEnumerable<double> generateBeats(IBeatmap beatmap)
{
var startTime = originalHitObjects.First().StartTime;
var endTime = originalHitObjects.Last().GetEndTime();
var beats = beatmap.ControlPointInfo.TimingPoints
// Ignore timing points after endTime
.Where(timingPoint => !definitelyBigger(timingPoint.Time, endTime))
// Generate the beats
.SelectMany(timingPoint => getBeatsForTimingPoint(timingPoint, endTime))
// Remove beats before startTime
.Where(beat => almostBigger(beat, startTime))
// Remove beats during breaks
.Where(beat => !isInsideBreakPeriod(beatmap.Breaks, beat))
.ToList();
// Remove beats that are too close to the next one (e.g. due to timing point changes)
for (var i = beats.Count - 2; i >= 0; i--)
{
var beat = beats[i];
if (!definitelyBigger(beats[i + 1] - beat, beatmap.ControlPointInfo.TimingPointAt(beat).BeatLength / 2))
beats.RemoveAt(i);
}
return beats;
}
private void addHitSamples(IEnumerable<OsuHitObject> hitObjects)
{
foreach (var obj in hitObjects)
{
var samples = getSamplesAtTime(originalHitObjects, obj.StartTime);
// If samples aren't available at the exact start time of the object,
// use samples (without additions) in the closest original hit object instead
obj.Samples = samples ?? getClosestHitObject(originalHitObjects, obj.StartTime).Samples.Where(s => !HitSampleInfo.AllAdditions.Contains(s.Name)).ToList();
}
}
private void fixComboInfo(List<OsuHitObject> hitObjects)
{
// Copy combo indices from an original object at the same time or from the closest preceding object
// (Objects lying between two combos are assumed to belong to the preceding combo)
hitObjects.ForEach(newObj =>
{
var closestOrigObj = originalHitObjects.FindLast(y => almostBigger(newObj.StartTime, y.StartTime));
// It shouldn't be possible for closestOrigObj to be null
// But if it is, obj should be in the first combo
newObj.ComboIndex = closestOrigObj?.ComboIndex ?? 0;
});
// The copied combo indices may not be continuous if the original map starts and ends a combo in between beats
// e.g. A stream with each object starting a new combo
// So combo indices need to be reprocessed to ensure continuity
// Other kinds of combo info are also added in the process
var combos = hitObjects.GroupBy(x => x.ComboIndex).ToList();
for (var i = 0; i < combos.Count; i++)
{
var group = combos[i].ToList();
group.First().NewCombo = true;
group.Last().LastInCombo = true;
for (var j = 0; j < group.Count; j++)
{
var x = group[j];
x.ComboIndex = i;
x.IndexInCurrentCombo = j;
}
}
}
private void randomizeCirclePos(IReadOnlyList<OsuHitObject> hitObjects)
{
if (hitObjects.Count == 0) return;
float nextSingle(float max = 1f) => (float)(rng.NextDouble() * max);
const float two_pi = MathF.PI * 2;
var direction = two_pi * nextSingle();
var maxComboIndex = hitObjects.Last().ComboIndex;
for (var i = 0; i < hitObjects.Count; i++)
{
var obj = hitObjects[i];
var lastPos = i == 0
? Vector2.Divide(OsuPlayfield.BASE_SIZE, 2)
: hitObjects[i - 1].Position;
var distance = maxComboIndex == 0
? (float)obj.Radius
: mapRange(obj.ComboIndex, 0, maxComboIndex, (float)obj.Radius, max_base_distance);
if (obj.NewCombo) distance *= 1.5f;
if (obj.Kiai) distance *= 1.2f;
distance = Math.Min(distance_cap, distance);
// Attempt to place the circle at a place that does not overlap with previous ones
var tryCount = 0;
// for checking overlap
var precedingObjects = hitObjects.SkipLast(hitObjects.Count - i).TakeLast(overlap_check_count).ToList();
do
{
if (tryCount > 0) direction = two_pi * nextSingle();
var relativePos = new Vector2(
distance * MathF.Cos(direction),
distance * MathF.Sin(direction)
);
// Rotate the new circle away from playfield border
relativePos = OsuHitObjectGenerationUtils.RotateAwayFromEdge(lastPos, relativePos, edge_rotation_multiplier);
direction = MathF.Atan2(relativePos.Y, relativePos.X);
var newPosition = Vector2.Add(lastPos, relativePos);
obj.Position = newPosition;
clampToPlayfield(obj);
tryCount++;
if (tryCount % 10 == 0) distance *= 0.9f;
} while (distance >= obj.Radius * 2 && checkForOverlap(precedingObjects, obj));
if (obj.LastInCombo)
direction = two_pi * nextSingle();
else
direction += distance / distance_cap * (nextSingle() * two_pi - MathF.PI);
}
}
#endregion
#region Metronome (IApplicableToDrawableRuleset)
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
drawableRuleset.Overlays.Add(new TargetBeatContainer(drawableRuleset.Beatmap.HitObjects.First().StartTime));
}
public class TargetBeatContainer : BeatSyncedContainer
{
private readonly double firstHitTime;
private PausableSkinnableSound sample;
public TargetBeatContainer(double firstHitTime)
{
this.firstHitTime = firstHitTime;
Divisor = 1;
}
[BackgroundDependencyLoader]
private void load()
{
InternalChildren = new Drawable[]
{
sample = new PausableSkinnableSound(new SampleInfo("Gameplay/catch-banana"))
};
}
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
{
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
if (!IsBeatSyncedWithTrack) return;
int timeSignature = (int)timingPoint.TimeSignature;
// play metronome from one measure before the first object.
// TODO: Use BeatSyncClock from https://github.com/ppy/osu/pull/13894.
if (Clock.CurrentTime < firstHitTime - timingPoint.BeatLength * timeSignature)
return;
sample.Frequency.Value = beatIndex % timeSignature == 0 ? 1 : 0.5f;
sample.Play();
}
}
#endregion
#region Helper Subroutines
/// <summary>
/// Check if a given time is inside a <see cref="BreakPeriod"/>.
/// </summary>
/// <remarks>
/// The given time is also considered to be inside a break if it is earlier than the
/// start time of the first original hit object after the break.
/// </remarks>
/// <param name="breaks">The breaks of the beatmap.</param>
/// <param name="time">The time to be checked.</param>=
private bool isInsideBreakPeriod(IEnumerable<BreakPeriod> breaks, double time)
{
return breaks.Any(breakPeriod =>
{
var firstObjAfterBreak = originalHitObjects.First(obj => almostBigger(obj.StartTime, breakPeriod.EndTime));
return almostBigger(time, breakPeriod.StartTime)
&& definitelyBigger(firstObjAfterBreak.StartTime, time);
});
}
private IEnumerable<double> getBeatsForTimingPoint(TimingControlPoint timingPoint, double mapEndTime)
{
var beats = new List<double>();
int i = 0;
var currentTime = timingPoint.Time;
while (!definitelyBigger(currentTime, mapEndTime) && controlPointInfo.TimingPointAt(currentTime) == timingPoint)
{
beats.Add(Math.Floor(currentTime));
i++;
currentTime = timingPoint.Time + i * timingPoint.BeatLength;
}
return beats;
}
private OsuHitObject getClosestHitObject(List<OsuHitObject> hitObjects, double time)
{
var precedingIndex = hitObjects.FindLastIndex(h => h.StartTime < time);
if (precedingIndex == hitObjects.Count - 1) return hitObjects[precedingIndex];
// return the closest preceding/succeeding hit object, whoever is closer in time
return hitObjects[precedingIndex + 1].StartTime - time < time - hitObjects[precedingIndex].StartTime
? hitObjects[precedingIndex + 1]
: hitObjects[precedingIndex];
}
/// <summary>
/// Get samples (if any) for a specific point in time.
/// </summary>
/// <remarks>
/// Samples will be returned if a hit circle or a slider node exists at that point of time.
/// </remarks>
/// <param name="hitObjects">The list of hit objects in a beatmap, ordered by StartTime</param>
/// <param name="time">The point in time to get samples for</param>
/// <returns>Hit samples</returns>
private IList<HitSampleInfo> getSamplesAtTime(IEnumerable<OsuHitObject> hitObjects, double time)
{
// Get a hit object that
// either has StartTime equal to the target time
// or has a repeat node at the target time
var sampleObj = hitObjects.FirstOrDefault(hitObject =>
{
if (almostEquals(time, hitObject.StartTime))
return true;
if (!(hitObject is IHasRepeats s))
return false;
// If time is outside the duration of the IHasRepeats,
// then this hitObject isn't the one we want
if (!almostBigger(time, hitObject.StartTime)
|| !almostBigger(s.EndTime, time))
return false;
return nodeIndexFromTime(s, time - hitObject.StartTime) != -1;
});
if (sampleObj == null) return null;
IList<HitSampleInfo> samples;
if (sampleObj is IHasRepeats slider)
samples = slider.NodeSamples[nodeIndexFromTime(slider, time - sampleObj.StartTime)];
else
samples = sampleObj.Samples;
return samples;
}
/// <summary>
/// Get the repeat node at a point in time.
/// </summary>
/// <param name="curve">The slider.</param>
/// <param name="timeSinceStart">The time since the start time of the slider.</param>
/// <returns>Index of the node. -1 if there isn't a node at the specific time.</returns>
private int nodeIndexFromTime(IHasRepeats curve, double timeSinceStart)
{
double spanDuration = curve.Duration / curve.SpanCount();
double nodeIndex = timeSinceStart / spanDuration;
if (almostEquals(nodeIndex, Math.Round(nodeIndex)))
return (int)Math.Round(nodeIndex);
return -1;
}
private bool checkForOverlap(IEnumerable<OsuHitObject> objectsToCheck, OsuHitObject target)
{
return objectsToCheck.Any(h => Vector2.Distance(h.Position, target.Position) < target.Radius * 2);
}
/// <summary>
/// Move the hit object into playfield, taking its radius into account.
/// </summary>
/// <param name="obj">The hit object to be clamped.</param>
private void clampToPlayfield(OsuHitObject obj)
{
var position = obj.Position;
var radius = (float)obj.Radius;
if (position.Y < radius)
position.Y = radius;
else if (position.Y > OsuPlayfield.BASE_SIZE.Y - radius)
position.Y = OsuPlayfield.BASE_SIZE.Y - radius;
if (position.X < radius)
position.X = radius;
else if (position.X > OsuPlayfield.BASE_SIZE.X - radius)
position.X = OsuPlayfield.BASE_SIZE.X - radius;
obj.Position = position;
}
/// <summary>
/// Re-maps a number from one range to another.
/// </summary>
/// <param name="value">The number to be re-mapped.</param>
/// <param name="fromLow">Beginning of the original range.</param>
/// <param name="fromHigh">End of the original range.</param>
/// <param name="toLow">Beginning of the new range.</param>
/// <param name="toHigh">End of the new range.</param>
/// <returns>The re-mapped number.</returns>
private static float mapRange(float value, float fromLow, float fromHigh, float toLow, float toHigh)
{
return (value - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow;
}
private static bool almostBigger(double value1, double value2)
{
return Precision.AlmostBigger(value1, value2, timing_precision);
}
private static bool definitelyBigger(double value1, double value2)
{
return Precision.DefinitelyBigger(value1, value2, timing_precision);
}
private static bool almostEquals(double value1, double value2)
{
return Precision.AlmostEquals(value1, value2, timing_precision);
}
#endregion
}
}

View File

@ -3,6 +3,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Osu.Configuration;
using osu.Game.Rulesets.UI;
@ -11,7 +12,7 @@ namespace osu.Game.Rulesets.Osu.UI
{
public class OsuSettingsSubsection : RulesetSettingsSubsection
{
protected override string Header => "osu!";
protected override LocalisableString Header => "osu!";
public OsuSettingsSubsection(Ruleset ruleset)
: base(ruleset)

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
@ -31,10 +30,10 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
public override double Calculate(Dictionary<string, double> categoryDifficulty = null)
{
mods = Score.Mods;
countGreat = Score.Statistics.GetOrDefault(HitResult.Great);
countOk = Score.Statistics.GetOrDefault(HitResult.Ok);
countMeh = Score.Statistics.GetOrDefault(HitResult.Meh);
countMiss = Score.Statistics.GetOrDefault(HitResult.Miss);
countGreat = Score.Statistics.GetValueOrDefault(HitResult.Great);
countOk = Score.Statistics.GetValueOrDefault(HitResult.Ok);
countMeh = Score.Statistics.GetValueOrDefault(HitResult.Meh);
countMiss = Score.Statistics.GetValueOrDefault(HitResult.Miss);
// Custom multipliers for NoFail and SpunOut.
double multiplier = 1.1; // This is being adjusted to keep the final pp value scaled around what it used to be when changing things

View File

@ -248,13 +248,13 @@ namespace osu.Game.Tests.NonVisual
}
[Test]
public void TestCreateCopyIsDeepClone()
public void TestDeepClone()
{
var cpi = new ControlPointInfo();
cpi.Add(1000, new TimingControlPoint { BeatLength = 500 });
var cpiCopy = cpi.CreateCopy();
var cpiCopy = cpi.DeepClone();
cpiCopy.Add(2000, new TimingControlPoint { BeatLength = 500 });

View File

@ -0,0 +1,33 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Tests.NonVisual
{
[TestFixture]
public class ScoreInfoTest
{
[Test]
public void TestDeepClone()
{
var score = new ScoreInfo();
score.Statistics.Add(HitResult.Good, 10);
score.Rank = ScoreRank.B;
var scoreCopy = score.DeepClone();
score.Statistics[HitResult.Good]++;
score.Rank = ScoreRank.X;
Assert.That(scoreCopy.Statistics[HitResult.Good], Is.EqualTo(10));
Assert.That(score.Statistics[HitResult.Good], Is.EqualTo(11));
Assert.That(scoreCopy.Rank, Is.EqualTo(ScoreRank.B));
Assert.That(score.Rank, Is.EqualTo(ScoreRank.X));
}
}
}

View File

@ -13,8 +13,8 @@ namespace osu.Game.Tests.Visual.Editing
{
public TestSceneEditorComposeRadioButtons()
{
RadioButtonCollection collection;
Add(collection = new RadioButtonCollection
EditorRadioButtonCollection collection;
Add(collection = new EditorRadioButtonCollection
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -2,17 +2,24 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Timing;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Edit;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Components.RadioButtons;
using osu.Game.Screens.Edit.Compose.Components;
using osuTK;
namespace osu.Game.Tests.Visual.Editing
@ -20,37 +27,89 @@ namespace osu.Game.Tests.Visual.Editing
[TestFixture]
public class TestSceneHitObjectComposer : EditorClockTestScene
{
[BackgroundDependencyLoader]
private void load()
private OsuHitObjectComposer hitObjectComposer;
private EditorBeatmapContainer editorBeatmapContainer;
private EditorBeatmap editorBeatmap => editorBeatmapContainer.EditorBeatmap;
[SetUpSteps]
public void SetUpSteps()
{
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
AddStep("create beatmap", () =>
{
HitObjects = new List<HitObject>
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
new HitCircle { Position = new Vector2(256, 192), Scale = 0.5f },
new HitCircle { Position = new Vector2(344, 148), Scale = 0.5f },
new Slider
HitObjects = new List<HitObject>
{
Position = new Vector2(128, 256),
Path = new SliderPath(PathType.Linear, new[]
new HitCircle { Position = new Vector2(256, 192), Scale = 0.5f },
new HitCircle { Position = new Vector2(344, 148), Scale = 0.5f },
new Slider
{
Vector2.Zero,
new Vector2(216, 0),
}),
Scale = 0.5f,
}
},
Position = new Vector2(128, 256),
Path = new SliderPath(PathType.Linear, new[]
{
Vector2.Zero,
new Vector2(216, 0),
}),
Scale = 0.5f,
}
},
});
});
var editorBeatmap = new EditorBeatmap(Beatmap.Value.GetPlayableBeatmap(new OsuRuleset().RulesetInfo));
AddStep("Create composer", () =>
{
Child = editorBeatmapContainer = new EditorBeatmapContainer(Beatmap.Value)
{
Child = hitObjectComposer = new OsuHitObjectComposer(new OsuRuleset())
};
});
}
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
Dependencies.CacheAs<IAdjustableClock>(clock);
Dependencies.CacheAs<IFrameBasedClock>(clock);
Dependencies.CacheAs(editorBeatmap);
Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap);
[Test]
public void TestPlacementOnlyWorksWithTiming()
{
AddStep("clear all control points", () => editorBeatmap.ControlPointInfo.Clear());
Child = new OsuHitObjectComposer(new OsuRuleset());
AddAssert("Tool is selection", () => hitObjectComposer.ChildrenOfType<ComposeBlueprintContainer>().First().CurrentTool is SelectTool);
AddAssert("Hitcircle button not clickable", () => !hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").Enabled.Value);
AddStep("Add timing point", () => editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint()));
AddAssert("Hitcircle button is clickable", () => hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").Enabled.Value);
AddStep("Change to hitcircle", () => hitObjectComposer.ChildrenOfType<EditorRadioButton>().First(d => d.Button.Label == "HitCircle").Click());
AddAssert("Tool changed", () => hitObjectComposer.ChildrenOfType<ComposeBlueprintContainer>().First().CurrentTool is HitCircleCompositionTool);
}
public class EditorBeatmapContainer : Container
{
private readonly WorkingBeatmap working;
public EditorBeatmap EditorBeatmap { get; private set; }
public EditorBeatmapContainer(WorkingBeatmap working)
{
this.working = working;
RelativeSizeAxes = Axes.Both;
}
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
{
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
EditorBeatmap = new EditorBeatmap(working.GetPlayableBeatmap(new OsuRuleset().RulesetInfo));
dependencies.CacheAs(EditorBeatmap);
dependencies.CacheAs<IBeatSnapProvider>(EditorBeatmap);
return dependencies;
}
protected override void LoadComplete()
{
base.LoadComplete();
Add(EditorBeatmap);
}
}
}
}

View File

@ -7,6 +7,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.Wiki;
@ -96,7 +97,7 @@ namespace osu.Game.Tests.Visual.Online
private class TestHeader : WikiHeader
{
public IReadOnlyList<string> TabControlItems => TabControl.Items;
public IReadOnlyList<LocalisableString?> TabControlItems => TabControl.Items;
}
}
}

View File

@ -88,7 +88,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("create mods", () =>
{
original = new OsuModDoubleTime();
copy = (OsuModDoubleTime)original.CreateCopy();
copy = (OsuModDoubleTime)original.DeepClone();
});
AddStep("change property", () => original.SpeedChange.Value = 2);
@ -106,7 +106,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("create mods", () =>
{
original = new MultiMod(new OsuModDoubleTime());
copy = (MultiMod)original.CreateCopy();
copy = (MultiMod)original.DeepClone();
});
AddStep("change property", () => ((OsuModDoubleTime)original.Mods[0]).SpeedChange.Value = 2);

View File

@ -28,6 +28,12 @@ namespace osu.Game.Tournament.Tests.Screens
setMatchDate(TimeSpan.FromHours(3));
}
[Test]
public void TestNoCurrentMatch()
{
AddStep("Set null current match", () => Ladder.CurrentMatch.Value = null);
}
private void setMatchDate(TimeSpan relativeTime)
// Humanizer cannot handle negative timespans.
=> AddStep($"start time is {relativeTime}", () =>

View File

@ -1,9 +1,13 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.Ladder.Components;
using osu.Game.Tournament.Screens.TeamIntro;
namespace osu.Game.Tournament.Tests.Screens
@ -11,16 +15,41 @@ namespace osu.Game.Tournament.Tests.Screens
public class TestSceneSeedingScreen : TournamentTestScene
{
[Cached]
private readonly LadderInfo ladder = new LadderInfo();
[BackgroundDependencyLoader]
private void load()
private readonly LadderInfo ladder = new LadderInfo
{
Add(new SeedingScreen
Teams =
{
new TournamentTeam
{
FullName = { Value = @"Japan" },
Acronym = { Value = "JPN" },
SeedingResults =
{
new SeedingResult
{
// Mod intentionally left blank.
Seed = { Value = 4 }
},
new SeedingResult
{
Mod = { Value = "DT" },
Seed = { Value = 8 }
}
}
}
}
};
[Test]
public void TestBasic()
{
AddStep("create seeding screen", () => Add(new SeedingScreen
{
FillMode = FillMode.Fit,
FillAspectRatio = 16 / 9f
});
}));
AddStep("set team to Japan", () => this.ChildrenOfType<SettingsTeamDropdown>().Single().Current.Value = ladder.Teams.Single());
}
}
}

View File

@ -11,7 +11,7 @@ using osu.Game.Tournament.IPC;
namespace osu.Game.Tournament.Screens
{
public abstract class BeatmapInfoScreen : TournamentScreen
public abstract class BeatmapInfoScreen : TournamentMatchScreen
{
protected readonly SongBar SongBar;

View File

@ -24,8 +24,6 @@ namespace osu.Game.Tournament.Screens.Gameplay
{
private readonly BindableBool warmup = new BindableBool();
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
public readonly Bindable<TourneyState> State = new Bindable<TourneyState>();
private OsuButton warmupButton;
private MatchIPCInfo ipc;
@ -131,14 +129,6 @@ namespace osu.Game.Tournament.Screens.Gameplay
ladder.ChromaKeyWidth.BindValueChanged(width => chroma.Width = width.NewValue, true);
currentMatch.BindValueChanged(m =>
{
warmup.Value = m.NewValue.Team1Score.Value + m.NewValue.Team2Score.Value == 0;
scheduledOperation?.Cancel();
});
currentMatch.BindTo(ladder.CurrentMatch);
warmup.BindValueChanged(w =>
{
warmupButton.Alpha = !w.NewValue ? 0.5f : 1;
@ -146,6 +136,17 @@ namespace osu.Game.Tournament.Screens.Gameplay
}, true);
}
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
base.CurrentMatchChanged(match);
if (match.NewValue == null)
return;
warmup.Value = match.NewValue.Team1Score.Value + match.NewValue.Team2Score.Value == 0;
scheduledOperation?.Cancel();
}
private ScheduledDelegate scheduledOperation;
private MatchScoreDisplay scoreDisplay;
@ -161,9 +162,9 @@ namespace osu.Game.Tournament.Screens.Gameplay
if (warmup.Value) return;
if (ipc.Score1.Value > ipc.Score2.Value)
currentMatch.Value.Team1Score.Value++;
CurrentMatch.Value.Team1Score.Value++;
else
currentMatch.Value.Team2Score.Value++;
CurrentMatch.Value.Team2Score.Value++;
}
scheduledOperation?.Cancel();
@ -198,9 +199,9 @@ namespace osu.Game.Tournament.Screens.Gameplay
// we should automatically proceed after a short delay
if (lastState == TourneyState.Ranking && !warmup.Value)
{
if (currentMatch.Value?.Completed.Value == true)
if (CurrentMatch.Value?.Completed.Value == true)
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(TeamWinScreen)); }, delay_before_progression);
else if (currentMatch.Value?.Completed.Value == false)
else if (CurrentMatch.Value?.Completed.Value == false)
scheduledOperation = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(MapPoolScreen)); }, delay_before_progression);
}

View File

@ -303,6 +303,15 @@ namespace osu.Game.Tournament.Screens.Ladder.Components
Match.LosersProgression.Value = null;
ladderInfo.Matches.Remove(Match);
foreach (var m in ladderInfo.Matches)
{
if (m.Progression.Value == Match)
m.Progression.Value = null;
if (m.LosersProgression.Value == Match)
m.LosersProgression.Value = null;
}
}
}
}

View File

@ -21,12 +21,10 @@ using osuTK.Input;
namespace osu.Game.Tournament.Screens.MapPool
{
public class MapPoolScreen : TournamentScreen
public class MapPoolScreen : TournamentMatchScreen
{
private readonly FillFlowContainer<FillFlowContainer<TournamentBeatmapPanel>> mapFlows;
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
[Resolved(canBeNull: true)]
private TournamentSceneManager sceneManager { get; set; }
@ -96,7 +94,7 @@ namespace osu.Game.Tournament.Screens.MapPool
Action = reset
},
new ControlPanel.Spacer(),
}
},
}
};
}
@ -104,15 +102,12 @@ namespace osu.Game.Tournament.Screens.MapPool
[BackgroundDependencyLoader]
private void load(MatchIPCInfo ipc)
{
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(LadderInfo.CurrentMatch);
ipc.Beatmap.BindValueChanged(beatmapChanged);
}
private void beatmapChanged(ValueChangedEvent<BeatmapInfo> beatmap)
{
if (currentMatch.Value == null || currentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
if (CurrentMatch.Value == null || CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) < 2)
return;
// if bans have already been placed, beatmap changes result in a selection being made autoamtically
@ -137,12 +132,12 @@ namespace osu.Game.Tournament.Screens.MapPool
{
const TeamColour roll_winner = TeamColour.Red; //todo: draw from match
var nextColour = (currentMatch.Value.PicksBans.LastOrDefault()?.Team ?? roll_winner) == TeamColour.Red ? TeamColour.Blue : TeamColour.Red;
var nextColour = (CurrentMatch.Value.PicksBans.LastOrDefault()?.Team ?? roll_winner) == TeamColour.Red ? TeamColour.Blue : TeamColour.Red;
if (pickType == ChoiceType.Ban && currentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2)
if (pickType == ChoiceType.Ban && CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2)
setMode(pickColour, ChoiceType.Pick);
else
setMode(nextColour, currentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2 ? ChoiceType.Pick : ChoiceType.Ban);
setMode(nextColour, CurrentMatch.Value.PicksBans.Count(p => p.Type == ChoiceType.Ban) >= 2 ? ChoiceType.Pick : ChoiceType.Ban);
}
protected override bool OnMouseDown(MouseDownEvent e)
@ -156,11 +151,11 @@ namespace osu.Game.Tournament.Screens.MapPool
addForBeatmap(map.Beatmap.OnlineBeatmapID.Value);
else
{
var existing = currentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap.OnlineBeatmapID);
var existing = CurrentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap.OnlineBeatmapID);
if (existing != null)
{
currentMatch.Value.PicksBans.Remove(existing);
CurrentMatch.Value.PicksBans.Remove(existing);
setNextMode();
}
}
@ -173,7 +168,7 @@ namespace osu.Game.Tournament.Screens.MapPool
private void reset()
{
currentMatch.Value.PicksBans.Clear();
CurrentMatch.Value.PicksBans.Clear();
setNextMode();
}
@ -181,18 +176,18 @@ namespace osu.Game.Tournament.Screens.MapPool
private void addForBeatmap(int beatmapId)
{
if (currentMatch.Value == null)
if (CurrentMatch.Value == null)
return;
if (currentMatch.Value.Round.Value.Beatmaps.All(b => b.BeatmapInfo.OnlineBeatmapID != beatmapId))
if (CurrentMatch.Value.Round.Value.Beatmaps.All(b => b.BeatmapInfo.OnlineBeatmapID != beatmapId))
// don't attempt to add if the beatmap isn't in our pool
return;
if (currentMatch.Value.PicksBans.Any(p => p.BeatmapID == beatmapId))
if (CurrentMatch.Value.PicksBans.Any(p => p.BeatmapID == beatmapId))
// don't attempt to add if already exists.
return;
currentMatch.Value.PicksBans.Add(new BeatmapChoice
CurrentMatch.Value.PicksBans.Add(new BeatmapChoice
{
Team = pickColour,
Type = pickType,
@ -201,17 +196,22 @@ namespace osu.Game.Tournament.Screens.MapPool
setNextMode();
if (pickType == ChoiceType.Pick && currentMatch.Value.PicksBans.Any(i => i.Type == ChoiceType.Pick))
if (pickType == ChoiceType.Pick && CurrentMatch.Value.PicksBans.Any(i => i.Type == ChoiceType.Pick))
{
scheduledChange?.Cancel();
scheduledChange = Scheduler.AddDelayed(() => { sceneManager?.SetScreen(typeof(GameplayScreen)); }, 10000);
}
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
base.CurrentMatchChanged(match);
mapFlows.Clear();
if (match.NewValue == null)
return;
int totalRows = 0;
if (match.NewValue.Round.Value != null)

View File

@ -96,19 +96,18 @@ namespace osu.Game.Tournament.Screens.Schedule
}
},
};
}
protected override void LoadComplete()
{
base.LoadComplete();
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(ladder.CurrentMatch);
currentMatch.BindValueChanged(matchChanged, true);
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
{
if (match.NewValue == null)
{
mainContainer.Clear();
return;
}
var upcoming = ladder.Matches.Where(p => !p.Completed.Value && p.Team1.Value != null && p.Team2.Value != null && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4);
var conditionals = ladder
.Matches.Where(p => !p.Completed.Value && (p.Team1.Value == null || p.Team2.Value == null) && Math.Abs(p.Date.Value.DayOfYear - DateTimeOffset.UtcNow.DayOfYear) < 4)
@ -117,6 +116,8 @@ namespace osu.Game.Tournament.Screens.Schedule
upcoming = upcoming.Concat(conditionals);
upcoming = upcoming.OrderBy(p => p.Date.Value).Take(8);
ScheduleContainer comingUpNext;
mainContainer.Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
@ -153,57 +154,58 @@ namespace osu.Game.Tournament.Screens.Schedule
}
}
},
new ScheduleContainer("coming up next")
comingUpNext = new ScheduleContainer("coming up next")
{
RelativeSizeAxes = Axes.Both,
Height = 0.25f,
Children = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(30),
Children = new Drawable[]
{
new ScheduleMatch(match.NewValue, false)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
new TournamentSpriteTextWithBackground(match.NewValue.Round.Value?.Name.Value)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Scale = new Vector2(0.5f)
},
new TournamentSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Text = match.NewValue.Team1.Value?.FullName + " vs " + match.NewValue.Team2.Value?.FullName,
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.SemiBold)
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Children = new Drawable[]
{
new ScheduleMatchDate(match.NewValue.Date.Value)
{
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.Regular)
}
}
},
}
},
}
}
}
};
if (match.NewValue != null)
{
comingUpNext.Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(30),
Children = new Drawable[]
{
new ScheduleMatch(match.NewValue, false)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
new TournamentSpriteTextWithBackground(match.NewValue.Round.Value?.Name.Value)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Scale = new Vector2(0.5f)
},
new TournamentSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Text = match.NewValue.Team1.Value?.FullName + " vs " + match.NewValue.Team2.Value?.FullName,
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.SemiBold)
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Children = new Drawable[]
{
new ScheduleMatchDate(match.NewValue.Date.Value)
{
Font = OsuFont.Torus.With(size: 24, weight: FontWeight.Regular)
}
}
},
}
};
}
}
public class ScheduleMatch : DrawableTournamentMatch

View File

@ -2,10 +2,12 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Tournament.Components;
using osu.Framework.Graphics.Shapes;
using osu.Game.Tournament.Models;
using osuTK.Graphics;
namespace osu.Game.Tournament.Screens.Showcase
@ -39,5 +41,11 @@ namespace osu.Game.Tournament.Screens.Showcase
}
});
}
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
// showcase screen doesn't care about a match being selected.
// base call intentionally omitted to not show match warning.
}
}
}

View File

@ -18,12 +18,10 @@ using osuTK;
namespace osu.Game.Tournament.Screens.TeamIntro
{
public class SeedingScreen : TournamentScreen, IProvideVideo
public class SeedingScreen : TournamentMatchScreen, IProvideVideo
{
private Container mainContainer;
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
private readonly Bindable<TournamentTeam> currentTeam = new Bindable<TournamentTeam>();
[BackgroundDependencyLoader]
@ -50,13 +48,13 @@ namespace osu.Game.Tournament.Screens.TeamIntro
{
RelativeSizeAxes = Axes.X,
Text = "Show first team",
Action = () => currentTeam.Value = currentMatch.Value.Team1.Value,
Action = () => currentTeam.Value = CurrentMatch.Value.Team1.Value,
},
new TourneyButton
{
RelativeSizeAxes = Axes.X,
Text = "Show second team",
Action = () => currentTeam.Value = currentMatch.Value.Team2.Value,
Action = () => currentTeam.Value = CurrentMatch.Value.Team2.Value,
},
new SettingsTeamDropdown(LadderInfo.Teams)
{
@ -67,9 +65,6 @@ namespace osu.Game.Tournament.Screens.TeamIntro
}
};
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(LadderInfo.CurrentMatch);
currentTeam.BindValueChanged(teamChanged, true);
}
@ -84,8 +79,15 @@ namespace osu.Game.Tournament.Screens.TeamIntro
showTeam(team.NewValue);
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match) =>
currentTeam.Value = currentMatch.Value.Team1.Value;
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
base.CurrentMatchChanged(match);
if (match.NewValue == null)
return;
currentTeam.Value = match.NewValue.Team1.Value;
}
private void showTeam(TournamentTeam team)
{
@ -179,44 +181,48 @@ namespace osu.Game.Tournament.Screens.TeamIntro
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
FillFlowContainer row;
InternalChildren = new Drawable[]
{
new FillFlowContainer
row = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5),
Children = new Drawable[]
{
new Sprite
{
Texture = textures.Get($"mods/{mods.ToLower()}"),
Scale = new Vector2(0.5f)
},
new Container
{
Size = new Vector2(50, 16),
CornerRadius = 10,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = TournamentGame.ELEMENT_BACKGROUND_COLOUR,
},
new TournamentSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = seeding.ToString("#,0"),
Colour = TournamentGame.ELEMENT_FOREGROUND_COLOUR
},
}
},
}
},
};
if (!string.IsNullOrEmpty(mods))
{
row.Add(new Sprite
{
Texture = textures.Get($"mods/{mods.ToLower()}"),
Scale = new Vector2(0.5f)
});
}
row.Add(new Container
{
Size = new Vector2(50, 16),
CornerRadius = 10,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = TournamentGame.ELEMENT_BACKGROUND_COLOUR,
},
new TournamentSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Text = seeding.ToString("#,0"),
Colour = TournamentGame.ELEMENT_FOREGROUND_COLOUR
},
}
});
}
}
}

View File

@ -12,12 +12,10 @@ using osuTK;
namespace osu.Game.Tournament.Screens.TeamIntro
{
public class TeamIntroScreen : TournamentScreen, IProvideVideo
public class TeamIntroScreen : TournamentMatchScreen, IProvideVideo
{
private Container mainContainer;
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
[BackgroundDependencyLoader]
private void load(Storage storage)
{
@ -35,18 +33,16 @@ namespace osu.Game.Tournament.Screens.TeamIntro
RelativeSizeAxes = Axes.Both,
}
};
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(LadderInfo.CurrentMatch);
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
base.CurrentMatchChanged(match);
mainContainer.Clear();
if (match.NewValue == null)
{
mainContainer.Clear();
return;
}
const float y_flag_offset = 292;

View File

@ -13,11 +13,10 @@ using osuTK;
namespace osu.Game.Tournament.Screens.TeamWin
{
public class TeamWinScreen : TournamentScreen, IProvideVideo
public class TeamWinScreen : TournamentMatchScreen, IProvideVideo
{
private Container mainContainer;
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
private readonly Bindable<bool> currentCompleted = new Bindable<bool>();
private TourneyVideo blueWinVideo;
@ -48,17 +47,19 @@ namespace osu.Game.Tournament.Screens.TeamWin
}
};
currentMatch.BindValueChanged(matchChanged);
currentMatch.BindTo(ladder.CurrentMatch);
currentCompleted.BindValueChanged(_ => update());
}
private void matchChanged(ValueChangedEvent<TournamentMatch> match)
protected override void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
currentCompleted.UnbindBindings();
currentCompleted.BindTo(match.NewValue.Completed);
base.CurrentMatchChanged(match);
currentCompleted.UnbindBindings();
if (match.NewValue == null)
return;
currentCompleted.BindTo(match.NewValue.Completed);
update();
}
@ -66,7 +67,7 @@ namespace osu.Game.Tournament.Screens.TeamWin
private void update() => Schedule(() =>
{
var match = currentMatch.Value;
var match = CurrentMatch.Value;
if (match.Winner == null)
{

View File

@ -0,0 +1,34 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Bindables;
using osu.Game.Tournament.Models;
namespace osu.Game.Tournament.Screens
{
public abstract class TournamentMatchScreen : TournamentScreen
{
protected readonly Bindable<TournamentMatch> CurrentMatch = new Bindable<TournamentMatch>();
private WarningBox noMatchWarning;
protected override void LoadComplete()
{
base.LoadComplete();
CurrentMatch.BindTo(LadderInfo.CurrentMatch);
CurrentMatch.BindValueChanged(CurrentMatchChanged, true);
}
protected virtual void CurrentMatchChanged(ValueChangedEvent<TournamentMatch> match)
{
if (match.NewValue == null)
{
AddInternal(noMatchWarning = new WarningBox("Choose a match first from the brackets screen"));
return;
}
noMatchWarning?.Expire();
noMatchWarning = null;
}
}
}

View File

@ -97,7 +97,12 @@ namespace osu.Game.Tournament
},
}
},
heightWarning = new WarningBox("Please make the window wider"),
heightWarning = new WarningBox("Please make the window wider")
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Margin = new MarginPadding(20),
},
new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Both,

View File

@ -3,11 +3,12 @@
using System;
using osu.Game.Graphics;
using osu.Game.Utils;
using osuTK.Graphics;
namespace osu.Game.Beatmaps.ControlPoints
{
public abstract class ControlPoint : IComparable<ControlPoint>
public abstract class ControlPoint : IComparable<ControlPoint>, IDeepCloneable<ControlPoint>
{
/// <summary>
/// The time at which the control point takes effect.
@ -32,7 +33,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <summary>
/// Create an unbound copy of this control point.
/// </summary>
public ControlPoint CreateCopy()
public ControlPoint DeepClone()
{
var copy = (ControlPoint)Activator.CreateInstance(GetType());

View File

@ -10,11 +10,12 @@ using osu.Framework.Bindables;
using osu.Framework.Lists;
using osu.Framework.Utils;
using osu.Game.Screens.Edit;
using osu.Game.Utils;
namespace osu.Game.Beatmaps.ControlPoints
{
[Serializable]
public class ControlPointInfo
public class ControlPointInfo : IDeepCloneable<ControlPointInfo>
{
/// <summary>
/// All control points grouped by time.
@ -350,12 +351,12 @@ namespace osu.Game.Beatmaps.ControlPoints
}
}
public ControlPointInfo CreateCopy()
public ControlPointInfo DeepClone()
{
var controlPointInfo = new ControlPointInfo();
foreach (var point in AllControlPoints)
controlPointInfo.Add(point.Time, point.CreateCopy());
controlPointInfo.Add(point.Time, point.DeepClone());
return controlPointInfo;
}

View File

@ -251,11 +251,8 @@ namespace osu.Game.Beatmaps.Formats
switch (beatmap.BeatmapInfo.RulesetID)
{
case 0:
position = ((IHasPosition)hitObject).Position;
break;
case 2:
position.X = ((IHasXPosition)hitObject).X;
position = ((IHasPosition)hitObject).Position;
break;
case 3:

View File

@ -14,6 +14,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Utils;
using osu.Game.Graphics.Sprites;
@ -153,6 +154,27 @@ namespace osu.Game.Graphics.UserInterface
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
LocalisableString text;
switch (value)
{
case IHasDescription hasDescription:
text = hasDescription.GetDescription();
break;
case Enum e:
text = e.GetLocalisableDescription();
break;
case LocalisableString l:
text = l;
break;
default:
text = value.ToString();
break;
}
Children = new Drawable[]
{
Text = new OsuSpriteText
@ -160,7 +182,7 @@ namespace osu.Game.Graphics.UserInterface
Margin = new MarginPadding { Top = 5, Bottom = 5 },
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
Text = (value as IHasDescription)?.Description ?? (value as Enum)?.GetLocalisableDescription() ?? value.ToString(),
Text = text,
Font = OsuFont.GetFont(size: 14)
},
Bar = new Box

View File

@ -0,0 +1,29 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation;
namespace osu.Game.Localisation
{
public static class BindingSettingsStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.BindingSettings";
/// <summary>
/// "Shortcut and gameplay bindings"
/// </summary>
public static LocalisableString ShortcutAndGameplayBindings => new TranslatableString(getKey(@"shortcut_and_gameplay_bindings"), @"Shortcut and gameplay bindings");
/// <summary>
/// "Configure"
/// </summary>
public static LocalisableString Configure => new TranslatableString(getKey(@"configure"), @"Configure");
/// <summary>
/// "change global shortcut keys and gameplay bindings"
/// </summary>
public static LocalisableString ChangeBindingsButton => new TranslatableString(getKey(@"change_bindings_button"), @"change global shortcut keys and gameplay bindings");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -14,6 +14,21 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString Cancel => new TranslatableString(getKey(@"cancel"), @"Cancel");
private static string getKey(string key) => $"{prefix}:{key}";
/// <summary>
/// "Enabled"
/// </summary>
public static LocalisableString Enabled => new TranslatableString(getKey(@"enabled"), @"Enabled");
/// <summary>
/// "Width"
/// </summary>
public static LocalisableString Width => new TranslatableString(getKey(@"width"), @"Width");
/// <summary>
/// "Height"
/// </summary>
public static LocalisableString Height => new TranslatableString(getKey(@"height"), @"Height");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}
}

View File

@ -0,0 +1,59 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation;
namespace osu.Game.Localisation
{
public static class MouseSettingsStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.MouseSettings";
/// <summary>
/// "Mouse"
/// </summary>
public static LocalisableString Mouse => new TranslatableString(getKey(@"mouse"), @"Mouse");
/// <summary>
/// "Not applicable in full screen mode"
/// </summary>
public static LocalisableString NotApplicableFullscreen => new TranslatableString(getKey(@"not_applicable_full_screen"), @"Not applicable in full screen mode");
/// <summary>
/// "High precision mouse"
/// </summary>
public static LocalisableString HighPrecisionMouse => new TranslatableString(getKey(@"high_precision_mouse"), @"High precision mouse");
/// <summary>
/// "Attempts to bypass any operation system mouse acceleration. On windows, this is equivalent to what used to be known as &quot;Raw Input&quot;."
/// </summary>
public static LocalisableString HighPrecisionMouseTooltip => new TranslatableString(getKey(@"high_precision_mouse_tooltip"), @"Attempts to bypass any operation system mouse acceleration. On windows, this is equivalent to what used to be known as ""Raw Input"".");
/// <summary>
/// "Confine mouse cursor to window"
/// </summary>
public static LocalisableString ConfineMouseMode => new TranslatableString(getKey(@"confine_mouse_mode"), @"Confine mouse cursor to window");
/// <summary>
/// "Disable mouse wheel during gameplay"
/// </summary>
public static LocalisableString DisableMouseWheel => new TranslatableString(getKey(@"disable_mouse_wheel"), @"Disable mouse wheel during gameplay");
/// <summary>
/// "Disable mouse buttons during gameplay"
/// </summary>
public static LocalisableString DisableMouseButtons => new TranslatableString(getKey(@"disable_mouse_buttons"), @"Disable mouse buttons during gameplay");
/// <summary>
/// "Enable high precision mouse to adjust sensitivity"
/// </summary>
public static LocalisableString EnableHighPrecisionForSensitivityAdjust => new TranslatableString(getKey(@"enable_high_precision_for_sensitivity_adjust"), @"Enable high precision mouse to adjust sensitivity");
/// <summary>
/// "Cursor sensitivity"
/// </summary>
public static LocalisableString CursorSensitivity => new TranslatableString(getKey(@"cursor_sensitivity"), @"Cursor sensitivity");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -0,0 +1,59 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation;
namespace osu.Game.Localisation
{
public static class TabletSettingsStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.TabletSettings";
/// <summary>
/// "Tablet"
/// </summary>
public static LocalisableString Tablet => new TranslatableString(getKey(@"tablet"), @"Tablet");
/// <summary>
/// "No tablet detected!"
/// </summary>
public static LocalisableString NoTabletDetected => new TranslatableString(getKey(@"no_tablet_detected"), @"No tablet detected!");
/// <summary>
/// "Reset to full area"
/// </summary>
public static LocalisableString ResetToFullArea => new TranslatableString(getKey(@"reset_to_full_area"), @"Reset to full area");
/// <summary>
/// "Conform to current game aspect ratio"
/// </summary>
public static LocalisableString ConformToCurrentGameAspectRatio => new TranslatableString(getKey(@"conform_to_current_game_aspect_ratio"), @"Conform to current game aspect ratio");
/// <summary>
/// "X Offset"
/// </summary>
public static LocalisableString XOffset => new TranslatableString(getKey(@"x_offset"), @"X Offset");
/// <summary>
/// "Y Offset"
/// </summary>
public static LocalisableString YOffset => new TranslatableString(getKey(@"y_offset"), @"Y Offset");
/// <summary>
/// "Rotation"
/// </summary>
public static LocalisableString Rotation => new TranslatableString(getKey(@"rotation"), @"Rotation");
/// <summary>
/// "Aspect Ratio"
/// </summary>
public static LocalisableString AspectRatio => new TranslatableString(getKey(@"aspect_ratio"), @"Aspect Ratio");
/// <summary>
/// "Lock aspect ratio"
/// </summary>
public static LocalisableString LockAspectRatio => new TranslatableString(getKey(@"lock_aspect_ratio"), @"Lock aspect ratio");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}

View File

@ -10,10 +10,11 @@ using osu.Game.IO.Serialization.Converters;
using osu.Game.Online.Rooms.GameTypes;
using osu.Game.Online.Rooms.RoomStatuses;
using osu.Game.Users;
using osu.Game.Utils;
namespace osu.Game.Online.Rooms
{
public class Room
public class Room : IDeepCloneable<Room>
{
[Cached]
[JsonProperty("id")]
@ -136,7 +137,7 @@ namespace osu.Game.Online.Rooms
/// Create a copy of this room without online information.
/// Should be used to create a local copy of a room for submitting in the future.
/// </summary>
public Room CreateCopy()
public Room DeepClone()
{
var copy = new Room();

View File

@ -4,15 +4,16 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays
{
public abstract class BreadcrumbControlOverlayHeader : TabControlOverlayHeader<string>
public abstract class BreadcrumbControlOverlayHeader : TabControlOverlayHeader<LocalisableString?>
{
protected override OsuTabControl<string> CreateTabControl() => new OverlayHeaderBreadcrumbControl();
protected override OsuTabControl<LocalisableString?> CreateTabControl() => new OverlayHeaderBreadcrumbControl();
public class OverlayHeaderBreadcrumbControl : BreadcrumbControl<string>
public class OverlayHeaderBreadcrumbControl : BreadcrumbControl<LocalisableString?>
{
public OverlayHeaderBreadcrumbControl()
{
@ -26,7 +27,7 @@ namespace osu.Game.Overlays
AccentColour = colourProvider.Light2;
}
protected override TabItem<string> CreateTabItem(string value) => new ControlTabItem(value)
protected override TabItem<LocalisableString?> CreateTabItem(LocalisableString? value) => new ControlTabItem(value)
{
AccentColour = AccentColour,
};
@ -35,7 +36,7 @@ namespace osu.Game.Overlays
{
protected override float ChevronSize => 8;
public ControlTabItem(string value)
public ControlTabItem(LocalisableString? value)
: base(value)
{
RelativeSizeAxes = Axes.Y;

View File

@ -3,6 +3,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Input.Bindings;
using osu.Game.Overlays.Settings;
@ -28,7 +29,7 @@ namespace osu.Game.Overlays.KeyBinding
private class DefaultBindingsSubsection : KeyBindingsSubsection
{
protected override string Header => string.Empty;
protected override LocalisableString Header => string.Empty;
public DefaultBindingsSubsection(GlobalActionContainer manager)
: base(null)
@ -39,7 +40,7 @@ namespace osu.Game.Overlays.KeyBinding
private class SongSelectKeyBindingSubsection : KeyBindingsSubsection
{
protected override string Header => "Song Select";
protected override LocalisableString Header => "Song Select";
public SongSelectKeyBindingSubsection(GlobalActionContainer manager)
: base(null)
@ -50,7 +51,7 @@ namespace osu.Game.Overlays.KeyBinding
private class InGameKeyBindingsSubsection : KeyBindingsSubsection
{
protected override string Header => "In Game";
protected override LocalisableString Header => "In Game";
public InGameKeyBindingsSubsection(GlobalActionContainer manager)
: base(null)
@ -61,7 +62,7 @@ namespace osu.Game.Overlays.KeyBinding
private class AudioControlKeyBindingsSubsection : KeyBindingsSubsection
{
protected override string Header => "Audio";
protected override LocalisableString Header => "Audio";
public AudioControlKeyBindingsSubsection(GlobalActionContainer manager)
: base(null)
@ -72,7 +73,7 @@ namespace osu.Game.Overlays.KeyBinding
private class EditorKeyBindingsSubsection : KeyBindingsSubsection
{
protected override string Header => "Editor";
protected override LocalisableString Header => "Editor";
public EditorKeyBindingsSubsection(GlobalActionContainer manager)
: base(null)

View File

@ -1,13 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Localisation;
using osu.Game.Rulesets;
namespace osu.Game.Overlays.KeyBinding
{
public class VariantBindingsSubsection : KeyBindingsSubsection
{
protected override string Header { get; }
protected override LocalisableString Header { get; }
public VariantBindingsSubsection(RulesetInfo ruleset, int variant)
: base(variant)

View File

@ -429,7 +429,7 @@ namespace osu.Game.Overlays.Mods
if (!Stacked)
modEnumeration = ModUtils.FlattenMods(modEnumeration);
section.Mods = modEnumeration.Select(getValidModOrNull).Where(m => m != null).Select(m => m.CreateCopy());
section.Mods = modEnumeration.Select(getValidModOrNull).Where(m => m != null).Select(m => m.DeepClone());
}
updateSelectedButtons();

View File

@ -13,7 +13,7 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
{
public class AudioDevicesSettings : SettingsSubsection
{
protected override string Header => "Devices";
protected override LocalisableString Header => "Devices";
[Resolved]
private AudioManager audio { get; set; }

View File

@ -11,7 +11,7 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
{
public class OffsetSettings : SettingsSubsection
{
protected override string Header => "Offset Adjustment";
protected override LocalisableString Header => "Offset Adjustment";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)

View File

@ -4,13 +4,14 @@
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Configuration;
namespace osu.Game.Overlays.Settings.Sections.Audio
{
public class VolumeSettings : SettingsSubsection
{
protected override string Header => "Volume";
protected override LocalisableString Header => "Volume";
[BackgroundDependencyLoader]
private void load(AudioManager audio, OsuConfigManager config)

View File

@ -4,6 +4,7 @@
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Screens;
using osu.Game.Screens.Import;
@ -11,7 +12,7 @@ namespace osu.Game.Overlays.Settings.Sections.Debug
{
public class GeneralSettings : SettingsSubsection
{
protected override string Header => "General";
protected override LocalisableString Header => "General";
[BackgroundDependencyLoader(true)]
private void load(FrameworkDebugConfigManager config, FrameworkConfigManager frameworkConfig, OsuGame game)

View File

@ -4,13 +4,14 @@
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Platform;
namespace osu.Game.Overlays.Settings.Sections.Debug
{
public class MemorySettings : SettingsSubsection
{
protected override string Header => "Memory";
protected override LocalisableString Header => "Memory";
[BackgroundDependencyLoader]
private void load(FrameworkDebugConfigManager config, GameHost host)

View File

@ -4,6 +4,7 @@
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Rulesets.Scoring;
@ -11,7 +12,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
{
public class GeneralSettings : SettingsSubsection
{
protected override string Header => "General";
protected override LocalisableString Header => "General";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)

View File

@ -4,13 +4,14 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Localisation;
using osu.Game.Configuration;
namespace osu.Game.Overlays.Settings.Sections.Gameplay
{
public class ModsSettings : SettingsSubsection
{
protected override string Header => "Mods";
protected override LocalisableString Header => "Mods";
public override IEnumerable<string> FilterTerms => base.FilterTerms.Concat(new[] { "mod" });

View File

@ -5,6 +5,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Extensions;
using osu.Game.Localisation;
@ -15,7 +16,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
private SettingsDropdown<Language> languageSelection;
private Bindable<string> frameworkLocale;
protected override string Header => "Language";
protected override LocalisableString Header => "Language";
[BackgroundDependencyLoader]
private void load(FrameworkConfigManager frameworkConfig)

View File

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Game.Configuration;
@ -19,7 +20,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
[Resolved(CanBeNull = true)]
private UpdateManager updateManager { get; set; }
protected override string Header => "Updates";
protected override LocalisableString Header => "Updates";
private SettingsButton checkForUpdatesButton;

View File

@ -3,13 +3,14 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Configuration;
namespace osu.Game.Overlays.Settings.Sections.Graphics
{
public class DetailSettings : SettingsSubsection
{
protected override string Header => "Detail Settings";
protected override LocalisableString Header => "Detail Settings";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)

View File

@ -22,7 +22,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
{
public class LayoutSettings : SettingsSubsection
{
protected override string Header => "Layout";
protected override LocalisableString Header => "Layout";
private FillFlowContainer<SettingsSlider<float>> scalingSettings;

View File

@ -4,6 +4,7 @@
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Game.Configuration;
@ -11,7 +12,7 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
{
public class RendererSettings : SettingsSubsection
{
protected override string Header => "Renderer";
protected override LocalisableString Header => "Renderer";
private SettingsEnumDropdown<FrameSync> frameLimiterDropdown;

View File

@ -2,12 +2,14 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.Input
{
public class BindingSettings : SettingsSubsection
{
protected override string Header => "Shortcut and gameplay bindings";
protected override LocalisableString Header => BindingSettingsStrings.ShortcutAndGameplayBindings;
public BindingSettings(KeyBindingPanel keyConfig)
{
@ -15,8 +17,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
new SettingsButton
{
Text = "Configure",
TooltipText = "change global shortcut keys and gameplay bindings",
Text = BindingSettingsStrings.Configure,
TooltipText = BindingSettingsStrings.ChangeBindingsButton,
Action = keyConfig.ToggleVisibility
},
};

View File

@ -10,6 +10,7 @@ using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.Input
{
@ -17,7 +18,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
private readonly MouseHandler mouseHandler;
protected override string Header => "Mouse";
protected override LocalisableString Header => MouseSettingsStrings.Mouse;
private Bindable<double> handlerSensitivity;
@ -46,27 +47,29 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
new SettingsCheckbox
{
LabelText = "High precision mouse",
Current = relativeMode
LabelText = MouseSettingsStrings.HighPrecisionMouse,
TooltipText = MouseSettingsStrings.HighPrecisionMouseTooltip,
Current = relativeMode,
Keywords = new[] { @"raw", @"input", @"relative", @"cursor" }
},
new SensitivitySetting
{
LabelText = "Cursor sensitivity",
LabelText = MouseSettingsStrings.CursorSensitivity,
Current = localSensitivity
},
confineMouseModeSetting = new SettingsEnumDropdown<OsuConfineMouseMode>
{
LabelText = "Confine mouse cursor to window",
LabelText = MouseSettingsStrings.ConfineMouseMode,
Current = osuConfig.GetBindable<OsuConfineMouseMode>(OsuSetting.ConfineMouseMode)
},
new SettingsCheckbox
{
LabelText = "Disable mouse wheel during gameplay",
LabelText = MouseSettingsStrings.DisableMouseWheel,
Current = osuConfig.GetBindable<bool>(OsuSetting.MouseDisableWheel)
},
new SettingsCheckbox
{
LabelText = "Disable mouse buttons during gameplay",
LabelText = MouseSettingsStrings.DisableMouseButtons,
Current = osuConfig.GetBindable<bool>(OsuSetting.MouseDisableButtons)
},
};
@ -96,7 +99,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
if (isFullscreen)
{
confineMouseModeSetting.Current.Disabled = true;
confineMouseModeSetting.TooltipText = "Not applicable in full screen mode";
confineMouseModeSetting.TooltipText = MouseSettingsStrings.NotApplicableFullscreen;
}
else
{
@ -117,7 +120,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
private class SensitivitySlider : OsuSliderBar<double>
{
public override LocalisableString TooltipText => Current.Disabled ? "enable high precision mouse to adjust sensitivity" : $"{base.TooltipText}x";
public override LocalisableString TooltipText => Current.Disabled ? MouseSettingsStrings.EnableHighPrecisionForSensitivityAdjust : $"{base.TooltipText}x";
}
}
}

View File

@ -36,7 +36,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
RelativeSizeAxes = Axes.X,
Height = height,
Width = 0.25f,
Text = $"{presetRotation}º",
Text = $@"{presetRotation}º",
Action = () => tabletHandler.Rotation.Value = presetRotation,
});
}

View File

@ -6,10 +6,12 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Handlers.Tablet;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Framework.Threading;
using osu.Game.Graphics.Sprites;
using osuTK;
using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.Input
{
@ -52,7 +54,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
private OsuSpriteText noTabletMessage;
protected override string Header => "Tablet";
protected override LocalisableString Header => TabletSettingsStrings.Tablet;
public TabletSettings(ITabletHandler tabletHandler)
{
@ -66,14 +68,14 @@ namespace osu.Game.Overlays.Settings.Sections.Input
{
new SettingsCheckbox
{
LabelText = "Enabled",
LabelText = CommonStrings.Enabled,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Current = tabletHandler.Enabled
},
noTabletMessage = new OsuSpriteText
{
Text = "No tablet detected!",
Text = TabletSettingsStrings.NoTabletDetected,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Padding = new MarginPadding { Horizontal = SettingsPanel.CONTENT_MARGINS }
@ -94,7 +96,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
},
new DangerousSettingsButton
{
Text = "Reset to full area",
Text = TabletSettingsStrings.ResetToFullArea,
Action = () =>
{
aspectLock.Value = false;
@ -105,7 +107,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
},
new SettingsButton
{
Text = "Conform to current game aspect ratio",
Text = TabletSettingsStrings.ConformToCurrentGameAspectRatio,
Action = () =>
{
forceAspectRatio((float)host.Window.ClientSize.Width / host.Window.ClientSize.Height);
@ -114,43 +116,43 @@ namespace osu.Game.Overlays.Settings.Sections.Input
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = "X Offset",
LabelText = TabletSettingsStrings.XOffset,
Current = offsetX
},
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = "Y Offset",
LabelText = TabletSettingsStrings.YOffset,
Current = offsetY
},
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = "Rotation",
LabelText = TabletSettingsStrings.Rotation,
Current = rotation
},
new RotationPresetButtons(tabletHandler),
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = "Aspect Ratio",
LabelText = TabletSettingsStrings.AspectRatio,
Current = aspectRatio
},
new SettingsCheckbox
{
LabelText = "Lock aspect ratio",
LabelText = TabletSettingsStrings.LockAspectRatio,
Current = aspectLock
},
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = "Width",
LabelText = CommonStrings.Width,
Current = sizeX
},
new SettingsSlider<float>
{
TransferValueOnCommit = true,
LabelText = "Height",
LabelText = CommonStrings.Height,
Current = sizeY
},
}

View File

@ -9,6 +9,7 @@ using osu.Framework.Input.Handlers.Joystick;
using osu.Framework.Input.Handlers.Midi;
using osu.Framework.Input.Handlers.Mouse;
using osu.Framework.Input.Handlers.Tablet;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Game.Overlays.Settings.Sections.Input;
@ -100,7 +101,7 @@ namespace osu.Game.Overlays.Settings.Sections
};
}
protected override string Header => handler.Description;
protected override LocalisableString Header => handler.Description;
}
}
}

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Beatmaps;
using osu.Game.Collections;
using osu.Game.Database;
@ -17,7 +18,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
{
public class GeneralSettings : SettingsSubsection
{
protected override string Header => "General";
protected override LocalisableString Header => "General";
private TriangleButton importBeatmapsButton;
private TriangleButton importScoresButton;

View File

@ -3,13 +3,14 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Configuration;
namespace osu.Game.Overlays.Settings.Sections.Online
{
public class AlertsAndPrivacySettings : SettingsSubsection
{
protected override string Header => "Alerts and Privacy";
protected override LocalisableString Header => "Alerts and Privacy";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)

View File

@ -3,13 +3,14 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Configuration;
namespace osu.Game.Overlays.Settings.Sections.Online
{
public class IntegrationSettings : SettingsSubsection
{
protected override string Header => "Integrations";
protected override LocalisableString Header => "Integrations";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)

View File

@ -3,13 +3,14 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Configuration;
namespace osu.Game.Overlays.Settings.Sections.Online
{
public class WebSettings : SettingsSubsection
{
protected override string Header => "Web";
protected override LocalisableString Header => "Web";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)

View File

@ -11,7 +11,7 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
{
public class GeneralSettings : SettingsSubsection
{
protected override string Header => "General";
protected override LocalisableString Header => "General";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)

View File

@ -4,6 +4,7 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Configuration;
using osu.Game.Online.API;
using osu.Game.Users;
@ -12,7 +13,7 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
{
public class MainMenuSettings : SettingsSubsection
{
protected override string Header => "Main Menu";
protected override LocalisableString Header => "Main Menu";
private IBindable<User> user;

View File

@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
private Bindable<double> minStars;
private Bindable<double> maxStars;
protected override string Header => "Song Select";
protected override LocalisableString Header => "Song Select";
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)

View File

@ -8,6 +8,7 @@ using osu.Game.Graphics.Sprites;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Localisation;
using osu.Framework.Testing;
using osu.Game.Graphics;
@ -20,10 +21,10 @@ namespace osu.Game.Overlays.Settings
protected readonly FillFlowContainer FlowContent;
protected abstract string Header { get; }
protected abstract LocalisableString Header { get; }
public IEnumerable<IFilterable> FilterableChildren => Children.OfType<IFilterable>();
public virtual IEnumerable<string> FilterTerms => new[] { Header };
public virtual IEnumerable<string> FilterTerms => new[] { Header.ToString() };
public bool MatchingFilter
{
@ -54,7 +55,7 @@ namespace osu.Game.Overlays.Settings
{
new OsuSpriteText
{
Text = Header.ToUpperInvariant(),
Text = Header.ToString().ToUpper(), // TODO: Add localisation support after https://github.com/ppy/osu-framework/pull/4603 is merged.
Margin = new MarginPadding { Vertical = 30, Left = SettingsPanel.CONTENT_MARGINS, Right = SettingsPanel.CONTENT_MARGINS },
Font = OsuFont.GetFont(weight: FontWeight.Bold),
},

View File

@ -14,7 +14,7 @@ namespace osu.Game.Overlays.Wiki.Markdown
public class WikiMarkdownImageBlock : FillFlowContainer
{
[Resolved]
private IMarkdownTextComponent parentTextComponent { get; set; }
private IMarkdownTextFlowComponent parentFlowComponent { get; set; }
private readonly LinkInline linkInline;
@ -31,16 +31,20 @@ namespace osu.Game.Overlays.Wiki.Markdown
[BackgroundDependencyLoader]
private void load()
{
MarkdownTextFlowContainer textFlow;
Children = new Drawable[]
{
new BlockMarkdownImage(linkInline),
parentTextComponent.CreateSpriteText().With(t =>
textFlow = parentFlowComponent.CreateTextFlow().With(t =>
{
t.Text = linkInline.Title;
t.Anchor = Anchor.TopCentre;
t.Origin = Anchor.TopCentre;
t.TextAnchor = Anchor.TopCentre;
}),
};
textFlow.AddText(linkInline.Title);
}
private class BlockMarkdownImage : WikiMarkdownImage

View File

@ -5,6 +5,7 @@ using System;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Overlays.Wiki
@ -51,7 +52,7 @@ namespace osu.Game.Overlays.Wiki
Current.Value = e.NewValue.Title;
}
private void onCurrentChange(ValueChangedEvent<string> e)
private void onCurrentChange(ValueChangedEvent<LocalisableString?> e)
{
if (e.NewValue == TabControl.Items.LastOrDefault())
return;

View File

@ -2,11 +2,13 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Replays;
using osu.Game.Utils;
namespace osu.Game.Replays
{
public class Replay
public class Replay : IDeepCloneable<Replay>
{
/// <summary>
/// Whether all frames for this replay have been received.
@ -15,5 +17,15 @@ namespace osu.Game.Replays
public bool HasReceivedAllFrames = true;
public List<ReplayFrame> Frames = new List<ReplayFrame>();
public Replay DeepClone()
{
return new Replay
{
HasReceivedAllFrames = HasReceivedAllFrames,
// individual frames are mutable for now but hopefully this will not be a thing in the future.
Frames = Frames.ToList(),
};
}
}
}

View File

@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Difficulty
/// <returns>A structure describing the difficulty of the beatmap.</returns>
public DifficultyAttributes Calculate(params Mod[] mods)
{
mods = mods.Select(m => m.CreateCopy()).ToArray();
mods = mods.Select(m => m.DeepClone()).ToArray();
IBeatmap playableBeatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo, mods);

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
@ -63,10 +64,12 @@ namespace osu.Game.Rulesets.Edit
private InputManager inputManager;
private RadioButtonCollection toolboxCollection;
private EditorRadioButtonCollection toolboxCollection;
private FillFlowContainer togglesCollection;
private IBindable<bool> hasTiming;
protected HitObjectComposer(Ruleset ruleset)
{
Ruleset = ruleset;
@ -126,7 +129,7 @@ namespace osu.Game.Rulesets.Edit
{
new ToolboxGroup("toolbox (1-9)")
{
Child = toolboxCollection = new RadioButtonCollection { RelativeSizeAxes = Axes.X }
Child = toolboxCollection = new EditorRadioButtonCollection { RelativeSizeAxes = Axes.X }
},
new ToolboxGroup("toggles (Q~P)")
{
@ -160,6 +163,14 @@ namespace osu.Game.Rulesets.Edit
base.LoadComplete();
inputManager = GetContainingInputManager();
hasTiming = EditorBeatmap.HasTiming.GetBoundCopy();
hasTiming.BindValueChanged(timing =>
{
// it's important this is performed before the similar code in EditorRadioButton disables the button.
if (!timing.NewValue)
setSelectTool();
});
}
public override Playfield Playfield => drawableRulesetWrapper.Playfield;
@ -219,7 +230,8 @@ namespace osu.Game.Rulesets.Edit
if (item != null)
{
item.Select();
if (!item.Selected.Disabled)
item.Select();
return true;
}
}

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Mods
/// The base class for gameplay modifiers.
/// </summary>
[ExcludeFromDynamicCompile]
public abstract class Mod : IMod, IEquatable<Mod>, IJsonSerializable
public abstract class Mod : IMod, IEquatable<Mod>, IJsonSerializable, IDeepCloneable<Mod>
{
/// <summary>
/// The name of this mod.
@ -132,7 +132,7 @@ namespace osu.Game.Rulesets.Mods
/// <summary>
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
/// </summary>
public virtual Mod CreateCopy()
public virtual Mod DeepClone()
{
var result = (Mod)Activator.CreateInstance(GetType());
result.CopyFrom(this);

View File

@ -20,7 +20,7 @@ namespace osu.Game.Rulesets.Mods
Mods = mods;
}
public override Mod CreateCopy() => new MultiMod(Mods.Select(m => m.CreateCopy()).ToArray());
public override Mod DeepClone() => new MultiMod(Mods.Select(m => m.DeepClone()).ToArray());
public override Type[] IncompatibleMods => Mods.SelectMany(m => m.IncompatibleMods).ToArray();
}

View File

@ -2,15 +2,20 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Objects.Types;
using osuTK;
namespace osu.Game.Rulesets.Objects.Legacy.Catch
{
/// <summary>
/// Legacy osu!catch Hit-type, used for parsing Beatmaps.
/// </summary>
internal sealed class ConvertHit : ConvertHitObject, IHasCombo, IHasXPosition
internal sealed class ConvertHit : ConvertHitObject, IHasPosition, IHasCombo
{
public float X { get; set; }
public float X => Position.X;
public float Y => Position.Y;
public Vector2 Position { get; set; }
public bool NewCombo { get; set; }

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
return new ConvertHit
{
X = position.X,
Position = position,
NewCombo = newCombo,
ComboOffset = comboOffset
};
@ -47,7 +47,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
return new ConvertSlider
{
X = position.X,
Position = position,
NewCombo = FirstObject || newCombo,
ComboOffset = comboOffset,
Path = new SliderPath(controlPoints, length),

View File

@ -2,15 +2,20 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Rulesets.Objects.Types;
using osuTK;
namespace osu.Game.Rulesets.Objects.Legacy.Catch
{
/// <summary>
/// Legacy osu!catch Slider-type, used for parsing Beatmaps.
/// </summary>
internal sealed class ConvertSlider : Legacy.ConvertSlider, IHasXPosition, IHasCombo
internal sealed class ConvertSlider : Legacy.ConvertSlider, IHasPosition, IHasCombo
{
public float X { get; set; }
public float X => Position.X;
public float Y => Position.Y;
public Vector2 Position { get; set; }
public bool NewCombo { get; set; }

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Utils;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
@ -146,7 +145,7 @@ namespace osu.Game.Rulesets.Scoring
rollingMaxBaseScore += result.Judgement.MaxNumericResult;
}
scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) + 1;
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) + 1;
hitEvents.Add(CreateHitEvent(result));
lastHitObject = result.HitObject;
@ -181,7 +180,7 @@ namespace osu.Game.Rulesets.Scoring
rollingMaxBaseScore -= result.Judgement.MaxNumericResult;
}
scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) - 1;
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) - 1;
Debug.Assert(hitEvents.Count > 0);
lastHitObject = hitEvents[^1].LastHitObject;
@ -272,8 +271,8 @@ namespace osu.Game.Rulesets.Scoring
private double calculateComboRatio(int maxCombo) => maxAchievableCombo > 0 ? (double)maxCombo / maxAchievableCombo : 1;
private double getBonusScore(Dictionary<HitResult, int> statistics)
=> statistics.GetOrDefault(HitResult.SmallBonus) * Judgement.SMALL_BONUS_SCORE
+ statistics.GetOrDefault(HitResult.LargeBonus) * Judgement.LARGE_BONUS_SCORE;
=> statistics.GetValueOrDefault(HitResult.SmallBonus) * Judgement.SMALL_BONUS_SCORE
+ statistics.GetValueOrDefault(HitResult.LargeBonus) * Judgement.LARGE_BONUS_SCORE;
private ScoreRank rankFrom(double acc)
{
@ -291,7 +290,7 @@ namespace osu.Game.Rulesets.Scoring
return ScoreRank.D;
}
public int GetStatistic(HitResult result) => scoreResultCounts.GetOrDefault(result);
public int GetStatistic(HitResult result) => scoreResultCounts.GetValueOrDefault(result);
public double GetStandardisedScore() => getScore(ScoringMode.Standardised);

View File

@ -2,12 +2,22 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Replays;
using osu.Game.Utils;
namespace osu.Game.Scoring
{
public class Score
public class Score : IDeepCloneable<Score>
{
public ScoreInfo ScoreInfo = new ScoreInfo();
public Replay Replay = new Replay();
public Score DeepClone()
{
return new Score
{
ScoreInfo = ScoreInfo.DeepClone(),
Replay = Replay.DeepClone(),
};
}
}
}

View File

@ -7,7 +7,6 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using osu.Framework.Extensions;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Online.API;
@ -19,7 +18,7 @@ using osu.Game.Utils;
namespace osu.Game.Scoring
{
public class ScoreInfo : IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete, IEquatable<ScoreInfo>
public class ScoreInfo : IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete, IEquatable<ScoreInfo>, IDeepCloneable<ScoreInfo>
{
public int ID { get; set; }
@ -209,13 +208,13 @@ namespace osu.Game.Scoring
{
foreach (var r in Ruleset.CreateInstance().GetHitResults())
{
int value = Statistics.GetOrDefault(r.result);
int value = Statistics.GetValueOrDefault(r.result);
switch (r.result)
{
case HitResult.SmallTickHit:
{
int total = value + Statistics.GetOrDefault(HitResult.SmallTickMiss);
int total = value + Statistics.GetValueOrDefault(HitResult.SmallTickMiss);
if (total > 0)
yield return new HitResultDisplayStatistic(r.result, value, total, r.displayName);
@ -224,7 +223,7 @@ namespace osu.Game.Scoring
case HitResult.LargeTickHit:
{
int total = value + Statistics.GetOrDefault(HitResult.LargeTickMiss);
int total = value + Statistics.GetValueOrDefault(HitResult.LargeTickMiss);
if (total > 0)
yield return new HitResultDisplayStatistic(r.result, value, total, r.displayName);
@ -243,6 +242,15 @@ namespace osu.Game.Scoring
}
}
public ScoreInfo DeepClone()
{
var clone = (ScoreInfo)MemberwiseClone();
clone.Statistics = new Dictionary<HitResult, int>(clone.Statistics);
return clone;
}
public override string ToString() => $"{User} playing {Beatmap}";
public bool Equals(ScoreInfo other)

View File

@ -11,7 +11,6 @@ using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
@ -210,7 +209,7 @@ namespace osu.Game.Scoring
{
// This is guaranteed to be a non-legacy score.
// The combo must be determined through the score's statistics, as both the beatmap's max combo and the difficulty calculator will provide osu!stable combo values.
beatmapMaxCombo = Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.AffectsCombo()).Select(r => score.Statistics.GetOrDefault(r)).Sum();
beatmapMaxCombo = Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.AffectsCombo()).Select(r => score.Statistics.GetValueOrDefault(r)).Sum();
}
updateScore(beatmapMaxCombo, accuracy);

View File

@ -5,9 +5,11 @@ using System;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
@ -16,26 +18,30 @@ using osuTK.Graphics;
namespace osu.Game.Screens.Edit.Components.RadioButtons
{
public class DrawableRadioButton : OsuButton
public class EditorRadioButton : OsuButton, IHasTooltip
{
/// <summary>
/// Invoked when this <see cref="DrawableRadioButton"/> has been selected.
/// Invoked when this <see cref="EditorRadioButton"/> has been selected.
/// </summary>
public Action<RadioButton> Selected;
public readonly RadioButton Button;
private Color4 defaultBackgroundColour;
private Color4 defaultBubbleColour;
private Color4 selectedBackgroundColour;
private Color4 selectedBubbleColour;
private Drawable icon;
private readonly RadioButton button;
public DrawableRadioButton(RadioButton button)
[Resolved(canBeNull: true)]
private EditorBeatmap editorBeatmap { get; set; }
public EditorRadioButton(RadioButton button)
{
this.button = button;
Button = button;
Text = button.Item.ToString();
Text = button.Label;
Action = button.Select;
RelativeSizeAxes = Axes.X;
@ -57,7 +63,7 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
Colour = Color4.Black.Opacity(0.5f)
};
Add(icon = (button.CreateIcon?.Invoke() ?? new Circle()).With(b =>
Add(icon = (Button.CreateIcon?.Invoke() ?? new Circle()).With(b =>
{
b.Blending = BlendingParameters.Additive;
b.Anchor = Anchor.CentreLeft;
@ -71,13 +77,16 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
{
base.LoadComplete();
button.Selected.ValueChanged += selected =>
Button.Selected.ValueChanged += selected =>
{
updateSelectionState();
if (selected.NewValue)
Selected?.Invoke(button);
Selected?.Invoke(Button);
};
editorBeatmap?.HasTiming.BindValueChanged(hasTiming => Button.Selected.Disabled = !hasTiming.NewValue, true);
Button.Selected.BindDisabledChanged(disabled => Enabled.Value = !disabled, true);
updateSelectionState();
}
@ -86,8 +95,8 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
if (!IsLoaded)
return;
BackgroundColour = button.Selected.Value ? selectedBackgroundColour : defaultBackgroundColour;
icon.Colour = button.Selected.Value ? selectedBubbleColour : defaultBubbleColour;
BackgroundColour = Button.Selected.Value ? selectedBackgroundColour : defaultBackgroundColour;
icon.Colour = Button.Selected.Value ? selectedBubbleColour : defaultBubbleColour;
}
protected override SpriteText CreateText() => new OsuSpriteText
@ -97,5 +106,7 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
Anchor = Anchor.CentreLeft,
X = 40f
};
public LocalisableString TooltipText => Enabled.Value ? string.Empty : "Add at least one timing point first!";
}
}

View File

@ -9,7 +9,7 @@ using osuTK;
namespace osu.Game.Screens.Edit.Components.RadioButtons
{
public class RadioButtonCollection : CompositeDrawable
public class EditorRadioButtonCollection : CompositeDrawable
{
private IReadOnlyList<RadioButton> items;
@ -28,13 +28,13 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
}
}
private readonly FlowContainer<DrawableRadioButton> buttonContainer;
private readonly FlowContainer<EditorRadioButton> buttonContainer;
public RadioButtonCollection()
public EditorRadioButtonCollection()
{
AutoSizeAxes = Axes.Y;
InternalChild = buttonContainer = new FillFlowContainer<DrawableRadioButton>
InternalChild = buttonContainer = new FillFlowContainer<EditorRadioButton>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
@ -58,7 +58,7 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
currentlySelected = null;
};
buttonContainer.Add(new DrawableRadioButton(button));
buttonContainer.Add(new EditorRadioButton(button));
}
}
}

View File

@ -17,7 +17,7 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
/// <summary>
/// The item related to this button.
/// </summary>
public object Item;
public string Label;
/// <summary>
/// A function which creates a drawable icon to represent this item. If null, a sane default should be used.
@ -26,21 +26,14 @@ namespace osu.Game.Screens.Edit.Components.RadioButtons
private readonly Action action;
public RadioButton(object item, Action action, Func<Drawable> createIcon = null)
public RadioButton(string label, Action action, Func<Drawable> createIcon = null)
{
Item = item;
Label = label;
CreateIcon = createIcon;
this.action = action;
Selected = new BindableBool();
}
public RadioButton(string item)
: this(item, null)
{
Item = item;
action = null;
}
/// <summary>
/// Selects this <see cref="RadioButton"/>.
/// </summary>

View File

@ -128,7 +128,7 @@ namespace osu.Game.Screens.Edit
// clone these locally for now to avoid incurring overhead on GetPlayableBeatmap usages.
// eventually we will want to improve how/where this is done as there are issues with *not* cloning it in all cases.
playableBeatmap.ControlPointInfo = playableBeatmap.ControlPointInfo.CreateCopy();
playableBeatmap.ControlPointInfo = playableBeatmap.ControlPointInfo.DeepClone();
}
catch (Exception e)
{

Some files were not shown because too many files have changed in this diff Show More