1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 12:42:54 +08:00

Merge branch 'master' into spectator-listing

This commit is contained in:
Dean Herbert 2020-11-02 15:48:21 +09:00
commit 414f65c1ef
58 changed files with 507 additions and 215 deletions

View File

@ -16,9 +16,9 @@
<EmbeddedResource Include="Resources\**\*.*" /> <EmbeddedResource Include="Resources\**\*.*" />
</ItemGroup> </ItemGroup>
<ItemGroup Label="Code Analysis"> <ItemGroup Label="Code Analysis">
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.0" PrivateAssets="All" /> <PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.1" PrivateAssets="All" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)CodeAnalysis\BannedSymbols.txt" /> <AdditionalFiles Include="$(MSBuildThisFileDirectory)CodeAnalysis\BannedSymbols.txt" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0" PrivateAssets="All" /> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Code Analysis"> <PropertyGroup Label="Code Analysis">
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodeAnalysis\osu.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodeAnalysis\osu.ruleset</CodeAnalysisRuleSet>

View File

@ -5,6 +5,6 @@
"version": "3.1.100" "version": "3.1.100"
}, },
"msbuild-sdks": { "msbuild-sdks": {
"Microsoft.Build.Traversal": "2.1.1" "Microsoft.Build.Traversal": "2.2.3"
} }
} }

View File

@ -51,7 +51,7 @@
<Reference Include="Java.Interop" /> <Reference Include="Java.Interop" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1016.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2020.1030.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.1029.1" /> <PackageReference Include="ppy.osu.Framework.Android" Version="2020.1029.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -6,20 +6,20 @@
"EndTime": 2750.0, "EndTime": 2750.0,
"Column": 1, "Column": 1,
"NodeSamples": [ "NodeSamples": [
["normal-hitnormal"], ["Gameplay/normal-hitnormal"],
["soft-hitnormal"], ["Gameplay/soft-hitnormal"],
["drum-hitnormal"] ["Gameplay/drum-hitnormal"]
], ],
"Samples": ["-hitnormal"] "Samples": ["Gameplay/-hitnormal"]
}, { }, {
"StartTime": 1875.0, "StartTime": 1875.0,
"EndTime": 2750.0, "EndTime": 2750.0,
"Column": 0, "Column": 0,
"NodeSamples": [ "NodeSamples": [
["soft-hitnormal"], ["Gameplay/soft-hitnormal"],
["drum-hitnormal"] ["Gameplay/drum-hitnormal"]
], ],
"Samples": ["-hitnormal"] "Samples": ["Gameplay/-hitnormal"]
}] }]
}, { }, {
"StartTime": 3750.0, "StartTime": 3750.0,
@ -27,7 +27,7 @@
"StartTime": 3750.0, "StartTime": 3750.0,
"EndTime": 3750.0, "EndTime": 3750.0,
"Column": 3, "Column": 3,
"Samples": ["normal-hitnormal"] "Samples": ["Gameplay/normal-hitnormal"]
}] }]
}] }]
} }

View File

@ -6,10 +6,10 @@
"EndTime": 1500.0, "EndTime": 1500.0,
"Column": 0, "Column": 0,
"NodeSamples": [ "NodeSamples": [
["normal-hitnormal"], ["Gameplay/normal-hitnormal"],
[] []
], ],
"Samples": ["normal-hitnormal"] "Samples": ["Gameplay/normal-hitnormal"]
}] }]
}, { }, {
"StartTime": 2000.0, "StartTime": 2000.0,
@ -18,10 +18,10 @@
"EndTime": 3000.0, "EndTime": 3000.0,
"Column": 2, "Column": 2,
"NodeSamples": [ "NodeSamples": [
["drum-hitnormal"], ["Gameplay/drum-hitnormal"],
[] []
], ],
"Samples": ["drum-hitnormal"] "Samples": ["Gameplay/drum-hitnormal"]
}] }]
}] }]
} }

View File

@ -5,17 +5,17 @@
"StartTime": 8470.0, "StartTime": 8470.0,
"EndTime": 8470.0, "EndTime": 8470.0,
"Column": 0, "Column": 0,
"Samples": ["normal-hitnormal", "normal-hitclap"] "Samples": ["Gameplay/normal-hitnormal", "Gameplay/normal-hitclap"]
}, { }, {
"StartTime": 8626.470587768974, "StartTime": 8626.470587768974,
"EndTime": 8626.470587768974, "EndTime": 8626.470587768974,
"Column": 1, "Column": 1,
"Samples": ["normal-hitnormal"] "Samples": ["Gameplay/normal-hitnormal"]
}, { }, {
"StartTime": 8782.941175537948, "StartTime": 8782.941175537948,
"EndTime": 8782.941175537948, "EndTime": 8782.941175537948,
"Column": 2, "Column": 2,
"Samples": ["normal-hitnormal", "normal-hitclap"] "Samples": ["Gameplay/normal-hitnormal", "Gameplay/normal-hitclap"]
}] }]
}] }]
} }

View File

