mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:18:22 +08:00
Merge branch 'master' into editor/setup-screen-textbox
This commit is contained in:
commit
49b14ad579
@ -10,7 +10,7 @@
|
||||
<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.831.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2024.904.0" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<!-- Fody does not handle Android build well, and warns when unchanged.
|
||||
|
@ -54,6 +54,8 @@ namespace osu.Desktop.Updater
|
||||
if (localUserInfo?.IsPlaying.Value == true)
|
||||
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 there is an update pending restart, show the notification to restart again.
|
||||
|
133
osu.Game.Rulesets.Osu.Tests/TestSceneOsuAnalysisContainer.cs
Normal file
133
osu.Game.Rulesets.Osu.Tests/TestSceneOsuAnalysisContainer.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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 osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Configuration;
|
||||
using osu.Game.Rulesets.UI;
|
||||
@ -11,7 +9,7 @@ namespace osu.Game.Rulesets.Osu.Configuration
|
||||
{
|
||||
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)
|
||||
{
|
||||
}
|
||||
@ -24,6 +22,12 @@ namespace osu.Game.Rulesets.Osu.Configuration
|
||||
SetDefault(OsuRulesetSetting.ShowCursorTrail, true);
|
||||
SetDefault(OsuRulesetSetting.ShowCursorRipples, false);
|
||||
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,
|
||||
ShowCursorRipples,
|
||||
PlayfieldBorderStyle,
|
||||
|
||||
// Replay
|
||||
ReplayClickMarkersEnabled,
|
||||
ReplayFrameMarkersEnabled,
|
||||
ReplayCursorPathEnabled,
|
||||
ReplayCursorHideEnabled,
|
||||
ReplayAnalysisDisplayLength,
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Input.Handlers;
|
||||
@ -25,18 +26,36 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
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 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)
|
||||
{
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
27
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/AnalysisMarker.cs
Normal file
27
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/AnalysisMarker.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
88
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/ClickMarker.cs
Normal file
88
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/ClickMarker.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
69
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/FrameMarker.cs
Normal file
69
osu.Game.Rulesets.Osu/UI/ReplayAnalysis/FrameMarker.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
128
osu.Game.Rulesets.Osu/UI/ReplayAnalysisOverlay.cs
Normal file
128
osu.Game.Rulesets.Osu/UI/ReplayAnalysisOverlay.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
55
osu.Game.Rulesets.Osu/UI/ReplayAnalysisSettings.cs
Normal file
55
osu.Game.Rulesets.Osu/UI/ReplayAnalysisSettings.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -43,6 +43,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
breakOverlay = new BreakOverlay(true, new ScoreProcessor(new OsuRuleset()))
|
||||
{
|
||||
ProcessCustomClock = false,
|
||||
BreakTracker = breakTracker,
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -57,9 +58,6 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestShowBreaks()
|
||||
{
|
||||
setClock(false);
|
||||
|
||||
addShowBreakStep(2);
|
||||
addShowBreakStep(5);
|
||||
addShowBreakStep(15);
|
||||
}
|
||||
@ -124,7 +122,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
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)
|
||||
};
|
||||
@ -138,7 +136,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -184,6 +182,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
}
|
||||
|
||||
public TestBreakTracker()
|
||||
: base(0, new ScoreProcessor(new OsuRuleset()))
|
||||
{
|
||||
FramedManualClock = new FramedClock(manualClock = new ManualClock());
|
||||
ProcessCustomClock = false;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -10,15 +10,18 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play.Break;
|
||||
using osu.Game.Utils;
|
||||
|
||||
namespace osu.Game.Screens.Play
|
||||
{
|
||||
public partial class BreakOverlay : Container
|
||||
public partial class BreakOverlay : BeatSyncedContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// 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;
|
||||
|
||||
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 IReadOnlyList<BreakPeriod> breaks = Array.Empty<BreakPeriod>();
|
||||
|
||||
public IReadOnlyList<BreakPeriod> Breaks
|
||||
{
|
||||
get => breaks;
|
||||
set
|
||||
{
|
||||
breaks = value;
|
||||
|
||||
if (IsLoaded)
|
||||
initializeBreaks();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool RemoveCompletedTransforms => false;
|
||||
|
||||
public BreakTracker BreakTracker { get; init; } = null!;
|
||||
|
||||
private readonly Container remainingTimeAdjustmentBox;
|
||||
private readonly Container remainingTimeBox;
|
||||
private readonly RemainingTimeCounter remainingTimeCounter;
|
||||
@ -53,11 +44,19 @@ namespace osu.Game.Screens.Play
|
||||
private readonly ScoreProcessor scoreProcessor;
|
||||
private readonly BreakInfo info;
|
||||
|
||||
private readonly IBindable<Period?> currentPeriod = new Bindable<Period?>();
|
||||
|
||||
public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor)
|
||||
{
|
||||
this.scoreProcessor = scoreProcessor;
|
||||
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
|
||||
{
|
||||
Alpha = 0,
|
||||
@ -114,13 +113,13 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Margin = new MarginPadding { Bottom = vertical_margin },
|
||||
Y = -vertical_margin,
|
||||
},
|
||||
info = new BreakInfo
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.TopCentre,
|
||||
Margin = new MarginPadding { Top = vertical_margin },
|
||||
Y = vertical_margin,
|
||||
},
|
||||
breakArrows = new BreakArrows
|
||||
{
|
||||
@ -134,30 +133,53 @@ namespace osu.Game.Screens.Play
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
initializeBreaks();
|
||||
|
||||
info.AccuracyDisplay.Current.BindTo(scoreProcessor.Accuracy);
|
||||
((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()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
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);
|
||||
Scheduler.CancelDelayedTasks();
|
||||
|
||||
foreach (var b in breaks)
|
||||
{
|
||||
if (!b.HasEffect)
|
||||
continue;
|
||||
if (period.NewValue == null)
|
||||
return;
|
||||
|
||||
using (BeginAbsoluteSequence(b.StartTime))
|
||||
var b = period.NewValue.Value;
|
||||
|
||||
using (BeginAbsoluteSequence(b.Start))
|
||||
{
|
||||
fadeContainer.FadeIn(BREAK_FADE_DURATION);
|
||||
breakArrows.Show(BREAK_FADE_DURATION);
|
||||
@ -167,13 +189,16 @@ namespace osu.Game.Screens.Play
|
||||
.Delay(b.Duration - BREAK_FADE_DURATION)
|
||||
.ResizeWidthTo(0);
|
||||
|
||||
remainingTimeBox
|
||||
.ResizeWidthTo(0, b.Duration - BREAK_FADE_DURATION)
|
||||
.Then()
|
||||
.ResizeWidthTo(1);
|
||||
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.FadeOut(BREAK_FADE_DURATION);
|
||||
@ -182,5 +207,4 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
@ -18,7 +16,7 @@ namespace osu.Game.Screens.Play
|
||||
private readonly ScoreProcessor scoreProcessor;
|
||||
private readonly double gameplayStartTime;
|
||||
|
||||
private PeriodTracker breaks;
|
||||
private PeriodTracker breaks = new PeriodTracker(Enumerable.Empty<Period>());
|
||||
|
||||
/// <summary>
|
||||
/// Whether the gameplay is currently in a break.
|
||||
@ -27,6 +25,8 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private readonly BindableBool isBreakTime = new BindableBool(true);
|
||||
|
||||
public readonly Bindable<Period?> CurrentPeriod = new Bindable<Period?>();
|
||||
|
||||
public IReadOnlyList<BreakPeriod> Breaks
|
||||
{
|
||||
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.scoreProcessor = scoreProcessor;
|
||||
@ -55,9 +55,16 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
double time = Clock.CurrentTime;
|
||||
|
||||
isBreakTime.Value = breaks?.IsInAny(time) == true
|
||||
|| time < gameplayStartTime
|
||||
|| scoreProcessor?.HasCompleted.Value == true;
|
||||
if (breaks.IsInAny(time, out var currentBreak))
|
||||
{
|
||||
CurrentPeriod.Value = currentBreak;
|
||||
isBreakTime.Value = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentPeriod.Value = null;
|
||||
isBreakTime.Value = time < gameplayStartTime || scoreProcessor.HasCompleted.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
Clock = DrawableRuleset.FrameStableClock,
|
||||
ProcessCustomClock = false,
|
||||
Breaks = working.Beatmap.Breaks
|
||||
BreakTracker = breakTracker,
|
||||
},
|
||||
// display the cursor above some HUD elements.
|
||||
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
|
||||
|
@ -55,6 +55,16 @@ namespace osu.Game.Screens.Play
|
||||
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]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Utils
|
||||
@ -24,8 +25,17 @@ namespace osu.Game.Utils
|
||||
/// Whether the provided time is in any of the added periods.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
return false;
|
||||
|
||||
@ -41,7 +51,15 @@ namespace osu.Game.Utils
|
||||
}
|
||||
|
||||
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>
|
||||
public readonly double End;
|
||||
|
||||
public double Duration => End - Start;
|
||||
|
||||
public Period(double start, double end)
|
||||
{
|
||||
if (start >= end)
|
||||
|
@ -35,8 +35,8 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Realm" Version="11.5.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2024.831.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.810.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2024.904.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.904.0" />
|
||||
<PackageReference Include="Sentry" Version="4.3.0" />
|
||||
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
||||
<PackageReference Include="SharpCompress" Version="0.36.0" />
|
||||
|
@ -17,6 +17,6 @@
|
||||
<MtouchInterpreter>-all</MtouchInterpreter>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2024.831.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2024.904.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user