1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Merge branch 'master' into ModCustomisationHeaderColor

This commit is contained in:
Fabep 2024-09-05 12:44:26 +02:00
commit 584d4a9abf
29 changed files with 1213 additions and 73 deletions

View File

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

View File

@ -54,6 +54,8 @@ namespace osu.Desktop.Updater
if (localUserInfo?.IsPlaying.Value == true) if (localUserInfo?.IsPlaying.Value == true)
return false; return false;
// TODO: we should probably be checking if there's a more recent update, rather than shortcutting here.
// Velopack does support this scenario (see https://github.com/ppy/osu/pull/28743#discussion_r1743495975).
if (pendingUpdate != null) if (pendingUpdate != null)
{ {
// If there is an update pending restart, show the notification to restart again. // If there is an update pending restart, show the notification to restart again.

View File

@ -0,0 +1,133 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Replays;
using osu.Game.Rulesets.Osu.Configuration;
using osu.Game.Rulesets.Osu.Replays;
using osu.Game.Rulesets.Osu.UI;
using osu.Game.Rulesets.Replays;
using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Osu.Tests
{
public partial class TestSceneOsuAnalysisContainer : OsuTestScene
{
private TestReplayAnalysisOverlay analysisContainer = null!;
private ReplayAnalysisSettings settings = null!;
[Cached]
private OsuRulesetConfigManager config = new OsuRulesetConfigManager(null, new OsuRuleset().RulesetInfo);
[SetUpSteps]
public void SetUpSteps()
{
AddStep("create analysis container", () =>
{
Children = new Drawable[]
{
new OsuPlayfieldAdjustmentContainer
{
Child = analysisContainer = new TestReplayAnalysisOverlay(fabricateReplay()),
},
settings = new ReplayAnalysisSettings(config),
};
settings.ShowClickMarkers.Value = false;
settings.ShowAimMarkers.Value = false;
settings.ShowCursorPath.Value = false;
});
}
[Test]
public void TestEverythingOn()
{
AddStep("enable everything", () =>
{
settings.ShowClickMarkers.Value = true;
settings.ShowAimMarkers.Value = true;
settings.ShowCursorPath.Value = true;
});
}
[Test]
public void TestHitMarkers()
{
AddStep("enable hit markers", () => settings.ShowClickMarkers.Value = true);
AddUntilStep("hit markers visible", () => analysisContainer.HitMarkersVisible);
AddStep("disable hit markers", () => settings.ShowClickMarkers.Value = false);
AddUntilStep("hit markers not visible", () => !analysisContainer.HitMarkersVisible);
}
[Test]
public void TestAimMarker()
{
AddStep("enable aim markers", () => settings.ShowAimMarkers.Value = true);
AddUntilStep("aim markers visible", () => analysisContainer.AimMarkersVisible);
AddStep("disable aim markers", () => settings.ShowAimMarkers.Value = false);
AddUntilStep("aim markers not visible", () => !analysisContainer.AimMarkersVisible);
}
[Test]
public void TestAimLines()
{
AddStep("enable aim lines", () => settings.ShowCursorPath.Value = true);
AddUntilStep("aim lines visible", () => analysisContainer.AimLinesVisible);
AddStep("disable aim lines", () => settings.ShowCursorPath.Value = false);
AddUntilStep("aim lines not visible", () => !analysisContainer.AimLinesVisible);
}
private Replay fabricateReplay()
{
var frames = new List<ReplayFrame>();
var random = new Random();
int posX = 250;
int posY = 250;
var actions = new HashSet<OsuAction>();
for (int i = 0; i < 1000; i++)
{
posX = Math.Clamp(posX + random.Next(-20, 21), -100, 600);
posY = Math.Clamp(posY + random.Next(-20, 21), -100, 600);
if (random.NextDouble() > (actions.Count == 0 ? 0.9 : 0.95))
{
actions.Add(random.NextDouble() > 0.5 ? OsuAction.LeftButton : OsuAction.RightButton);
}
else if (random.NextDouble() > 0.7)
{
actions.Remove(random.NextDouble() > 0.5 ? OsuAction.LeftButton : OsuAction.RightButton);
}
frames.Add(new OsuReplayFrame
{
Time = Time.Current + i * 15,
Position = new Vector2(posX, posY),
Actions = actions.ToList(),
});
}
return new Replay { Frames = frames };
}
private partial class TestReplayAnalysisOverlay : ReplayAnalysisOverlay
{
public TestReplayAnalysisOverlay(Replay replay)
: base(replay)
{
}
public bool HitMarkersVisible => ClickMarkers?.Alpha > 0 && ClickMarkers.Entries.Any();
public bool AimMarkersVisible => FrameMarkers?.Alpha > 0 && FrameMarkers.Entries.Any();
public bool AimLinesVisible => CursorPath?.Alpha > 0 && CursorPath.Vertices.Count > 1;
}
}
}

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Rulesets.Configuration; using osu.Game.Rulesets.Configuration;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
@ -11,7 +9,7 @@ namespace osu.Game.Rulesets.Osu.Configuration
{ {
public class OsuRulesetConfigManager : RulesetConfigManager<OsuRulesetSetting> public class OsuRulesetConfigManager : RulesetConfigManager<OsuRulesetSetting>
{ {
public OsuRulesetConfigManager(SettingsStore settings, RulesetInfo ruleset, int? variant = null) public OsuRulesetConfigManager(SettingsStore? settings, RulesetInfo ruleset, int? variant = null)
: base(settings, ruleset, variant) : base(settings, ruleset, variant)
{ {
} }
@ -24,6 +22,12 @@ namespace osu.Game.Rulesets.Osu.Configuration
SetDefault(OsuRulesetSetting.ShowCursorTrail, true); SetDefault(OsuRulesetSetting.ShowCursorTrail, true);
SetDefault(OsuRulesetSetting.ShowCursorRipples, false); SetDefault(OsuRulesetSetting.ShowCursorRipples, false);
SetDefault(OsuRulesetSetting.PlayfieldBorderStyle, PlayfieldBorderStyle.None); SetDefault(OsuRulesetSetting.PlayfieldBorderStyle, PlayfieldBorderStyle.None);
SetDefault(OsuRulesetSetting.ReplayClickMarkersEnabled, false);
SetDefault(OsuRulesetSetting.ReplayFrameMarkersEnabled, false);
SetDefault(OsuRulesetSetting.ReplayCursorPathEnabled, false);
SetDefault(OsuRulesetSetting.ReplayCursorHideEnabled, false);
SetDefault(OsuRulesetSetting.ReplayAnalysisDisplayLength, 750);
} }
} }
@ -34,5 +38,12 @@ namespace osu.Game.Rulesets.Osu.Configuration
ShowCursorTrail, ShowCursorTrail,
ShowCursorRipples, ShowCursorRipples,
PlayfieldBorderStyle, PlayfieldBorderStyle,
// Replay
ReplayClickMarkersEnabled,
ReplayFrameMarkersEnabled,
ReplayCursorPathEnabled,
ReplayCursorHideEnabled,
ReplayAnalysisDisplayLength,
} }
} }