@ -64,8 +64,8 @@ namespace osu.Game.Rulesets.Osu.Mods
/// </summary> /// </summary>
private const float target_clamp = 1; private const float target_clamp = 1;
private readonly float targetBreakMultiplier = 0; private readonly float targetBreakMultiplier;
private readonly float easing = 1; private readonly float easing;
private readonly CompositeDrawable restrictTo; private readonly CompositeDrawable restrictTo;
@ -86,6 +86,9 @@ namespace osu.Game.Rulesets.Osu.Mods
{ {
this.restrictTo = restrictTo; this.restrictTo = restrictTo;
this.beatmap = beatmap; this.beatmap = beatmap;
targetBreakMultiplier = 0;
easing = 1;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -2,6 +2,10 @@
// 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.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
@ -18,47 +22,83 @@ namespace osu.Game.Rulesets.Taiko.Audio
private readonly ControlPointInfo controlPoints; private readonly ControlPointInfo controlPoints;
private readonly Dictionary<double, DrumSample> mappings = new Dictionary<double, DrumSample>(); private readonly Dictionary<double, DrumSample> mappings = new Dictionary<double, DrumSample>();
private IBindableList<SampleControlPoint> samplePoints;
public DrumSampleContainer(ControlPointInfo controlPoints) public DrumSampleContainer(ControlPointInfo controlPoints)
{ {
this.controlPoints = controlPoints; this.controlPoints = controlPoints;
}
IReadOnlyList<SampleControlPoint> samplePoints = controlPoints.SamplePoints.Count == 0 ? new[] { controlPoints.SamplePointAt(double.MinValue) } : controlPoints.SamplePoints; [BackgroundDependencyLoader]
private void load()
for (int i = 0; i < samplePoints.Count; i++)
{ {
var samplePoint = samplePoints[i]; samplePoints = controlPoints.SamplePoints.GetBoundCopy();
samplePoints.BindCollectionChanged((_, __) => recreateMappings(), true);
}
var centre = samplePoint.GetSampleInfo(); private void recreateMappings()
var rim = samplePoint.GetSampleInfo(HitSampleInfo.HIT_CLAP); {
mappings.Clear();
ClearInternal();
SampleControlPoint[] points = samplePoints.Count == 0
? new[] { controlPoints.SamplePointAt(double.MinValue) }
: samplePoints.ToArray();
for (int i = 0; i < points.Length; i++)
{
var samplePoint = points[i];
var lifetimeStart = i > 0 ? samplePoint.Time : double.MinValue; var lifetimeStart = i > 0 ? samplePoint.Time : double.MinValue;
var lifetimeEnd = i + 1 < samplePoints.Count ? samplePoints[i + 1].Time : double.MaxValue; var lifetimeEnd = i + 1 < points.Length ? points[i + 1].Time : double.MaxValue;
mappings[samplePoint.Time] = new DrumSample AddInternal(mappings[samplePoint.Time] = new DrumSample(samplePoint)
{
Centre = addSound(centre, lifetimeStart, lifetimeEnd),
Rim = addSound(rim, lifetimeStart, lifetimeEnd)
};
}
}
private PausableSkinnableSound addSound(HitSampleInfo hitSampleInfo, double lifetimeStart, double lifetimeEnd)
{
var drawable = new PausableSkinnableSound(hitSampleInfo)
{ {
LifetimeStart = lifetimeStart, LifetimeStart = lifetimeStart,
LifetimeEnd = lifetimeEnd LifetimeEnd = lifetimeEnd
}; });
AddInternal(drawable); }
return drawable;
} }
public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time).Time]; public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time).Time];
public class DrumSample public class DrumSample : CompositeDrawable
{ {
public PausableSkinnableSound Centre; public override bool RemoveWhenNotAlive => false;
public PausableSkinnableSound Rim;
public PausableSkinnableSound Centre { get; private set; }
public PausableSkinnableSound Rim { get; private set; }
private readonly SampleControlPoint samplePoint;
private Bindable<string> sampleBank;
private BindableNumber<int> sampleVolume;
public DrumSample(SampleControlPoint samplePoint)
{
this.samplePoint = samplePoint;
}
[BackgroundDependencyLoader]
private void load()
{
sampleBank = samplePoint.SampleBankBindable.GetBoundCopy();
sampleBank.BindValueChanged(_ => recreate());
sampleVolume = samplePoint.SampleVolumeBindable.GetBoundCopy();
sampleVolume.BindValueChanged(_ => recreate());
recreate();
}
private void recreate()
{
InternalChildren = new Drawable[]
{
Centre = new PausableSkinnableSound(samplePoint.GetSampleInfo()),
Rim = new PausableSkinnableSound(samplePoint.GetSampleInfo(HitSampleInfo.HIT_CLAP))
};
}
} }
} }
} }

View File

@ -162,7 +162,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning
get get
{ {
foreach (var name in source.LookupNames) foreach (var name in source.LookupNames)
yield return $"taiko-{name}"; yield return name.Insert(name.LastIndexOf('/') + 1, "taiko-");
foreach (var name in source.LookupNames) foreach (var name in source.LookupNames)
yield return name; yield return name;

View File

@ -410,13 +410,13 @@ namespace osu.Game.Tests.Beatmaps.Formats
{ {
var hitObjects = decoder.Decode(stream).HitObjects; var hitObjects = decoder.Decode(stream).HitObjects;
Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[3]).LookupNames.First());
// The control point at the end time of the slider should be applied // The control point at the end time of the slider should be applied
Assert.AreEqual("soft-hitnormal8", getTestableSampleInfo(hitObjects[4]).LookupNames.First()); Assert.AreEqual("Gameplay/soft-hitnormal8", getTestableSampleInfo(hitObjects[4]).LookupNames.First());
} }
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]); static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
@ -432,9 +432,9 @@ namespace osu.Game.Tests.Beatmaps.Formats
{ {
var hitObjects = decoder.Decode(stream).HitObjects; var hitObjects = decoder.Decode(stream).HitObjects;
Assert.AreEqual("normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); Assert.AreEqual("Gameplay/normal-hitnormal", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
Assert.AreEqual("normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); Assert.AreEqual("Gameplay/normal-hitnormal3", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
} }
static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]); static HitSampleInfo getTestableSampleInfo(HitObject hitObject) => hitObject.SampleControlPoint.ApplyTo(hitObject.Samples[0]);
@ -452,7 +452,7 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[0]).LookupNames.First()); Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[0]).LookupNames.First());
Assert.AreEqual("hit_2.wav", getTestableSampleInfo(hitObjects[1]).LookupNames.First()); Assert.AreEqual("hit_2.wav", getTestableSampleInfo(hitObjects[1]).LookupNames.First());
Assert.AreEqual("normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First()); Assert.AreEqual("Gameplay/normal-hitnormal2", getTestableSampleInfo(hitObjects[2]).LookupNames.First());
Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[3]).LookupNames.First()); Assert.AreEqual("hit_1.wav", getTestableSampleInfo(hitObjects[3]).LookupNames.First());
Assert.AreEqual(70, getTestableSampleInfo(hitObjects[3]).Volume); Assert.AreEqual(70, getTestableSampleInfo(hitObjects[3]).Volume);
} }

View File

@ -821,15 +821,13 @@ namespace osu.Game.Tests.Beatmaps.IO
var manager = osu.Dependencies.Get<BeatmapManager>(); var manager = osu.Dependencies.Get<BeatmapManager>();
await manager.Import(temp); var importedSet = await manager.Import(temp);
var imported = manager.GetAllUsableBeatmapSets();
ensureLoaded(osu); ensureLoaded(osu);
waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000); waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
return imported.LastOrDefault(); return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.ID);
} }
private void deleteBeatmapSet(BeatmapSetInfo imported, OsuGameBase osu) private void deleteBeatmapSet(BeatmapSetInfo imported, OsuGameBase osu)

View File

@ -81,8 +81,8 @@ namespace osu.Game.Tests.Gameplay
private class TestHitObjectWithCombo : ConvertHitObject, IHasComboInformation private class TestHitObjectWithCombo : ConvertHitObject, IHasComboInformation
{ {
public bool NewCombo { get; set; } = false; public bool NewCombo { get; set; }
public int ComboOffset { get; } = 0; public int ComboOffset => 0;
public Bindable<int> IndexInCurrentComboBindable { get; } = new Bindable<int>(); public Bindable<int> IndexInCurrentComboBindable { get; } = new Bindable<int>();

View File

@ -149,18 +149,14 @@ namespace osu.Game.Tests.Visual.Background
=> AddStep($"set seasonal mode to {mode}", () => config.Set(OsuSetting.SeasonalBackgroundMode, mode)); => AddStep($"set seasonal mode to {mode}", () => config.Set(OsuSetting.SeasonalBackgroundMode, mode));
private void createLoader() private void createLoader()
{ => AddStep("create loader", () =>
AddStep("create loader", () =>
{ {
if (backgroundLoader != null) if (backgroundLoader != null)
Remove(backgroundLoader); Remove(backgroundLoader);
LoadComponentAsync(backgroundLoader = new SeasonalBackgroundLoader(), Add); Add(backgroundLoader = new SeasonalBackgroundLoader());
}); });
AddUntilStep("wait for loaded", () => backgroundLoader.IsLoaded);
}
private void loadNextBackground() private void loadNextBackground()
{ {
SeasonalBackground background = null; SeasonalBackground background = null;

View File

@ -19,7 +19,6 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens; using osu.Game.Screens;
@ -193,9 +192,9 @@ namespace osu.Game.Tests.Visual.Background
AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(new ScoreInfo AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(new ScoreInfo
{ {
Ruleset = new OsuRuleset().RulesetInfo,
User = new User { Username = "osu!" }, User = new User { Username = "osu!" },
Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo Beatmap = new TestBeatmap(Ruleset.Value).BeatmapInfo,
Ruleset = Ruleset.Value,
}))); })));
AddUntilStep("Wait for results is current", () => results.IsCurrentScreen()); AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());

