1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:47:26 +08:00

Merge branch 'master' into convert-path-string-new

This commit is contained in:
Bartłomiej Dach 2024-02-29 08:51:04 +01:00 committed by GitHub
commit 9a40a4f700
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
58 changed files with 341 additions and 339 deletions

View File

@ -10,7 +10,7 @@
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.221.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.223.0" />
</ItemGroup>
<PropertyGroup>
<!-- Fody does not handle Android build well, and warns when unchanged.

View File

@ -92,9 +92,10 @@ namespace osu.Desktop
return;
}
if (status.Value == UserStatus.Online && activity.Value != null)
if (activity.Value != null)
{
bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited;
bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited || status.Value == UserStatus.DoNotDisturb;
presence.State = truncate(activity.Value.GetStatus(hideIdentifiableInformation));
presence.Details = truncate(activity.Value.GetDetails(hideIdentifiableInformation) ?? string.Empty);

View File

@ -80,11 +80,29 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
base.UpdateInitialTransforms();
foreach (var piece in DimmablePieces)
{
// if the specified dimmable piece is a DHO, it is generally not safe to tack transforms onto it directly
// as they may be cleared via the `updateState()` DHO flow,
// so use `ApplyCustomUpdateState` instead. which does not have this pitfall.
if (piece is DrawableHitObject drawableObjectPiece)
{
// this method can be called multiple times, and we don't want to subscribe to the event more than once,
// so this is what it is going to have to be...
drawableObjectPiece.ApplyCustomUpdateState -= applyDimToDrawableHitObject;
drawableObjectPiece.ApplyCustomUpdateState += applyDimToDrawableHitObject;
}
else
applyDim(piece);
}
void applyDim(Drawable piece)
{
piece.FadeColour(new Color4(195, 195, 195, 255));
using (piece.BeginDelayedSequence(InitialLifetimeOffset - OsuHitWindows.MISS_WINDOW))
piece.FadeColour(Color4.White, 100);
}
void applyDimToDrawableHitObject(DrawableHitObject dho, ArmedState _) => applyDim(dho);
}
protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt;

View File

@ -44,7 +44,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
SnakingOut.BindTo(configSnakingOut);
BorderSize = skin.GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.SliderBorderSize)?.Value ?? 1;
BorderColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBorder)?.Value ?? Color4.White;
}

View File

@ -23,29 +23,35 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
private partial class LegacyDrawableSliderPath : DrawableSliderPath
{
private const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS);
protected new float CalculatedBorderPortion
// Roughly matches osu!stable's slider border portions.
=> base.CalculatedBorderPortion * 0.77f;
protected override Color4 ColourAt(float position)
{
float realBorderPortion = shadow_portion + CalculatedBorderPortion;
float realGradientPortion = 1 - realBorderPortion;
if (position <= shadow_portion)
return new Color4(0f, 0f, 0f, 0.25f * position / shadow_portion);
if (position <= realBorderPortion)
return BorderColour;
position -= realBorderPortion;
// https://github.com/peppy/osu-stable-reference/blob/3ea48705eb67172c430371dcfc8a16a002ed0d3d/osu!/Graphics/Renderers/MmSliderRendererGL.cs#L99
// float aaWidth = Math.Min(Math.Max(0.5f / PathRadius, 3.0f / 256.0f), 1.0f / 16.0f);
// applying the aa_width constant from stable makes sliders blurry, especially on CS>5. set to zero for now.
// this might be related to SmoothPath applying AA internally, but disabling that does not seem to have much of an effect.
const float aa_width = 0f;
Color4 shadow = new Color4(0, 0, 0, 0.25f);
Color4 outerColour = AccentColour.Darken(0.1f);
Color4 innerColour = lighten(AccentColour, 0.5f);
return LegacyUtils.InterpolateNonLinear(position / realGradientPortion, outerColour, innerColour, 0, 1);
// https://github.com/peppy/osu-stable-reference/blob/3ea48705eb67172c430371dcfc8a16a002ed0d3d/osu!/Graphics/Renderers/MmSliderRendererGL.cs#L59-L70
const float shadow_portion = 1 - (OsuLegacySkinTransformer.LEGACY_CIRCLE_RADIUS / OsuHitObject.OBJECT_RADIUS);
const float border_portion = 0.1875f;
if (position <= shadow_portion - aa_width)
return LegacyUtils.InterpolateNonLinear(position, Color4.Black.Opacity(0f), shadow, 0, shadow_portion - aa_width);
if (position <= shadow_portion + aa_width)
return LegacyUtils.InterpolateNonLinear(position, shadow, BorderColour, shadow_portion - aa_width, shadow_portion + aa_width);
if (position <= border_portion - aa_width)
return BorderColour;
if (position <= border_portion + aa_width)
return LegacyUtils.InterpolateNonLinear(position, BorderColour, outerColour, border_portion - aa_width, border_portion + aa_width);
return LegacyUtils.InterpolateNonLinear(position, outerColour, innerColour, border_portion + aa_width, 1);
}
/// <summary>

View File