View File

@ -1,11 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Input.Handlers; using osu.Game.Input.Handlers;
@ -25,18 +26,36 @@ namespace osu.Game.Rulesets.Osu.UI
{ {
public partial class DrawableOsuRuleset : DrawableRuleset<OsuHitObject> public partial class DrawableOsuRuleset : DrawableRuleset<OsuHitObject>
{ {
protected new OsuRulesetConfigManager Config => (OsuRulesetConfigManager)base.Config; private Bindable<bool>? cursorHideEnabled;
public new OsuInputManager KeyBindingInputManager => (OsuInputManager)base.KeyBindingInputManager; public new OsuInputManager KeyBindingInputManager => (OsuInputManager)base.KeyBindingInputManager;
public new OsuPlayfield Playfield => (OsuPlayfield)base.Playfield; public new OsuPlayfield Playfield => (OsuPlayfield)base.Playfield;
public DrawableOsuRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null) protected new OsuRulesetConfigManager Config => (OsuRulesetConfigManager)base.Config;
public DrawableOsuRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod>? mods = null)
: base(ruleset, beatmap, mods) : base(ruleset, beatmap, mods)
{ {
} }
public override DrawableHitObject<OsuHitObject> CreateDrawableRepresentation(OsuHitObject h) => null; [BackgroundDependencyLoader]
private void load(ReplayPlayer? replayPlayer)
{
if (replayPlayer != null)
{
PlayfieldAdjustmentContainer.Add(new ReplayAnalysisOverlay(replayPlayer.Score.Replay));
replayPlayer.AddSettings(new ReplayAnalysisSettings(Config));
cursorHideEnabled = Config.GetBindable<bool>(OsuRulesetSetting.ReplayCursorHideEnabled);
// I have little faith in this working (other things touch cursor visibility) but haven't broken it yet.
// Let's wait for someone to report an issue before spending too much time on it.
cursorHideEnabled.BindValueChanged(enabled => Playfield.Cursor.FadeTo(enabled.NewValue ? 0 : 1), true);
}
}
public override DrawableHitObject<OsuHitObject>? CreateDrawableRepresentation(OsuHitObject h) => null;
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; // always show the gameplay cursor public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true; // always show the gameplay cursor

View File

@ -0,0 +1,23 @@
// 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.Performance;
using osuTK;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class AnalysisFrameEntry : LifetimeEntry
{
public OsuAction[] Action { get; }
public Vector2 Position { get; }
public AnalysisFrameEntry(double time, double displayLength, Vector2 position, params OsuAction[] action)
{
LifetimeStart = time;
LifetimeEnd = time + displayLength;
Position = position;
Action = action;
}
}
}

View File

@ -0,0 +1,27 @@
// 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.Allocation;
using osu.Framework.Graphics;
using osu.Game.Graphics;
using osu.Game.Rulesets.Objects.Pooling;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public abstract partial class AnalysisMarker : PoolableDrawableWithLifetime<AnalysisFrameEntry>
{
[Resolved]
protected OsuColour Colours { get; private set; } = null!;
[BackgroundDependencyLoader]
private void load()
{
Origin = Anchor.Centre;
}
protected override void OnApply(AnalysisFrameEntry entry)
{
Position = entry.Position;
}
}
}

View File

@ -0,0 +1,88 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
/// <summary>
/// A marker which shows one click, with visuals focusing on the button which was clicked and the precise location of the click.
/// </summary>
public partial class ClickMarker : AnalysisMarker
{
private CircularProgress leftClickDisplay = null!;
private CircularProgress rightClickDisplay = null!;
[BackgroundDependencyLoader]
private void load()
{
InternalChildren = new Drawable[]
{
new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(0.125f),
RelativeSizeAxes = Axes.Both,
Blending = BlendingParameters.Additive,
Colour = Colours.Gray5,
},
new CircularContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Colour = Colours.Gray5,
Masking = true,
BorderThickness = 2.2f,
BorderColour = Color4.White,
Child = new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
AlwaysPresent = true,
Alpha = 0,
},
},
leftClickDisplay = new CircularProgress
{
Colour = Colours.Yellow,
Size = new Vector2(0.95f),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
Rotation = 180,
Progress = 0.5f,
InnerRadius = 0.18f,
RelativeSizeAxes = Axes.Both,
},
rightClickDisplay = new CircularProgress
{
Colour = Colours.Yellow,
Size = new Vector2(0.95f),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Progress = 0.5f,
InnerRadius = 0.18f,
RelativeSizeAxes = Axes.Both,
},
};
Size = new Vector2(16);
}
protected override void OnApply(AnalysisFrameEntry entry)
{
base.OnApply(entry);
leftClickDisplay.Alpha = entry.Action.Contains(OsuAction.LeftButton) ? 1 : 0;
rightClickDisplay.Alpha = entry.Action.Contains(OsuAction.RightButton) ? 1 : 0;
}
}
}