View File

@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Gameplay
skinSource = new TestSkinSourceContainer skinSource = new TestSkinSourceContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Child = skinnableSound = new PausableSkinnableSound(new SampleInfo("normal-sliderslide")) Child = skinnableSound = new PausableSkinnableSound(new SampleInfo("Gameplay/normal-sliderslide"))
}, },
}; };
}); });

View File

@ -135,7 +135,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true); public Bindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);
public IBindableList<Room> Rooms { get; } = null; public IBindableList<Room> Rooms => null;
public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null) public void CreateRoom(Room room, Action<Room> onSuccess = null, Action<string> onError = null)
{ {

View File

@ -120,7 +120,7 @@ namespace osu.Game.Tests.Visual.Ranking
} }
} }
}, },
new AccuracyCircle(score) new AccuracyCircle(score, true)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -197,8 +197,8 @@ namespace osu.Game.Tests.Visual.SongSelect
private class TestHitObject : ConvertHitObject, IHasPosition private class TestHitObject : ConvertHitObject, IHasPosition
{ {
public float X { get; } = 0; public float X => 0;
public float Y { get; } = 0; public float Y => 0;
public Vector2 Position { get; } = Vector2.Zero; public Vector2 Position { get; } = Vector2.Zero;
} }
} }

View File

@ -50,9 +50,9 @@ namespace osu.Game.Audio
get get
{ {
if (!string.IsNullOrEmpty(Suffix)) if (!string.IsNullOrEmpty(Suffix))
yield return $"{Bank}-{Name}{Suffix}"; yield return $"Gameplay/{Bank}-{Name}{Suffix}";
yield return $"{Bank}-{Name}"; yield return $"Gameplay/{Bank}-{Name}";
} }
} }

View File

@ -10,14 +10,14 @@ namespace osu.Game.Audio
/// </summary> /// </summary>
public class SampleInfo : ISampleInfo public class SampleInfo : ISampleInfo
{ {
private readonly string sampleName; private readonly string[] sampleNames;
public SampleInfo(string sampleName) public SampleInfo(params string[] sampleNames)
{ {
this.sampleName = sampleName; this.sampleNames = sampleNames;
} }
public IEnumerable<string> LookupNames => new[] { sampleName }; public IEnumerable<string> LookupNames => sampleNames;
public int Volume { get; } = 100; public int Volume { get; } = 100;
} }

View File

@ -17,6 +17,7 @@ using osu.Framework.Logging;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
@ -238,7 +239,7 @@ namespace osu.Game.Beatmaps
var calculator = ruleset.CreateDifficultyCalculator(beatmapManager.GetWorkingBeatmap(beatmapInfo)); var calculator = ruleset.CreateDifficultyCalculator(beatmapManager.GetWorkingBeatmap(beatmapInfo));
var attributes = calculator.Calculate(key.Mods); var attributes = calculator.Calculate(key.Mods);
return difficultyCache[key] = new StarDifficulty(attributes.StarRating, attributes.MaxCombo); return difficultyCache[key] = new StarDifficulty(attributes);
} }
catch (BeatmapInvalidForRulesetException e) catch (BeatmapInvalidForRulesetException e)
{ {
@ -346,17 +347,46 @@ namespace osu.Game.Beatmaps
public readonly struct StarDifficulty public readonly struct StarDifficulty
{ {
/// <summary>
/// The star difficulty rating for the given beatmap.
/// </summary>
public readonly double Stars; public readonly double Stars;
/// <summary>
/// The maximum combo achievable on the given beatmap.
/// </summary>
public readonly int MaxCombo; public readonly int MaxCombo;
public StarDifficulty(double stars, int maxCombo) /// <summary>
{ /// The difficulty attributes computed for the given beatmap.
Stars = stars; /// Might not be available if the star difficulty is associated with a beatmap that's not locally available.
MaxCombo = maxCombo; /// </summary>
[CanBeNull]
public readonly DifficultyAttributes Attributes;
/// <summary>
/// Creates a <see cref="StarDifficulty"/> structure based on <see cref="DifficultyAttributes"/> computed
/// by a <see cref="DifficultyCalculator"/>.
/// </summary>
public StarDifficulty([NotNull] DifficultyAttributes attributes)
{
Stars = attributes.StarRating;
MaxCombo = attributes.MaxCombo;
Attributes = attributes;
// Todo: Add more members (BeatmapInfo.DifficultyRating? Attributes? Etc...) // Todo: Add more members (BeatmapInfo.DifficultyRating? Attributes? Etc...)
} }
/// <summary>
/// Creates a <see cref="StarDifficulty"/> structure with a pre-populated star difficulty and max combo
/// in scenarios where computing <see cref="DifficultyAttributes"/> is not feasible (i.e. when working with online sources).
/// </summary>
public StarDifficulty(double starDifficulty, int maxCombo)
{
Stars = starDifficulty;
MaxCombo = maxCombo;
Attributes = null;
}
public DifficultyRating DifficultyRating => BeatmapDifficultyManager.GetDifficultyRating(Stars); public DifficultyRating DifficultyRating => BeatmapDifficultyManager.GetDifficultyRating(Stars);
} }
} }

View File

@ -41,9 +41,9 @@ namespace osu.Game.Beatmaps.ControlPoints
/// All sound points. /// All sound points.
/// </summary> /// </summary>
[JsonProperty] [JsonProperty]
public IReadOnlyList<SampleControlPoint> SamplePoints => samplePoints; public IBindableList<SampleControlPoint> SamplePoints => samplePoints;
private readonly SortedList<SampleControlPoint> samplePoints = new SortedList<SampleControlPoint>(Comparer<SampleControlPoint>.Default); private readonly BindableList<SampleControlPoint> samplePoints = new BindableList<SampleControlPoint>();
/// <summary> /// <summary>
/// All effect points. /// All effect points.

View File