@ -5,7 +5,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
{
public enum OsuSkinConfiguration
{
SliderBorderSize,
SliderPathRadius,
CursorCentre,
CursorExpand,

View File

@ -538,7 +538,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
Assert.That(filterCriteria.LastPlayed.Max, Is.Not.Null);
// the parser internally references `DateTimeOffset.Now`, so to not make things too annoying for tests, just assume some tolerance
// (irrelevant in proportion to the actual filter proscribed).
Assert.That(filterCriteria.LastPlayed.Min, Is.EqualTo(DateTimeOffset.Now.AddYears(-1).AddMonths(-6)).Within(TimeSpan.FromSeconds(5)));
Assert.That(filterCriteria.LastPlayed.Min, Is.EqualTo(DateTimeOffset.Now.AddMonths(-6).AddYears(-1)).Within(TimeSpan.FromSeconds(5)));
Assert.That(filterCriteria.LastPlayed.Max, Is.EqualTo(DateTimeOffset.Now.AddMonths(-3)).Within(TimeSpan.FromSeconds(5)));
}

View File

@ -349,8 +349,9 @@ namespace osu.Game.Tests.Visual.Background
private partial class FadeAccessibleResults : ResultsScreen
{
public FadeAccessibleResults(ScoreInfo score)
: base(score, true)
: base(score)
{
AllowRetry = true;
}
protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);

View File

@ -1,9 +1,6 @@
// 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.
#nullable disable
using System;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
@ -21,10 +18,12 @@ namespace osu.Game.Tests.Visual.Gameplay
[Description("player pause/fail screens")]
public partial class TestSceneGameplayMenuOverlay : OsuManualInputManagerTestScene
{
private FailOverlay failOverlay;
private PauseOverlay pauseOverlay;
private FailOverlay failOverlay = null!;
private PauseOverlay pauseOverlay = null!;
private GlobalActionContainer globalActionContainer;
private GlobalActionContainer globalActionContainer = null!;
private bool triggeredRetryButton;
[BackgroundDependencyLoader]
private void load(OsuGameBase game)
@ -35,12 +34,18 @@ namespace osu.Game.Tests.Visual.Gameplay
[SetUp]
public void SetUp() => Schedule(() =>
{
triggeredRetryButton = false;
globalActionContainer.Children = new Drawable[]
{
pauseOverlay = new PauseOverlay
{
OnResume = () => Logger.Log(@"Resume"),
OnRetry = () => Logger.Log(@"Retry"),
OnRetry = () =>
{
Logger.Log(@"Retry");
triggeredRetryButton = true;
},
OnQuit = () => Logger.Log(@"Quit"),
},
failOverlay = new FailOverlay
@ -224,17 +229,9 @@ namespace osu.Game.Tests.Visual.Gameplay
{
showOverlay();
bool triggered = false;
AddStep("Click retry button", () =>
{
var lastAction = pauseOverlay.OnRetry;
pauseOverlay.OnRetry = () => triggered = true;
AddStep("Click retry button", () => getButton(1).TriggerClick());
getButton(1).TriggerClick();
pauseOverlay.OnRetry = lastAction;
});
AddAssert("Action was triggered", () => triggered);
AddAssert("Retry was triggered", () => triggeredRetryButton);
AddAssert("Overlay is closed", () => pauseOverlay.State.Value == Visibility.Hidden);
}
@ -252,25 +249,9 @@ namespace osu.Game.Tests.Visual.Gameplay
InputManager.Key(Key.Down);
});
bool triggered = false;
Action lastAction = null;
AddStep("Press enter", () =>
{
lastAction = pauseOverlay.OnRetry;
pauseOverlay.OnRetry = () => triggered = true;
InputManager.Key(Key.Enter);
});
AddStep("Press enter", () => InputManager.Key(Key.Enter));
AddAssert("Action was triggered", () =>
{
if (lastAction != null)
{
pauseOverlay.OnRetry = lastAction;
lastAction = null;
}
return triggered;
});
AddAssert("Retry was triggered", () => triggeredRetryButton);
AddAssert("Overlay is closed", () => pauseOverlay.State.Value == Visibility.Hidden);
}

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
@ -12,6 +10,7 @@ using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Spectator;
using osu.Game.Rulesets.Osu;
@ -39,13 +38,13 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override bool UseOnlineAPI => true;
[Resolved]
private OsuGameBase game { get; set; }
private OsuGameBase game { get; set; } = null!;
private TestSpectatorClient spectatorClient => dependenciesScreen.SpectatorClient;
private DependenciesScreen dependenciesScreen;
private SoloSpectatorScreen spectatorScreen;
private DependenciesScreen dependenciesScreen = null!;
private SoloSpectatorScreen spectatorScreen = null!;
private BeatmapSetInfo importedBeatmap;
private BeatmapSetInfo importedBeatmap = null!;
private int importedBeatmapId;
[SetUpSteps]
@ -188,7 +187,7 @@ namespace osu.Game.Tests.Visual.Gameplay
waitForPlayerCurrent();
Player lastPlayer = null;
Player lastPlayer = null!;
AddStep("store first player", () => lastPlayer = player);
start();
@ -214,6 +213,11 @@ namespace osu.Game.Tests.Visual.Gameplay
checkPaused(false); // Should continue playing until out of frames
checkPaused(true); // And eventually stop after running out of frames and fail.
// Todo: Should check for + display a failed message.
AddAssert("fail overlay present", () => player.ChildrenOfType<FailOverlay>().Single().IsPresent);
AddAssert("overlay can only quit", () => player.ChildrenOfType<FailOverlay>().Single().Buttons.Single().Text == GameplayMenuOverlayStrings.Quit);
AddStep("press quit button", () => player.ChildrenOfType<FailOverlay>().Single().Buttons.Single().TriggerClick());
AddAssert("player exited", () => Stack.CurrentScreen is SoloSpectatorScreen);
}
[Test]
@ -278,7 +282,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestFinalFrameInBundleHasHeader()
{
FrameDataBundle lastBundle = null;
FrameDataBundle? lastBundle = null;
AddStep("bind to client", () => spectatorClient.OnNewFrames += (_, bundle) => lastBundle = bundle);
@ -287,8 +291,8 @@ namespace osu.Game.Tests.Visual.Gameplay
finish();
AddUntilStep("bundle received", () => lastBundle != null);
AddAssert("first frame does not have header", () => lastBundle.Frames[0].Header == null);
AddAssert("last frame has header", () => lastBundle.Frames[^1].Header != null);
AddAssert("first frame does not have header", () => lastBundle?.Frames[0].Header == null);
AddAssert("last frame has header", () => lastBundle?.Frames[^1].Header != null);
}
[Test]
@ -383,7 +387,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}
private OsuFramedReplayInputHandler replayHandler =>
(OsuFramedReplayInputHandler)Stack.ChildrenOfType<OsuInputManager>().First().ReplayInputHandler;
(OsuFramedReplayInputHandler)Stack.ChildrenOfType<OsuInputManager>().First().ReplayInputHandler!;
private Player player => this.ChildrenOfType<Player>().Single();

View File

