Skip to content

Commit

Permalink
Merge branch 'master' into convert-path-string-new
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach authored Feb 29, 2024
2 parents f28f19e + 9a1403d commit 9a40a4f
Show file tree
Hide file tree
Showing 58 changed files with 340 additions and 338 deletions.
2 changes: 1 addition & 1 deletion osu.Android.props
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions osu.Desktop/DiscordRichPresence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ private void updateStatus()
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);

Expand Down
18 changes: 18 additions & 0 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,29 @@ protected override void UpdateInitialTransforms()
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;
Expand Down
1 change: 0 additions & 1 deletion osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ private void load(ISkinSource skin, DrawableHitObject drawableObject)

SnakingOut.BindTo(configSnakingOut);

BorderSize = skin.GetConfig<OsuSkinConfiguration, float>(OsuSkinConfiguration.SliderBorderSize)?.Value ?? 1;
BorderColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBorder)?.Value ?? Color4.White;
}

Expand Down
38 changes: 22 additions & 16 deletions osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySliderBody.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,35 @@ protected override Color4 GetBodyAccentColour(ISkinSource skin, Color4 hitObject

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;
// 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;

if (position <= shadow_portion)
return new Color4(0f, 0f, 0f, 0.25f * position / shadow_portion);
Color4 shadow = new Color4(0, 0, 0, 0.25f);
Color4 outerColour = AccentColour.Darken(0.1f);
Color4 innerColour = lighten(AccentColour, 0.5f);

if (position <= realBorderPortion)
return BorderColour;
// 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;

position -= realBorderPortion;
if (position <= shadow_portion - aa_width)
return LegacyUtils.InterpolateNonLinear(position, Color4.Black.Opacity(0f), shadow, 0, shadow_portion - aa_width);

Color4 outerColour = AccentColour.Darken(0.1f);
Color4 innerColour = lighten(AccentColour, 0.5f);
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 / realGradientPortion, outerColour, innerColour, 0, 1);
return LegacyUtils.InterpolateNonLinear(position, outerColour, innerColour, border_portion + aa_width, 1);
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion osu.Game.Rulesets.Osu/Skinning/OsuSkinConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace osu.Game.Rulesets.Osu.Skinning
{
public enum OsuSkinConfiguration
{
SliderBorderSize,
SliderPathRadius,
CursorCentre,
CursorExpand,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ public void TestBothSidesDateQuery()
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)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,9 @@ private void load(OsuConfigManager config)
private partial class FadeAccessibleResults : ResultsScreen
{
public FadeAccessibleResults(ScoreInfo score)
: base(score, true)
: base(score)
{
AllowRetry = true;
}

protected override BackgroundScreen CreateBackground() => new FadeAccessibleBackground(Beatmap.Value);
Expand Down
51 changes: 16 additions & 35 deletions osu.Game.Tests/Visual/Gameplay/TestSceneGameplayMenuOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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;
Expand All @@ -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 = null!;

private GlobalActionContainer globalActionContainer;
private bool triggeredRetryButton;

[BackgroundDependencyLoader]
private void load(OsuGameBase game)
Expand All @@ -35,12 +34,18 @@ private void load(OsuGameBase game)
[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
Expand Down Expand Up @@ -224,17 +229,9 @@ public void TestClickSelection()
{
showOverlay();

bool triggered = false;
AddStep("Click retry button", () =>
{
var lastAction = pauseOverlay.OnRetry;
pauseOverlay.OnRetry = () => triggered = true;

getButton(1).TriggerClick();
pauseOverlay.OnRetry = lastAction;
});
AddStep("Click retry button", () => getButton(1).TriggerClick());

AddAssert("Action was triggered", () => triggered);
AddAssert("Retry was triggered", () => triggeredRetryButton);
AddAssert("Overlay is closed", () => pauseOverlay.State.Value == Visibility.Hidden);
}

Expand All @@ -252,25 +249,9 @@ public void TestEnterKeySelection()
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);
}

Expand Down
26 changes: 15 additions & 11 deletions osu.Game.Tests/Visual/Gameplay/TestSceneSpectator.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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;
Expand All @@ -12,6 +10,7 @@
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;
Expand Down Expand Up @@ -39,13 +38,13 @@ public partial class TestSceneSpectator : ScreenTestScene
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]
Expand Down Expand Up @@ -188,7 +187,7 @@ public void TestHostRetriesWhileWatching()

waitForPlayerCurrent();

Player lastPlayer = null;
Player lastPlayer = null!;
AddStep("store first player", () => lastPlayer = player);

start();
Expand All @@ -214,6 +213,11 @@ public void TestHostFails()
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]
Expand Down Expand Up @@ -278,7 +282,7 @@ public void TestFinalFramesPurgedBeforeEndingPlay()
[Test]
public void TestFinalFrameInBundleHasHeader()
{
FrameDataBundle lastBundle = null;
FrameDataBundle? lastBundle = null;

AddStep("bind to client", () => spectatorClient.OnNewFrames += (_, bundle) => lastBundle = bundle);

Expand All @@ -287,8 +291,8 @@ public void TestFinalFrameInBundleHasHeader()
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]
Expand Down Expand Up @@ -383,7 +387,7 @@ public void TestFailedStateDuringLoading()
}

private OsuFramedReplayInputHandler replayHandler =>
(OsuFramedReplayInputHandler)Stack.ChildrenOfType<OsuInputManager>().First().ReplayInputHandler;
(OsuFramedReplayInputHandler)Stack.ChildrenOfType<OsuInputManager>().First().ReplayInputHandler!;

private Player player => this.ChildrenOfType<Player>().Single();

Expand Down
12 changes: 6 additions & 6 deletions osu.Game.Tests/Visual/Menus/TestSceneToolbarUserButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
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;
Expand Down Expand Up @@ -100,7 +100,7 @@ public void TestTransientUserStatisticsDisplay()
AddStep("Gain", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate(
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
Expand All @@ -116,7 +116,7 @@ public void TestTransientUserStatisticsDisplay()
AddStep("Loss", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate(
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
Expand All @@ -132,7 +132,7 @@ public void TestTransientUserStatisticsDisplay()
AddStep("No change", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate(
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
Expand All @@ -148,7 +148,7 @@ public void TestTransientUserStatisticsDisplay()
AddStep("Was null", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate(
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
Expand All @@ -164,7 +164,7 @@ public void TestTransientUserStatisticsDisplay()
AddStep("Became null", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new SoloStatisticsUpdate(
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
Expand Down
Loading

0 comments on commit 9a40a4f

Please sign in to comment.