@ -417,7 +417,7 @@ namespace osu.Game.Beatmaps.Formats
string sampleFilename = samples.FirstOrDefault(s => string.IsNullOrEmpty(s.Name))?.LookupNames.First() ?? string.Empty; string sampleFilename = samples.FirstOrDefault(s => string.IsNullOrEmpty(s.Name))?.LookupNames.First() ?? string.Empty;
int volume = samples.FirstOrDefault()?.Volume ?? 100; int volume = samples.FirstOrDefault()?.Volume ?? 100;
sb.Append(":"); sb.Append(':');
sb.Append(FormattableString.Invariant($"{customSampleBank}:")); sb.Append(FormattableString.Invariant($"{customSampleBank}:"));
sb.Append(FormattableString.Invariant($"{volume}:")); sb.Append(FormattableString.Invariant($"{volume}:"));
sb.Append(FormattableString.Invariant($"{sampleFilename}")); sb.Append(FormattableString.Invariant($"{sampleFilename}"));

View File

@ -347,7 +347,7 @@ namespace osu.Game.Beatmaps.Formats
/// <param name="line">The line which may contains variables.</param> /// <param name="line">The line which may contains variables.</param>
private void decodeVariables(ref string line) private void decodeVariables(ref string line)
{ {
while (line.IndexOf('$') >= 0) while (line.Contains('$'))
{ {
string origLine = line; string origLine = line;

View File

@ -26,7 +26,7 @@ namespace osu.Game.Database
/// Whether this write usage will commit a transaction on completion. /// Whether this write usage will commit a transaction on completion.
/// If false, there is a parent usage responsible for transaction commit. /// If false, there is a parent usage responsible for transaction commit.
/// </summary> /// </summary>
public bool IsTransactionLeader = false; public bool IsTransactionLeader;
protected void Dispose(bool disposing) protected void Dispose(bool disposing)
{ {

View File

@ -15,7 +15,6 @@ using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Graphics.Backgrounds namespace osu.Game.Graphics.Backgrounds
{ {
[LongRunningLoad]
public class SeasonalBackgroundLoader : Component public class SeasonalBackgroundLoader : Component
{ {
/// <summary> /// <summary>

View File

@ -21,7 +21,7 @@ namespace osu.Game.Graphics.Containers
/// Allows controlling the scroll bar from any position in the container using the right mouse button. /// Allows controlling the scroll bar from any position in the container using the right mouse button.
/// Uses the value of <see cref="DistanceDecayOnRightMouseScrollbar"/> to smoothly scroll to the dragged location. /// Uses the value of <see cref="DistanceDecayOnRightMouseScrollbar"/> to smoothly scroll to the dragged location.
/// </summary> /// </summary>
public bool RightMouseScrollbar = false; public bool RightMouseScrollbar;
/// <summary> /// <summary>
/// Controls the rate with which the target position is approached when performing a relative drag. Default is 0.02. /// Controls the rate with which the target position is approached when performing a relative drag. Default is 0.02.

View File

@ -41,7 +41,7 @@ namespace osu.Game.IO.Archives
return null; return null;
byte[] buffer = new byte[input.Length]; byte[] buffer = new byte[input.Length];
await input.ReadAsync(buffer, 0, buffer.Length); await input.ReadAsync(buffer);
return buffer; return buffer;
} }
} }

View File

@ -70,7 +70,7 @@ namespace osu.Game.Online.Spectator
public event Action<int, SpectatorState> OnUserBeganPlaying; public event Action<int, SpectatorState> OnUserBeganPlaying;
/// <summary> /// <summary>
/// Called whenever a user starts a play session. /// Called whenever a user finishes a play session.
/// </summary> /// </summary>
public event Action<int, SpectatorState> OnUserFinishedPlaying; public event Action<int, SpectatorState> OnUserFinishedPlaying;

View File

@ -229,6 +229,10 @@ namespace osu.Game
dependencies.Cache(DifficultyManager = new BeatmapDifficultyManager()); dependencies.Cache(DifficultyManager = new BeatmapDifficultyManager());
AddInternal(DifficultyManager); AddInternal(DifficultyManager);
var scorePerformanceManager = new ScorePerformanceManager();
dependencies.Cache(scorePerformanceManager);
AddInternal(scorePerformanceManager);
dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore)); dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore));
dependencies.Cache(SettingsStore = new SettingsStore(contextFactory)); dependencies.Cache(SettingsStore = new SettingsStore(contextFactory));
dependencies.Cache(RulesetConfigCache = new RulesetConfigCache(SettingsStore)); dependencies.Cache(RulesetConfigCache = new RulesetConfigCache(SettingsStore));

View File

@ -69,10 +69,10 @@ namespace osu.Game.Rulesets.Mods
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
hatSample = new PausableSkinnableSound(new SampleInfo("nightcore-hat")), hatSample = new PausableSkinnableSound(new SampleInfo("Gameplay/nightcore-hat")),
clapSample = new PausableSkinnableSound(new SampleInfo("nightcore-clap")), clapSample = new PausableSkinnableSound(new SampleInfo("Gameplay/nightcore-clap")),
kickSample = new PausableSkinnableSound(new SampleInfo("nightcore-kick")), kickSample = new PausableSkinnableSound(new SampleInfo("Gameplay/nightcore-kick")),
finishSample = new PausableSkinnableSound(new SampleInfo("nightcore-finish")), finishSample = new PausableSkinnableSound(new SampleInfo("Gameplay/nightcore-finish")),
}; };
} }

View File

@ -73,7 +73,7 @@ namespace osu.Game.Rulesets.Replays
/// When set, we will ensure frames executed by nested drawables are frame-accurate to replay data. /// When set, we will ensure frames executed by nested drawables are frame-accurate to replay data.
/// Disabling this can make replay playback smoother (useful for autoplay, currently). /// Disabling this can make replay playback smoother (useful for autoplay, currently).
/// </summary> /// </summary>
public bool FrameAccuratePlayback = false; public bool FrameAccuratePlayback;
public bool HasFrames => Frames.Count > 0; public bool HasFrames => Frames.Count > 0;

View File

@ -10,6 +10,9 @@ namespace osu.Game.Rulesets.UI
{ {
IBindable<bool> IsCatchingUp { get; } IBindable<bool> IsCatchingUp { get; }
/// <summary>
/// Whether the frame stable clock is waiting on new frames to arrive to be able to progress time.
/// </summary>
IBindable<bool> WaitingOnFrames { get; } IBindable<bool> WaitingOnFrames { get; }
} }
} }

View File