View File

@ -0,0 +1,20 @@
// 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.Pooling;
using osu.Game.Rulesets.Objects.Pooling;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class ClickMarkerContainer : PooledDrawableWithLifetimeContainer<AnalysisFrameEntry, AnalysisMarker>
{
private readonly DrawablePool<ClickMarker> clickMarkerPool;
public ClickMarkerContainer()
{
AddInternal(clickMarkerPool = new DrawablePool<ClickMarker>(30));
}
protected override AnalysisMarker GetDrawable(AnalysisFrameEntry entry) => clickMarkerPool.Get(d => d.Apply(entry));
}
}

View File

@ -0,0 +1,86 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Lines;
using osu.Framework.Graphics.Performance;
using osu.Game.Graphics;
using osuTK;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class CursorPathContainer : Path
{
private readonly LifetimeEntryManager lifetimeManager = new LifetimeEntryManager();
private readonly SortedSet<AnalysisFrameEntry> aliveEntries = new SortedSet<AnalysisFrameEntry>(new AimLinePointComparator());
public CursorPathContainer()
{
lifetimeManager.EntryBecameAlive += entryBecameAlive;
lifetimeManager.EntryBecameDead += entryBecameDead;
PathRadius = 0.5f;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Colour = colours.Pink2;
BackgroundColour = colours.Pink2.Opacity(0);
}
protected override void Update()
{
base.Update();
lifetimeManager.Update(Time.Current);
}
public void Add(AnalysisFrameEntry entry) => lifetimeManager.AddEntry(entry);
private void entryBecameAlive(LifetimeEntry entry)
{
aliveEntries.Add((AnalysisFrameEntry)entry);
updateVertices();
}
private void entryBecameDead(LifetimeEntry entry)
{
aliveEntries.Remove((AnalysisFrameEntry)entry);
updateVertices();
}
private void updateVertices()
{
ClearVertices();
Vector2 min = Vector2.Zero;
foreach (var entry in aliveEntries)
{
AddVertex(entry.Position);
if (entry.Position.X < min.X)
min.X = entry.Position.X;
if (entry.Position.Y < min.Y)
min.Y = entry.Position.Y;
}
Position = min;
}
private sealed class AimLinePointComparator : IComparer<AnalysisFrameEntry>
{
public int Compare(AnalysisFrameEntry? x, AnalysisFrameEntry? y)
{
ArgumentNullException.ThrowIfNull(x);
ArgumentNullException.ThrowIfNull(y);
return x.LifetimeStart.CompareTo(y.LifetimeStart);
}
}
}
}

View File

@ -0,0 +1,69 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osuTK;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
/// <summary>
/// A marker which shows one movement frame, include any buttons which are pressed.
/// </summary>
public partial class FrameMarker : AnalysisMarker
{
private CircularProgress leftClickDisplay = null!;
private CircularProgress rightClickDisplay = null!;
private Circle mainCircle = null!;
[BackgroundDependencyLoader]
private void load()
{
InternalChildren = new Drawable[]
{
mainCircle = new Circle
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Colour = Colours.Pink2,
},
leftClickDisplay = new CircularProgress
{
Colour = Colours.Yellow,
Size = new Vector2(0.8f),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreRight,
Rotation = 180,
Progress = 0.5f,
InnerRadius = 0.5f,
RelativeSizeAxes = Axes.Both,
},
rightClickDisplay = new CircularProgress
{
Colour = Colours.Yellow,
Size = new Vector2(0.8f),
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Progress = 0.5f,
InnerRadius = 0.5f,
RelativeSizeAxes = Axes.Both,
},
};
}
protected override void OnApply(AnalysisFrameEntry entry)
{
base.OnApply(entry);
Size = new Vector2(entry.Action.Any() ? 4 : 2.5f);
mainCircle.Colour = entry.Action.Any() ? Colours.Gray4 : Colours.Pink2;
leftClickDisplay.Alpha = entry.Action.Contains(OsuAction.LeftButton) ? 1 : 0;
rightClickDisplay.Alpha = entry.Action.Contains(OsuAction.RightButton) ? 1 : 0;
}
}
}

View File

@ -0,0 +1,20 @@
// 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.Pooling;
using osu.Game.Rulesets.Objects.Pooling;
namespace osu.Game.Rulesets.Osu.UI.ReplayAnalysis
{
public partial class FrameMarkerContainer : PooledDrawableWithLifetimeContainer<AnalysisFrameEntry, AnalysisMarker>
{
private readonly DrawablePool<FrameMarker> pool;
public FrameMarkerContainer()
{
AddInternal(pool = new DrawablePool<FrameMarker>(80));
}
protected override AnalysisMarker GetDrawable(AnalysisFrameEntry entry) => pool.Get(d => d.Apply(entry));
}
}

View File

