mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 18:42:56 +08:00
Merge branch 'scoreprocessor-cleanup' into multiplayer-leaderboard-user-mods-2
This commit is contained in:
commit
13d85b8cc7
@ -52,7 +52,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.529.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2022.530.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Transitive Dependencies">
|
<ItemGroup Label="Transitive Dependencies">
|
||||||
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
|
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
|
||||||
|
@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
if (positionInfo == positionInfos.First())
|
if (positionInfo == positionInfos.First())
|
||||||
{
|
{
|
||||||
positionInfo.DistanceFromPrevious = (float)(rng.NextDouble() * OsuPlayfield.BASE_SIZE.X / 2);
|
positionInfo.DistanceFromPrevious = (float)(rng.NextDouble() * OsuPlayfield.BASE_SIZE.Y / 2);
|
||||||
positionInfo.RelativeAngle = (float)(rng.NextDouble() * 2 * Math.PI - Math.PI);
|
positionInfo.RelativeAngle = (float)(rng.NextDouble() * 2 * Math.PI - Math.PI);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -116,6 +116,7 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
if (!(osuObject is Slider slider))
|
if (!(osuObject is Slider slider))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// No need to update the head and tail circles, since slider handles that when the new slider path is set
|
||||||
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(OsuPlayfield.BASE_SIZE.X - h.Position.X, h.Position.Y));
|
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(OsuPlayfield.BASE_SIZE.X - h.Position.X, h.Position.Y));
|
||||||
slider.NestedHitObjects.OfType<SliderRepeat>().ForEach(h => h.Position = new Vector2(OsuPlayfield.BASE_SIZE.X - h.Position.X, h.Position.Y));
|
slider.NestedHitObjects.OfType<SliderRepeat>().ForEach(h => h.Position = new Vector2(OsuPlayfield.BASE_SIZE.X - h.Position.X, h.Position.Y));
|
||||||
|
|
||||||
@ -137,6 +138,7 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
if (!(osuObject is Slider slider))
|
if (!(osuObject is Slider slider))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// No need to update the head and tail circles, since slider handles that when the new slider path is set
|
||||||
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
slider.NestedHitObjects.OfType<SliderTick>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||||
slider.NestedHitObjects.OfType<SliderRepeat>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
slider.NestedHitObjects.OfType<SliderRepeat>().ForEach(h => h.Position = new Vector2(h.Position.X, OsuPlayfield.BASE_SIZE.Y - h.Position.Y));
|
||||||
|
|
||||||
@ -146,5 +148,41 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
|
|
||||||
slider.Path = new SliderPath(controlPoints, slider.Path.ExpectedDistance.Value);
|
slider.Path = new SliderPath(controlPoints, slider.Path.ExpectedDistance.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rotate a slider about its start position by the specified angle.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="slider">The slider to be rotated.</param>
|
||||||
|
/// <param name="rotation">The angle, measured in radians, to rotate the slider by.</param>
|
||||||
|
public static void RotateSlider(Slider slider, float rotation)
|
||||||
|
{
|
||||||
|
void rotateNestedObject(OsuHitObject nested) => nested.Position = rotateVector(nested.Position - slider.Position, rotation) + slider.Position;
|
||||||
|
|
||||||
|
// No need to update the head and tail circles, since slider handles that when the new slider path is set
|
||||||
|
slider.NestedHitObjects.OfType<SliderTick>().ForEach(rotateNestedObject);
|
||||||
|
slider.NestedHitObjects.OfType<SliderRepeat>().ForEach(rotateNestedObject);
|
||||||
|
|
||||||
|
var controlPoints = slider.Path.ControlPoints.Select(p => new PathControlPoint(p.Position, p.Type)).ToArray();
|
||||||
|
foreach (var point in controlPoints)
|
||||||
|
point.Position = rotateVector(point.Position, rotation);
|
||||||
|
|
||||||
|
slider.Path = new SliderPath(controlPoints, slider.Path.ExpectedDistance.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rotate a vector by the specified angle.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vector">The vector to be rotated.</param>
|
||||||
|
/// <param name="rotation">The angle, measured in radians, to rotate the vector by.</param>
|
||||||
|
/// <returns>The rotated vector.</returns>
|
||||||
|
private static Vector2 rotateVector(Vector2 vector, float rotation)
|
||||||
|
{
|
||||||
|
float angle = MathF.Atan2(vector.Y, vector.X) + rotation;
|
||||||
|
float length = vector.Length;
|
||||||
|
return new Vector2(
|
||||||
|
length * MathF.Cos(angle),
|
||||||
|
length * MathF.Sin(angle)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -37,15 +38,23 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
foreach (OsuHitObject hitObject in hitObjects)
|
foreach (OsuHitObject hitObject in hitObjects)
|
||||||
{
|
{
|
||||||
Vector2 relativePosition = hitObject.Position - previousPosition;
|
Vector2 relativePosition = hitObject.Position - previousPosition;
|
||||||
float absoluteAngle = (float)Math.Atan2(relativePosition.Y, relativePosition.X);
|
float absoluteAngle = MathF.Atan2(relativePosition.Y, relativePosition.X);
|
||||||
float relativeAngle = absoluteAngle - previousAngle;
|
float relativeAngle = absoluteAngle - previousAngle;
|
||||||
|
|
||||||
positionInfos.Add(new ObjectPositionInfo(hitObject)
|
ObjectPositionInfo positionInfo;
|
||||||
|
positionInfos.Add(positionInfo = new ObjectPositionInfo(hitObject)
|
||||||
{
|
{
|
||||||
RelativeAngle = relativeAngle,
|
RelativeAngle = relativeAngle,
|
||||||
DistanceFromPrevious = relativePosition.Length
|
DistanceFromPrevious = relativePosition.Length
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (hitObject is Slider slider)
|
||||||
|
{
|
||||||
|
float absoluteRotation = getSliderRotation(slider);
|
||||||
|
positionInfo.Rotation = absoluteRotation - absoluteAngle;
|
||||||
|
absoluteAngle = absoluteRotation;
|
||||||
|
}
|
||||||
|
|
||||||
previousPosition = hitObject.EndPosition;
|
previousPosition = hitObject.EndPosition;
|
||||||
previousAngle = absoluteAngle;
|
previousAngle = absoluteAngle;
|
||||||
}
|
}
|
||||||
@ -70,7 +79,7 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
|
|
||||||
if (hitObject is Spinner)
|
if (hitObject is Spinner)
|
||||||
{
|
{
|
||||||
previous = null;
|
previous = current;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,17 +132,24 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
float previousAbsoluteAngle = 0f;
|
float previousAbsoluteAngle = 0f;
|
||||||
|
|
||||||
if (previous != null)
|
if (previous != null)
|
||||||
|
{
|
||||||
|
if (previous.HitObject is Slider s)
|
||||||
|
{
|
||||||
|
previousAbsoluteAngle = getSliderRotation(s);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Vector2 earliestPosition = beforePrevious?.HitObject.EndPosition ?? playfield_centre;
|
Vector2 earliestPosition = beforePrevious?.HitObject.EndPosition ?? playfield_centre;
|
||||||
Vector2 relativePosition = previous.HitObject.Position - earliestPosition;
|
Vector2 relativePosition = previous.HitObject.Position - earliestPosition;
|
||||||
previousAbsoluteAngle = (float)Math.Atan2(relativePosition.Y, relativePosition.X);
|
previousAbsoluteAngle = MathF.Atan2(relativePosition.Y, relativePosition.X);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float absoluteAngle = previousAbsoluteAngle + current.PositionInfo.RelativeAngle;
|
float absoluteAngle = previousAbsoluteAngle + current.PositionInfo.RelativeAngle;
|
||||||
|
|
||||||
var posRelativeToPrev = new Vector2(
|
var posRelativeToPrev = new Vector2(
|
||||||
current.PositionInfo.DistanceFromPrevious * (float)Math.Cos(absoluteAngle),
|
current.PositionInfo.DistanceFromPrevious * MathF.Cos(absoluteAngle),
|
||||||
current.PositionInfo.DistanceFromPrevious * (float)Math.Sin(absoluteAngle)
|
current.PositionInfo.DistanceFromPrevious * MathF.Sin(absoluteAngle)
|
||||||
);
|
);
|
||||||
|
|
||||||
Vector2 lastEndPosition = previous?.EndPositionModified ?? playfield_centre;
|
Vector2 lastEndPosition = previous?.EndPositionModified ?? playfield_centre;
|
||||||
@ -141,6 +157,19 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
posRelativeToPrev = RotateAwayFromEdge(lastEndPosition, posRelativeToPrev);
|
posRelativeToPrev = RotateAwayFromEdge(lastEndPosition, posRelativeToPrev);
|
||||||
|
|
||||||
current.PositionModified = lastEndPosition + posRelativeToPrev;
|
current.PositionModified = lastEndPosition + posRelativeToPrev;
|
||||||
|
|
||||||
|
if (!(current.HitObject is Slider slider))
|
||||||
|
return;
|
||||||
|
|
||||||
|
absoluteAngle = MathF.Atan2(posRelativeToPrev.Y, posRelativeToPrev.X);
|
||||||
|
|
||||||
|
Vector2 centreOfMassOriginal = calculateCentreOfMass(slider);
|
||||||
|
Vector2 centreOfMassModified = rotateVector(centreOfMassOriginal, current.PositionInfo.Rotation + absoluteAngle - getSliderRotation(slider));
|
||||||
|
centreOfMassModified = RotateAwayFromEdge(current.PositionModified, centreOfMassModified);
|
||||||
|
|
||||||
|
float relativeRotation = MathF.Atan2(centreOfMassModified.Y, centreOfMassModified.X) - MathF.Atan2(centreOfMassOriginal.Y, centreOfMassOriginal.X);
|
||||||
|
if (!Precision.AlmostEquals(relativeRotation, 0))
|
||||||
|
RotateSlider(slider, relativeRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -172,13 +201,13 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
var previousPosition = workingObject.PositionModified;
|
var previousPosition = workingObject.PositionModified;
|
||||||
|
|
||||||
// Clamp slider position to the placement area
|
// Clamp slider position to the placement area
|
||||||
// If the slider is larger than the playfield, force it to stay at the original position
|
// If the slider is larger than the playfield, at least make sure that the head circle is inside the playfield
|
||||||
float newX = possibleMovementBounds.Width < 0
|
float newX = possibleMovementBounds.Width < 0
|
||||||
? workingObject.PositionOriginal.X
|
? Math.Clamp(possibleMovementBounds.Left, 0, OsuPlayfield.BASE_SIZE.X)
|
||||||
: Math.Clamp(previousPosition.X, possibleMovementBounds.Left, possibleMovementBounds.Right);
|
: Math.Clamp(previousPosition.X, possibleMovementBounds.Left, possibleMovementBounds.Right);
|
||||||
|
|
||||||
float newY = possibleMovementBounds.Height < 0
|
float newY = possibleMovementBounds.Height < 0
|
||||||
? workingObject.PositionOriginal.Y
|
? Math.Clamp(possibleMovementBounds.Top, 0, OsuPlayfield.BASE_SIZE.Y)
|
||||||
: Math.Clamp(previousPosition.Y, possibleMovementBounds.Top, possibleMovementBounds.Bottom);
|
: Math.Clamp(previousPosition.Y, possibleMovementBounds.Top, possibleMovementBounds.Bottom);
|
||||||
|
|
||||||
slider.Position = workingObject.PositionModified = new Vector2(newX, newY);
|
slider.Position = workingObject.PositionModified = new Vector2(newX, newY);
|
||||||
@ -287,6 +316,45 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Estimate the centre of mass of a slider relative to its start position.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="slider">The slider to process.</param>
|
||||||
|
/// <returns>The centre of mass of the slider.</returns>
|
||||||
|
private static Vector2 calculateCentreOfMass(Slider slider)
|
||||||
|
{
|
||||||
|
const double sample_step = 50;
|
||||||
|
|
||||||
|
// just sample the start and end positions if the slider is too short
|
||||||
|
if (slider.Distance <= sample_step)
|
||||||
|
{
|
||||||
|
return Vector2.Divide(slider.Path.PositionAt(1), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
Vector2 sum = Vector2.Zero;
|
||||||
|
double pathDistance = slider.Distance;
|
||||||
|
|
||||||
|
for (double i = 0; i < pathDistance; i += sample_step)
|
||||||
|
{
|
||||||
|
sum += slider.Path.PositionAt(i / pathDistance);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum / count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the absolute rotation of a slider, defined as the angle from its start position to the end of its path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="slider">The slider to process.</param>
|
||||||
|
/// <returns>The angle in radians.</returns>
|
||||||
|
private static float getSliderRotation(Slider slider)
|
||||||
|
{
|
||||||
|
var endPositionVector = slider.Path.PositionAt(1);
|
||||||
|
return MathF.Atan2(endPositionVector.Y, endPositionVector.X);
|
||||||
|
}
|
||||||
|
|
||||||
public class ObjectPositionInfo
|
public class ObjectPositionInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -309,6 +377,13 @@ namespace osu.Game.Rulesets.Osu.Utils
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public float DistanceFromPrevious { get; set; }
|
public float DistanceFromPrevious { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The rotation of the hit object, relative to its jump angle.
|
||||||
|
/// For sliders, this is defined as the angle from the slider's start position to the end of its path, relative to its jump angle.
|
||||||
|
/// For hit circles and spinners, this property is ignored.
|
||||||
|
/// </summary>
|
||||||
|
public float Rotation { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The hit object associated with this <see cref="ObjectPositionInfo"/>.
|
/// The hit object associated with this <see cref="ObjectPositionInfo"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -61,13 +61,13 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
|
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
|
||||||
|
|
||||||
// No header shouldn't cause any change
|
// No header shouldn't cause any change
|
||||||
scoreProcessor.ResetFromReplayFrame(new OsuRuleset(), new OsuReplayFrame());
|
scoreProcessor.ResetFromReplayFrame(new OsuReplayFrame());
|
||||||
|
|
||||||
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(1_000_000));
|
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(1_000_000));
|
||||||
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
|
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
|
||||||
|
|
||||||
// Reset with a miss instead.
|
// Reset with a miss instead.
|
||||||
scoreProcessor.ResetFromReplayFrame(new OsuRuleset(), new OsuReplayFrame
|
scoreProcessor.ResetFromReplayFrame(new OsuReplayFrame
|
||||||
{
|
{
|
||||||
Header = new FrameHeader(0, 0, 0, new Dictionary<HitResult, int> { { HitResult.Miss, 1 } }, DateTimeOffset.Now)
|
Header = new FrameHeader(0, 0, 0, new Dictionary<HitResult, int> { { HitResult.Miss, 1 } }, DateTimeOffset.Now)
|
||||||
});
|
});
|
||||||
@ -76,7 +76,7 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
|
Assert.That(scoreProcessor.JudgedHits, Is.EqualTo(1));
|
||||||
|
|
||||||
// Reset with no judged hit.
|
// Reset with no judged hit.
|
||||||
scoreProcessor.ResetFromReplayFrame(new OsuRuleset(), new OsuReplayFrame
|
scoreProcessor.ResetFromReplayFrame(new OsuReplayFrame
|
||||||
{
|
{
|
||||||
Header = new FrameHeader(0, 0, 0, new Dictionary<HitResult, int>(), DateTimeOffset.Now)
|
Header = new FrameHeader(0, 0, 0, new Dictionary<HitResult, int>(), DateTimeOffset.Now)
|
||||||
});
|
});
|
||||||
|
@ -115,9 +115,12 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
BeatmapID = 0,
|
BeatmapID = 0,
|
||||||
RulesetID = 0,
|
RulesetID = 0,
|
||||||
Mods = user.Mods,
|
Mods = user.Mods,
|
||||||
MaxAchievableCombo = 1000,
|
MaximumScoringValues = new ScoringValues
|
||||||
MaxAchievableBaseScore = 10000,
|
{
|
||||||
TotalBasicHitObjects = 1000
|
BaseScore = 10000,
|
||||||
|
MaxCombo = 1000,
|
||||||
|
HitObjects = 1000
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Testing;
|
|||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Spectator;
|
using osu.Game.Online.Spectator;
|
||||||
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Dashboard;
|
using osu.Game.Overlays.Dashboard;
|
||||||
using osu.Game.Tests.Visual.Spectator;
|
using osu.Game.Tests.Visual.Spectator;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -42,7 +43,8 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
CachedDependencies = new (Type, object)[]
|
CachedDependencies = new (Type, object)[]
|
||||||
{
|
{
|
||||||
(typeof(SpectatorClient), spectatorClient),
|
(typeof(SpectatorClient), spectatorClient),
|
||||||
(typeof(UserLookupCache), lookupCache)
|
(typeof(UserLookupCache), lookupCache),
|
||||||
|
(typeof(OverlayColourProvider), new OverlayColourProvider(OverlayColourScheme.Purple)),
|
||||||
},
|
},
|
||||||
Child = currentlyPlaying = new CurrentlyPlayingDisplay
|
Child = currentlyPlaying = new CurrentlyPlayingDisplay
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Buffers;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Microsoft.Toolkit.HighPerformance;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.IO.Stores;
|
using osu.Framework.IO.Stores;
|
||||||
using SharpCompress.Archives.Zip;
|
using SharpCompress.Archives.Zip;
|
||||||
|
using SixLabors.ImageSharp.Memory;
|
||||||
|
|
||||||
namespace osu.Game.IO.Archives
|
namespace osu.Game.IO.Archives
|
||||||
{
|
{
|
||||||
@ -27,15 +31,12 @@ namespace osu.Game.IO.Archives
|
|||||||
if (entry == null)
|
if (entry == null)
|
||||||
throw new FileNotFoundException();
|
throw new FileNotFoundException();
|
||||||
|
|
||||||
// allow seeking
|
var owner = MemoryAllocator.Default.Allocate<byte>((int)entry.Size);
|
||||||
MemoryStream copy = new MemoryStream();
|
|
||||||
|
|
||||||
using (Stream s = entry.OpenEntryStream())
|
using (Stream s = entry.OpenEntryStream())
|
||||||
s.CopyTo(copy);
|
s.ReadToFill(owner.Memory.Span);
|
||||||
|
|
||||||
copy.Position = 0;
|
return new MemoryOwnerMemoryStream(owner);
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
@ -45,5 +46,48 @@ namespace osu.Game.IO.Archives
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<string> Filenames => archive.Entries.Select(e => e.Key).ExcludeSystemFileNames();
|
public override IEnumerable<string> Filenames => archive.Entries.Select(e => e.Key).ExcludeSystemFileNames();
|
||||||
|
|
||||||
|
private class MemoryOwnerMemoryStream : Stream
|
||||||
|
{
|
||||||
|
private readonly IMemoryOwner<byte> owner;
|
||||||
|
private readonly Stream stream;
|
||||||
|
|
||||||
|
public MemoryOwnerMemoryStream(IMemoryOwner<byte> owner)
|
||||||
|
{
|
||||||
|
this.owner = owner;
|
||||||
|
|
||||||
|
stream = owner.Memory.AsStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
owner?.Dispose();
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Flush() => stream.Flush();
|
||||||
|
|
||||||
|
public override int Read(byte[] buffer, int offset, int count) => stream.Read(buffer, offset, count);
|
||||||
|
|
||||||
|
public override long Seek(long offset, SeekOrigin origin) => stream.Seek(offset, origin);
|
||||||
|
|
||||||
|
public override void SetLength(long value) => stream.SetLength(value);
|
||||||
|
|
||||||
|
public override void Write(byte[] buffer, int offset, int count) => stream.Write(buffer, offset, count);
|
||||||
|
|
||||||
|
public override bool CanRead => stream.CanRead;
|
||||||
|
|
||||||
|
public override bool CanSeek => stream.CanSeek;
|
||||||
|
|
||||||
|
public override bool CanWrite => stream.CanWrite;
|
||||||
|
|
||||||
|
public override long Length => stream.Length;
|
||||||
|
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get => stream.Position;
|
||||||
|
set => stream.Position = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,9 +172,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
currentState.RulesetID = score.ScoreInfo.RulesetID;
|
currentState.RulesetID = score.ScoreInfo.RulesetID;
|
||||||
currentState.Mods = score.ScoreInfo.Mods.Select(m => new APIMod(m)).ToArray();
|
currentState.Mods = score.ScoreInfo.Mods.Select(m => new APIMod(m)).ToArray();
|
||||||
currentState.State = SpectatedUserState.Playing;
|
currentState.State = SpectatedUserState.Playing;
|
||||||
currentState.MaxAchievableCombo = state.ScoreProcessor.MaxAchievableCombo;
|
currentState.MaximumScoringValues = state.ScoreProcessor.MaximumScoringValues;
|
||||||
currentState.MaxAchievableBaseScore = state.ScoreProcessor.MaxAchievableBaseScore;
|
|
||||||
currentState.TotalBasicHitObjects = state.ScoreProcessor.TotalBasicHitObjects;
|
|
||||||
|
|
||||||
currentBeatmap = state.Beatmap;
|
currentBeatmap = state.Beatmap;
|
||||||
currentScore = score;
|
currentScore = score;
|
||||||
|
@ -62,6 +62,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
private readonly List<TimedFrame> replayFrames = new List<TimedFrame>();
|
private readonly List<TimedFrame> replayFrames = new List<TimedFrame>();
|
||||||
private readonly int userId;
|
private readonly int userId;
|
||||||
|
|
||||||
|
private SpectatorState? spectatorState;
|
||||||
private ScoreProcessor? scoreProcessor;
|
private ScoreProcessor? scoreProcessor;
|
||||||
private ScoreInfo? scoreInfo;
|
private ScoreInfo? scoreInfo;
|
||||||
|
|
||||||
@ -89,6 +90,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
scoreProcessor?.RemoveAndDisposeImmediately();
|
scoreProcessor?.RemoveAndDisposeImmediately();
|
||||||
scoreProcessor = null;
|
scoreProcessor = null;
|
||||||
scoreInfo = null;
|
scoreInfo = null;
|
||||||
|
spectatorState = null;
|
||||||
replayFrames.Clear();
|
replayFrames.Clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,18 +106,13 @@ namespace osu.Game.Online.Spectator
|
|||||||
|
|
||||||
Ruleset ruleset = rulesetInfo.CreateInstance();
|
Ruleset ruleset = rulesetInfo.CreateInstance();
|
||||||
|
|
||||||
|
spectatorState = userState;
|
||||||
scoreInfo = new ScoreInfo { Ruleset = rulesetInfo };
|
scoreInfo = new ScoreInfo { Ruleset = rulesetInfo };
|
||||||
scoreProcessor = ruleset.CreateScoreProcessor();
|
scoreProcessor = ruleset.CreateScoreProcessor();
|
||||||
|
|
||||||
// Mods are required for score multiplier.
|
// Mods are required for score multiplier.
|
||||||
scoreProcessor.Mods.Value = userState.Mods.Select(m => m.ToMod(ruleset)).ToArray();
|
scoreProcessor.Mods.Value = userState.Mods.Select(m => m.ToMod(ruleset)).ToArray();
|
||||||
|
|
||||||
// Applying beatmap required to call ComputePartialScore().
|
|
||||||
scoreProcessor.ApplyBeatmap(new DummyBeatmap());
|
scoreProcessor.ApplyBeatmap(new DummyBeatmap());
|
||||||
|
|
||||||
scoreProcessor.MaxAchievableCombo = userState.MaxAchievableCombo;
|
|
||||||
scoreProcessor.MaxAchievableBaseScore = userState.MaxAchievableBaseScore;
|
|
||||||
scoreProcessor.TotalBasicHitObjects = userState.TotalBasicHitObjects;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onNewFrames(int incomingUserId, FrameDataBundle bundle)
|
private void onNewFrames(int incomingUserId, FrameDataBundle bundle)
|
||||||
@ -138,6 +135,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
if (scoreInfo == null || replayFrames.Count == 0)
|
if (scoreInfo == null || replayFrames.Count == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Debug.Assert(spectatorState != null);
|
||||||
Debug.Assert(scoreProcessor != null);
|
Debug.Assert(scoreProcessor != null);
|
||||||
|
|
||||||
int frameIndex = replayFrames.BinarySearch(new TimedFrame(Time.Current));
|
int frameIndex = replayFrames.BinarySearch(new TimedFrame(Time.Current));
|
||||||
@ -153,7 +151,9 @@ namespace osu.Game.Online.Spectator
|
|||||||
|
|
||||||
Accuracy.Value = frame.Header.Accuracy;
|
Accuracy.Value = frame.Header.Accuracy;
|
||||||
Combo.Value = frame.Header.Combo;
|
Combo.Value = frame.Header.Combo;
|
||||||
TotalScore.Value = scoreProcessor.ComputePartialScore(Mode.Value, scoreInfo);
|
|
||||||
|
scoreProcessor.ExtractScoringValues(frame.Header, out var currentScoringValues, out _);
|
||||||
|
TotalScore.Value = scoreProcessor.ComputeScore(Mode.Value, currentScoringValues, spectatorState.MaximumScoringValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
@ -7,6 +7,7 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using MessagePack;
|
using MessagePack;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Online.Spectator
|
namespace osu.Game.Online.Spectator
|
||||||
{
|
{
|
||||||
@ -27,23 +28,8 @@ namespace osu.Game.Online.Spectator
|
|||||||
[Key(3)]
|
[Key(3)]
|
||||||
public SpectatedUserState State { get; set; }
|
public SpectatedUserState State { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The maximum achievable combo, if everything is hit perfectly.
|
|
||||||
/// </summary>
|
|
||||||
[Key(4)]
|
[Key(4)]
|
||||||
public int MaxAchievableCombo { get; set; }
|
public ScoringValues MaximumScoringValues { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The maximum achievable base score, if everything is hit perfectly.
|
|
||||||
/// </summary>
|
|
||||||
[Key(5)]
|
|
||||||
public double MaxAchievableBaseScore { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The total number of basic (non-tick and non-bonus) hitobjects that can be hit.
|
|
||||||
/// </summary>
|
|
||||||
[Key(6)]
|
|
||||||
public int TotalBasicHitObjects { get; set; }
|
|
||||||
|
|
||||||
public bool Equals(SpectatorState other)
|
public bool Equals(SpectatorState other)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -9,11 +10,16 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Spectator;
|
using osu.Game.Online.Spectator;
|
||||||
|
using osu.Game.Resources.Localisation.Web;
|
||||||
using osu.Game.Screens;
|
using osu.Game.Screens;
|
||||||
using osu.Game.Screens.OnlinePlay.Match.Components;
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
@ -24,26 +30,62 @@ namespace osu.Game.Overlays.Dashboard
|
|||||||
{
|
{
|
||||||
internal class CurrentlyPlayingDisplay : CompositeDrawable
|
internal class CurrentlyPlayingDisplay : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
private const float search_textbox_height = 40;
|
||||||
|
private const float padding = 10;
|
||||||
|
|
||||||
private readonly IBindableList<int> playingUsers = new BindableList<int>();
|
private readonly IBindableList<int> playingUsers = new BindableList<int>();
|
||||||
|
|
||||||
private FillFlowContainer<PlayingUserPanel> userFlow;
|
private SearchContainer<PlayingUserPanel> userFlow;
|
||||||
|
private BasicSearchTextBox searchTextBox;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private SpectatorClient spectatorClient { get; set; }
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load(OverlayColourProvider colourProvider)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
|
|
||||||
InternalChild = userFlow = new FillFlowContainer<PlayingUserPanel>
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = padding * 2 + search_textbox_height,
|
||||||
|
Colour = colourProvider.Background4,
|
||||||
|
},
|
||||||
|
new Container<BasicSearchTextBox>
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Padding = new MarginPadding(padding),
|
||||||
|
Child = searchTextBox = new BasicSearchTextBox
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Height = search_textbox_height,
|
||||||
|
ReleaseFocusOnCommit = false,
|
||||||
|
HoldFocus = true,
|
||||||
|
PlaceholderText = HomeStrings.SearchPlaceholder,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
userFlow = new SearchContainer<PlayingUserPanel>
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Padding = new MarginPadding(10),
|
|
||||||
Spacing = new Vector2(10),
|
Spacing = new Vector2(10),
|
||||||
|
Padding = new MarginPadding
|
||||||
|
{
|
||||||
|
Top = padding * 3 + search_textbox_height,
|
||||||
|
Bottom = padding,
|
||||||
|
Right = padding,
|
||||||
|
Left = padding,
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
searchTextBox.Current.ValueChanged += text => userFlow.SearchTerm = text.NewValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -57,6 +99,13 @@ namespace osu.Game.Overlays.Dashboard
|
|||||||
playingUsers.BindCollectionChanged(onPlayingUsersChanged, true);
|
playingUsers.BindCollectionChanged(onPlayingUsersChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnFocus(FocusEvent e)
|
||||||
|
{
|
||||||
|
base.OnFocus(e);
|
||||||
|
|
||||||
|
searchTextBox.TakeFocus();
|
||||||
|
}
|
||||||
|
|
||||||
private void onPlayingUsersChanged(object sender, NotifyCollectionChangedEventArgs e) => Schedule(() =>
|
private void onPlayingUsersChanged(object sender, NotifyCollectionChangedEventArgs e) => Schedule(() =>
|
||||||
{
|
{
|
||||||
switch (e.Action)
|
switch (e.Action)
|
||||||
@ -102,17 +151,34 @@ namespace osu.Game.Overlays.Dashboard
|
|||||||
panel.Origin = Anchor.TopCentre;
|
panel.Origin = Anchor.TopCentre;
|
||||||
});
|
});
|
||||||
|
|
||||||
private class PlayingUserPanel : CompositeDrawable
|
public class PlayingUserPanel : CompositeDrawable, IFilterable
|
||||||
{
|
{
|
||||||
public readonly APIUser User;
|
public readonly APIUser User;
|
||||||
|
|
||||||
|
public IEnumerable<LocalisableString> FilterTerms { get; }
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private IPerformFromScreenRunner performer { get; set; }
|
private IPerformFromScreenRunner performer { get; set; }
|
||||||
|
|
||||||
|
public bool FilteringActive { set; get; }
|
||||||
|
|
||||||
|
public bool MatchingFilter
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
Show();
|
||||||
|
else
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public PlayingUserPanel(APIUser user)
|
public PlayingUserPanel(APIUser user)
|
||||||
{
|
{
|
||||||
User = user;
|
User = user;
|
||||||
|
|
||||||
|
FilterTerms = new LocalisableString[] { User.Username };
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
protected override DashboardOverlayHeader CreateHeader() => new DashboardOverlayHeader();
|
protected override DashboardOverlayHeader CreateHeader() => new DashboardOverlayHeader();
|
||||||
|
|
||||||
|
public override bool AcceptsFocus => false;
|
||||||
|
|
||||||
protected override void CreateDisplayToLoad(DashboardOverlayTabs tab)
|
protected override void CreateDisplayToLoad(DashboardOverlayTabs tab)
|
||||||
{
|
{
|
||||||
switch (tab)
|
switch (tab)
|
||||||
|
@ -117,9 +117,8 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// If the provided replay frame does not have any header information, this will be a noop.
|
/// If the provided replay frame does not have any header information, this will be a noop.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <param name="ruleset">The ruleset to be used for retrieving statistics.</param>
|
|
||||||
/// <param name="frame">The replay frame to read header statistics from.</param>
|
/// <param name="frame">The replay frame to read header statistics from.</param>
|
||||||
public virtual void ResetFromReplayFrame(Ruleset ruleset, ReplayFrame frame)
|
public virtual void ResetFromReplayFrame(ReplayFrame frame)
|
||||||
{
|
{
|
||||||
if (frame.Header == null)
|
if (frame.Header == null)
|
||||||
return;
|
return;
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -89,19 +90,22 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
private readonly double comboPortion;
|
private readonly double comboPortion;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum achievable combo, if everything is hit perfectly.
|
/// Scoring values for a perfect play.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal int MaxAchievableCombo;
|
public ScoringValues MaximumScoringValues { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum achievable base score, if everything is hit perfectly.
|
/// Scoring values for the current play assuming all perfect hits.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal double MaxAchievableBaseScore;
|
/// <remarks>
|
||||||
|
/// This is only used to determine the accuracy with respect to the current point in time for an ongoing play session.
|
||||||
|
/// </remarks>
|
||||||
|
private ScoringValues currentMaximumScoringValues;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The total number of basic (non-tick and non-bonus) hitobjects that can be hit.
|
/// Scoring values for the current play.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal int TotalBasicHitObjects;
|
private ScoringValues currentScoringValues;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum <see cref="HitResult"/> of a basic (non-tick and non-bonus) hitobject.
|
/// The maximum <see cref="HitResult"/> of a basic (non-tick and non-bonus) hitobject.
|
||||||
@ -109,9 +113,6 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private HitResult? maxBasicResult;
|
private HitResult? maxBasicResult;
|
||||||
|
|
||||||
private double rollingMaxAchievableBaseScore;
|
|
||||||
private double rollingBaseScore;
|
|
||||||
private int rollingBasicHitObjects;
|
|
||||||
private bool beatmapApplied;
|
private bool beatmapApplied;
|
||||||
|
|
||||||
private readonly Dictionary<HitResult, int> scoreResultCounts = new Dictionary<HitResult, int>();
|
private readonly Dictionary<HitResult, int> scoreResultCounts = new Dictionary<HitResult, int>();
|
||||||
@ -167,23 +168,42 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) + 1;
|
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) + 1;
|
||||||
|
|
||||||
if (!result.Type.IsScorable())
|
if (!result.Type.IsScorable())
|
||||||
return;
|
{
|
||||||
|
// The inverse of non-scorable (ignore) judgements may be bonus judgements.
|
||||||
|
if (result.Judgement.MaxResult.IsBonus())
|
||||||
|
currentMaximumScoringValues.BonusScore += result.Judgement.MaxNumericResult;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update rolling combo.
|
||||||
if (result.Type.IncreasesCombo())
|
if (result.Type.IncreasesCombo())
|
||||||
Combo.Value++;
|
Combo.Value++;
|
||||||
else if (result.Type.BreaksCombo())
|
else if (result.Type.BreaksCombo())
|
||||||
Combo.Value = 0;
|
Combo.Value = 0;
|
||||||
|
|
||||||
double scoreIncrease = result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
// Update maximum combo.
|
||||||
|
currentScoringValues.MaxCombo = HighestCombo.Value;
|
||||||
|
currentMaximumScoringValues.MaxCombo += result.Judgement.MaxResult.AffectsCombo() ? 1 : 0;
|
||||||
|
|
||||||
if (!result.Type.IsBonus())
|
// Update base/bonus score.
|
||||||
|
if (result.Type.IsBonus())
|
||||||
{
|
{
|
||||||
rollingBaseScore += scoreIncrease;
|
currentScoringValues.BonusScore += result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
||||||
rollingMaxAchievableBaseScore += result.Judgement.MaxNumericResult;
|
currentMaximumScoringValues.BonusScore += result.Judgement.MaxNumericResult;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentScoringValues.BaseScore += result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
||||||
|
currentMaximumScoringValues.BaseScore += result.Judgement.MaxNumericResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update hitobject count.
|
||||||
if (result.Type.IsBasic())
|
if (result.Type.IsBasic())
|
||||||
rollingBasicHitObjects++;
|
{
|
||||||
|
currentScoringValues.HitObjects++;
|
||||||
|
currentMaximumScoringValues.HitObjects++;
|
||||||
|
}
|
||||||
|
|
||||||
hitEvents.Add(CreateHitEvent(result));
|
hitEvents.Add(CreateHitEvent(result));
|
||||||
lastHitObject = result.HitObject;
|
lastHitObject = result.HitObject;
|
||||||
@ -210,18 +230,36 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) - 1;
|
scoreResultCounts[result.Type] = scoreResultCounts.GetValueOrDefault(result.Type) - 1;
|
||||||
|
|
||||||
if (!result.Type.IsScorable())
|
if (!result.Type.IsScorable())
|
||||||
return;
|
|
||||||
|
|
||||||
double scoreIncrease = result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
|
||||||
|
|
||||||
if (!result.Type.IsBonus())
|
|
||||||
{
|
{
|
||||||
rollingBaseScore -= scoreIncrease;
|
// The inverse of non-scorable (ignore) judgements may be bonus judgements.
|
||||||
rollingMaxAchievableBaseScore -= result.Judgement.MaxNumericResult;
|
if (result.Judgement.MaxResult.IsBonus())
|
||||||
|
currentMaximumScoringValues.BonusScore -= result.Judgement.MaxNumericResult;
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update maximum combo.
|
||||||
|
currentScoringValues.MaxCombo = HighestCombo.Value;
|
||||||
|
currentMaximumScoringValues.MaxCombo -= result.Judgement.MaxResult.AffectsCombo() ? 1 : 0;
|
||||||
|
|
||||||
|
// Update base/bonus score.
|
||||||
|
if (result.Type.IsBonus())
|
||||||
|
{
|
||||||
|
currentScoringValues.BonusScore -= result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
||||||
|
currentMaximumScoringValues.BonusScore -= result.Judgement.MaxNumericResult;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentScoringValues.BaseScore -= result.Type.IsHit() ? result.Judgement.NumericResultFor(result) : 0;
|
||||||
|
currentMaximumScoringValues.BaseScore -= result.Judgement.MaxNumericResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update hitobject count.
|
||||||
if (result.Type.IsBasic())
|
if (result.Type.IsBasic())
|
||||||
rollingBasicHitObjects--;
|
{
|
||||||
|
currentScoringValues.HitObjects--;
|
||||||
|
currentMaximumScoringValues.HitObjects--;
|
||||||
|
}
|
||||||
|
|
||||||
Debug.Assert(hitEvents.Count > 0);
|
Debug.Assert(hitEvents.Count > 0);
|
||||||
lastHitObject = hitEvents[^1].LastHitObject;
|
lastHitObject = hitEvents[^1].LastHitObject;
|
||||||
@ -232,12 +270,8 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
|
|
||||||
private void updateScore()
|
private void updateScore()
|
||||||
{
|
{
|
||||||
double rollingAccuracyRatio = rollingMaxAchievableBaseScore > 0 ? rollingBaseScore / rollingMaxAchievableBaseScore : 1;
|
Accuracy.Value = currentMaximumScoringValues.BaseScore > 0 ? currentScoringValues.BaseScore / currentMaximumScoringValues.BaseScore : 1;
|
||||||
double accuracyRatio = MaxAchievableBaseScore > 0 ? rollingBaseScore / MaxAchievableBaseScore : 1;
|
TotalScore.Value = ComputeScore(Mode.Value, currentScoringValues, MaximumScoringValues);
|
||||||
double comboRatio = MaxAchievableCombo > 0 ? (double)HighestCombo.Value / MaxAchievableCombo : 1;
|
|
||||||
|
|
||||||
Accuracy.Value = rollingAccuracyRatio;
|
|
||||||
TotalScore.Value = ComputeScore(Mode.Value, accuracyRatio, comboRatio, getBonusScore(scoreResultCounts), TotalBasicHitObjects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -254,17 +288,10 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
if (!ruleset.RulesetInfo.Equals(scoreInfo.Ruleset))
|
if (!ruleset.RulesetInfo.Equals(scoreInfo.Ruleset))
|
||||||
throw new ArgumentException($"Unexpected score ruleset. Expected \"{ruleset.RulesetInfo.ShortName}\" but was \"{scoreInfo.Ruleset.ShortName}\".");
|
throw new ArgumentException($"Unexpected score ruleset. Expected \"{ruleset.RulesetInfo.ShortName}\" but was \"{scoreInfo.Ruleset.ShortName}\".");
|
||||||
|
|
||||||
extractFromStatistics(ruleset,
|
extractScoringValues(scoreInfo.Statistics, out var current, out var maximum);
|
||||||
scoreInfo.Statistics,
|
current.MaxCombo = scoreInfo.MaxCombo;
|
||||||
out double extractedBaseScore,
|
|
||||||
out double extractedMaxBaseScore,
|
|
||||||
out int extractedMaxCombo,
|
|
||||||
out int extractedBasicHitObjects);
|
|
||||||
|
|
||||||
double accuracyRatio = extractedMaxBaseScore > 0 ? extractedBaseScore / extractedMaxBaseScore : 1;
|
return ComputeScore(mode, current, maximum);
|
||||||
double comboRatio = extractedMaxCombo > 0 ? (double)scoreInfo.MaxCombo / extractedMaxCombo : 1;
|
|
||||||
|
|
||||||
return ComputeScore(mode, accuracyRatio, comboRatio, getBonusScore(scoreInfo.Statistics), extractedBasicHitObjects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -284,17 +311,10 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
if (!beatmapApplied)
|
if (!beatmapApplied)
|
||||||
throw new InvalidOperationException($"Cannot compute partial score without calling {nameof(ApplyBeatmap)}.");
|
throw new InvalidOperationException($"Cannot compute partial score without calling {nameof(ApplyBeatmap)}.");
|
||||||
|
|
||||||
extractFromStatistics(ruleset,
|
extractScoringValues(scoreInfo.Statistics, out var current, out _);
|
||||||
scoreInfo.Statistics,
|
current.MaxCombo = scoreInfo.MaxCombo;
|
||||||
out double extractedBaseScore,
|
|
||||||
out _,
|
|
||||||
out _,
|
|
||||||
out _);
|
|
||||||
|
|
||||||
double accuracyRatio = MaxAchievableBaseScore > 0 ? extractedBaseScore / MaxAchievableBaseScore : 1;
|
return ComputeScore(mode, current, MaximumScoringValues);
|
||||||
double comboRatio = MaxAchievableCombo > 0 ? (double)scoreInfo.MaxCombo / MaxAchievableCombo : 1;
|
|
||||||
|
|
||||||
return ComputeScore(mode, accuracyRatio, comboRatio, getBonusScore(scoreInfo.Statistics), TotalBasicHitObjects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -316,26 +336,29 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
double accuracyRatio = scoreInfo.Accuracy;
|
double accuracyRatio = scoreInfo.Accuracy;
|
||||||
double comboRatio = maxAchievableCombo > 0 ? (double)scoreInfo.MaxCombo / maxAchievableCombo : 1;
|
double comboRatio = maxAchievableCombo > 0 ? (double)scoreInfo.MaxCombo / maxAchievableCombo : 1;
|
||||||
|
|
||||||
|
extractScoringValues(scoreInfo.Statistics, out var current, out var maximum);
|
||||||
|
|
||||||
// For legacy osu!mania scores, a full-GREAT score has 100% accuracy. If combined with a full-combo, the score becomes indistinguishable from a full-PERFECT score.
|
// For legacy osu!mania scores, a full-GREAT score has 100% accuracy. If combined with a full-combo, the score becomes indistinguishable from a full-PERFECT score.
|
||||||
// To get around this, the accuracy ratio is always recalculated based on the hit statistics rather than trusting the score.
|
// To get around this, the accuracy ratio is always recalculated based on the hit statistics rather than trusting the score.
|
||||||
// Note: This cannot be applied universally to all legacy scores, as some rulesets (e.g. catch) group multiple judgements together.
|
// Note: This cannot be applied universally to all legacy scores, as some rulesets (e.g. catch) group multiple judgements together.
|
||||||
if (scoreInfo.IsLegacyScore && scoreInfo.Ruleset.OnlineID == 3)
|
if (scoreInfo.IsLegacyScore && scoreInfo.Ruleset.OnlineID == 3 && maximum.BaseScore > 0)
|
||||||
{
|
accuracyRatio = current.BaseScore / maximum.BaseScore;
|
||||||
extractFromStatistics(
|
|
||||||
ruleset,
|
|
||||||
scoreInfo.Statistics,
|
|
||||||
out double computedBaseScore,
|
|
||||||
out double computedMaxBaseScore,
|
|
||||||
out _,
|
|
||||||
out _);
|
|
||||||
|
|
||||||
if (computedMaxBaseScore > 0)
|
return ComputeScore(mode, accuracyRatio, comboRatio, current.BonusScore, maximum.HitObjects);
|
||||||
accuracyRatio = computedBaseScore / computedMaxBaseScore;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int computedBasicHitObjects = scoreInfo.Statistics.Where(kvp => kvp.Key.IsBasic()).Select(kvp => kvp.Value).Sum();
|
/// <summary>
|
||||||
|
/// Computes the total score from scoring values.
|
||||||
return ComputeScore(mode, accuracyRatio, comboRatio, getBonusScore(scoreInfo.Statistics), computedBasicHitObjects);
|
/// </summary>
|
||||||
|
/// <param name="mode">The <see cref="ScoringMode"/> to represent the score as.</param>
|
||||||
|
/// <param name="current">The current scoring values.</param>
|
||||||
|
/// <param name="maximum">The maximum scoring values.</param>
|
||||||
|
/// <returns>The total score computed from the given scoring values.</returns>
|
||||||
|
public double ComputeScore(ScoringMode mode, ScoringValues current, ScoringValues maximum)
|
||||||
|
{
|
||||||
|
double accuracyRatio = maximum.BaseScore > 0 ? current.BaseScore / maximum.BaseScore : 1;
|
||||||
|
double comboRatio = maximum.MaxCombo > 0 ? (double)current.MaxCombo / maximum.MaxCombo : 1;
|
||||||
|
return ComputeScore(mode, accuracyRatio, comboRatio, current.BonusScore, maximum.HitObjects);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -365,15 +388,6 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Calculates the total bonus score from score statistics.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="statistics">The score statistics.</param>
|
|
||||||
/// <returns>The total bonus score.</returns>
|
|
||||||
private double getBonusScore(IReadOnlyDictionary<HitResult, int> statistics)
|
|
||||||
=> statistics.GetValueOrDefault(HitResult.SmallBonus) * Judgement.SMALL_BONUS_SCORE
|
|
||||||
+ statistics.GetValueOrDefault(HitResult.LargeBonus) * Judgement.LARGE_BONUS_SCORE;
|
|
||||||
|
|
||||||
private ScoreRank rankFrom(double acc)
|
private ScoreRank rankFrom(double acc)
|
||||||
{
|
{
|
||||||
if (acc == 1)
|
if (acc == 1)
|
||||||
@ -405,15 +419,10 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
lastHitObject = null;
|
lastHitObject = null;
|
||||||
|
|
||||||
if (storeResults)
|
if (storeResults)
|
||||||
{
|
MaximumScoringValues = currentScoringValues;
|
||||||
MaxAchievableCombo = HighestCombo.Value;
|
|
||||||
MaxAchievableBaseScore = rollingBaseScore;
|
|
||||||
TotalBasicHitObjects = rollingBasicHitObjects;
|
|
||||||
}
|
|
||||||
|
|
||||||
rollingBaseScore = 0;
|
currentScoringValues = default;
|
||||||
rollingMaxAchievableBaseScore = 0;
|
currentMaximumScoringValues = default;
|
||||||
rollingBasicHitObjects = 0;
|
|
||||||
|
|
||||||
TotalScore.Value = 0;
|
TotalScore.Value = 0;
|
||||||
Accuracy.Value = 1;
|
Accuracy.Value = 1;
|
||||||
@ -440,14 +449,19 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
score.TotalScore = (long)Math.Round(ComputeFinalScore(ScoringMode.Standardised, score));
|
score.TotalScore = (long)Math.Round(ComputeFinalScore(ScoringMode.Standardised, score));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ResetFromReplayFrame(Ruleset ruleset, ReplayFrame frame)
|
public override void ResetFromReplayFrame(ReplayFrame frame)
|
||||||
{
|
{
|
||||||
base.ResetFromReplayFrame(ruleset, frame);
|
base.ResetFromReplayFrame(frame);
|
||||||
|
|
||||||
if (frame.Header == null)
|
if (frame.Header == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
extractFromStatistics(ruleset, frame.Header.Statistics, out rollingBaseScore, out rollingMaxAchievableBaseScore, out _, out _);
|
extractScoringValues(frame.Header.Statistics, out var current, out var maximum);
|
||||||
|
currentScoringValues.BaseScore = current.BaseScore;
|
||||||
|
currentScoringValues.MaxCombo = frame.Header.MaxCombo;
|
||||||
|
currentMaximumScoringValues.BaseScore = maximum.BaseScore;
|
||||||
|
currentMaximumScoringValues.MaxCombo = maximum.MaxCombo;
|
||||||
|
|
||||||
HighestCombo.Value = frame.Header.MaxCombo;
|
HighestCombo.Value = frame.Header.MaxCombo;
|
||||||
|
|
||||||
scoreResultCounts.Clear();
|
scoreResultCounts.Clear();
|
||||||
@ -458,20 +472,85 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
OnResetFromReplayFrame?.Invoke();
|
OnResetFromReplayFrame?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractFromStatistics(Ruleset ruleset, IReadOnlyDictionary<HitResult, int> statistics, out double baseScore, out double maxBaseScore, out int maxCombo,
|
#region ScoringValue extraction
|
||||||
out int basicHitObjects)
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies a best-effort extraction of hit statistics into <see cref="ScoringValues"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This method is useful in a variety of situations, with a few drawbacks that need to be considered:
|
||||||
|
/// <list type="bullet">
|
||||||
|
/// <item>The maximum <see cref="ScoringValues.BonusScore"/> will always be 0.</item>
|
||||||
|
/// <item>The current and maximum <see cref="ScoringValues.HitObjects"/> will always be the same value.</item>
|
||||||
|
/// </list>
|
||||||
|
/// Consumers are expected to more accurately fill in the above values through external means.
|
||||||
|
/// <para>
|
||||||
|
/// <b>Ensure</b> to fill in the maximum <see cref="ScoringValues.HitObjects"/> for use in
|
||||||
|
/// <see cref="ComputeScore(osu.Game.Rulesets.Scoring.ScoringMode,osu.Game.Scoring.ScoringValues,osu.Game.Scoring.ScoringValues)"/>.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="scoreInfo">The score to extract scoring values from.</param>
|
||||||
|
/// <param name="current">The "current" scoring values, representing the hit statistics as they appear.</param>
|
||||||
|
/// <param name="maximum">The "maximum" scoring values, representing the hit statistics as if the maximum hit result was attained each time.</param>
|
||||||
|
public void ExtractScoringValues(ScoreInfo scoreInfo, out ScoringValues current, out ScoringValues maximum)
|
||||||
{
|
{
|
||||||
baseScore = 0;
|
extractScoringValues(scoreInfo.Statistics, out current, out maximum);
|
||||||
maxBaseScore = 0;
|
current.MaxCombo = scoreInfo.MaxCombo;
|
||||||
maxCombo = 0;
|
}
|
||||||
basicHitObjects = 0;
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies a best-effort extraction of hit statistics into <see cref="ScoringValues"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This method is useful in a variety of situations, with a few drawbacks that need to be considered:
|
||||||
|
/// <list type="bullet">
|
||||||
|
/// <item>The maximum <see cref="ScoringValues.BonusScore"/> will always be 0.</item>
|
||||||
|
/// <item>The current and maximum <see cref="ScoringValues.HitObjects"/> will always be the same value.</item>
|
||||||
|
/// </list>
|
||||||
|
/// Consumers are expected to more accurately fill in the above values through external means.
|
||||||
|
/// <para>
|
||||||
|
/// <b>Ensure</b> to fill in the maximum <see cref="ScoringValues.HitObjects"/> for use in
|
||||||
|
/// <see cref="ComputeScore(osu.Game.Rulesets.Scoring.ScoringMode,osu.Game.Scoring.ScoringValues,osu.Game.Scoring.ScoringValues)"/>.
|
||||||
|
/// </para>
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="header">The replay frame header to extract scoring values from.</param>
|
||||||
|
/// <param name="current">The "current" scoring values, representing the hit statistics as they appear.</param>
|
||||||
|
/// <param name="maximum">The "maximum" scoring values, representing the hit statistics as if the maximum hit result was attained each time.</param>
|
||||||
|
public void ExtractScoringValues(FrameHeader header, out ScoringValues current, out ScoringValues maximum)
|
||||||
|
{
|
||||||
|
extractScoringValues(header.Statistics, out current, out maximum);
|
||||||
|
current.MaxCombo = header.MaxCombo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies a best-effort extraction of hit statistics into <see cref="ScoringValues"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This method is useful in a variety of situations, with a few drawbacks that need to be considered:
|
||||||
|
/// <list type="bullet">
|
||||||
|
/// <item>The current <see cref="ScoringValues.MaxCombo"/> will always be 0.</item>
|
||||||
|
/// <item>The maximum <see cref="ScoringValues.BonusScore"/> will always be 0.</item>
|
||||||
|
/// <item>The current and maximum <see cref="ScoringValues.HitObjects"/> will always be the same value.</item>
|
||||||
|
/// </list>
|
||||||
|
/// Consumers are expected to more accurately fill in the above values (especially the current <see cref="ScoringValues.MaxCombo"/>) via external means (e.g. <see cref="ScoreInfo"/>).
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="statistics">The hit statistics to extract scoring values from.</param>
|
||||||
|
/// <param name="current">The "current" scoring values, representing the hit statistics as they appear.</param>
|
||||||
|
/// <param name="maximum">The "maximum" scoring values, representing the hit statistics as if the maximum hit result was attained each time.</param>
|
||||||
|
private void extractScoringValues(IReadOnlyDictionary<HitResult, int> statistics, out ScoringValues current, out ScoringValues maximum)
|
||||||
|
{
|
||||||
|
current = default;
|
||||||
|
maximum = default;
|
||||||
|
|
||||||
foreach ((HitResult result, int count) in statistics)
|
foreach ((HitResult result, int count) in statistics)
|
||||||
{
|
{
|
||||||
// Bonus scores are counted separately directly from the statistics dictionary later on.
|
if (!result.IsScorable())
|
||||||
if (!result.IsScorable() || result.IsBonus())
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (result.IsBonus())
|
||||||
|
current.BonusScore += count * Judgement.ToNumericResult(result);
|
||||||
|
else
|
||||||
|
{
|
||||||
// The maximum result of this judgement if it wasn't a miss.
|
// The maximum result of this judgement if it wasn't a miss.
|
||||||
// E.g. For a GOOD judgement, the max result is either GREAT/PERFECT depending on which one the ruleset uses (osu!: GREAT, osu!mania: PERFECT).
|
// E.g. For a GOOD judgement, the max result is either GREAT/PERFECT depending on which one the ruleset uses (osu!: GREAT, osu!mania: PERFECT).
|
||||||
HitResult maxResult;
|
HitResult maxResult;
|
||||||
@ -493,16 +572,22 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
baseScore += count * Judgement.ToNumericResult(result);
|
current.BaseScore += count * Judgement.ToNumericResult(result);
|
||||||
maxBaseScore += count * Judgement.ToNumericResult(maxResult);
|
maximum.BaseScore += count * Judgement.ToNumericResult(maxResult);
|
||||||
|
}
|
||||||
|
|
||||||
if (result.AffectsCombo())
|
if (result.AffectsCombo())
|
||||||
maxCombo += count;
|
maximum.MaxCombo += count;
|
||||||
|
|
||||||
if (result.IsBasic())
|
if (result.IsBasic())
|
||||||
basicHitObjects += count;
|
{
|
||||||
|
current.HitObjects += count;
|
||||||
|
maximum.HitObjects += count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
@ -27,8 +27,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
{
|
{
|
||||||
public readonly KeyBindingContainer<T> KeyBindingContainer;
|
public readonly KeyBindingContainer<T> KeyBindingContainer;
|
||||||
|
|
||||||
private readonly Ruleset ruleset;
|
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private ScoreProcessor scoreProcessor { get; set; }
|
private ScoreProcessor scoreProcessor { get; set; }
|
||||||
|
|
||||||
@ -57,8 +55,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
protected RulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
protected RulesetInputManager(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
|
||||||
{
|
{
|
||||||
this.ruleset = ruleset.CreateInstance();
|
|
||||||
|
|
||||||
InternalChild = KeyBindingContainer =
|
InternalChild = KeyBindingContainer =
|
||||||
CreateKeyBindingContainer(ruleset, variant, unique)
|
CreateKeyBindingContainer(ruleset, variant, unique)
|
||||||
.WithChild(content = new Container { RelativeSizeAxes = Axes.Both });
|
.WithChild(content = new Container { RelativeSizeAxes = Axes.Both });
|
||||||
@ -85,7 +81,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ReplayStatisticsFrameEvent statisticsStateChangeEvent:
|
case ReplayStatisticsFrameEvent statisticsStateChangeEvent:
|
||||||
scoreProcessor?.ResetFromReplayFrame(ruleset, statisticsStateChangeEvent.Frame);
|
scoreProcessor?.ResetFromReplayFrame(statisticsStateChangeEvent.Frame);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
38
osu.Game/Scoring/ScoringValues.cs
Normal file
38
osu.Game/Scoring/ScoringValues.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// 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 MessagePack;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Scoring
|
||||||
|
{
|
||||||
|
[MessagePackObject]
|
||||||
|
public struct ScoringValues
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The sum of all "basic" <see cref="HitObject"/> scoring values. See: <see cref="HitResultExtensions.IsBasic"/> and <see cref="Judgement.ToNumericResult"/>.
|
||||||
|
/// </summary>
|
||||||
|
[Key(0)]
|
||||||
|
public double BaseScore;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The sum of all "bonus" <see cref="HitObject"/> scoring values. See: <see cref="HitResultExtensions.IsBonus"/> and <see cref="Judgement.ToNumericResult"/>.
|
||||||
|
/// </summary>
|
||||||
|
[Key(1)]
|
||||||
|
public double BonusScore;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The highest achieved combo.
|
||||||
|
/// </summary>
|
||||||
|
[Key(2)]
|
||||||
|
public int MaxCombo;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The count of "basic" <see cref="HitObject"/>s. See: <see cref="HitResultExtensions.IsBasic"/>.
|
||||||
|
/// </summary>
|
||||||
|
[Key(3)]
|
||||||
|
public int HitObjects;
|
||||||
|
}
|
||||||
|
}
|
@ -29,13 +29,14 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Toolkit.HighPerformance" Version="7.1.2" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="ppy.LocalisationAnalyser" Version="2022.417.0">
|
<PackageReference Include="ppy.LocalisationAnalyser" Version="2022.417.0">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Realm" Version="10.11.2" />
|
<PackageReference Include="Realm" Version="10.11.2" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2022.529.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2022.530.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" />
|
||||||
<PackageReference Include="Sentry" Version="3.17.1" />
|
<PackageReference Include="Sentry" Version="3.17.1" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.529.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2022.530.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2022.527.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
|
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net6.0) -->
|
||||||
@ -84,7 +84,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.14" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="5.0.14" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2022.529.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2022.530.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
<PackageReference Include="SharpCompress" Version="0.31.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.3" />
|
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user