@ -0,0 +1,83 @@
// 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.Concurrent;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
namespace osu.Game.Scoring
{
/// <summary>
/// A global component which calculates and caches results of performance calculations for locally databased scores.
/// </summary>
public class ScorePerformanceManager : Component
{
// this cache will grow indefinitely per session and should be considered temporary.
// this whole component should likely be replaced with database persistence.
private readonly ConcurrentDictionary<PerformanceCacheLookup, double> performanceCache = new ConcurrentDictionary<PerformanceCacheLookup, double>();
[Resolved]
private BeatmapDifficultyManager difficultyManager { get; set; }
/// <summary>
/// Calculates performance for the given <see cref="ScoreInfo"/>.
/// </summary>
/// <param name="score">The score to do the calculation on. </param>
/// <param name="token">An optional <see cref="CancellationToken"/> to cancel the operation.</param>
public Task<double?> CalculatePerformanceAsync([NotNull] ScoreInfo score, CancellationToken token = default)
{
var lookupKey = new PerformanceCacheLookup(score);
if (performanceCache.TryGetValue(lookupKey, out double performance))
return Task.FromResult((double?)performance);
return computePerformanceAsync(score, lookupKey, token);
}
private async Task<double?> computePerformanceAsync(ScoreInfo score, PerformanceCacheLookup lookupKey, CancellationToken token = default)
{
var attributes = await difficultyManager.GetDifficultyAsync(score.Beatmap, score.Ruleset, score.Mods, token);
// Performance calculation requires the beatmap and ruleset to be locally available. If not, return a default value.
if (attributes.Attributes == null)
return null;
token.ThrowIfCancellationRequested();
var calculator = score.Ruleset.CreateInstance().CreatePerformanceCalculator(attributes.Attributes, score);
var total = calculator?.Calculate();
if (total.HasValue)
performanceCache[lookupKey] = total.Value;
return total;
}
public readonly struct PerformanceCacheLookup
{
public readonly string ScoreHash;
public readonly int LocalScoreID;
public PerformanceCacheLookup(ScoreInfo info)
{
ScoreHash = info.Hash;
LocalScoreID = info.ID;
}
public override int GetHashCode()
{
var hash = new HashCode();
hash.Add(ScoreHash);
hash.Add(LocalScoreID);
return hash.ToHashCode();
}
}
}
}

View File

@ -44,6 +44,8 @@ namespace osu.Game.Screens.Backgrounds
mode = config.GetBindable<BackgroundSource>(OsuSetting.MenuBackgroundSource); mode = config.GetBindable<BackgroundSource>(OsuSetting.MenuBackgroundSource);
introSequence = config.GetBindable<IntroSequence>(OsuSetting.IntroSequence); introSequence = config.GetBindable<IntroSequence>(OsuSetting.IntroSequence);
AddInternal(seasonalBackgroundLoader);
user.ValueChanged += _ => Next(); user.ValueChanged += _ => Next();
skin.ValueChanged += _ => Next(); skin.ValueChanged += _ => Next();
mode.ValueChanged += _ => Next(); mode.ValueChanged += _ => Next();
@ -53,7 +55,6 @@ namespace osu.Game.Screens.Backgrounds
currentDisplay = RNG.Next(0, background_count); currentDisplay = RNG.Next(0, background_count);
LoadComponentAsync(seasonalBackgroundLoader);
Next(); Next();
} }

View File

@ -210,10 +210,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
} }
if (DragBox.State == Visibility.Visible) if (DragBox.State == Visibility.Visible)
{
DragBox.Hide(); DragBox.Hide();
SelectionHandler.UpdateVisibility();
}
} }
protected override bool OnKeyDown(KeyDownEvent e) protected override bool OnKeyDown(KeyDownEvent e)
@ -352,11 +349,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary> /// <summary>
/// Selects all <see cref="SelectionBlueprint"/>s. /// Selects all <see cref="SelectionBlueprint"/>s.
/// </summary> /// </summary>
private void selectAll() private void selectAll() => SelectionBlueprints.ToList().ForEach(m => m.Select());
{
SelectionBlueprints.ToList().ForEach(m => m.Select());
SelectionHandler.UpdateVisibility();
}
/// <summary> /// <summary>
/// Deselects all selected <see cref="SelectionBlueprint"/>s. /// Deselects all selected <see cref="SelectionBlueprint"/>s.

View File

@ -201,8 +201,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
// there are potentially multiple SelectionHandlers active, but we only want to add hitobjects to the selected list once. // there are potentially multiple SelectionHandlers active, but we only want to add hitobjects to the selected list once.
if (!EditorBeatmap.SelectedHitObjects.Contains(blueprint.HitObject)) if (!EditorBeatmap.SelectedHitObjects.Contains(blueprint.HitObject))
EditorBeatmap.SelectedHitObjects.Add(blueprint.HitObject); EditorBeatmap.SelectedHitObjects.Add(blueprint.HitObject);
UpdateVisibility();
} }
/// <summary> /// <summary>
@ -214,8 +212,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
selectedBlueprints.Remove(blueprint); selectedBlueprints.Remove(blueprint);
EditorBeatmap.SelectedHitObjects.Remove(blueprint.HitObject); EditorBeatmap.SelectedHitObjects.Remove(blueprint.HitObject);
UpdateVisibility();
} }
/// <summary> /// <summary>
@ -226,13 +222,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state) internal void HandleSelectionRequested(SelectionBlueprint blueprint, InputState state)
{ {
if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right)) if (state.Keyboard.ShiftPressed && state.Mouse.IsPressed(MouseButton.Right))
EditorBeatmap.Remove(blueprint.HitObject); handleQuickDeletion(blueprint);
else if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left)) else if (state.Keyboard.ControlPressed && state.Mouse.IsPressed(MouseButton.Left))
blueprint.ToggleSelection(); blueprint.ToggleSelection();
else else
ensureSelected(blueprint); ensureSelected(blueprint);
} }
private void handleQuickDeletion(SelectionBlueprint blueprint)
{
if (!blueprint.IsSelected)
EditorBeatmap.Remove(blueprint.HitObject);
else
deleteSelected();
}
private void ensureSelected(SelectionBlueprint blueprint) private void ensureSelected(SelectionBlueprint blueprint)
{ {
if (blueprint.IsSelected) if (blueprint.IsSelected)
@ -254,23 +258,18 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary> /// <summary>
/// Updates whether this <see cref="SelectionHandler"/> is visible. /// Updates whether this <see cref="SelectionHandler"/> is visible.
/// </summary> /// </summary>
internal void UpdateVisibility() private void updateVisibility()
{ {
int count = selectedBlueprints.Count; int count = selectedBlueprints.Count;
selectionDetailsText.Text = count > 0 ? count.ToString() : string.Empty; selectionDetailsText.Text = count > 0 ? count.ToString() : string.Empty;
if (count > 0) this.FadeTo(count > 0 ? 1 : 0);
{
Show();
OnSelectionChanged(); OnSelectionChanged();
} }
else
Hide();
}
/// <summary> /// <summary>
/// Triggered whenever more than one object is selected, on each change. /// Triggered whenever the set of selected objects changes.
/// Should update the selection box's state to match supported operations. /// Should update the selection box's state to match supported operations.
/// </summary> /// </summary>
protected virtual void OnSelectionChanged() protected virtual void OnSelectionChanged()
@ -421,7 +420,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
// bring in updates from selection changes // bring in updates from selection changes
EditorBeatmap.HitObjectUpdated += _ => UpdateTernaryStates(); EditorBeatmap.HitObjectUpdated += _ => UpdateTernaryStates();
EditorBeatmap.SelectedHitObjects.CollectionChanged += (sender, args) => UpdateTernaryStates(); EditorBeatmap.SelectedHitObjects.CollectionChanged += (sender, args) =>
{
Scheduler.AddOnce(updateVisibility);
UpdateTernaryStates();
};
} }
/// <summary> /// <summary>