@ -8,8 +8,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing;
using osu.Game.Online;
using osu.Game.Online.API;
using osu.Game.Online.Solo;
using osu.Game.Overlays.Toolbar;
using osu.Game.Scoring;
using osu.Game.Users;
@ -100,7 +100,7 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("Gain", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate(
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
@ -116,7 +116,7 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("Loss", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate(
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
@ -132,7 +132,7 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("No change", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate(
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
@ -148,7 +148,7 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("Was null", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate(
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
@ -164,7 +164,7 @@ namespace osu.Game.Tests.Visual.Menus
AddStep("Became null", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate(
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{

View File

@ -8,10 +8,10 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Testing;
using osu.Game.Models;
using osu.Game.Online;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Solo;
using osu.Game.Online.Spectator;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
@ -21,11 +21,11 @@ using osu.Game.Users;
namespace osu.Game.Tests.Visual.Online
{
[HeadlessTest]
public partial class TestSceneSoloStatisticsWatcher : OsuTestScene
public partial class TestSceneUserStatisticsWatcher : OsuTestScene
{
protected override bool UseOnlineAPI => false;
private SoloStatisticsWatcher watcher = null!;
private UserStatisticsWatcher watcher = null!;
[Resolved]
private SpectatorClient spectatorClient { get; set; } = null!;
@ -107,7 +107,7 @@ namespace osu.Game.Tests.Visual.Online
AddStep("create watcher", () =>
{
Child = watcher = new SoloStatisticsWatcher();
Child = watcher = new UserStatisticsWatcher();
});
}
@ -123,7 +123,7 @@ namespace osu.Game.Tests.Visual.Online
var ruleset = new OsuRuleset().RulesetInfo;
SoloStatisticsUpdate? update = null;
UserStatisticsUpdate? update = null;
registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate);
feignScoreProcessing(userId, ruleset, 5_000_000);
@ -146,7 +146,7 @@ namespace osu.Game.Tests.Visual.Online
// note ordering - in this test processing completes *before* the registration is added.
feignScoreProcessing(userId, ruleset, 5_000_000);
SoloStatisticsUpdate? update = null;
UserStatisticsUpdate? update = null;
registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate);
AddStep("signal score processed", () => ((ISpectatorClient)spectatorClient).UserScoreProcessed(userId, scoreId));
@ -164,7 +164,7 @@ namespace osu.Game.Tests.Visual.Online
long scoreId = getScoreId();
var ruleset = new OsuRuleset().RulesetInfo;
SoloStatisticsUpdate? update = null;
UserStatisticsUpdate? update = null;
registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate);
feignScoreProcessing(userId, ruleset, 5_000_000);
@ -191,7 +191,7 @@ namespace osu.Game.Tests.Visual.Online
long scoreId = getScoreId();
var ruleset = new OsuRuleset().RulesetInfo;
SoloStatisticsUpdate? update = null;
UserStatisticsUpdate? update = null;
registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate);
feignScoreProcessing(userId, ruleset, 5_000_000);
@ -212,7 +212,7 @@ namespace osu.Game.Tests.Visual.Online
long scoreId = getScoreId();
var ruleset = new OsuRuleset().RulesetInfo;
SoloStatisticsUpdate? update = null;
UserStatisticsUpdate? update = null;
registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate);
feignScoreProcessing(userId, ruleset, 5_000_000);
@ -241,7 +241,7 @@ namespace osu.Game.Tests.Visual.Online
feignScoreProcessing(userId, ruleset, 6_000_000);
SoloStatisticsUpdate? update = null;
UserStatisticsUpdate? update = null;
registerForUpdates(secondScoreId, ruleset, receivedUpdate => update = receivedUpdate);
AddStep("signal score processed", () => ((ISpectatorClient)spectatorClient).UserScoreProcessed(userId, secondScoreId));
@ -259,7 +259,7 @@ namespace osu.Game.Tests.Visual.Online
var ruleset = new OsuRuleset().RulesetInfo;
SoloStatisticsUpdate? update = null;
UserStatisticsUpdate? update = null;
registerForUpdates(scoreId, ruleset, receivedUpdate => update = receivedUpdate);
feignScoreProcessing(userId, ruleset, 5_000_000);
@ -289,7 +289,7 @@ namespace osu.Game.Tests.Visual.Online
});
}
private void registerForUpdates(long scoreId, RulesetInfo rulesetInfo, Action<SoloStatisticsUpdate> onUpdateReady) =>
private void registerForUpdates(long scoreId, RulesetInfo rulesetInfo, Action<UserStatisticsUpdate> onUpdateReady) =>
AddStep("register for updates", () =>
{
watcher.RegisterForStatisticsUpdateAfter(

View File

@ -420,9 +420,10 @@ namespace osu.Game.Tests.Visual.Playlists
public new LoadingSpinner RightSpinner => base.RightSpinner;
public new ScorePanelList ScorePanelList => base.ScorePanelList;
public TestResultsScreen([CanBeNull] ScoreInfo score, int roomId, PlaylistItem playlistItem, bool allowRetry = true)
: base(score, roomId, playlistItem, allowRetry)
public TestResultsScreen([CanBeNull] ScoreInfo score, int roomId, PlaylistItem playlistItem)
: base(score, roomId, playlistItem)
{
AllowRetry = true;
}
}
}

View File

@ -3,7 +3,7 @@
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.Online.Solo;
using osu.Game.Online;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Statistics.User;
using osu.Game.Users;
@ -112,6 +112,6 @@ namespace osu.Game.Tests.Visual.Ranking
});
private void displayUpdate(UserStatistics before, UserStatistics after) =>
AddStep("display update", () => overallRanking.StatisticsUpdate.Value = new SoloStatisticsUpdate(new ScoreInfo(), before, after));
AddStep("display update", () => overallRanking.StatisticsUpdate.Value = new UserStatisticsUpdate(new ScoreInfo(), before, after));
}
}

View File

@ -399,8 +399,9 @@ namespace osu.Game.Tests.Visual.Ranking
public HotkeyRetryOverlay RetryOverlay;
public TestResultsScreen(ScoreInfo score)
: base(score, true)
: base(score)
{
AllowRetry = true;
ShowUserStatistics = true;
}
@ -470,8 +471,9 @@ namespace osu.Game.Tests.Visual.Ranking
public HotkeyRetryOverlay RetryOverlay;
public UnrankedSoloResultsScreen(ScoreInfo score)
: base(score, true)
: base(score)
{
AllowRetry = true;
Score!.BeatmapInfo!.OnlineID = 0;
Score.BeatmapInfo.Status = BeatmapOnlineStatus.Pending;
}

View File

@ -13,7 +13,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Solo;
using osu.Game.Online;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Difficulty;
using osu.Game.Rulesets.Mods;
@ -82,14 +82,14 @@ namespace osu.Game.Tests.Visual.Ranking
private void loadPanel(ScoreInfo score) => AddStep("load panel", () =>
{
Child = new SoloStatisticsPanel(score)
Child = new UserStatisticsPanel(score)
{
RelativeSizeAxes = Axes.Both,
State = { Value = Visibility.Visible },
Score = { Value = score },
StatisticsUpdate =
DisplayedUserStatisticsUpdate =
{
Value = new SoloStatisticsUpdate(score, new UserStatistics
Value = new UserStatisticsUpdate(score, new UserStatistics
{
Level = new UserStatistics.LevelInfo
{

View File

@ -37,15 +37,9 @@ namespace osu.Game.Tests.Visual.SongSelect
[SetUp]
public void Setup() => Schedule(() => Child = advancedStats = new TestAdvancedStats
{
Width = 500
Width = 500,
});
[SetUpSteps]
public void SetUpSteps()
{
AddStep("reset game ruleset", () => Ruleset.Value = new OsuRuleset().RulesetInfo);
}
private BeatmapInfo exampleBeatmapInfo => new BeatmapInfo
{
Ruleset = rulesets.AvailableRulesets.First(),
@ -74,45 +68,12 @@ namespace osu.Game.Tests.Visual.SongSelect
}
[Test]
public void TestManiaFirstBarTextManiaBeatmap()
public void TestFirstBarText()
{
AddStep("set game ruleset to mania", () => Ruleset.Value = new ManiaRuleset().RulesetInfo);
AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo
{
Ruleset = rulesets.GetRuleset(3) ?? throw new InvalidOperationException("osu!mania ruleset not found"),
Difficulty = new BeatmapDifficulty
{
CircleSize = 5,
DrainRate = 4.3f,
OverallDifficulty = 4.5f,
ApproachRate = 3.1f
},
StarRating = 8
});
AddAssert("first bar text is correct", () => advancedStats.ChildrenOfType<SpriteText>().First().Text == BeatmapsetsStrings.ShowStatsCsMania);
}
[Test]
public void TestManiaFirstBarTextConvert()
{
AddStep("set game ruleset to mania", () => Ruleset.Value = new ManiaRuleset().RulesetInfo);
AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo
{
Ruleset = new OsuRuleset().RulesetInfo,
Difficulty = new BeatmapDifficulty
{
CircleSize = 5,
DrainRate = 4.3f,
OverallDifficulty = 4.5f,
ApproachRate = 3.1f
},
StarRating = 8
});
AddStep("set ruleset to mania", () => advancedStats.Ruleset.Value = new ManiaRuleset().RulesetInfo);
AddAssert("first bar text is correct", () => advancedStats.ChildrenOfType<SpriteText>().First().Text == BeatmapsetsStrings.ShowStatsCsMania);
AddStep("set ruleset to osu", () => advancedStats.Ruleset.Value = new OsuRuleset().RulesetInfo);
AddAssert("first bar text is correct", () => advancedStats.ChildrenOfType<SpriteText>().First().Text == BeatmapsetsStrings.ShowStatsCs);
}
[Test]

View File

@ -382,7 +382,7 @@ namespace osu.Game.Database
HashSet<Guid> scoreIds = realmAccess.Run(r => new HashSet<Guid>(
r.All<ScoreInfo>()
.Where(s => s.TotalScoreVersion < LegacyScoreEncoder.LATEST_VERSION)
.Where(s => s.TotalScoreVersion < 30000013) // last total score version with a significant change to ranks
.AsEnumerable()
// must be done after materialisation, as realm doesn't support
// filtering on nested property predicates or projection via `.Select()`

View File

@ -365,6 +365,17 @@ namespace osu.Game.Database
+ bonusProportion) * modMultiplier);
}
// see similar check above.
// if there is no legacy combo score, all combo conversion operations below
// are either pointless or wildly wrong.
if (maximumLegacyComboScore + maximumLegacyBonusScore == 0)
{
return (long)Math.Round((
500000 * comboProportion // as above, zero if mods result in zero multiplier, one otherwise
+ 500000 * Math.Pow(score.Accuracy, 5)
+ bonusProportion) * modMultiplier);
}
// Assumptions:
// - sliders and slider ticks are uniformly distributed in the beatmap, and thus can be ignored without losing much precision.
// We thus consider a map of hit-circles only, which gives objectCount == maximumCombo.

View File

@ -127,7 +127,7 @@ namespace osu.Game.Graphics.Containers
}
protected virtual void ScrollFromMouseEvent(MouseEvent e) =>
ScrollTo(Clamp(ToLocalSpace(e.ScreenSpaceMousePosition)[ScrollDim] / DrawSize[ScrollDim]) * Content.DrawSize[ScrollDim], true, DistanceDecayOnRightMouseScrollbar);
ScrollTo(Clamp(ToLocalSpace(e.ScreenSpaceMousePosition)[ScrollDim] / DrawSize[ScrollDim] * Content.DrawSize[ScrollDim]), true, DistanceDecayOnRightMouseScrollbar);
protected override ScrollbarContainer CreateScrollbar(Direction direction) => new OsuScrollbar(direction);

View File

@ -220,12 +220,16 @@ namespace osu.Game.Graphics.Cursor
{
activeCursor.FadeTo(1, 250, Easing.OutQuint);
activeCursor.ScaleTo(1, 400, Easing.OutQuint);
activeCursor.RotateTo(0, 400, Easing.OutQuint);
dragRotationState = DragRotationState.NotDragging;
}
protected override void PopOut()
{
activeCursor.FadeTo(0, 250, Easing.OutQuint);
activeCursor.ScaleTo(0.6f, 250, Easing.In);
activeCursor.RotateTo(0, 400, Easing.OutQuint);
dragRotationState = DragRotationState.NotDragging;
}
private void playTapSample(double baseFrequency = 1f)

View File

@ -4,12 +4,12 @@
using osu.Game.Scoring;
using osu.Game.Users;
namespace osu.Game.Online.Solo
namespace osu.Game.Online
{
/// <summary>
/// Contains data about the change in a user's profile statistics after completing a score.
/// </summary>
public class SoloStatisticsUpdate
public class UserStatisticsUpdate
{
/// <summary>
/// The score set by the user that triggered the update.
@ -27,12 +27,12 @@ namespace osu.Game.Online.Solo
public UserStatistics After { get; }
/// <summary>
/// Creates a new <see cref="SoloStatisticsUpdate"/>.
/// Creates a new <see cref="UserStatisticsUpdate"/>.
/// </summary>
/// <param name="score">The score set by the user that triggered the update.</param>
/// <param name="before">The user's profile statistics prior to the score being set.</param>
/// <param name="after">The user's profile statistics after the score was set.</param>
public SoloStatisticsUpdate(ScoreInfo score, UserStatistics before, UserStatistics after)
public UserStatisticsUpdate(ScoreInfo score, UserStatistics before, UserStatistics after)
{
Score = score;
Before = before;

View File

@ -15,15 +15,15 @@ using osu.Game.Online.Spectator;
using osu.Game.Scoring;
using osu.Game.Users;
namespace osu.Game.Online.Solo
namespace osu.Game.Online
{
/// <summary>
/// A persistent component that binds to the spectator server and API in order to deliver updates about the logged in user's gameplay statistics.
/// </summary>
public partial class SoloStatisticsWatcher : Component
public partial class UserStatisticsWatcher : Component
{
public IBindable<SoloStatisticsUpdate?> LatestUpdate => latestUpdate;
private readonly Bindable<SoloStatisticsUpdate?> latestUpdate = new Bindable<SoloStatisticsUpdate?>();
public IBindable<UserStatisticsUpdate?> LatestUpdate => latestUpdate;
private readonly Bindable<UserStatisticsUpdate?> latestUpdate = new Bindable<UserStatisticsUpdate?>();
[Resolved]
private SpectatorClient spectatorClient { get; set; } = null!;
@ -120,7 +120,7 @@ namespace osu.Game.Online.Solo
latestStatistics.TryGetValue(rulesetName, out UserStatistics? latestRulesetStatistics);
latestRulesetStatistics ??= new UserStatistics();
latestUpdate.Value = new SoloStatisticsUpdate(scoreInfo, latestRulesetStatistics, updatedStatistics);
latestUpdate.Value = new UserStatisticsUpdate(scoreInfo, latestRulesetStatistics, updatedStatistics);
latestStatistics[rulesetName] = updatedStatistics;
}

View File

@ -47,7 +47,6 @@ using osu.Game.Localisation;
using osu.Game.Online;
using osu.Game.Online.Chat;
using osu.Game.Online.Rooms;
using osu.Game.Online.Solo;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapListing;
using osu.Game.Overlays.Music;
@ -767,7 +766,7 @@ namespace osu.Game
break;
case ScorePresentType.Results:
screen.Push(new SoloResultsScreen(databasedScore.ScoreInfo, false));
screen.Push(new SoloResultsScreen(databasedScore.ScoreInfo));
break;
}
}, validScreens: validScreens);
@ -1019,7 +1018,7 @@ namespace osu.Game
ScreenStack.Push(CreateLoader().With(l => l.RelativeSizeAxes = Axes.Both));
});
loadComponentSingleFile(new SoloStatisticsWatcher(), Add, true);
loadComponentSingleFile(new UserStatisticsWatcher(), Add, true);
loadComponentSingleFile(Toolbar = new Toolbar
{
OnHome = delegate

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.BeatmapSet.Buttons;
using osu.Game.Rulesets;
using osu.Game.Screens.Select.Details;
using osuTK;
@ -33,10 +34,10 @@ namespace osu.Game.Overlays.BeatmapSet
{
if (value == beatmapSet) return;
beatmapSet = value;
basic.BeatmapSet = preview.BeatmapSet = beatmapSet = value;
basic.BeatmapSet = preview.BeatmapSet = BeatmapSet;
updateDisplay();
if (IsLoaded)
updateDisplay();
}
}
@ -50,13 +51,10 @@ namespace osu.Game.Overlays.BeatmapSet
if (value == beatmapInfo) return;
basic.BeatmapInfo = advanced.BeatmapInfo = beatmapInfo = value;
}
}
private void updateDisplay()
{
Ratings.Ratings = BeatmapSet?.Ratings;
ratingBox.Alpha = BeatmapSet?.Status > 0 ? 1 : 0;
if (IsLoaded)
updateDisplay();
}
}
public Details()
@ -101,12 +99,22 @@ namespace osu.Game.Overlays.BeatmapSet
};
}
[BackgroundDependencyLoader]
private void load()
[Resolved]
private RulesetStore rulesets { get; set; }
protected override void LoadComplete()
{
base.LoadComplete();
updateDisplay();
}
private void updateDisplay()
{
Ratings.Ratings = BeatmapSet?.Ratings;
ratingBox.Alpha = BeatmapSet?.Status > 0 ? 1 : 0;
advanced.Ruleset.Value = rulesets.GetRuleset(beatmapInfo?.Ruleset.OnlineID ?? 0);
}
private partial class DetailBox : Container
{
private readonly Container content;

View File

@ -13,7 +13,7 @@ using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Solo;
using osu.Game.Online;
using osu.Game.Resources.Localisation.Web;
using osuTK;
@ -21,13 +21,13 @@ namespace osu.Game.Overlays.Toolbar
{
public partial class TransientUserStatisticsUpdateDisplay : CompositeDrawable
{
public Bindable<SoloStatisticsUpdate?> LatestUpdate { get; } = new Bindable<SoloStatisticsUpdate?>();
public Bindable<UserStatisticsUpdate?> LatestUpdate { get; } = new Bindable<UserStatisticsUpdate?>();
private Statistic<int> globalRank = null!;
private Statistic<decimal> pp = null!;
[BackgroundDependencyLoader]
private void load(SoloStatisticsWatcher? soloStatisticsWatcher)
private void load(UserStatisticsWatcher? userStatisticsWatcher)
{
RelativeSizeAxes = Axes.Y;
AutoSizeAxes = Axes.X;
@ -47,8 +47,8 @@ namespace osu.Game.Overlays.Toolbar
}
};
if (soloStatisticsWatcher != null)
((IBindable<SoloStatisticsUpdate?>)LatestUpdate).BindTo(soloStatisticsWatcher.LatestUpdate);
if (userStatisticsWatcher != null)
((IBindable<UserStatisticsUpdate?>)LatestUpdate).BindTo(userStatisticsWatcher.LatestUpdate);
}
protected override void LoadComplete()

View File

@ -44,9 +44,10 @@ namespace osu.Game.Scoring.Legacy
/// <see cref="LegacyRulesetExtensions.CalculateDifficultyPeppyStars"/> method. Reconvert all scores.
/// </description></item>
/// <item><description>30000013: All local scores will use lazer definitions of ranks for consistency. Recalculates the rank of all scores.</description></item>
/// <item><description>30000014: Fix edge cases in conversion for osu! scores on selected beatmaps. Reconvert all scores.</description></item>
/// </list>
/// </remarks>
public const int LATEST_VERSION = 30000013;
public const int LATEST_VERSION = 30000014;
/// <summary>
/// The first stable-compatible YYYYMMDD format version given to lazer usage of replays.

View File

@ -200,7 +200,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
return multiplayerLeaderboard.TeamScores.Count == 2
? new MultiplayerTeamResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, multiplayerLeaderboard.TeamScores)
: new MultiplayerResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem);
{
ShowUserStatistics = true,
}
: new MultiplayerResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem)
{
ShowUserStatistics = true
};
}
protected override void Dispose(bool isDisposing)

