1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 03:27:24 +08:00

refactor(hud/gameplay/SongProgress): Add interface to designate SongProgressBars

This commit is contained in:
tsrk 2023-01-09 21:48:53 +01:00
parent 91eab7985b
commit 0f1fe1d683
No known key found for this signature in database
GPG Key ID: EBD46BB3049B56D6
5 changed files with 35 additions and 11 deletions

View File

@ -188,7 +188,7 @@ namespace osu.Game.Tests.Visual.Gameplay
[Test]
public void TestInputDoesntWorkWhenHUDHidden()
{
SongProgressBar? getSongProgress() => hudOverlay.ChildrenOfType<SongProgressBar>().SingleOrDefault();
ISongProgressBar? getSongProgress() => hudOverlay.ChildrenOfType<ISongProgressBar>().SingleOrDefault();
bool seeked = false;
@ -204,7 +204,7 @@ namespace osu.Game.Tests.Visual.Gameplay
Debug.Assert(progress != null);
progress.ShowHandle = true;
progress.Interactive = true;
progress.OnSeek += _ => seeked = true;
});
@ -213,7 +213,17 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("attempt seek", () =>
{
InputManager.MoveMouseTo(getSongProgress());
switch (getSongProgress())
{
case SongProgressBar defaultBar:
InputManager.MoveMouseTo(defaultBar);
break;
case ArgonSongProgressBar argonBar:
InputManager.MoveMouseTo(argonBar);
break;
}
InputManager.Click(MouseButton.Left);
});

View File

@ -121,7 +121,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddUntilStep("all interactive elements removed", () => this.ChildrenOfType<Player>().All(p =>
!p.ChildrenOfType<PlayerSettingsOverlay>().Any() &&
!p.ChildrenOfType<HoldForMenuButton>().Any() &&
p.ChildrenOfType<SongProgressBar>().SingleOrDefault()?.ShowHandle == false));
p.ChildrenOfType<ISongProgressBar>().SingleOrDefault()?.Interactive == false));
AddStep("restore config hud visibility", () => config.SetValue(OsuSetting.HUDVisibilityMode, originalConfigValue));
}

View File

@ -133,7 +133,7 @@ namespace osu.Game.Screens.Play.HUD
private void updateBarVisibility()
{
bar.ShowHandle = AllowSeeking.Value;
bar.Interactive = AllowSeeking.Value;
updateInfoMargin();
}

View File

@ -0,0 +1,16 @@
// 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;
namespace osu.Game.Screens.Play.HUD
{
public interface ISongProgressBar
{
public Action<double>? OnSeek { get; set; }
public double StartTime { set; }
public double EndTime { set; }
public double CurrentTime { set; }
public bool Interactive { get; set; }
}
}

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
#nullable disable
using System;
using osuTK;
using osuTK.Graphics;
@ -15,9 +13,9 @@ using osu.Framework.Threading;
namespace osu.Game.Screens.Play.HUD
{
public partial class SongProgressBar : SliderBar<double>
public partial class SongProgressBar : SliderBar<double>, ISongProgressBar
{
public Action<double> OnSeek;
public Action<double>? OnSeek { get; set; }
private readonly Box fill;
private readonly Container handleBase;
@ -25,7 +23,7 @@ namespace osu.Game.Screens.Play.HUD
private bool showHandle;
public bool ShowHandle
public bool Interactive
{
get => showHandle;
set
@ -142,7 +140,7 @@ namespace osu.Game.Screens.Play.HUD
handleBase.X = newX;
}
private ScheduledDelegate scheduledSeek;
private ScheduledDelegate? scheduledSeek;
protected override void OnUserChange(double value)
{