View File

@ -9,10 +9,10 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Utils;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts; using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Screens.Edit.Compose.Components.Timeline namespace osu.Game.Screens.Edit.Compose.Components.Timeline
@ -137,8 +137,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private class TimelineDragBox : DragBox private class TimelineDragBox : DragBox
{ {
private Vector2 lastMouseDown; // the following values hold the start and end X positions of the drag box in the timeline's local space,
private float localMouseDown; // but with zoom unapplied in order to be able to compensate for positional changes
// while the timeline is being zoomed in/out.
private float? selectionStart;
private float selectionEnd;
[Resolved]
private Timeline timeline { get; set; }
public TimelineDragBox(Action<RectangleF> performSelect) public TimelineDragBox(Action<RectangleF> performSelect)
: base(performSelect) : base(performSelect)
@ -153,21 +159,34 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
public override bool HandleDrag(MouseButtonEvent e) public override bool HandleDrag(MouseButtonEvent e)
{ {
// store the original position of the mouse down, as we may be scrolled during selection. selectionStart ??= e.MouseDownPosition.X / timeline.CurrentZoom;
if (lastMouseDown != e.ScreenSpaceMouseDownPosition)
{ // only calculate end when a transition is not in progress to avoid bouncing.
lastMouseDown = e.ScreenSpaceMouseDownPosition; if (Precision.AlmostEquals(timeline.CurrentZoom, timeline.Zoom))
localMouseDown = e.MouseDownPosition.X; selectionEnd = e.MousePosition.X / timeline.CurrentZoom;
updateDragBoxPosition();
return true;
} }
float selection1 = localMouseDown; private void updateDragBoxPosition()
float selection2 = e.MousePosition.X; {
if (selectionStart == null)
return;
Box.X = Math.Min(selection1, selection2); float rescaledStart = selectionStart.Value * timeline.CurrentZoom;
Box.Width = Math.Abs(selection1 - selection2); float rescaledEnd = selectionEnd * timeline.CurrentZoom;
Box.X = Math.Min(rescaledStart, rescaledEnd);
Box.Width = Math.Abs(rescaledStart - rescaledEnd);
PerformSelection?.Invoke(Box.ScreenSpaceDrawQuad.AABBFloat); PerformSelection?.Invoke(Box.ScreenSpaceDrawQuad.AABBFloat);
return true; }
public override void Hide()
{
base.Hide();
selectionStart = null;
} }
} }

View File

@ -29,9 +29,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
private readonly Container zoomedContent; private readonly Container zoomedContent;
protected override Container<Drawable> Content => zoomedContent; protected override Container<Drawable> Content => zoomedContent;
private float currentZoom = 1; private float currentZoom = 1;
/// <summary>
/// The current zoom level of <see cref="ZoomableScrollContainer" />.
/// It may differ from <see cref="Zoom" /> during transitions.
/// </summary>
public float CurrentZoom => currentZoom;
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private IFrameBasedClock editorClock { get; set; } private IFrameBasedClock editorClock { get; set; }

View File

@ -84,7 +84,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
matchingFilter &= r.Room.Playlist.Count == 0 || r.Room.Playlist.Any(i => i.Ruleset.Value.Equals(criteria.Ruleset)); matchingFilter &= r.Room.Playlist.Count == 0 || r.Room.Playlist.Any(i => i.Ruleset.Value.Equals(criteria.Ruleset));
if (!string.IsNullOrEmpty(criteria.SearchString)) if (!string.IsNullOrEmpty(criteria.SearchString))
matchingFilter &= r.FilterTerms.Any(term => term.IndexOf(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase) >= 0); matchingFilter &= r.FilterTerms.Any(term => term.Contains(criteria.SearchString, StringComparison.InvariantCultureIgnoreCase));
r.MatchingFilter = matchingFilter; r.MatchingFilter = matchingFilter;
} }

View File

@ -28,7 +28,7 @@ namespace osu.Game.Screens.Play
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config) private void load(OsuConfigManager config)
{ {
InternalChild = comboBreakSample = new SkinnableSound(new SampleInfo("combobreak")); InternalChild = comboBreakSample = new SkinnableSound(new SampleInfo("Gameplay/combobreak"));
alwaysPlay = config.GetBindable<bool>(OsuSetting.AlwaysPlayFirstComboBreak); alwaysPlay = config.GetBindable<bool>(OsuSetting.AlwaysPlayFirstComboBreak);
} }

View File

@ -63,6 +63,14 @@ namespace osu.Game.Screens.Play
private readonly FramedOffsetClock platformOffsetClock; private readonly FramedOffsetClock platformOffsetClock;
/// <summary>
/// Creates a new <see cref="GameplayClockContainer"/>.
/// </summary>
/// <param name="beatmap">The beatmap being played.</param>
/// <param name="gameplayStartTime">The suggested time to start gameplay at.</param>
/// <param name="startAtGameplayStart">
/// Whether <paramref name="gameplayStartTime"/> should be used regardless of when storyboard events and hitobjects are supposed to start.
/// </param>
public GameplayClockContainer(WorkingBeatmap beatmap, double gameplayStartTime, bool startAtGameplayStart = false) public GameplayClockContainer(WorkingBeatmap beatmap, double gameplayStartTime, bool startAtGameplayStart = false)
{ {
this.beatmap = beatmap; this.beatmap = beatmap;

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Play
AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke()); AddButton("Retry", colours.YellowDark, () => OnRetry?.Invoke());
AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke()); AddButton("Quit", new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("pause-loop")) AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("Gameplay/pause-loop"))
{ {
Looping = true, Looping = true,
Volume = { Value = 0 } Volume = { Value = 0 }

View File

@ -54,25 +54,6 @@ namespace osu.Game.Screens.Play
DrawableRuleset?.SetReplayScore(score); DrawableRuleset?.SetReplayScore(score);
} }
private void userBeganPlaying(int userId, SpectatorState state)
{
if (userId == score.ScoreInfo.UserID)
{
Schedule(() =>
{
if (this.IsCurrentScreen()) this.Exit();
});
}
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (spectatorStreaming != null)
spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying;
}
protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) protected override GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart)
{ {
// if we already have frames, start gameplay at the point in time they exist, should they be too far into the beatmap. // if we already have frames, start gameplay at the point in time they exist, should they be too far into the beatmap.
@ -83,5 +64,29 @@ namespace osu.Game.Screens.Play
return new GameplayClockContainer(beatmap, firstFrameTime.Value, true); return new GameplayClockContainer(beatmap, firstFrameTime.Value, true);
} }
public override bool OnExiting(IScreen next)
{
spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying;
return base.OnExiting(next);
}
private void userBeganPlaying(int userId, SpectatorState state)
{
if (userId != score.ScoreInfo.UserID) return;
Schedule(() =>
{
if (this.IsCurrentScreen()) this.Exit();
});
}
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
if (spectatorStreaming != null)
spectatorStreaming.OnUserBeganPlaying -= userBeganPlaying;
}
} }
} }