View File

@ -10,7 +10,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
public partial class MultiplayerResultsScreen : PlaylistsResultsScreen
{
public MultiplayerResultsScreen(ScoreInfo score, long roomId, PlaylistItem playlistItem)
: base(score, roomId, playlistItem, false)
: base(score, roomId, playlistItem)
{
}
}

View File

@ -58,7 +58,11 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
protected override ResultsScreen CreateResults(ScoreInfo score)
{
Debug.Assert(Room.RoomID.Value != null);
return new PlaylistsResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, true);
return new PlaylistsResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem)
{
AllowRetry = true,
ShowUserStatistics = true,
};
}
protected override void Dispose(bool isDisposing)

View File

@ -41,8 +41,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
[Resolved]
private RulesetStore rulesets { get; set; }
public PlaylistsResultsScreen([CanBeNull] ScoreInfo score, long roomId, PlaylistItem playlistItem, bool allowRetry, bool allowWatchingReplay = true)
: base(score, allowRetry, allowWatchingReplay)
public PlaylistsResultsScreen([CanBeNull] ScoreInfo score, long roomId, PlaylistItem playlistItem)
: base(score)
{
this.roomId = roomId;
this.playlistItem = playlistItem;

View File

@ -114,7 +114,7 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
RequestResults = item =>
{
Debug.Assert(RoomId.Value != null);
ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item, false));
ParentScreen?.Push(new PlaylistsResultsScreen(null, RoomId.Value.Value, item));
}
}
},

