From bb2b7d3c313ab8c2e78ca9a790de290f874c0b6d Mon Sep 17 00:00:00 2001 From: Nitrous Date: Tue, 9 Jan 2024 12:23:01 +0800 Subject: [PATCH 01/17] Add playback controls. --- .../Play/PlayerSettings/PlaybackSettings.cs | 117 ++++++++++++++++-- 1 file changed, 105 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 4753effdb0..69bfe666ee 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -1,11 +1,17 @@ // Copyright (c) ppy Pty Ltd . 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.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Sprites; +using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; +using osuTK; namespace osu.Game.Screens.Play.PlayerSettings { @@ -24,34 +30,115 @@ namespace osu.Game.Screens.Play.PlayerSettings private readonly OsuSpriteText multiplierText; + private readonly IconButton play; + + [Resolved] + private GameplayClockContainer gameplayClock { get; set; } = null!; + + [Resolved] + private GameplayState gameplayState { get; set; } = null!; + public PlaybackSettings() : base("playback") { + const double seek_amount = 5000; + const double seek_fast_amount = 10000; + Children = new Drawable[] { - new Container + new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Padding = new MarginPadding { Horizontal = padding }, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0, padding), Children = new Drawable[] { - new OsuSpriteText + new FillFlowContainer { - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Text = "Playback speed", + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5, 0), + Children = new Drawable[] + { + new IconButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.Solid.FastBackward, + Action = () => seek(-1, seek_fast_amount), + }, + new IconButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.Solid.Backward, + Action = () => seek(-1, seek_amount), + }, + play = new IconButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(1.4f), + IconScale = new Vector2(1.4f), + Icon = FontAwesome.Regular.PlayCircle, + Action = () => + { + if (gameplayClock != null) + { + if (gameplayClock.IsRunning) + gameplayClock.Stop(); + else + gameplayClock.Start(); + } + } + }, + new IconButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.Solid.Forward, + Action = () => seek(1, seek_amount), + }, + new IconButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Icon = FontAwesome.Solid.FastForward, + Action = () => seek(1, seek_fast_amount), + }, + }, }, - multiplierText = new OsuSpriteText + new Container { - Anchor = Anchor.CentreRight, - Origin = Anchor.CentreRight, - Font = OsuFont.GetFont(weight: FontWeight.Bold), - } + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Children = new Drawable[] + { + rateSlider = new PlayerSliderBar + { + LabelText = "Playback speed", + Current = UserPlaybackRate, + }, + multiplierText = new OsuSpriteText + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + Font = OsuFont.GetFont(weight: FontWeight.Bold), + Margin = new MarginPadding { Right = 20 }, + } + }, + }, }, }, - rateSlider = new PlayerSliderBar { Current = UserPlaybackRate } }; + + void seek(int direction, double amount) + { + double target = Math.Clamp((gameplayClock?.CurrentTime ?? 0) + (direction * amount), 0, gameplayState.Beatmap.GetLastObjectTime()); + gameplayClock?.Seek(target); + } } protected override void LoadComplete() @@ -59,5 +146,11 @@ namespace osu.Game.Screens.Play.PlayerSettings base.LoadComplete(); rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true); } + + protected override void Update() + { + base.Update(); + play.Icon = gameplayClock.IsRunning ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle; + } } } From 2e041823a15b2720c90c0f2fbcdf8afcee8417df Mon Sep 17 00:00:00 2001 From: Nitrous Date: Tue, 9 Jan 2024 12:24:09 +0800 Subject: [PATCH 02/17] Perform null check on gameplay state. --- osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 69bfe666ee..3662b7ddc8 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -136,7 +136,7 @@ namespace osu.Game.Screens.Play.PlayerSettings void seek(int direction, double amount) { - double target = Math.Clamp((gameplayClock?.CurrentTime ?? 0) + (direction * amount), 0, gameplayState.Beatmap.GetLastObjectTime()); + double target = Math.Clamp((gameplayClock?.CurrentTime ?? 0) + (direction * amount), 0, gameplayState?.Beatmap.GetLastObjectTime() ?? 0); gameplayClock?.Seek(target); } } From afa808695bf9c6060f2f706c15172861e1c56269 Mon Sep 17 00:00:00 2001 From: Nitrous Date: Tue, 9 Jan 2024 12:48:11 +0800 Subject: [PATCH 03/17] Make resolved properties nullable. --- osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 3662b7ddc8..2a8701d4d5 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -33,10 +33,10 @@ namespace osu.Game.Screens.Play.PlayerSettings private readonly IconButton play; [Resolved] - private GameplayClockContainer gameplayClock { get; set; } = null!; + private GameplayClockContainer? gameplayClock { get; set; } [Resolved] - private GameplayState gameplayState { get; set; } = null!; + private GameplayState? gameplayState { get; set; } public PlaybackSettings() : base("playback") @@ -150,7 +150,7 @@ namespace osu.Game.Screens.Play.PlayerSettings protected override void Update() { base.Update(); - play.Icon = gameplayClock.IsRunning ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle; + play.Icon = gameplayClock?.IsRunning == true ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle; } } } From 99c76854956f1d6f3116a462fa6af4f0320500c6 Mon Sep 17 00:00:00 2001 From: Nitrous Date: Tue, 9 Jan 2024 15:18:21 +0800 Subject: [PATCH 04/17] use `GameplayClock.IsPaused` bindable instead of polling in `Update` --- .../Screens/Play/PlayerSettings/PlaybackSettings.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 2a8701d4d5..a0fafb821c 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -32,6 +32,8 @@ namespace osu.Game.Screens.Play.PlayerSettings private readonly IconButton play; + private readonly BindableBool isPaused = new BindableBool(); + [Resolved] private GameplayClockContainer? gameplayClock { get; set; } @@ -134,6 +136,8 @@ namespace osu.Game.Screens.Play.PlayerSettings }, }; + isPaused.BindValueChanged(e => play.Icon = e.NewValue ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle, true); + void seek(int direction, double amount) { double target = Math.Clamp((gameplayClock?.CurrentTime ?? 0) + (direction * amount), 0, gameplayState?.Beatmap.GetLastObjectTime() ?? 0); @@ -145,12 +149,7 @@ namespace osu.Game.Screens.Play.PlayerSettings { base.LoadComplete(); rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true); - } - - protected override void Update() - { - base.Update(); - play.Icon = gameplayClock?.IsRunning == true ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle; + gameplayClock?.IsPaused.BindTo(isPaused); } } } From bdecac6d797661836279482a031ee97d3aae955a Mon Sep 17 00:00:00 2001 From: Nitrous Date: Tue, 9 Jan 2024 15:19:54 +0800 Subject: [PATCH 05/17] Inverse check. --- osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index a0fafb821c..7974b07438 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -136,7 +136,7 @@ namespace osu.Game.Screens.Play.PlayerSettings }, }; - isPaused.BindValueChanged(e => play.Icon = e.NewValue ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle, true); + isPaused.BindValueChanged(e => play.Icon = !e.NewValue ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle, true); void seek(int direction, double amount) { From 63961ea276a282f681e1b57866ad36dbb3d472e1 Mon Sep 17 00:00:00 2001 From: Nitrous Date: Tue, 9 Jan 2024 16:08:29 +0800 Subject: [PATCH 06/17] use `RepeatingButtonBehavior` for seek buttons --- .../Play/PlayerSettings/PlaybackSettings.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 7974b07438..6e1ce39d9b 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -11,6 +11,7 @@ using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; +using osu.Game.Screens.Edit.Timing; using osuTK; namespace osu.Game.Screens.Play.PlayerSettings @@ -64,14 +65,14 @@ namespace osu.Game.Screens.Play.PlayerSettings Spacing = new Vector2(5, 0), Children = new Drawable[] { - new IconButton + new SeekButton { Anchor = Anchor.Centre, Origin = Anchor.Centre, Icon = FontAwesome.Solid.FastBackward, Action = () => seek(-1, seek_fast_amount), }, - new IconButton + new SeekButton { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -96,14 +97,14 @@ namespace osu.Game.Screens.Play.PlayerSettings } } }, - new IconButton + new SeekButton { Anchor = Anchor.Centre, Origin = Anchor.Centre, Icon = FontAwesome.Solid.Forward, Action = () => seek(1, seek_amount), }, - new IconButton + new SeekButton { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -151,5 +152,13 @@ namespace osu.Game.Screens.Play.PlayerSettings rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true); gameplayClock?.IsPaused.BindTo(isPaused); } + + private partial class SeekButton : IconButton + { + public SeekButton() + { + AddInternal(new RepeatingButtonBehaviour(this)); + } + } } } From c081ca21451baa684c343c8a019b90432a4c1336 Mon Sep 17 00:00:00 2001 From: Nitrous Date: Tue, 9 Jan 2024 16:30:48 +0800 Subject: [PATCH 07/17] Make field to a local. --- osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 6e1ce39d9b..e208be6095 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -31,8 +31,6 @@ namespace osu.Game.Screens.Play.PlayerSettings private readonly OsuSpriteText multiplierText; - private readonly IconButton play; - private readonly BindableBool isPaused = new BindableBool(); [Resolved] @@ -47,6 +45,8 @@ namespace osu.Game.Screens.Play.PlayerSettings const double seek_amount = 5000; const double seek_fast_amount = 10000; + IconButton play; + Children = new Drawable[] { new FillFlowContainer From 484e9e8ee636d9d1ec4aaf549e7615fb18682226 Mon Sep 17 00:00:00 2001 From: Nitrous Date: Tue, 9 Jan 2024 22:09:20 +0800 Subject: [PATCH 08/17] Fix binding order of `IsPaused` bindable and disable playback controls in spectator mode. --- .../Screens/Play/PlayerSettings/PlaybackSettings.cs | 13 +++++++++++-- osu.Game/Screens/Play/SpectatorPlayer.cs | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index e208be6095..e2859868bd 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -27,6 +27,8 @@ namespace osu.Game.Screens.Play.PlayerSettings Precision = 0.1, }; + public readonly Bindable AllowControls = new BindableBool(true); + private readonly PlayerSliderBar rateSlider; private readonly OsuSpriteText multiplierText; @@ -71,6 +73,7 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.FastBackward, Action = () => seek(-1, seek_fast_amount), + Enabled = { BindTarget = AllowControls }, }, new SeekButton { @@ -78,6 +81,7 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.Backward, Action = () => seek(-1, seek_amount), + Enabled = { BindTarget = AllowControls }, }, play = new IconButton { @@ -95,7 +99,8 @@ namespace osu.Game.Screens.Play.PlayerSettings else gameplayClock.Start(); } - } + }, + Enabled = { BindTarget = AllowControls }, }, new SeekButton { @@ -103,6 +108,7 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.Forward, Action = () => seek(1, seek_amount), + Enabled = { BindTarget = AllowControls }, }, new SeekButton { @@ -110,6 +116,7 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.FastForward, Action = () => seek(1, seek_fast_amount), + Enabled = { BindTarget = AllowControls }, }, }, }, @@ -150,7 +157,9 @@ namespace osu.Game.Screens.Play.PlayerSettings { base.LoadComplete(); rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true); - gameplayClock?.IsPaused.BindTo(isPaused); + + if (gameplayClock != null) + isPaused.BindTarget = gameplayClock.IsPaused; } private partial class SeekButton : IconButton diff --git a/osu.Game/Screens/Play/SpectatorPlayer.cs b/osu.Game/Screens/Play/SpectatorPlayer.cs index 2faead0ee1..dd7418d563 100644 --- a/osu.Game/Screens/Play/SpectatorPlayer.cs +++ b/osu.Game/Screens/Play/SpectatorPlayer.cs @@ -68,6 +68,8 @@ namespace osu.Game.Screens.Play master.UserPlaybackRate.Value = 1; } }, true); + + HUDOverlay.PlayerSettingsOverlay.PlaybackSettings.AllowControls.Value = false; } /// From c40462811363c7432ede91c4475d7d6e7cd6d28b Mon Sep 17 00:00:00 2001 From: Nitrous Date: Fri, 12 Jan 2024 15:12:02 +0800 Subject: [PATCH 09/17] move creation of `PlaybackSettings` to `ReplayPlayer` --- osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs | 9 +++++---- osu.Game/Screens/Play/Player.cs | 3 --- .../Screens/Play/PlayerSettings/PlaybackSettings.cs | 6 ------ osu.Game/Screens/Play/ReplayPlayer.cs | 12 ++++++++++++ osu.Game/Screens/Play/SpectatorPlayer.cs | 2 -- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs index dbb0456cd0..b7f3dc36c3 100644 --- a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs +++ b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs @@ -12,17 +12,19 @@ namespace osu.Game.Screens.Play.HUD { private const int fade_duration = 200; - public readonly PlaybackSettings PlaybackSettings; - public readonly VisualSettings VisualSettings; + protected override Container Content => content; + + private readonly FillFlowContainer content; + public PlayerSettingsOverlay() { Anchor = Anchor.TopRight; Origin = Anchor.TopRight; AutoSizeAxes = Axes.Both; - Child = new FillFlowContainer + InternalChild = content = new FillFlowContainer { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -31,7 +33,6 @@ namespace osu.Game.Screens.Play.HUD Spacing = new Vector2(0, 20), Children = new PlayerSettingsGroup[] { - PlaybackSettings = new PlaybackSettings { Expanded = { Value = false } }, VisualSettings = new VisualSettings { Expanded = { Value = false } }, new AudioSettings { Expanded = { Value = false } } } diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index b87306b9a2..29c7849685 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -476,9 +476,6 @@ namespace osu.Game.Screens.Play skipOutroOverlay.Expire(); } - if (GameplayClockContainer is MasterGameplayClockContainer master) - HUDOverlay.PlayerSettingsOverlay.PlaybackSettings.UserPlaybackRate.BindTarget = master.UserPlaybackRate; - return container; } diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index e2859868bd..0c9f5bb6ee 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -27,7 +27,6 @@ namespace osu.Game.Screens.Play.PlayerSettings Precision = 0.1, }; - public readonly Bindable AllowControls = new BindableBool(true); private readonly PlayerSliderBar rateSlider; @@ -73,7 +72,6 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.FastBackward, Action = () => seek(-1, seek_fast_amount), - Enabled = { BindTarget = AllowControls }, }, new SeekButton { @@ -81,7 +79,6 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.Backward, Action = () => seek(-1, seek_amount), - Enabled = { BindTarget = AllowControls }, }, play = new IconButton { @@ -100,7 +97,6 @@ namespace osu.Game.Screens.Play.PlayerSettings gameplayClock.Start(); } }, - Enabled = { BindTarget = AllowControls }, }, new SeekButton { @@ -108,7 +104,6 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.Forward, Action = () => seek(1, seek_amount), - Enabled = { BindTarget = AllowControls }, }, new SeekButton { @@ -116,7 +111,6 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.FastForward, Action = () => seek(1, seek_fast_amount), - Enabled = { BindTarget = AllowControls }, }, }, }, diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index ca71a89b48..788eb75283 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -15,6 +15,7 @@ using osu.Game.Input.Bindings; using osu.Game.Rulesets.Mods; using osu.Game.Scoring; using osu.Game.Screens.Play.HUD; +using osu.Game.Screens.Play.PlayerSettings; using osu.Game.Screens.Ranking; using osu.Game.Users; @@ -49,6 +50,17 @@ namespace osu.Game.Screens.Play this.createScore = createScore; } + protected override void LoadComplete() + { + base.LoadComplete(); + + var playerSettingsOverlay = new PlaybackSettings { Expanded = { Value = false } }; + HUDOverlay.PlayerSettingsOverlay.Add(playerSettingsOverlay); + + if (GameplayClockContainer is MasterGameplayClockContainer master) + playerSettingsOverlay.UserPlaybackRate.BindTarget = master.UserPlaybackRate; + } + protected override void PrepareReplay() { DrawableRuleset?.SetReplayScore(Score); diff --git a/osu.Game/Screens/Play/SpectatorPlayer.cs b/osu.Game/Screens/Play/SpectatorPlayer.cs index dd7418d563..2faead0ee1 100644 --- a/osu.Game/Screens/Play/SpectatorPlayer.cs +++ b/osu.Game/Screens/Play/SpectatorPlayer.cs @@ -68,8 +68,6 @@ namespace osu.Game.Screens.Play master.UserPlaybackRate.Value = 1; } }, true); - - HUDOverlay.PlayerSettingsOverlay.PlaybackSettings.AllowControls.Value = false; } /// From c545a9c242d56a499ddd6be46e69fd0730eed97e Mon Sep 17 00:00:00 2001 From: Nitrous Date: Fri, 12 Jan 2024 15:13:38 +0800 Subject: [PATCH 10/17] remove extra new line --- osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 0c9f5bb6ee..0fe3a08985 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -27,7 +27,6 @@ namespace osu.Game.Screens.Play.PlayerSettings Precision = 0.1, }; - private readonly PlayerSliderBar rateSlider; private readonly OsuSpriteText multiplierText; From ccbba8a00b7bcb7404cb31333742eafd21a5e62b Mon Sep 17 00:00:00 2001 From: Nitrous Date: Fri, 12 Jan 2024 17:19:59 +0800 Subject: [PATCH 11/17] Avoid NRE due to a beatmap loading with no hit objects. --- osu.Game/Screens/Play/ReplayPlayer.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index 788eb75283..f6e4ac489a 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -54,11 +54,14 @@ namespace osu.Game.Screens.Play { base.LoadComplete(); - var playerSettingsOverlay = new PlaybackSettings { Expanded = { Value = false } }; - HUDOverlay.PlayerSettingsOverlay.Add(playerSettingsOverlay); + if (HUDOverlay != null) + { + var playerSettingsOverlay = new PlaybackSettings { Expanded = { Value = false } }; + HUDOverlay.PlayerSettingsOverlay.Add(playerSettingsOverlay); - if (GameplayClockContainer is MasterGameplayClockContainer master) - playerSettingsOverlay.UserPlaybackRate.BindTarget = master.UserPlaybackRate; + if (GameplayClockContainer is MasterGameplayClockContainer master) + playerSettingsOverlay.UserPlaybackRate.BindTarget = master.UserPlaybackRate; + } } protected override void PrepareReplay() From 42f64c2c44f34bceb9fbbadb8a5cb6d2f8ed04aa Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 Jan 2024 14:48:33 +0900 Subject: [PATCH 12/17] Move load procedure to async method and simplify code --- .../Screens/Play/HUD/PlayerSettingsOverlay.cs | 2 ++ osu.Game/Screens/Play/ReplayPlayer.cs | 20 ++++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs index b7f3dc36c3..8c74b0254d 100644 --- a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs +++ b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs @@ -41,5 +41,7 @@ namespace osu.Game.Screens.Play.HUD protected override void PopIn() => this.FadeIn(fade_duration); protected override void PopOut() => this.FadeOut(fade_duration); + + public void Insert(int i, PlayerSettingsGroup drawable) => content.Insert(i, drawable); } } diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index f6e4ac489a..39df223a9d 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; @@ -50,18 +51,19 @@ namespace osu.Game.Screens.Play this.createScore = createScore; } - protected override void LoadComplete() + [BackgroundDependencyLoader] + private void load() { - base.LoadComplete(); - - if (HUDOverlay != null) + var playbackSettings = new PlaybackSettings { - var playerSettingsOverlay = new PlaybackSettings { Expanded = { Value = false } }; - HUDOverlay.PlayerSettingsOverlay.Add(playerSettingsOverlay); + Depth = float.MaxValue, + Expanded = { Value = false } + }; - if (GameplayClockContainer is MasterGameplayClockContainer master) - playerSettingsOverlay.UserPlaybackRate.BindTarget = master.UserPlaybackRate; - } + if (GameplayClockContainer is MasterGameplayClockContainer master) + playbackSettings.UserPlaybackRate.BindTo(master.UserPlaybackRate); + + HUDOverlay.PlayerSettingsOverlay.Insert(-1, playbackSettings); } protected override void PrepareReplay() From 042e852a3ec027721a80817a7d3a9538df5904ff Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 Jan 2024 14:53:49 +0900 Subject: [PATCH 13/17] Adjust playback speed range to allow slower minimum speed --- osu.Game/Screens/Play/MasterGameplayClockContainer.cs | 4 ++-- osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs index 8b8bf87436..1b7588d81a 100644 --- a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs +++ b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs @@ -35,9 +35,9 @@ namespace osu.Game.Screens.Play public readonly BindableNumber UserPlaybackRate = new BindableDouble(1) { - MinValue = 0.5, + MinValue = 0.05, MaxValue = 2, - Precision = 0.1, + Precision = 0.01, }; /// diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 0fe3a08985..2f37b8877f 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -22,9 +22,9 @@ namespace osu.Game.Screens.Play.PlayerSettings public readonly Bindable UserPlaybackRate = new BindableDouble(1) { - MinValue = 0.5, + MinValue = 0.05, MaxValue = 2, - Precision = 0.1, + Precision = 0.01, }; private readonly PlayerSliderBar rateSlider; @@ -149,7 +149,7 @@ namespace osu.Game.Screens.Play.PlayerSettings protected override void LoadComplete() { base.LoadComplete(); - rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.0}x", true); + rateSlider.Current.BindValueChanged(multiplier => multiplierText.Text = $"{multiplier.NewValue:0.00}x", true); if (gameplayClock != null) isPaused.BindTarget = gameplayClock.IsPaused; From e53989faebebb0bf323cac4a0f76e6bebd042939 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 Jan 2024 14:54:14 +0900 Subject: [PATCH 14/17] Change replay playback adjustment to skew frequency, not tempo --- osu.Game/Screens/Play/MasterGameplayClockContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs index 1b7588d81a..1159e5f6d9 100644 --- a/osu.Game/Screens/Play/MasterGameplayClockContainer.cs +++ b/osu.Game/Screens/Play/MasterGameplayClockContainer.cs @@ -274,7 +274,7 @@ namespace osu.Game.Screens.Play track.BindAdjustments(AdjustmentsFromMods); track.AddAdjustment(AdjustableProperty.Frequency, GameplayClock.ExternalPauseFrequencyAdjust); - track.AddAdjustment(AdjustableProperty.Tempo, UserPlaybackRate); + track.AddAdjustment(AdjustableProperty.Frequency, UserPlaybackRate); speedAdjustmentsApplied = true; } @@ -286,7 +286,7 @@ namespace osu.Game.Screens.Play track.UnbindAdjustments(AdjustmentsFromMods); track.RemoveAdjustment(AdjustableProperty.Frequency, GameplayClock.ExternalPauseFrequencyAdjust); - track.RemoveAdjustment(AdjustableProperty.Tempo, UserPlaybackRate); + track.RemoveAdjustment(AdjustableProperty.Frequency, UserPlaybackRate); speedAdjustmentsApplied = false; } From 2788bd912e87068c370b27ff40333bda3c85139a Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 Jan 2024 15:12:33 +0900 Subject: [PATCH 15/17] Add tooltips and localisation --- .../PlayerSettingsOverlayStrings.cs | 24 +++++++++++++++++++ .../Play/PlayerSettings/PlaybackSettings.cs | 19 ++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Localisation/PlayerSettingsOverlayStrings.cs diff --git a/osu.Game/Localisation/PlayerSettingsOverlayStrings.cs b/osu.Game/Localisation/PlayerSettingsOverlayStrings.cs new file mode 100644 index 0000000000..1aedd9fc5b --- /dev/null +++ b/osu.Game/Localisation/PlayerSettingsOverlayStrings.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Localisation; + +namespace osu.Game.Localisation +{ + public static class PlayerSettingsOverlayStrings + { + private const string prefix = @"osu.Game.Resources.Localisation.PlaybackSettings"; + + /// + /// "Seek backward {0} seconds" + /// + public static LocalisableString SeekBackwardSeconds(double arg0) => new TranslatableString(getKey(@"seek_backward_seconds"), @"Seek backward {0} seconds", arg0); + + /// + /// "Seek forward {0} seconds" + /// + public static LocalisableString SeekForwardSeconds(double arg0) => new TranslatableString(getKey(@"seek_forward_seconds"), @"Seek forward {0} seconds", arg0); + + private static string getKey(string key) => $@"{prefix}:{key}"; + } +} diff --git a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs index 2f37b8877f..44cfa8d811 100644 --- a/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs +++ b/osu.Game/Screens/Play/PlayerSettings/PlaybackSettings.cs @@ -13,6 +13,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Screens.Edit.Timing; using osuTK; +using osu.Game.Localisation; namespace osu.Game.Screens.Play.PlayerSettings { @@ -71,6 +72,7 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.FastBackward, Action = () => seek(-1, seek_fast_amount), + TooltipText = PlayerSettingsOverlayStrings.SeekBackwardSeconds(seek_fast_amount / 1000), }, new SeekButton { @@ -78,6 +80,7 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.Backward, Action = () => seek(-1, seek_amount), + TooltipText = PlayerSettingsOverlayStrings.SeekBackwardSeconds(seek_amount / 1000), }, play = new IconButton { @@ -103,6 +106,7 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.Forward, Action = () => seek(1, seek_amount), + TooltipText = PlayerSettingsOverlayStrings.SeekForwardSeconds(seek_amount / 1000), }, new SeekButton { @@ -110,6 +114,7 @@ namespace osu.Game.Screens.Play.PlayerSettings Origin = Anchor.Centre, Icon = FontAwesome.Solid.FastForward, Action = () => seek(1, seek_fast_amount), + TooltipText = PlayerSettingsOverlayStrings.SeekForwardSeconds(seek_fast_amount / 1000), }, }, }, @@ -137,7 +142,19 @@ namespace osu.Game.Screens.Play.PlayerSettings }, }; - isPaused.BindValueChanged(e => play.Icon = !e.NewValue ? FontAwesome.Regular.PauseCircle : FontAwesome.Regular.PlayCircle, true); + isPaused.BindValueChanged(paused => + { + if (!paused.NewValue) + { + play.TooltipText = ToastStrings.PauseTrack; + play.Icon = FontAwesome.Regular.PauseCircle; + } + else + { + play.TooltipText = ToastStrings.PlayTrack; + play.Icon = FontAwesome.Regular.PlayCircle; + } + }, true); void seek(int direction, double amount) { From e7732caaf79a90c15354502ab307e8927373a46e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 Jan 2024 15:13:59 +0900 Subject: [PATCH 16/17] Make `PlayerSettingsOverlay`'s api more stringent --- osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs | 2 +- osu.Game/Screens/Play/ReplayPlayer.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs index 8c74b0254d..a2b49f6302 100644 --- a/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs +++ b/osu.Game/Screens/Play/HUD/PlayerSettingsOverlay.cs @@ -42,6 +42,6 @@ namespace osu.Game.Screens.Play.HUD protected override void PopIn() => this.FadeIn(fade_duration); protected override void PopOut() => this.FadeOut(fade_duration); - public void Insert(int i, PlayerSettingsGroup drawable) => content.Insert(i, drawable); + public void AddAtStart(PlayerSettingsGroup drawable) => content.Insert(-1, drawable); } } diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index 39df223a9d..69913c6555 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -63,7 +63,7 @@ namespace osu.Game.Screens.Play if (GameplayClockContainer is MasterGameplayClockContainer master) playbackSettings.UserPlaybackRate.BindTo(master.UserPlaybackRate); - HUDOverlay.PlayerSettingsOverlay.Insert(-1, playbackSettings); + HUDOverlay.PlayerSettingsOverlay.AddAtStart(playbackSettings); } protected override void PrepareReplay() From e97b31d82e9aa6c9dace49742ff3c246d27c3368 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 17 Jan 2024 16:40:45 +0900 Subject: [PATCH 17/17] Fix test failures --- osu.Game/Screens/Play/ReplayPlayer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/osu.Game/Screens/Play/ReplayPlayer.cs b/osu.Game/Screens/Play/ReplayPlayer.cs index 69913c6555..805f907466 100644 --- a/osu.Game/Screens/Play/ReplayPlayer.cs +++ b/osu.Game/Screens/Play/ReplayPlayer.cs @@ -54,6 +54,9 @@ namespace osu.Game.Screens.Play [BackgroundDependencyLoader] private void load() { + if (!LoadedBeatmapSuccessfully) + return; + var playbackSettings = new PlaybackSettings { Depth = float.MaxValue,