@ -0,0 +1,128 @@
// 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.Threading;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Caching;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Replays;
using osu.Game.Rulesets.Osu.Configuration;
using osu.Game.Rulesets.Osu.Replays;
using osu.Game.Rulesets.Osu.UI.ReplayAnalysis;
namespace osu.Game.Rulesets.Osu.UI
{
public partial class ReplayAnalysisOverlay : CompositeDrawable
{
private BindableBool showClickMarkers { get; } = new BindableBool();
private BindableBool showFrameMarkers { get; } = new BindableBool();
private BindableBool showCursorPath { get; } = new BindableBool();
private BindableInt displayLength { get; } = new BindableInt();
protected ClickMarkerContainer? ClickMarkers;
protected FrameMarkerContainer? FrameMarkers;
protected CursorPathContainer? CursorPath;
private readonly Replay replay;
public ReplayAnalysisOverlay(Replay replay)
{
RelativeSizeAxes = Axes.Both;
this.replay = replay;
}
private bool requireDisplay => showClickMarkers.Value || showFrameMarkers.Value || showCursorPath.Value;
[BackgroundDependencyLoader]
private void load(OsuRulesetConfigManager config)
{
config.BindWith(OsuRulesetSetting.ReplayClickMarkersEnabled, showClickMarkers);
config.BindWith(OsuRulesetSetting.ReplayFrameMarkersEnabled, showFrameMarkers);
config.BindWith(OsuRulesetSetting.ReplayCursorPathEnabled, showCursorPath);
config.BindWith(OsuRulesetSetting.ReplayAnalysisDisplayLength, displayLength);
}
protected override void LoadComplete()
{
base.LoadComplete();
displayLength.BindValueChanged(_ =>
{
// Need to fully reload to make this work.
loaded.Invalidate();
}, true);
}
private readonly Cached loaded = new Cached();
private CancellationTokenSource? generationCancellationSource;
protected override void Update()
{
base.Update();
if (requireDisplay)
initialise();
if (ClickMarkers != null) ClickMarkers.Alpha = showClickMarkers.Value ? 1 : 0;
if (FrameMarkers != null) FrameMarkers.Alpha = showFrameMarkers.Value ? 1 : 0;
if (CursorPath != null) CursorPath.Alpha = showCursorPath.Value ? 1 : 0;
}
private void initialise()
{
if (loaded.IsValid)
return;
loaded.Validate();
generationCancellationSource?.Cancel();
generationCancellationSource = new CancellationTokenSource();
// It's faster to reinitialise the whole drawable stack than use `Clear` on `PooledDrawableWithLifetimeContainer`
var newDrawables = new Drawable[]
{
CursorPath = new CursorPathContainer(),
ClickMarkers = new ClickMarkerContainer(),
FrameMarkers = new FrameMarkerContainer(),
};
bool leftHeld = false;
bool rightHeld = false;
// This should probably be async as well, but it's a bit of a pain to debounce and everything.
// Let's address concerns when they are raised.
foreach (var frame in replay.Frames)
{
var osuFrame = (OsuReplayFrame)frame;
bool leftButton = osuFrame.Actions.Contains(OsuAction.LeftButton);
bool rightButton = osuFrame.Actions.Contains(OsuAction.RightButton);
if (leftHeld && !leftButton)
leftHeld = false;
else if (!leftHeld && leftButton)
{
leftHeld = true;
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, displayLength.Value, osuFrame.Position, OsuAction.LeftButton));
}
if (rightHeld && !rightButton)
rightHeld = false;
else if (!rightHeld && rightButton)
{
rightHeld = true;
ClickMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, displayLength.Value, osuFrame.Position, OsuAction.RightButton));
}
FrameMarkers.Add(new AnalysisFrameEntry(osuFrame.Time, displayLength.Value, osuFrame.Position, osuFrame.Actions.ToArray()));
CursorPath.Add(new AnalysisFrameEntry(osuFrame.Time, displayLength.Value, osuFrame.Position));
}
LoadComponentsAsync(newDrawables, drawables => InternalChildrenEnumerable = drawables, generationCancellationSource.Token);
}
}
}

View File

@ -0,0 +1,55 @@
// 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.Allocation;
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Rulesets.Osu.Configuration;
using osu.Game.Screens.Play.PlayerSettings;
namespace osu.Game.Rulesets.Osu.UI
{
public partial class ReplayAnalysisSettings : PlayerSettingsGroup
{
private readonly OsuRulesetConfigManager config;
[SettingSource("Show click markers", SettingControlType = typeof(PlayerCheckbox))]
public BindableBool ShowClickMarkers { get; } = new BindableBool();
[SettingSource("Show frame markers", SettingControlType = typeof(PlayerCheckbox))]
public BindableBool ShowAimMarkers { get; } = new BindableBool();
[SettingSource("Show cursor path", SettingControlType = typeof(PlayerCheckbox))]
public BindableBool ShowCursorPath { get; } = new BindableBool();
[SettingSource("Hide gameplay cursor", SettingControlType = typeof(PlayerCheckbox))]
public BindableBool HideSkinCursor { get; } = new BindableBool();
[SettingSource("Display length", SettingControlType = typeof(PlayerSliderBar<int>))]
public BindableInt DisplayLength { get; } = new BindableInt
{
MinValue = 200,
MaxValue = 2000,
Default = 800,
Precision = 200,
};
public ReplayAnalysisSettings(OsuRulesetConfigManager config)
: base("Analysis Settings")
{
this.config = config;
}
[BackgroundDependencyLoader]
private void load()
{
AddRange(this.CreateSettingsControls());
config.BindWith(OsuRulesetSetting.ReplayClickMarkersEnabled, ShowClickMarkers);
config.BindWith(OsuRulesetSetting.ReplayFrameMarkersEnabled, ShowAimMarkers);
config.BindWith(OsuRulesetSetting.ReplayCursorPathEnabled, ShowCursorPath);
config.BindWith(OsuRulesetSetting.ReplayCursorHideEnabled, HideSkinCursor);
config.BindWith(OsuRulesetSetting.ReplayAnalysisDisplayLength, DisplayLength);
}
}
}

View File