View File

@ -1,15 +1,11 @@
// 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.
#nullable disable
using System;
using System.Threading.Tasks;
using osu.Game.Scoring;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -22,26 +18,13 @@ namespace osu.Game.Screens.Play
{
public partial class FailOverlay : GameplayMenuOverlay
{
public Func<Task<ScoreInfo>> SaveReplay;
public Func<Task<ScoreInfo>>? SaveReplay;
public override LocalisableString Header => GameplayMenuOverlayStrings.FailedHeader;
private readonly bool showButtons;
public FailOverlay(bool showButtons = true)
{
this.showButtons = showButtons;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load()
{
if (showButtons)
{
AddButton(GameplayMenuOverlayStrings.Retry, colours.YellowDark, () => OnRetry?.Invoke());
AddButton(GameplayMenuOverlayStrings.Quit, new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
}
// from #10339 maybe this is a better visual effect
Add(new Container
{

View File

@ -38,8 +38,9 @@ namespace osu.Game.Screens.Play
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public Action? OnRetry;
public Action? OnQuit;
public Action? OnResume { get; init; }
public Action? OnRetry { get; init; }
public Action? OnQuit { get; init; }
/// <summary>
/// Action that is invoked when <see cref="GlobalAction.Back"/> is triggered.
@ -129,6 +130,15 @@ namespace osu.Game.Screens.Play
},
};
if (OnResume != null)
AddButton(GameplayMenuOverlayStrings.Continue, colours.Green, () => OnResume.Invoke());
if (OnRetry != null)
AddButton(GameplayMenuOverlayStrings.Retry, colours.YellowDark, () => OnRetry.Invoke());
if (OnQuit != null)
AddButton(GameplayMenuOverlayStrings.Quit, new Color4(170, 27, 39, 255), () => OnQuit.Invoke());
State.ValueChanged += _ => InternalButtons.Deselect();
updateInfoText();

View File

@ -75,21 +75,21 @@ namespace osu.Game.Screens.Play.HUD
AutoSizeAxes = Axes.Both,
Child = wholePart = new ArgonCounterTextComponent(Anchor.TopRight, BeatmapsetsStrings.ShowScoreboardHeadersAccuracy.ToUpper())
{
RequiredDisplayDigits = { Value = 3 },
WireframeOpacity = { BindTarget = WireframeOpacity },
WireframeTemplate = @"###",
ShowLabel = { BindTarget = ShowLabel },
}
},
fractionPart = new ArgonCounterTextComponent(Anchor.TopLeft)
{
RequiredDisplayDigits = { Value = 2 },
WireframeOpacity = { BindTarget = WireframeOpacity },
WireframeTemplate = @".##",
Scale = new Vector2(0.5f),
},
percentText = new ArgonCounterTextComponent(Anchor.TopLeft)
{
Text = @"%",
RequiredDisplayDigits = { Value = 1 },
WireframeTemplate = @"#",
WireframeOpacity = { BindTarget = WireframeOpacity }
},
}

View File

@ -68,7 +68,10 @@ namespace osu.Game.Screens.Play.HUD
private void updateWireframe()
{
text.RequiredDisplayDigits.Value = getDigitsRequiredForDisplayCount();
int digitsRequiredForDisplayCount = getDigitsRequiredForDisplayCount();
if (digitsRequiredForDisplayCount != text.WireframeTemplate.Length)
text.WireframeTemplate = new string('#', digitsRequiredForDisplayCount);
}
private int getDigitsRequiredForDisplayCount()

View File

@ -25,7 +25,6 @@ namespace osu.Game.Screens.Play.HUD
private readonly OsuSpriteText labelText;
public IBindable<float> WireframeOpacity { get; } = new BindableFloat();
public Bindable<int> RequiredDisplayDigits { get; } = new BindableInt();
public Bindable<bool> ShowLabel { get; } = new BindableBool();
public Container NumberContainer { get; private set; }
@ -36,6 +35,18 @@ namespace osu.Game.Screens.Play.HUD
set => textPart.Text = value;
}
/// <summary>
/// The template for the wireframe displayed behind the <see cref="Text"/>.
/// Any character other than a dot is interpreted to mean a full segmented display "wireframe".
/// </summary>
public string WireframeTemplate
{
get => wireframeTemplate;
set => wireframesPart.Text = wireframeTemplate = value;
}
private string wireframeTemplate = string.Empty;
public ArgonCounterTextComponent(Anchor anchor, LocalisableString? label = null)
{
Anchor = anchor;
@ -69,8 +80,6 @@ namespace osu.Game.Screens.Play.HUD
}
}
};
RequiredDisplayDigits.BindValueChanged(digits => wireframesPart.Text = new string('#', digits.NewValue));
}
private string textLookup(char c)

