mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 16:27:26 +08:00
refactor(hud/gameplay/SongProgress): Add interface to designate SongProgressBar
s
This commit is contained in:
parent
91eab7985b
commit
0f1fe1d683
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private void updateBarVisibility()
|
||||
{
|
||||
bar.ShowHandle = AllowSeeking.Value;
|
||||
bar.Interactive = AllowSeeking.Value;
|
||||
|
||||
updateInfoMargin();
|
||||
}
|
||||
|
16
osu.Game/Screens/Play/HUD/ISongProgressBar.cs
Normal file
16
osu.Game/Screens/Play/HUD/ISongProgressBar.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user