@ -43,6 +43,7 @@ namespace osu.Game.Tests.Visual.Gameplay
breakOverlay = new BreakOverlay(true, new ScoreProcessor(new OsuRuleset())) breakOverlay = new BreakOverlay(true, new ScoreProcessor(new OsuRuleset()))
{ {
ProcessCustomClock = false, ProcessCustomClock = false,
BreakTracker = breakTracker,
} }
}; };
} }
@ -57,9 +58,6 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test] [Test]
public void TestShowBreaks() public void TestShowBreaks()
{ {
setClock(false);
addShowBreakStep(2);
addShowBreakStep(5); addShowBreakStep(5);
addShowBreakStep(15); addShowBreakStep(15);
} }
@ -124,7 +122,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
AddStep($"show '{seconds}s' break", () => AddStep($"show '{seconds}s' break", () =>
{ {
breakOverlay.Breaks = breakTracker.Breaks = new List<BreakPeriod> breakTracker.Breaks = new List<BreakPeriod>
{ {
new BreakPeriod(Clock.CurrentTime, Clock.CurrentTime + seconds * 1000) new BreakPeriod(Clock.CurrentTime, Clock.CurrentTime + seconds * 1000)
}; };
@ -138,7 +136,7 @@ namespace osu.Game.Tests.Visual.Gameplay
private void loadBreaksStep(string breakDescription, IReadOnlyList<BreakPeriod> breaks) private void loadBreaksStep(string breakDescription, IReadOnlyList<BreakPeriod> breaks)
{ {
AddStep($"load {breakDescription}", () => breakOverlay.Breaks = breakTracker.Breaks = breaks); AddStep($"load {breakDescription}", () => breakTracker.Breaks = breaks);
seekAndAssertBreak("seek back to 0", 0, false); seekAndAssertBreak("seek back to 0", 0, false);
} }
@ -184,6 +182,7 @@ namespace osu.Game.Tests.Visual.Gameplay
} }
public TestBreakTracker() public TestBreakTracker()
: base(0, new ScoreProcessor(new OsuRuleset()))
{ {
FramedManualClock = new FramedClock(manualClock = new ManualClock()); FramedManualClock = new FramedClock(manualClock = new ManualClock());
ProcessCustomClock = false; ProcessCustomClock = false;

View File

@ -0,0 +1,61 @@
// 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.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK;
namespace osu.Game.Tests.Visual.UserInterface
{
public partial class TestSceneFormControls : ThemeComparisonTestScene
{
public TestSceneFormControls()
: base(false)
{
}
protected override Drawable CreateContent() => new OsuContextMenuContainer
{
RelativeSizeAxes = Axes.Both,
Child = new PopoverContainer
{
RelativeSizeAxes = Axes.Both,
Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(5),
Padding = new MarginPadding(10),
Children = new Drawable[]
{
new FormTextBox
{
Caption = "Artist",
HintText = "Poot artist here!",
PlaceholderText = "Here is an artist",
TabbableContentContainer = this,
},
new FormTextBox
{
Caption = "Artist",
HintText = "Poot artist here!",
PlaceholderText = "Here is an artist",
Current = { Disabled = true },
TabbableContentContainer = this,
},
new FormNumberBox
{
Caption = "Number",
HintText = "Insert your favourite number",
PlaceholderText = "Mine is 42!",
TabbableContentContainer = this,
},
},
},
},
};
}
}

View File

@ -75,7 +75,7 @@ namespace osu.Game.Tests.Visual.UserInterface
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background4 Colour = colourProvider.Background3
}, },
CreateContent() CreateContent()
} }

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 osu.Framework.Allocation;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics.Sprites;
using osuTK;
namespace osu.Game.Graphics.UserInterfaceV2
{
public partial class FormFieldCaption : CompositeDrawable, IHasTooltip
{
private LocalisableString caption;
public LocalisableString Caption
{
get => caption;
set
{
caption = value;
if (captionText.IsNotNull())
captionText.Text = value;
}
}
private OsuSpriteText captionText = null!;
public LocalisableString TooltipText { get; set; }
[BackgroundDependencyLoader]
private void load()
{
AutoSizeAxes = Axes.Both;
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5),
Children = new Drawable[]
{
captionText = new OsuSpriteText
{
Text = caption,
Font = OsuFont.Default.With(size: 12, weight: FontWeight.SemiBold),
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
new SpriteIcon
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Alpha = TooltipText == default ? 0 : 1,
Size = new Vector2(10),
Icon = FontAwesome.Solid.QuestionCircle,
Margin = new MarginPadding { Top = 1, },
}
},
};
}
}
}

View File

@ -0,0 +1,23 @@
// 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.
namespace osu.Game.Graphics.UserInterfaceV2
{
public partial class FormNumberBox : FormTextBox
{
public bool AllowDecimals { get; init; }
internal override InnerTextBox CreateTextBox() => new InnerNumberBox
{
AllowDecimals = AllowDecimals,
};
internal partial class InnerNumberBox : InnerTextBox
{
public bool AllowDecimals { get; init; }
protected override bool CanAddCharacter(char character)
=> char.IsAsciiDigit(character) || (AllowDecimals && character == '.');
}
}
}

View File