View File

@ -58,8 +58,10 @@ namespace osu.Game.Screens.Play.HUD
private void updateWireframe()
{
scoreText.RequiredDisplayDigits.Value =
Math.Max(RequiredDisplayDigits.Value, getDigitsRequiredForDisplayCount());
int digitsRequiredForDisplayCount = Math.Max(RequiredDisplayDigits.Value, getDigitsRequiredForDisplayCount());
if (digitsRequiredForDisplayCount != scoreText.WireframeTemplate.Length)
scoreText.WireframeTemplate = new string('#', digitsRequiredForDisplayCount);
}
private int getDigitsRequiredForDisplayCount()

View File

@ -1,8 +1,6 @@
// 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.
#nullable disable
using System;
using System.Linq;
using osu.Framework.Allocation;
@ -11,23 +9,19 @@ using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Audio;
using osu.Game.Graphics;
using osu.Game.Input.Bindings;
using osu.Game.Localisation;
using osu.Game.Skinning;
using osuTK.Graphics;
namespace osu.Game.Screens.Play
{
public partial class PauseOverlay : GameplayMenuOverlay
{
public Action OnResume;
public override bool IsPresent => base.IsPresent || pauseLoop.IsPlaying;
public override LocalisableString Header => GameplayMenuOverlayStrings.PausedHeader;
private SkinnableSound pauseLoop;
private SkinnableSound pauseLoop = null!;
protected override Action BackAction => () =>
{
@ -38,12 +32,8 @@ namespace osu.Game.Screens.Play
};
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load()
{
AddButton(GameplayMenuOverlayStrings.Continue, colours.Green, () => OnResume?.Invoke());
AddButton(GameplayMenuOverlayStrings.Retry, colours.YellowDark, () => OnRetry?.Invoke());
AddButton(GameplayMenuOverlayStrings.Quit, new Color4(170, 27, 39, 255), () => OnQuit?.Invoke());
AddInternal(pauseLoop = new SkinnableSound(new SampleInfo("Gameplay/pause-loop"))
{
Looping = true,

View File

@ -278,10 +278,10 @@ namespace osu.Game.Screens.Play
createGameplayComponents(Beatmap.Value)
}
},
FailOverlay = new FailOverlay(Configuration.AllowUserInteraction)
FailOverlay = new FailOverlay
{
SaveReplay = async () => await prepareAndImportScoreAsync(true).ConfigureAwait(false),
OnRetry = () => Restart(),
OnRetry = Configuration.AllowUserInteraction ? () => Restart() : null,
OnQuit = () => PerformExit(true),
},
new HotkeyExitOverlay
@ -1224,9 +1224,10 @@ namespace osu.Game.Screens.Play
/// </summary>
/// <param name="score">The <see cref="ScoreInfo"/> to be displayed in the results screen.</param>
/// <returns>The <see cref="ResultsScreen"/>.</returns>
protected virtual ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, true)
protected virtual ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score)
{
ShowUserStatistics = true
AllowRetry = true,
ShowUserStatistics = true,
};
private void fadeOut(bool instant = false)

View File

@ -92,7 +92,7 @@ namespace osu.Game.Screens.Play
Scores = { BindTarget = LeaderboardScores }
};
protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score, false);
protected override ResultsScreen CreateResults(ScoreInfo score) => new SoloResultsScreen(score);
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{

View File

@ -30,13 +30,13 @@ namespace osu.Game.Screens.Play
private readonly Bindable<DownloadState> state = new Bindable<DownloadState>();
private readonly Func<Task<ScoreInfo>> importFailedScore;
private readonly Func<Task<ScoreInfo>>? importFailedScore;
private ScoreInfo? importedScore;
private DownloadButton button = null!;
public SaveFailedScoreButton(Func<Task<ScoreInfo>> importFailedScore)
public SaveFailedScoreButton(Func<Task<ScoreInfo>>? importFailedScore)
{
Size = new Vector2(50, 30);
@ -60,11 +60,16 @@ namespace osu.Game.Screens.Play
case DownloadState.NotDownloaded:
state.Value = DownloadState.Importing;
Task.Run(importFailedScore).ContinueWith(t =>
if (importFailedScore != null)
{
importedScore = realm.Run(r => r.Find<ScoreInfo>(t.GetResultSafely().ID)?.Detach());
Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded);
}).FireAndForget();
Task.Run(importFailedScore).ContinueWith(t =>
{
importedScore = realm.Run(r => r.Find<ScoreInfo>(t.GetResultSafely().ID)?.Detach());
Schedule(() => state.Value = importedScore != null ? DownloadState.LocallyAvailable : DownloadState.NotDownloaded);
}).FireAndForget();
}
break;
}
}

View File

@ -1,9 +1,8 @@
// 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.
#nullable disable
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Screens;
using osu.Game.Online.Spectator;
using osu.Game.Scoring;
@ -50,7 +49,7 @@ namespace osu.Game.Screens.Play
{
base.Dispose(isDisposing);
if (SpectatorClient != null)
if (SpectatorClient.IsNotNull())
SpectatorClient.OnUserBeganPlaying -= userBeganPlaying;
}
}

View File