View File

@ -4,14 +4,17 @@
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Audio;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Skinning;
using osuTK; using osuTK;
namespace osu.Game.Screens.Ranking.Expanded.Accuracy namespace osu.Game.Screens.Ranking.Expanded.Accuracy
@ -73,18 +76,23 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
private readonly ScoreInfo score; private readonly ScoreInfo score;
private readonly bool withFlair;
private SmoothCircularProgress accuracyCircle; private SmoothCircularProgress accuracyCircle;
private SmoothCircularProgress innerMask; private SmoothCircularProgress innerMask;
private Container<RankBadge> badges; private Container<RankBadge> badges;
private RankText rankText; private RankText rankText;
public AccuracyCircle(ScoreInfo score) private SkinnableSound applauseSound;
public AccuracyCircle(ScoreInfo score, bool withFlair)
{ {
this.score = score; this.score = score;
this.withFlair = withFlair;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(AudioManager audio)
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
@ -203,6 +211,13 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
}, },
rankText = new RankText(score.Rank) rankText = new RankText(score.Rank)
}; };
if (withFlair)
{
AddInternal(applauseSound = score.Rank >= ScoreRank.A
? new SkinnableSound(new SampleInfo("Results/rankpass", "applause"))
: new SkinnableSound(new SampleInfo("Results/rankfail")));
}
} }
private ScoreRank getRank(ScoreRank rank) private ScoreRank getRank(ScoreRank rank)
@ -234,13 +249,18 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
continue; continue;
using (BeginDelayedSequence(inverseEasing(ACCURACY_TRANSFORM_EASING, Math.Min(1 - virtual_ss_percentage, badge.Accuracy) / targetAccuracy) * ACCURACY_TRANSFORM_DURATION, true)) using (BeginDelayedSequence(inverseEasing(ACCURACY_TRANSFORM_EASING, Math.Min(1 - virtual_ss_percentage, badge.Accuracy) / targetAccuracy) * ACCURACY_TRANSFORM_DURATION, true))
{
badge.Appear(); badge.Appear();
} }
}
using (BeginDelayedSequence(TEXT_APPEAR_DELAY, true)) using (BeginDelayedSequence(TEXT_APPEAR_DELAY, true))
{
this.Delay(-1440).Schedule(() => applauseSound?.Play());
rankText.Appear(); rankText.Appear();
} }
} }
}
private double inverseEasing(Easing easing, double targetValue) private double inverseEasing(Easing easing, double targetValue)
{ {

View File

@ -66,7 +66,7 @@ namespace osu.Game.Screens.Ranking.Expanded
{ {
new AccuracyStatistic(score.Accuracy), new AccuracyStatistic(score.Accuracy),
new ComboStatistic(score.MaxCombo, !score.Statistics.TryGetValue(HitResult.Miss, out var missCount) || missCount == 0), new ComboStatistic(score.MaxCombo, !score.Statistics.TryGetValue(HitResult.Miss, out var missCount) || missCount == 0),
new CounterStatistic("pp", (int)(score.PP ?? 0)), new PerformanceStatistic(score),
}; };
var bottomStatistics = new List<HitResultStatistic>(); var bottomStatistics = new List<HitResultStatistic>();
@ -120,7 +120,7 @@ namespace osu.Game.Screens.Ranking.Expanded
Margin = new MarginPadding { Top = 40 }, Margin = new MarginPadding { Top = 40 },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = 230, Height = 230,
Child = new AccuracyCircle(score) Child = new AccuracyCircle(score, withFlair)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -6,7 +6,6 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Ranking.Expanded.Accuracy;
using osuTK; using osuTK;
namespace osu.Game.Screens.Ranking.Expanded.Statistics namespace osu.Game.Screens.Ranking.Expanded.Statistics
@ -46,7 +45,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Child = counter = new Counter Child = counter = new StatisticCounter
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre Origin = Anchor.TopCentre
@ -67,18 +66,5 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
return container; return container;
} }
private class Counter : RollingCounter<int>
{
protected override double RollingDuration => AccuracyCircle.ACCURACY_TRANSFORM_DURATION;
protected override Easing RollingEasing => AccuracyCircle.ACCURACY_TRANSFORM_EASING;
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
{
s.Font = OsuFont.Torus.With(size: 20, fixedWidth: true);
s.Spacing = new Vector2(-2, 0);
});
}
} }
} }

View File

@ -0,0 +1,68 @@
// 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.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Scoring;
namespace osu.Game.Screens.Ranking.Expanded.Statistics
{
public class PerformanceStatistic : StatisticDisplay
{
private readonly ScoreInfo score;
private readonly Bindable<int> performance = new Bindable<int>();
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
private RollingCounter<int> counter;
public PerformanceStatistic(ScoreInfo score)
: base("PP")
{
this.score = score;
}
[BackgroundDependencyLoader]
private void load(ScorePerformanceManager performanceManager)
{
if (score.PP.HasValue)
{
setPerformanceValue(score.PP.Value);
}
else
{
performanceManager.CalculatePerformanceAsync(score, cancellationTokenSource.Token)
.ContinueWith(t => Schedule(() => setPerformanceValue(t.Result)), cancellationTokenSource.Token);
}
}
private void setPerformanceValue(double? pp)
{
if (pp.HasValue)
performance.Value = (int)Math.Round(pp.Value, MidpointRounding.AwayFromZero);
}
public override void Appear()
{
base.Appear();
counter.Current.BindTo(performance);
}
protected override void Dispose(bool isDisposing)
{
cancellationTokenSource?.Cancel();
base.Dispose(isDisposing);
}
protected override Drawable CreateContent() => counter = new StatisticCounter
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre
};
}
}

View File

@ -0,0 +1,25 @@
// 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.Graphics;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Ranking.Expanded.Accuracy;
using osuTK;
namespace osu.Game.Screens.Ranking.Expanded.Statistics
{
public class StatisticCounter : RollingCounter<int>
{
protected override double RollingDuration => AccuracyCircle.ACCURACY_TRANSFORM_DURATION;
protected override Easing RollingEasing => AccuracyCircle.ACCURACY_TRANSFORM_EASING;
protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(s =>
{
s.Font = OsuFont.Torus.With(size: 20, fixedWidth: true);
s.Spacing = new Vector2(-2, 0);
});
}
}

View File