@ -0,0 +1,239 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
namespace osu.Game.Graphics.UserInterfaceV2
{
public partial class FormTextBox : CompositeDrawable, IHasCurrentValue<string>
{
public Bindable<string> Current
{
get => current.Current;
set => current.Current = value;
}
private bool readOnly;
public bool ReadOnly
{
get => readOnly;
set
{
readOnly = value;
if (textBox.IsNotNull())
updateState();
}
}
private CompositeDrawable? tabbableContentContainer;
public CompositeDrawable? TabbableContentContainer
{
set
{
tabbableContentContainer = value;
if (textBox.IsNotNull())
textBox.TabbableContentContainer = tabbableContentContainer;
}
}
public event TextBox.OnCommitHandler? OnCommit;
private readonly BindableWithCurrent<string> current = new BindableWithCurrent<string>();
public LocalisableString Caption { get; init; }
public LocalisableString HintText { get; init; }
public LocalisableString PlaceholderText { get; init; }
private Box background = null!;
private Box flashLayer = null!;
private InnerTextBox textBox = null!;
private FormFieldCaption caption = null!;
private IFocusManager focusManager = null!;
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
RelativeSizeAxes = Axes.X;
Height = 50;
Masking = true;
CornerRadius = 5;
CornerExponent = 2.5f;
InternalChildren = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background5,
},
flashLayer = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Colour4.Transparent,
},
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(9),
Children = new Drawable[]
{
caption = new FormFieldCaption
{
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
Caption = Caption,
TooltipText = HintText,
},
textBox = CreateTextBox().With(t =>
{
t.Anchor = Anchor.BottomRight;
t.Origin = Anchor.BottomRight;
t.RelativeSizeAxes = Axes.X;
t.Width = 1;
t.PlaceholderText = PlaceholderText;
t.Current = Current;
t.CommitOnFocusLost = true;
t.OnCommit += (textBox, newText) =>
{
OnCommit?.Invoke(textBox, newText);
if (!current.Disabled && !ReadOnly)
{
flashLayer.Colour = ColourInfo.GradientVertical(colourProvider.Dark1.Opacity(0), colourProvider.Dark2);
flashLayer.FadeOutFromOne(800, Easing.OutQuint);
}
};
t.OnInputError = () =>
{
flashLayer.Colour = ColourInfo.GradientVertical(colours.Red3.Opacity(0), colours.Red3);
flashLayer.FadeOutFromOne(200, Easing.OutQuint);
};
t.TabbableContentContainer = tabbableContentContainer;
}),
},
},
};
}
internal virtual InnerTextBox CreateTextBox() => new InnerTextBox();
protected override void LoadComplete()
{
base.LoadComplete();
focusManager = GetContainingFocusManager()!;
textBox.Focused.BindValueChanged(_ => updateState());
current.BindDisabledChanged(_ => updateState(), true);
}
protected override bool OnHover(HoverEvent e)
{
updateState();
return true;
}
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
updateState();
}
protected override bool OnClick(ClickEvent e)
{
focusManager.ChangeFocus(textBox);
return true;
}
private void updateState()
{
bool disabled = Current.Disabled || ReadOnly;
textBox.ReadOnly = disabled;
textBox.Alpha = 1;
caption.Colour = disabled ? colourProvider.Foreground1 : colourProvider.Content2;
textBox.Colour = disabled ? colourProvider.Foreground1 : colourProvider.Content1;
if (!disabled)
{
BorderThickness = IsHovered || textBox.Focused.Value ? 2 : 0;
BorderColour = textBox.Focused.Value ? colourProvider.Highlight1 : colourProvider.Light4;
if (textBox.Focused.Value)
background.Colour = ColourInfo.GradientVertical(colourProvider.Background5, colourProvider.Dark3);
else if (IsHovered)
background.Colour = ColourInfo.GradientVertical(colourProvider.Background5, colourProvider.Dark4);
else
background.Colour = colourProvider.Background5;
}
else
{
background.Colour = colourProvider.Background4;
}
}
internal partial class InnerTextBox : OsuTextBox
{
public BindableBool Focused { get; } = new BindableBool();
public Action? OnInputError { get; set; }
protected override float LeftRightPadding => 0;
[BackgroundDependencyLoader]
private void load()
{
Height = 16;
TextContainer.Height = 1;
Masking = false;
BackgroundUnfocused = BackgroundFocused = BackgroundCommit = Colour4.Transparent;
}
protected override SpriteText CreatePlaceholder() => base.CreatePlaceholder().With(t => t.Margin = default);
protected override void OnFocus(FocusEvent e)
{
base.OnFocus(e);
Focused.Value = true;
}
protected override void OnFocusLost(FocusLostEvent e)
{
base.OnFocusLost(e);
Focused.Value = false;
}
protected override void NotifyInputError()
{
PlayFeedbackSample(FeedbackSampleType.TextInvalid);
// base call intentionally suppressed
OnInputError?.Invoke();
}
}
}
}

View File

@ -46,6 +46,9 @@ namespace osu.Game.Online.API
Response = ((OsuJsonWebRequest<T>)WebRequest).ResponseObject; Response = ((OsuJsonWebRequest<T>)WebRequest).ResponseObject;
Logger.Log($"{GetType().ReadableName()} finished with response size of {WebRequest.ResponseStream.Length:#,0} bytes", LoggingTarget.Network); Logger.Log($"{GetType().ReadableName()} finished with response size of {WebRequest.ResponseStream.Length:#,0} bytes", LoggingTarget.Network);
} }
if (Response == null)
TriggerFailure(new ArgumentNullException(nameof(Response)));
} }
internal void TriggerSuccess(T result) internal void TriggerSuccess(T result)
@ -152,6 +155,8 @@ namespace osu.Game.Online.API
PostProcess(); PostProcess();
if (isFailing) return;
TriggerSuccess(); TriggerSuccess();
} }

View File