@ -1,10 +1,8 @@
// 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.
#nullable disable
using System.Diagnostics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Screens;
using osu.Game.Beatmaps;
@ -21,12 +19,10 @@ namespace osu.Game.Screens.Play
public abstract partial class SpectatorPlayer : Player
{
[Resolved]
protected SpectatorClient SpectatorClient { get; private set; }
protected SpectatorClient SpectatorClient { get; private set; } = null!;
private readonly Score score;
public override bool AllowBackButton => true;
protected override bool CheckModsAllowFailure()
{
if (!allowFail)
@ -37,7 +33,7 @@ namespace osu.Game.Screens.Play
private bool allowFail;
protected SpectatorPlayer(Score score, PlayerConfiguration configuration = null)
protected SpectatorPlayer(Score score, PlayerConfiguration? configuration = null)
: base(configuration)
{
this.score = score;
@ -100,8 +96,7 @@ namespace osu.Game.Screens.Play
foreach (var frame in bundle.Frames)
{
IConvertibleReplayFrame convertibleFrame = GameplayState.Ruleset.CreateConvertibleReplayFrame();
Debug.Assert(convertibleFrame != null);
IConvertibleReplayFrame convertibleFrame = GameplayState.Ruleset.CreateConvertibleReplayFrame()!;
convertibleFrame.FromLegacy(frame, GameplayState.Beatmap);
var convertedFrame = (ReplayFrame)convertibleFrame;
@ -136,7 +131,7 @@ namespace osu.Game.Screens.Play
{
base.Dispose(isDisposing);
if (SpectatorClient != null)
if (SpectatorClient.IsNotNull())
SpectatorClient.OnNewFrames -= userSentFrames;
}
}

View File

@ -13,7 +13,7 @@ namespace osu.Game.Screens.Play
public partial class SpectatorResultsScreen : SoloResultsScreen
{
public SpectatorResultsScreen(ScoreInfo score)
: base(score, false)
: base(score)
{
}

View File

@ -14,10 +14,10 @@ using osu.Framework.Screens;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Online;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Online.Solo;
using osu.Game.Online.Spectator;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
@ -45,7 +45,7 @@ namespace osu.Game.Screens.Play
[Resolved(canBeNull: true)]
[CanBeNull]
private SoloStatisticsWatcher soloStatisticsWatcher { get; set; }
private UserStatisticsWatcher userStatisticsWatcher { get; set; }
private readonly object scoreSubmissionLock = new object();
private TaskCompletionSource<bool> scoreSubmissionSource;
@ -189,7 +189,7 @@ namespace osu.Game.Screens.Play
await submitScore(score).ConfigureAwait(false);
spectatorClient.EndPlaying(GameplayState);
soloStatisticsWatcher?.RegisterForStatisticsUpdateAfter(score.ScoreInfo);
userStatisticsWatcher?.RegisterForStatisticsUpdateAfter(score.ScoreInfo);
}
[Resolved]

View File

@ -63,16 +63,28 @@ namespace osu.Game.Screens.Ranking
private bool lastFetchCompleted;
private readonly bool allowRetry;
private readonly bool allowWatchingReplay;
/// <summary>
/// Whether the user can retry the beatmap from the results screen.
/// </summary>
public bool AllowRetry { get; init; }
/// <summary>
/// Whether the user can watch the replay of the completed play from the results screen.
/// </summary>
public bool AllowWatchingReplay { get; init; } = true;
/// <summary>
/// Whether the user's personal statistics should be shown on the extended statistics panel
/// after clicking the score panel associated with the <see cref="ResultsScreen.Score"/> being presented.
/// Requires <see cref="Score"/> to be present.
/// </summary>
public bool ShowUserStatistics { get; init; }
private Sample popInSample;
protected ResultsScreen([CanBeNull] ScoreInfo score, bool allowRetry, bool allowWatchingReplay = true)
protected ResultsScreen([CanBeNull] ScoreInfo score)
{
Score = score;
this.allowRetry = allowRetry;
this.allowWatchingReplay = allowWatchingReplay;
SelectedScore.Value = score;
}
@ -100,7 +112,7 @@ namespace osu.Game.Screens.Ranking
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
StatisticsPanel = CreateStatisticsPanel().With(panel =>
StatisticsPanel = createStatisticsPanel().With(panel =>
{
panel.RelativeSizeAxes = Axes.Both;
panel.Score.BindTarget = SelectedScore;
@ -162,7 +174,7 @@ namespace osu.Game.Screens.Ranking
ScorePanelList.AddScore(Score, shouldFlair);
}
if (allowWatchingReplay)
if (AllowWatchingReplay)
{
buttons.Add(new ReplayDownloadButton(SelectedScore.Value)
{
@ -171,7 +183,7 @@ namespace osu.Game.Screens.Ranking
});
}
if (player != null && allowRetry)
if (player != null && AllowRetry)
{
buttons.Add(new RetryButton { Width = 300 });
@ -238,7 +250,12 @@ namespace osu.Game.Screens.Ranking
/// <summary>
/// Creates the <see cref="Statistics.StatisticsPanel"/> to be used to display extended information about scores.
/// </summary>
protected virtual StatisticsPanel CreateStatisticsPanel() => new StatisticsPanel();
private StatisticsPanel createStatisticsPanel()
{
return ShowUserStatistics && Score != null
? new UserStatisticsPanel(Score)
: new StatisticsPanel();
}
private void fetchScoresCallback(IEnumerable<ScoreInfo> scores) => Schedule(() =>
{

View File

@ -6,70 +6,27 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.Solo;
using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Statistics;
namespace osu.Game.Screens.Ranking
{
public partial class SoloResultsScreen : ResultsScreen
{
/// <summary>
/// Whether the user's personal statistics should be shown on the extended statistics panel
/// after clicking the score panel associated with the <see cref="ResultsScreen.Score"/> being presented.
/// </summary>
public bool ShowUserStatistics { get; init; }
private GetScoresRequest? getScoreRequest;
[Resolved]
private RulesetStore rulesets { get; set; } = null!;
private IBindable<SoloStatisticsUpdate?> latestUpdate = null!;
private readonly Bindable<SoloStatisticsUpdate?> statisticsUpdate = new Bindable<SoloStatisticsUpdate?>();
public SoloResultsScreen(ScoreInfo score, bool allowRetry)
: base(score, allowRetry)
public SoloResultsScreen(ScoreInfo score)
: base(score)
{
}
[BackgroundDependencyLoader]
private void load(SoloStatisticsWatcher? soloStatisticsWatcher)
{
if (ShowUserStatistics && soloStatisticsWatcher != null)
{
Debug.Assert(Score != null);
latestUpdate = soloStatisticsWatcher.LatestUpdate.GetBoundCopy();
latestUpdate.BindValueChanged(update =>
{
if (update.NewValue?.Score.MatchesOnlineID(Score) == true)
statisticsUpdate.Value = update.NewValue;
});
}
}
protected override StatisticsPanel CreateStatisticsPanel()
{
Debug.Assert(Score != null);
if (ShowUserStatistics)
{
return new SoloStatisticsPanel(Score)
{
StatisticsUpdate = { BindTarget = statisticsUpdate }
};
}
return base.CreateStatisticsPanel();
}
protected override APIRequest? FetchScores(Action<IEnumerable<ScoreInfo>>? scoresCallback)
{
Debug.Assert(Score != null);

View File

@ -6,7 +6,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Solo;
using osu.Game.Online;
namespace osu.Game.Screens.Ranking.Statistics.User
{
@ -14,7 +14,7 @@ namespace osu.Game.Screens.Ranking.Statistics.User
{
private const float transition_duration = 300;
public Bindable<SoloStatisticsUpdate?> StatisticsUpdate { get; } = new Bindable<SoloStatisticsUpdate?>();
public Bindable<UserStatisticsUpdate?> StatisticsUpdate { get; } = new Bindable<UserStatisticsUpdate?>();
private LoadingLayer loadingLayer = null!;
private GridContainer content = null!;
@ -86,7 +86,7 @@ namespace osu.Game.Screens.Ranking.Statistics.User
FinishTransforms(true);
}
private void onUpdateReceived(ValueChangedEvent<SoloStatisticsUpdate?> update)
private void onUpdateReceived(ValueChangedEvent<UserStatisticsUpdate?> update)
{
if (update.NewValue == null)
{

View File

@ -11,7 +11,7 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.Solo;
using osu.Game.Online;
using osu.Game.Users;
using osuTK;
@ -19,7 +19,7 @@ namespace osu.Game.Screens.Ranking.Statistics.User
{
public abstract partial class RankingChangeRow<T> : CompositeDrawable
{
public Bindable<SoloStatisticsUpdate?> StatisticsUpdate { get; } = new Bindable<SoloStatisticsUpdate?>();
public Bindable<UserStatisticsUpdate?> StatisticsUpdate { get; } = new Bindable<UserStatisticsUpdate?>();
private readonly Func<UserStatistics, T> accessor;
@ -113,7 +113,7 @@ namespace osu.Game.Screens.Ranking.Statistics.User
StatisticsUpdate.BindValueChanged(onStatisticsUpdate, true);
}
private void onStatisticsUpdate(ValueChangedEvent<SoloStatisticsUpdate?> statisticsUpdate)
private void onStatisticsUpdate(ValueChangedEvent<UserStatisticsUpdate?> statisticsUpdate)
{
var update = statisticsUpdate.NewValue;

View File

@ -3,25 +3,43 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Online.Solo;
using osu.Game.Extensions;
using osu.Game.Online;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Statistics.User;
namespace osu.Game.Screens.Ranking.Statistics
{
public partial class SoloStatisticsPanel : StatisticsPanel
public partial class UserStatisticsPanel : StatisticsPanel
{
private readonly ScoreInfo achievedScore;
public SoloStatisticsPanel(ScoreInfo achievedScore)
internal readonly Bindable<UserStatisticsUpdate?> DisplayedUserStatisticsUpdate = new Bindable<UserStatisticsUpdate?>();
private IBindable<UserStatisticsUpdate?> latestGlobalStatisticsUpdate = null!;
public UserStatisticsPanel(ScoreInfo achievedScore)
{
this.achievedScore = achievedScore;
}
public Bindable<SoloStatisticsUpdate?> StatisticsUpdate { get; } = new Bindable<SoloStatisticsUpdate?>();
[BackgroundDependencyLoader]
private void load(UserStatisticsWatcher? userStatisticsWatcher)
{
if (userStatisticsWatcher != null)
{
latestGlobalStatisticsUpdate = userStatisticsWatcher.LatestUpdate.GetBoundCopy();
latestGlobalStatisticsUpdate.BindValueChanged(update =>
{
if (update.NewValue?.Score.MatchesOnlineID(achievedScore) == true)
DisplayedUserStatisticsUpdate.Value = update.NewValue;
});
}
}
protected override ICollection<StatisticItem> CreateStatisticItems(ScoreInfo newScore, IBeatmap playableBeatmap)
{
@ -37,7 +55,7 @@ namespace osu.Game.Screens.Ranking.Statistics
RelativeSizeAxes = Axes.X,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
StatisticsUpdate = { BindTarget = StatisticsUpdate }
StatisticsUpdate = { BindTarget = DisplayedUserStatisticsUpdate }
})).ToArray();
}

View File

@ -215,6 +215,12 @@ namespace osu.Game.Screens.Select
InternalChild = new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding
{
// Avoid clash between scrollbar and osu! logo.
Top = 10,
Bottom = 100,
},
Children = new Drawable[]
{
setPool,

View File

@ -38,11 +38,6 @@ namespace osu.Game.Screens.Select.Details
[Resolved]
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
[Resolved]
private OsuGameBase game { get; set; }
private IBindable<RulesetInfo> gameRuleset;
protected readonly StatisticRow FirstValue, HpDrain, Accuracy, ApproachRate;
private readonly StatisticRow starDifficulty;
@ -64,6 +59,15 @@ namespace osu.Game.Screens.Select.Details
}
}
/// <summary>
/// Ruleset to be used for certain elements of display.
/// When set, this will override the set <see cref="Beatmap"/>'s own ruleset.
/// </summary>
/// <remarks>
/// No checks are done as to whether the ruleset specified is valid for the currently <see cref="BeatmapInfo"/>.
/// </remarks>
public Bindable<RulesetInfo> Ruleset { get; } = new Bindable<RulesetInfo>();
public AdvancedStats(int columns = 1)
{
switch (columns)
@ -137,12 +141,7 @@ namespace osu.Game.Screens.Select.Details
{
base.LoadComplete();
// the cached ruleset bindable might be a decoupled bindable provided by SongSelect,
// which we can't rely on in combination with the game-wide selected mods list,
// since mods could be updated to the new ruleset instances while the decoupled bindable is held behind,
// therefore resulting in performing difficulty calculation with invalid states.
gameRuleset = game.Ruleset.GetBoundCopy();
gameRuleset.BindValueChanged(_ => updateStatistics());
Ruleset.BindValueChanged(_ => updateStatistics());
mods.BindValueChanged(modsChanged, true);
}
@ -169,8 +168,6 @@ namespace osu.Game.Screens.Select.Details
IBeatmapDifficultyInfo baseDifficulty = BeatmapInfo?.Difficulty;
BeatmapDifficulty adjustedDifficulty = null;
IRulesetInfo ruleset = gameRuleset?.Value ?? beatmapInfo.Ruleset;
if (baseDifficulty != null)
{
BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(baseDifficulty);
@ -180,24 +177,24 @@ namespace osu.Game.Screens.Select.Details
adjustedDifficulty = originalDifficulty;
if (gameRuleset != null)
if (Ruleset.Value != null)
{
double rate = 1;
foreach (var mod in mods.Value.OfType<IApplicableToRate>())
rate = mod.ApplyToRate(0, rate);
adjustedDifficulty = ruleset.CreateInstance().GetRateAdjustedDisplayDifficulty(originalDifficulty, rate);
adjustedDifficulty = Ruleset.Value.CreateInstance().GetRateAdjustedDisplayDifficulty(originalDifficulty, rate);
TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty);
}
}
switch (ruleset.OnlineID)
switch (Ruleset.Value?.OnlineID)
{
case 3:
// Account for mania differences locally for now.
// Eventually this should be handled in a more modular way, allowing rulesets to return arbitrary difficulty attributes.
ILegacyRuleset legacyRuleset = (ILegacyRuleset)ruleset.CreateInstance();
ILegacyRuleset legacyRuleset = (ILegacyRuleset)Ruleset.Value.CreateInstance();
// For the time being, the key count is static no matter what, because:
// a) The method doesn't have knowledge of the active keymods. Doing so may require considerations for filtering.
@ -206,7 +203,6 @@ namespace osu.Game.Screens.Select.Details
FirstValue.Title = BeatmapsetsStrings.ShowStatsCsMania;
FirstValue.Value = (keyCount, keyCount);
break;
default:
@ -240,8 +236,8 @@ namespace osu.Game.Screens.Select.Details
starDifficultyCancellationSource = new CancellationTokenSource();
var normalStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, gameRuleset.Value, null, starDifficultyCancellationSource.Token);
var moddedStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, gameRuleset.Value, mods.Value, starDifficultyCancellationSource.Token);
var normalStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, Ruleset.Value, null, starDifficultyCancellationSource.Token);
var moddedStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, Ruleset.Value, mods.Value, starDifficultyCancellationSource.Token);
Task.WhenAll(normalStarDifficultyTask, moddedStarDifficultyTask).ContinueWith(_ => Schedule(() =>
{

View File

@ -54,7 +54,7 @@ namespace osu.Game.Screens.Select
}
protected void PresentScore(ScoreInfo score) =>
FinaliseSelection(score.BeatmapInfo, score.Ruleset, () => this.Push(new SoloResultsScreen(score, false)));
FinaliseSelection(score.BeatmapInfo, score.Ruleset, () => this.Push(new SoloResultsScreen(score)));
protected override BeatmapDetailArea CreateBeatmapDetailArea()
{

View File

@ -286,7 +286,7 @@ namespace osu.Game.Screens.Select
AutoSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Padding = new MarginPadding(10)
Padding = new MarginPadding(10),
},
}
},
@ -585,6 +585,11 @@ namespace osu.Game.Screens.Select
beatmapInfoPrevious = beatmap;
}
// we can't run this in the debounced run due to the selected mods bindable not being debounced,
// since mods could be updated to the new ruleset instances while the decoupled bindable is held behind,
// therefore resulting in performing difficulty calculation with invalid states.
advancedStats.Ruleset.Value = ruleset;
void run()
{
// clear pending task immediately to track any potential nested debounce operation.

View File

@ -168,7 +168,7 @@ namespace osu.Game.Users
Title = UsersStrings.ShowRankGlobalSimple,
// TODO: implement highest rank tooltip
// `RankHighest` resides in `APIUser`, but `api.LocalUser` doesn't update
// maybe move to `UserStatistics` in api, so `SoloStatisticsWatcher` can update the value
// maybe move to `UserStatistics` in api, so `UserStatisticsWatcher` can update the value
},
countryRankDisplay = new ProfileValueDisplay(true)
{

View File

@ -36,7 +36,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Realm" Version="11.5.0" />
<PackageReference Include="ppy.osu.Framework" Version="2024.221.0" />
<PackageReference Include="ppy.osu.Framework" Version="2024.223.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.207.0" />
<PackageReference Include="Sentry" Version="3.41.3" />
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->

View File

@ -23,6 +23,6 @@
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.iOS" Version="2024.221.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2024.223.0" />
</ItemGroup>
</Project>