@ -300,6 +300,7 @@ namespace osu.Game.Screens.Select
public MetadataSection(string title) public MetadataSection(string title)
{ {
Alpha = 0;
RelativeSizeAxes = Axes.X; RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y; AutoSizeAxes = Axes.Y;

View File

@ -59,7 +59,7 @@ namespace osu.Game.Screens.Select.Carousel
var terms = Beatmap.SearchableTerms; var terms = Beatmap.SearchableTerms;
foreach (var criteriaTerm in criteria.SearchTerms) foreach (var criteriaTerm in criteria.SearchTerms)
match &= terms.Any(term => term.IndexOf(criteriaTerm, StringComparison.InvariantCultureIgnoreCase) >= 0); match &= terms.Any(term => term.Contains(criteriaTerm, StringComparison.InvariantCultureIgnoreCase));
// if a match wasn't found via text matching of terms, do a second catch-all check matching against online IDs. // if a match wasn't found via text matching of terms, do a second catch-all check matching against online IDs.
// this should be done after text matching so we can prioritise matching numbers in metadata. // this should be done after text matching so we can prioritise matching numbers in metadata.

View File

@ -126,7 +126,7 @@ namespace osu.Game.Screens.Select
if (string.IsNullOrEmpty(value)) if (string.IsNullOrEmpty(value))
return false; return false;
return value.IndexOf(SearchTerm, StringComparison.InvariantCultureIgnoreCase) >= 0; return value.Contains(SearchTerm, StringComparison.InvariantCultureIgnoreCase);
} }
public string SearchTerm; public string SearchTerm;

View File

@ -32,11 +32,7 @@ namespace osu.Game.Screens.Select
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {
BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () => BeatmapOptions.AddButton(@"Edit", @"beatmap", FontAwesome.Solid.PencilAlt, colours.Yellow, () => Edit());
{
ValidForResume = false;
Edit();
});
((PlayBeatmapDetailArea)BeatmapDetails).Leaderboard.ScoreSelected += PresentScore; ((PlayBeatmapDetailArea)BeatmapDetails).Leaderboard.ScoreSelected += PresentScore;
} }

View File

@ -417,10 +417,14 @@ namespace osu.Game.Skinning
public override SampleChannel GetSample(ISampleInfo sampleInfo) public override SampleChannel GetSample(ISampleInfo sampleInfo)
{ {
var lookupNames = sampleInfo.LookupNames; IEnumerable<string> lookupNames;
if (sampleInfo is HitSampleInfo hitSample) if (sampleInfo is HitSampleInfo hitSample)
lookupNames = getLegacyLookupNames(hitSample); lookupNames = getLegacyLookupNames(hitSample);
else
{
lookupNames = sampleInfo.LookupNames.SelectMany(getFallbackNames);
}
foreach (var lookup in lookupNames) foreach (var lookup in lookupNames)
{ {
@ -433,6 +437,27 @@ namespace osu.Game.Skinning
return null; return null;
} }
private IEnumerable<string> getLegacyLookupNames(HitSampleInfo hitSample)
{
var lookupNames = hitSample.LookupNames.SelectMany(getFallbackNames);
if (!UseCustomSampleBanks && !string.IsNullOrEmpty(hitSample.Suffix))
{
// for compatibility with stable, exclude the lookup names with the custom sample bank suffix, if they are not valid for use in this skin.
// using .EndsWith() is intentional as it ensures parity in all edge cases
// (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply, but the sample bank should not).
lookupNames = lookupNames.Where(name => !name.EndsWith(hitSample.Suffix, StringComparison.Ordinal));
}
foreach (var l in lookupNames)
yield return l;
// also for compatibility, try falling back to non-bank samples (so-called "universal" samples) as the last resort.
// going forward specifying banks shall always be required, even for elements that wouldn't require it on stable,
// which is why this is done locally here.
yield return hitSample.Name;
}
private IEnumerable<string> getFallbackNames(string componentName) private IEnumerable<string> getFallbackNames(string componentName)
{ {
// May be something like "Gameplay/osu/approachcircle" from lazer, or "Arrows/note1" from a user skin. // May be something like "Gameplay/osu/approachcircle" from lazer, or "Arrows/note1" from a user skin.
@ -442,23 +467,5 @@ namespace osu.Game.Skinning
string lastPiece = componentName.Split('/').Last(); string lastPiece = componentName.Split('/').Last();
yield return componentName.StartsWith("Gameplay/taiko/", StringComparison.Ordinal) ? "taiko-" + lastPiece : lastPiece; yield return componentName.StartsWith("Gameplay/taiko/", StringComparison.Ordinal) ? "taiko-" + lastPiece : lastPiece;
} }
private IEnumerable<string> getLegacyLookupNames(HitSampleInfo hitSample)
{
var lookupNames = hitSample.LookupNames;
if (!UseCustomSampleBanks && !string.IsNullOrEmpty(hitSample.Suffix))
// for compatibility with stable, exclude the lookup names with the custom sample bank suffix, if they are not valid for use in this skin.
// using .EndsWith() is intentional as it ensures parity in all edge cases
// (see LegacyTaikoSampleInfo for an example of one - prioritising the taiko prefix should still apply, but the sample bank should not).
lookupNames = hitSample.LookupNames.Where(name => !name.EndsWith(hitSample.Suffix, StringComparison.Ordinal));
// also for compatibility, try falling back to non-bank samples (so-called "universal" samples) as the last resort.
// going forward specifying banks shall always be required, even for elements that wouldn't require it on stable,
// which is why this is done locally here.
lookupNames = lookupNames.Append(hitSample.Name);
return lookupNames;
}
} }
} }

View File

@ -88,7 +88,7 @@ namespace osu.Game.Skinning
{ {
foreach (var lookup in s.LookupNames) foreach (var lookup in s.LookupNames)
{ {
if ((ch = samples.Get($"Gameplay/{lookup}")) != null) if ((ch = samples.Get(lookup)) != null)
break; break;
} }
} }

View File

@ -18,7 +18,7 @@ namespace osu.Game.Tests.Visual
/// <summary> /// <summary>
/// Whether custom test steps are provided. Custom tests should invoke <see cref="CreateTest"/> to create the test steps. /// Whether custom test steps are provided. Custom tests should invoke <see cref="CreateTest"/> to create the test steps.
/// </summary> /// </summary>
protected virtual bool HasCustomSteps { get; } = false; protected virtual bool HasCustomSteps => false;
protected TestPlayer Player; protected TestPlayer Player;

View File

@ -27,7 +27,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Framework" Version="2020.1029.1" /> <PackageReference Include="ppy.osu.Framework" Version="2020.1029.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1016.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2020.1030.0" />
<PackageReference Include="Sentry" Version="2.1.6" /> <PackageReference Include="Sentry" Version="2.1.6" />
<PackageReference Include="SharpCompress" Version="0.26.0" /> <PackageReference Include="SharpCompress" Version="0.26.0" />
<PackageReference Include="NUnit" Version="3.12.0" /> <PackageReference Include="NUnit" Version="3.12.0" />

View File

@ -71,7 +71,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup Label="Package References"> <ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.1029.1" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2020.1029.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1016.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2020.1030.0" />
</ItemGroup> </ItemGroup>
<!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. --> <!-- Xamarin.iOS does not automatically handle transitive dependencies from NuGet packages. -->
<ItemGroup Label="Transitive Dependencies"> <ItemGroup Label="Transitive Dependencies">