@ -2,7 +2,7 @@
// 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; using System;
using System.Collections.Generic; using osu.Framework.Audio.Track;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -10,15 +10,18 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Play.Break; using osu.Game.Screens.Play.Break;
using osu.Game.Utils;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
public partial class BreakOverlay : Container public partial class BreakOverlay : BeatSyncedContainer
{ {
/// <summary> /// <summary>
/// The duration of the break overlay fading. /// The duration of the break overlay fading.
@ -26,26 +29,14 @@ namespace osu.Game.Screens.Play
public const double BREAK_FADE_DURATION = BreakPeriod.MIN_BREAK_DURATION / 2; public const double BREAK_FADE_DURATION = BreakPeriod.MIN_BREAK_DURATION / 2;
private const float remaining_time_container_max_size = 0.3f; private const float remaining_time_container_max_size = 0.3f;
private const int vertical_margin = 25; private const int vertical_margin = 15;
private readonly Container fadeContainer; private readonly Container fadeContainer;
private IReadOnlyList<BreakPeriod> breaks = Array.Empty<BreakPeriod>();
public IReadOnlyList<BreakPeriod> Breaks
{
get => breaks;
set
{
breaks = value;
if (IsLoaded)
initializeBreaks();
}
}
public override bool RemoveCompletedTransforms => false; public override bool RemoveCompletedTransforms => false;
public BreakTracker BreakTracker { get; init; } = null!;
private readonly Container remainingTimeAdjustmentBox; private readonly Container remainingTimeAdjustmentBox;
private readonly Container remainingTimeBox; private readonly Container remainingTimeBox;
private readonly RemainingTimeCounter remainingTimeCounter; private readonly RemainingTimeCounter remainingTimeCounter;
@ -53,11 +44,19 @@ namespace osu.Game.Screens.Play
private readonly ScoreProcessor scoreProcessor; private readonly ScoreProcessor scoreProcessor;
private readonly BreakInfo info; private readonly BreakInfo info;
private readonly IBindable<Period?> currentPeriod = new Bindable<Period?>();
public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor) public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor)
{ {
this.scoreProcessor = scoreProcessor; this.scoreProcessor = scoreProcessor;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
MinimumBeatLength = 200;
// Doesn't play well with pause/unpause.
// This might mean that some beats don't animate if the user is running <60fps, but we'll deal with that if anyone notices.
AllowMistimedEventFiring = false;
Child = fadeContainer = new Container Child = fadeContainer = new Container
{ {
Alpha = 0, Alpha = 0,
@ -114,13 +113,13 @@ namespace osu.Game.Screens.Play
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
Margin = new MarginPadding { Bottom = vertical_margin }, Y = -vertical_margin,
}, },
info = new BreakInfo info = new BreakInfo
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = vertical_margin }, Y = vertical_margin,
}, },
breakArrows = new BreakArrows breakArrows = new BreakArrows
{ {
@ -134,51 +133,76 @@ namespace osu.Game.Screens.Play
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
initializeBreaks();
info.AccuracyDisplay.Current.BindTo(scoreProcessor.Accuracy); info.AccuracyDisplay.Current.BindTo(scoreProcessor.Accuracy);
((IBindable<ScoreRank>)info.GradeDisplay.Current).BindTo(scoreProcessor.Rank); ((IBindable<ScoreRank>)info.GradeDisplay.Current).BindTo(scoreProcessor.Rank);
currentPeriod.BindTo(BreakTracker.CurrentPeriod);
currentPeriod.BindValueChanged(updateDisplay, true);
} }
private float remainingTimeForCurrentPeriod =>
currentPeriod.Value == null ? 0 : (float)Math.Max(0, (currentPeriod.Value.Value.End - Time.Current - BREAK_FADE_DURATION) / currentPeriod.Value.Value.Duration);
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
remainingTimeBox.Height = Math.Min(8, remainingTimeBox.DrawWidth); remainingTimeBox.Height = Math.Min(8, remainingTimeBox.DrawWidth);
// Keep things simple by resetting beat synced transforms on a rewind.
if (Clock.ElapsedFrameTime < 0)
{
remainingTimeBox.ClearTransforms(targetMember: nameof(Width));
remainingTimeBox.Width = remainingTimeForCurrentPeriod;
}
} }
private void initializeBreaks() protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
{
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
if (currentPeriod.Value == null)
return;
float timeBoxTargetWidth = (float)Math.Max(0, (remainingTimeForCurrentPeriod - timingPoint.BeatLength / currentPeriod.Value.Value.Duration));
remainingTimeBox.ResizeWidthTo(timeBoxTargetWidth, timingPoint.BeatLength * 2, Easing.OutQuint);
}
private void updateDisplay(ValueChangedEvent<Period?> period)
{ {
FinishTransforms(true); FinishTransforms(true);
Scheduler.CancelDelayedTasks(); Scheduler.CancelDelayedTasks();
foreach (var b in breaks) if (period.NewValue == null)
return;
var b = period.NewValue.Value;
using (BeginAbsoluteSequence(b.Start))
{ {
if (!b.HasEffect) fadeContainer.FadeIn(BREAK_FADE_DURATION);
continue; breakArrows.Show(BREAK_FADE_DURATION);
using (BeginAbsoluteSequence(b.StartTime)) remainingTimeAdjustmentBox
.ResizeWidthTo(remaining_time_container_max_size, BREAK_FADE_DURATION, Easing.OutQuint)
.Delay(b.Duration - BREAK_FADE_DURATION)
.ResizeWidthTo(0);
remainingTimeBox.ResizeWidthTo(remainingTimeForCurrentPeriod);
remainingTimeCounter.CountTo(b.Duration).CountTo(0, b.Duration);
remainingTimeCounter.MoveToX(-50)
.MoveToX(0, BREAK_FADE_DURATION, Easing.OutQuint);
info.MoveToX(50)
.MoveToX(0, BREAK_FADE_DURATION, Easing.OutQuint);
using (BeginDelayedSequence(b.Duration - BREAK_FADE_DURATION))
{ {
fadeContainer.FadeIn(BREAK_FADE_DURATION); fadeContainer.FadeOut(BREAK_FADE_DURATION);
breakArrows.Show(BREAK_FADE_DURATION); breakArrows.Hide(BREAK_FADE_DURATION);
remainingTimeAdjustmentBox
.ResizeWidthTo(remaining_time_container_max_size, BREAK_FADE_DURATION, Easing.OutQuint)
.Delay(b.Duration - BREAK_FADE_DURATION)
.ResizeWidthTo(0);
remainingTimeBox
.ResizeWidthTo(0, b.Duration - BREAK_FADE_DURATION)
.Then()
.ResizeWidthTo(1);
remainingTimeCounter.CountTo(b.Duration).CountTo(0, b.Duration);
using (BeginDelayedSequence(b.Duration - BREAK_FADE_DURATION))
{
fadeContainer.FadeOut(BREAK_FADE_DURATION);
breakArrows.Hide(BREAK_FADE_DURATION);
}
} }
} }
} }

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -18,7 +16,7 @@ namespace osu.Game.Screens.Play
private readonly ScoreProcessor scoreProcessor; private readonly ScoreProcessor scoreProcessor;
private readonly double gameplayStartTime; private readonly double gameplayStartTime;
private PeriodTracker breaks; private PeriodTracker breaks = new PeriodTracker(Enumerable.Empty<Period>());
/// <summary> /// <summary>
/// Whether the gameplay is currently in a break. /// Whether the gameplay is currently in a break.
@ -27,6 +25,8 @@ namespace osu.Game.Screens.Play
private readonly BindableBool isBreakTime = new BindableBool(true); private readonly BindableBool isBreakTime = new BindableBool(true);
public readonly Bindable<Period?> CurrentPeriod = new Bindable<Period?>();
public IReadOnlyList<BreakPeriod> Breaks public IReadOnlyList<BreakPeriod> Breaks
{ {
set set
@ -39,7 +39,7 @@ namespace osu.Game.Screens.Play
} }
} }
public BreakTracker(double gameplayStartTime = 0, ScoreProcessor scoreProcessor = null) public BreakTracker(double gameplayStartTime, ScoreProcessor scoreProcessor)
{ {
this.gameplayStartTime = gameplayStartTime; this.gameplayStartTime = gameplayStartTime;
this.scoreProcessor = scoreProcessor; this.scoreProcessor = scoreProcessor;
@ -55,9 +55,16 @@ namespace osu.Game.Screens.Play
{ {
double time = Clock.CurrentTime; double time = Clock.CurrentTime;
isBreakTime.Value = breaks?.IsInAny(time) == true if (breaks.IsInAny(time, out var currentBreak))
|| time < gameplayStartTime {
|| scoreProcessor?.HasCompleted.Value == true; CurrentPeriod.Value = currentBreak;
isBreakTime.Value = true;
}
else
{
CurrentPeriod.Value = null;
isBreakTime.Value = time < gameplayStartTime || scoreProcessor.HasCompleted.Value;
}
} }
} }
} }

