mirror of
https://github.com/osukey/osukey.git
synced 2025-06-09 21:37:59 +09: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]
|
[Test]
|
||||||
public void TestInputDoesntWorkWhenHUDHidden()
|
public void TestInputDoesntWorkWhenHUDHidden()
|
||||||
{
|
{
|
||||||
SongProgressBar? getSongProgress() => hudOverlay.ChildrenOfType<SongProgressBar>().SingleOrDefault();
|
ISongProgressBar? getSongProgress() => hudOverlay.ChildrenOfType<ISongProgressBar>().SingleOrDefault();
|
||||||
|
|
||||||
bool seeked = false;
|
bool seeked = false;
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
Debug.Assert(progress != null);
|
Debug.Assert(progress != null);
|
||||||
|
|
||||||
progress.ShowHandle = true;
|
progress.Interactive = true;
|
||||||
progress.OnSeek += _ => seeked = true;
|
progress.OnSeek += _ => seeked = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -213,7 +213,17 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
|
|
||||||
AddStep("attempt seek", () =>
|
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);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddUntilStep("all interactive elements removed", () => this.ChildrenOfType<Player>().All(p =>
|
AddUntilStep("all interactive elements removed", () => this.ChildrenOfType<Player>().All(p =>
|
||||||
!p.ChildrenOfType<PlayerSettingsOverlay>().Any() &&
|
!p.ChildrenOfType<PlayerSettingsOverlay>().Any() &&
|
||||||
!p.ChildrenOfType<HoldForMenuButton>().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));
|
AddStep("restore config hud visibility", () => config.SetValue(OsuSetting.HUDVisibilityMode, originalConfigValue));
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
private void updateBarVisibility()
|
private void updateBarVisibility()
|
||||||
{
|
{
|
||||||
bar.ShowHandle = AllowSeeking.Value;
|
bar.Interactive = AllowSeeking.Value;
|
||||||
|
|
||||||
updateInfoMargin();
|
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.
|
// 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 osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
@ -15,9 +13,9 @@ using osu.Framework.Threading;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Play.HUD
|
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 Box fill;
|
||||||
private readonly Container handleBase;
|
private readonly Container handleBase;
|
||||||
@ -25,7 +23,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
private bool showHandle;
|
private bool showHandle;
|
||||||
|
|
||||||
public bool ShowHandle
|
public bool Interactive
|
||||||
{
|
{
|
||||||
get => showHandle;
|
get => showHandle;
|
||||||
set
|
set
|
||||||
@ -142,7 +140,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
handleBase.X = newX;
|
handleBase.X = newX;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledDelegate scheduledSeek;
|
private ScheduledDelegate? scheduledSeek;
|
||||||
|
|
||||||
protected override void OnUserChange(double value)
|
protected override void OnUserChange(double value)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user