mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 04:13:03 +08:00
Add setting to collapse the song progress graph
This commit is contained in:
parent
f41c89c3be
commit
608223cbb4
@ -1,6 +1,7 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
@ -15,6 +16,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneSongProgress : OsuTestScene
|
public class TestSceneSongProgress : OsuTestScene
|
||||||
{
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(SongProgressBar),
|
||||||
|
};
|
||||||
|
|
||||||
private readonly SongProgress progress;
|
private readonly SongProgress progress;
|
||||||
private readonly TestSongProgressGraph graph;
|
private readonly TestSongProgressGraph graph;
|
||||||
|
|
||||||
@ -46,24 +52,26 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
Origin = Anchor.TopLeft,
|
Origin = Anchor.TopLeft,
|
||||||
});
|
});
|
||||||
|
|
||||||
AddWaitStep("wait some", 5);
|
|
||||||
AddAssert("ensure not created", () => graph.CreationCount == 0);
|
AddAssert("ensure not created", () => graph.CreationCount == 0);
|
||||||
|
|
||||||
AddStep("display values", displayNewValues);
|
AddStep("display values", displayNewValues);
|
||||||
AddWaitStep("wait some", 5);
|
|
||||||
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
||||||
|
|
||||||
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
||||||
AddWaitStep("wait some", 5);
|
|
||||||
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
||||||
|
|
||||||
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
AddStep("Toggle Bar", () => progress.AllowSeeking = !progress.AllowSeeking);
|
||||||
AddWaitStep("wait some", 5);
|
|
||||||
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
AddUntilStep("wait for creation count", () => graph.CreationCount == 1);
|
||||||
AddRepeatStep("New Values", displayNewValues, 5);
|
AddRepeatStep("New Values", displayNewValues, 5);
|
||||||
|
|
||||||
AddWaitStep("wait some", 5);
|
AddWaitStep("wait some", 5);
|
||||||
AddAssert("ensure debounced", () => graph.CreationCount == 2);
|
AddAssert("ensure debounced", () => graph.CreationCount == 2);
|
||||||
|
|
||||||
|
AddStep("hide graph", () => progress.CollapseGraph.Value = true);
|
||||||
|
AddStep("show graph", () => progress.CollapseGraph.Value = false);
|
||||||
|
|
||||||
|
AddStep("start", clock.Start);
|
||||||
|
AddStep("pause", clock.Stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayNewValues()
|
private void displayNewValues()
|
||||||
|
@ -77,6 +77,7 @@ namespace osu.Game.Configuration
|
|||||||
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
|
Set(OsuSetting.BlurLevel, 0, 0, 1, 0.01);
|
||||||
|
|
||||||
Set(OsuSetting.ShowInterface, true);
|
Set(OsuSetting.ShowInterface, true);
|
||||||
|
Set(OsuSetting.CollapseProgressGraph, false);
|
||||||
Set(OsuSetting.KeyOverlay, false);
|
Set(OsuSetting.KeyOverlay, false);
|
||||||
|
|
||||||
Set(OsuSetting.FloatingComments, false);
|
Set(OsuSetting.FloatingComments, false);
|
||||||
@ -131,6 +132,7 @@ namespace osu.Game.Configuration
|
|||||||
KeyOverlay,
|
KeyOverlay,
|
||||||
FloatingComments,
|
FloatingComments,
|
||||||
ShowInterface,
|
ShowInterface,
|
||||||
|
CollapseProgressGraph,
|
||||||
MouseDisableButtons,
|
MouseDisableButtons,
|
||||||
MouseDisableWheel,
|
MouseDisableWheel,
|
||||||
AudioOffset,
|
AudioOffset,
|
||||||
|
@ -35,6 +35,11 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
|||||||
Bindable = config.GetBindable<bool>(OsuSetting.ShowInterface)
|
Bindable = config.GetBindable<bool>(OsuSetting.ShowInterface)
|
||||||
},
|
},
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
|
{
|
||||||
|
LabelText = "Collapse song progress graph",
|
||||||
|
Bindable = config.GetBindable<bool>(OsuSetting.CollapseProgressGraph)
|
||||||
|
},
|
||||||
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
LabelText = "Always show key overlay",
|
LabelText = "Always show key overlay",
|
||||||
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
Bindable = config.GetBindable<bool>(OsuSetting.KeyOverlay)
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Allocation;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
@ -20,7 +21,7 @@ namespace osu.Game.Screens.Play
|
|||||||
public class SongProgress : OverlayContainer
|
public class SongProgress : OverlayContainer
|
||||||
{
|
{
|
||||||
private const int bottom_bar_height = 5;
|
private const int bottom_bar_height = 5;
|
||||||
|
private const float graph_height = SquareGraph.Column.WIDTH * 6;
|
||||||
private static readonly Vector2 handle_size = new Vector2(10, 18);
|
private static readonly Vector2 handle_size = new Vector2(10, 18);
|
||||||
|
|
||||||
private const float transition_duration = 200;
|
private const float transition_duration = 200;
|
||||||
@ -30,13 +31,13 @@ namespace osu.Game.Screens.Play
|
|||||||
private readonly SongProgressInfo info;
|
private readonly SongProgressInfo info;
|
||||||
|
|
||||||
public Action<double> RequestSeek;
|
public Action<double> RequestSeek;
|
||||||
|
public readonly Bindable<bool> CollapseGraph = new Bindable<bool>();
|
||||||
|
|
||||||
public override bool HandleNonPositionalInput => AllowSeeking;
|
public override bool HandleNonPositionalInput => AllowSeeking;
|
||||||
public override bool HandlePositionalInput => AllowSeeking;
|
public override bool HandlePositionalInput => AllowSeeking;
|
||||||
|
|
||||||
private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1;
|
|
||||||
|
|
||||||
private double firstHitTime => objects.First().StartTime;
|
private double firstHitTime => objects.First().StartTime;
|
||||||
|
private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1;
|
||||||
|
|
||||||
private IEnumerable<HitObject> objects;
|
private IEnumerable<HitObject> objects;
|
||||||
|
|
||||||
@ -54,25 +55,28 @@ namespace osu.Game.Screens.Play
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool allowSeeking;
|
||||||
|
|
||||||
|
public bool AllowSeeking
|
||||||
|
{
|
||||||
|
get => allowSeeking;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (allowSeeking == value) return;
|
||||||
|
|
||||||
|
allowSeeking = value;
|
||||||
|
updateBarVisibility();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private readonly BindableBool replayLoaded = new BindableBool();
|
private readonly BindableBool replayLoaded = new BindableBool();
|
||||||
|
|
||||||
public IClock ReferenceClock;
|
public IClock ReferenceClock;
|
||||||
|
|
||||||
private IClock gameplayClock;
|
private IClock gameplayClock;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
|
||||||
private void load(OsuColour colours, GameplayClock clock)
|
|
||||||
{
|
|
||||||
if (clock != null)
|
|
||||||
gameplayClock = clock;
|
|
||||||
|
|
||||||
graph.FillColour = bar.FillColour = colours.BlueLighter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SongProgress()
|
public SongProgress()
|
||||||
{
|
{
|
||||||
const float graph_height = SquareGraph.Column.WIDTH * 6;
|
|
||||||
|
|
||||||
Height = bottom_bar_height + graph_height + handle_size.Y;
|
Height = bottom_bar_height + graph_height + handle_size.Y;
|
||||||
Y = bottom_bar_height;
|
Y = bottom_bar_height;
|
||||||
|
|
||||||
@ -104,12 +108,23 @@ namespace osu.Game.Screens.Play
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader(true)]
|
||||||
|
private void load(OsuColour colours, GameplayClock clock, OsuConfigManager config)
|
||||||
|
{
|
||||||
|
if (clock != null)
|
||||||
|
gameplayClock = clock;
|
||||||
|
|
||||||
|
config.BindWith(OsuSetting.CollapseProgressGraph, CollapseGraph);
|
||||||
|
|
||||||
|
graph.FillColour = bar.FillColour = colours.BlueLighter;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
Show();
|
Show();
|
||||||
|
|
||||||
replayLoaded.ValueChanged += loaded => AllowSeeking = loaded.NewValue;
|
replayLoaded.BindValueChanged(loaded => AllowSeeking = loaded.NewValue, true);
|
||||||
replayLoaded.TriggerChange();
|
CollapseGraph.BindValueChanged(_ => updateGraphVisibility(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BindDrawableRuleset(DrawableRuleset drawableRuleset)
|
public void BindDrawableRuleset(DrawableRuleset drawableRuleset)
|
||||||
@ -117,28 +132,6 @@ namespace osu.Game.Screens.Play
|
|||||||
replayLoaded.BindTo(drawableRuleset.HasReplayLoaded);
|
replayLoaded.BindTo(drawableRuleset.HasReplayLoaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool allowSeeking;
|
|
||||||
|
|
||||||
public bool AllowSeeking
|
|
||||||
{
|
|
||||||
get => allowSeeking;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (allowSeeking == value) return;
|
|
||||||
|
|
||||||
allowSeeking = value;
|
|
||||||
updateBarVisibility();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateBarVisibility()
|
|
||||||
{
|
|
||||||
bar.FadeTo(allowSeeking ? 1 : 0, transition_duration, Easing.In);
|
|
||||||
this.MoveTo(new Vector2(0, allowSeeking ? 0 : bottom_bar_height), transition_duration, Easing.In);
|
|
||||||
|
|
||||||
info.Margin = new MarginPadding { Bottom = Height - (allowSeeking ? 0 : handle_size.Y) };
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void PopIn()
|
protected override void PopIn()
|
||||||
{
|
{
|
||||||
updateBarVisibility();
|
updateBarVisibility();
|
||||||
@ -165,5 +158,29 @@ namespace osu.Game.Screens.Play
|
|||||||
bar.CurrentTime = gameplayTime;
|
bar.CurrentTime = gameplayTime;
|
||||||
graph.Progress = (int)(graph.ColumnCount * progress);
|
graph.Progress = (int)(graph.ColumnCount * progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateBarVisibility()
|
||||||
|
{
|
||||||
|
bar.FadeTo(allowSeeking ? 1 : 0, transition_duration, Easing.In);
|
||||||
|
this.MoveTo(new Vector2(0, allowSeeking ? 0 : bottom_bar_height), transition_duration, Easing.In);
|
||||||
|
|
||||||
|
updateInfoMargin();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateGraphVisibility()
|
||||||
|
{
|
||||||
|
float barHeight = bottom_bar_height + handle_size.Y;
|
||||||
|
|
||||||
|
bar.ResizeHeightTo(CollapseGraph.Value ? barHeight : barHeight + graph_height, transition_duration, Easing.In);
|
||||||
|
graph.MoveToY(CollapseGraph.Value ? graph_height : 0, transition_duration, Easing.In);
|
||||||
|
|
||||||
|
updateInfoMargin();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateInfoMargin()
|
||||||
|
{
|
||||||
|
float finalMargin = bottom_bar_height + (allowSeeking ? handle_size.Y : 0) + (CollapseGraph.Value ? 0 : graph_height);
|
||||||
|
info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
private readonly Box fill;
|
private readonly Box fill;
|
||||||
private readonly Container handleBase;
|
private readonly Container handleBase;
|
||||||
|
private readonly Container handleContainer;
|
||||||
|
|
||||||
public Color4 FillColour
|
public Color4 FillColour
|
||||||
{
|
{
|
||||||
@ -73,7 +74,6 @@ namespace osu.Game.Screens.Play
|
|||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Width = 2,
|
Width = 2,
|
||||||
Height = barHeight + handleBarHeight,
|
|
||||||
Colour = Color4.White,
|
Colour = Color4.White,
|
||||||
Position = new Vector2(2, 0),
|
Position = new Vector2(2, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -83,7 +83,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Name = "HandleBar box",
|
Name = "HandleBar box",
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
},
|
||||||
new Container
|
handleContainer = new Container
|
||||||
{
|
{
|
||||||
Name = "Handle container",
|
Name = "Handle container",
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomCentre,
|
||||||
@ -115,6 +115,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
|
handleBase.Height = Height - handleContainer.Height;
|
||||||
float newX = (float)Interpolation.Lerp(handleBase.X, NormalizedValue * UsableWidth, MathHelper.Clamp(Time.Elapsed / 40, 0, 1));
|
float newX = (float)Interpolation.Lerp(handleBase.X, NormalizedValue * UsableWidth, MathHelper.Clamp(Time.Elapsed / 40, 0, 1));
|
||||||
|
|
||||||
fill.Width = newX;
|
fill.Width = newX;
|
||||||
|
Loading…
Reference in New Issue
Block a user