View File

@ -468,7 +468,7 @@ namespace osu.Game.Screens.Play
{ {
Clock = DrawableRuleset.FrameStableClock, Clock = DrawableRuleset.FrameStableClock,
ProcessCustomClock = false, ProcessCustomClock = false,
Breaks = working.Beatmap.Breaks BreakTracker = breakTracker,
}, },
// display the cursor above some HUD elements. // display the cursor above some HUD elements.
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(), DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),

View File

@ -573,6 +573,9 @@ namespace osu.Game.Screens.Play
// if the player never got pushed, we should explicitly dispose it. // if the player never got pushed, we should explicitly dispose it.
DisposalTask = LoadTask?.ContinueWith(_ => CurrentPlayer?.Dispose()); DisposalTask = LoadTask?.ContinueWith(_ => CurrentPlayer?.Dispose());
} }
highPerformanceSession?.Dispose();
highPerformanceSession = null;
} }
#endregion #endregion

View File

@ -55,6 +55,16 @@ namespace osu.Game.Screens.Play
this.createScore = createScore; this.createScore = createScore;
} }
/// <summary>
/// Add a settings group to the HUD overlay. Intended to be used by rulesets to add replay-specific settings.
/// </summary>
/// <param name="settings">The settings group to be shown.</param>
public void AddSettings(PlayerSettingsGroup settings) => Schedule(() =>
{
settings.Expanded.Value = false;
HUDOverlay.PlayerSettingsOverlay.Add(settings);
});
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config) private void load(OsuConfigManager config)
{ {

View File

@ -3,6 +3,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
namespace osu.Game.Utils namespace osu.Game.Utils
@ -24,8 +25,17 @@ namespace osu.Game.Utils
/// Whether the provided time is in any of the added periods. /// Whether the provided time is in any of the added periods.
/// </summary> /// </summary>
/// <param name="time">The time value to check.</param> /// <param name="time">The time value to check.</param>
public bool IsInAny(double time) public bool IsInAny(double time) => IsInAny(time, out _);
/// <summary>
/// Whether the provided time is in any of the added periods.
/// </summary>
/// <param name="time">The time value to check.</param>
/// <param name="period">The period which matched.</param>
public bool IsInAny(double time, [NotNullWhen(true)] out Period? period)
{ {
period = null;
if (periods.Count == 0) if (periods.Count == 0)
return false; return false;
@ -41,7 +51,15 @@ namespace osu.Game.Utils
} }
var nearest = periods[nearestIndex]; var nearest = periods[nearestIndex];
return time >= nearest.Start && time <= nearest.End; bool isInAny = time >= nearest.Start && time <= nearest.End;
if (isInAny)
{
period = nearest;
return true;
}
return false;
} }
} }
@ -57,6 +75,8 @@ namespace osu.Game.Utils
/// </summary> /// </summary>
public readonly double End; public readonly double End;
public double Duration => End - Start;
public Period(double start, double end) public Period(double start, double end)
{ {
if (start >= end) if (start >= end)

View File

@ -35,8 +35,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Realm" Version="11.5.0" /> <PackageReference Include="Realm" Version="11.5.0" />
<PackageReference Include="ppy.osu.Framework" Version="2024.831.0" /> <PackageReference Include="ppy.osu.Framework" Version="2024.904.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.810.0" /> <PackageReference Include="ppy.osu.Game.Resources" Version="2024.904.0" />
<PackageReference Include="Sentry" Version="4.3.0" /> <PackageReference Include="Sentry" Version="4.3.0" />
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. --> <!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
<PackageReference Include="SharpCompress" Version="0.36.0" /> <PackageReference Include="SharpCompress" Version="0.36.0" />

View File

@ -17,6 +17,6 @@
<MtouchInterpreter>-all</MtouchInterpreter> <MtouchInterpreter>-all</MtouchInterpreter>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="ppy.osu.Framework.iOS" Version="2024.831.0" /> <PackageReference Include="ppy.osu.Framework.iOS" Version="2024.904.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>