mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 21:42:55 +08:00
Combine common code into SongProgress
base class
This commit is contained in:
parent
afc12e0b83
commit
5429979049
@ -54,10 +54,10 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
void applyToDefaultProgress(Action<DefaultSongProgress> action) =>
|
||||
this.ChildrenOfType<DefaultSongProgress>().ForEach(action);
|
||||
|
||||
AddStep("allow seeking", () => applyToDefaultProgress(s => s.AllowSeeking.Value = true));
|
||||
AddStep("allow seeking", () => applyToDefaultProgress(s => s.Interactive.Value = true));
|
||||
AddStep("hide graph", () => applyToDefaultProgress(s => s.ShowGraph.Value = false));
|
||||
AddStep("disallow seeking", () => applyToDefaultProgress(s => s.AllowSeeking.Value = false));
|
||||
AddStep("allow seeking", () => applyToDefaultProgress(s => s.AllowSeeking.Value = true));
|
||||
AddStep("disallow seeking", () => applyToDefaultProgress(s => s.Interactive.Value = false));
|
||||
AddStep("allow seeking", () => applyToDefaultProgress(s => s.Interactive.Value = true));
|
||||
AddStep("show graph", () => applyToDefaultProgress(s => s.ShowGraph.Value = true));
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,9 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
@ -23,11 +21,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private const float bar_height = 10;
|
||||
|
||||
public readonly Bindable<bool> AllowSeeking = new BindableBool();
|
||||
|
||||
[SettingSource("Show difficulty graph", "Whether a graph displaying difficulty throughout the beatmap should be shown")]
|
||||
public Bindable<bool> ShowGraph { get; } = new BindableBool(true);
|
||||
|
||||
[Resolved]
|
||||
private DrawableRuleset? drawableRuleset { get; set; }
|
||||
|
||||
@ -80,14 +73,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (drawableRuleset != null)
|
||||
{
|
||||
if (player?.Configuration.AllowUserInteraction == true)
|
||||
((IBindable<bool>)AllowSeeking).BindTo(drawableRuleset.HasReplayLoaded);
|
||||
}
|
||||
|
||||
info.ShowProgress = false;
|
||||
info.TextColour = Colour4.White;
|
||||
info.Font = OsuFont.Torus.With(size: 18, weight: FontWeight.Bold);
|
||||
@ -95,7 +80,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
AllowSeeking.BindValueChanged(_ => updateBarVisibility(), true);
|
||||
base.LoadComplete();
|
||||
|
||||
Interactive.BindValueChanged(_ => bar.Interactive = Interactive.Value, true);
|
||||
ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true);
|
||||
}
|
||||
|
||||
@ -107,11 +94,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
info.EndTime = bar.EndTime = LastHitTime;
|
||||
}
|
||||
|
||||
private void updateBarVisibility()
|
||||
{
|
||||
bar.Interactive = AllowSeeking.Value;
|
||||
}
|
||||
|
||||
private void updateGraphVisibility()
|
||||
{
|
||||
graph.FadeTo(ShowGraph.Value ? 1 : 0, 200, Easing.In);
|
||||
@ -125,16 +107,6 @@ namespace osu.Game.Screens.Play.HUD
|
||||
graphContainer.Height = bar.Height;
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
this.FadeIn(500, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
this.FadeOut(100);
|
||||
}
|
||||
|
||||
protected override void UpdateProgress(double progress, bool isIntro)
|
||||
{
|
||||
bar.ReferenceTime = GameplayClock.CurrentTime;
|
||||
|
@ -3,12 +3,9 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD
|
||||
@ -27,23 +24,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
private readonly SongProgressGraph graph;
|
||||
private readonly SongProgressInfo info;
|
||||
|
||||
/// <summary>
|
||||
/// Whether seeking is allowed and the progress bar should be shown.
|
||||
/// </summary>
|
||||
public readonly Bindable<bool> AllowSeeking = new Bindable<bool>();
|
||||
|
||||
[SettingSource("Show difficulty graph", "Whether a graph displaying difficulty throughout the beatmap should be shown")]
|
||||
public Bindable<bool> ShowGraph { get; } = new BindableBool(true);
|
||||
|
||||
public override bool HandleNonPositionalInput => AllowSeeking.Value;
|
||||
public override bool HandlePositionalInput => AllowSeeking.Value;
|
||||
|
||||
[Resolved]
|
||||
private Player? player { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private DrawableRuleset? drawableRuleset { get; set; }
|
||||
|
||||
public DefaultSongProgress()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
@ -75,34 +58,18 @@ namespace osu.Game.Screens.Play.HUD
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
if (drawableRuleset != null)
|
||||
{
|
||||
if (player?.Configuration.AllowUserInteraction == true)
|
||||
((IBindable<bool>)AllowSeeking).BindTo(drawableRuleset.HasReplayLoaded);
|
||||
}
|
||||
|
||||
graph.FillColour = bar.FillColour = colours.BlueLighter;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
AllowSeeking.BindValueChanged(_ => updateBarVisibility(), true);
|
||||
Interactive.BindValueChanged(_ => updateBarVisibility(), true);
|
||||
ShowGraph.BindValueChanged(_ => updateGraphVisibility(), true);
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
this.FadeIn(500, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
this.FadeOut(100);
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
protected override void UpdateObjects(IEnumerable<HitObject> objects)
|
||||
@ -133,7 +100,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private void updateBarVisibility()
|
||||
{
|
||||
bar.Interactive = AllowSeeking.Value;
|
||||
bar.Interactive = Interactive.Value;
|
||||
|
||||
updateInfoMargin();
|
||||
}
|
||||
@ -150,7 +117,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private void updateInfoMargin()
|
||||
{
|
||||
float finalMargin = bottom_bar_height + (AllowSeeking.Value ? handle_size.Y : 0) + (ShowGraph.Value ? graph_height : 0);
|
||||
float finalMargin = bottom_bar_height + (Interactive.Value ? handle_size.Y : 0) + (ShowGraph.Value ? graph_height : 0);
|
||||
info.TransformTo(nameof(info.Margin), new MarginPadding { Bottom = finalMargin }, transition_duration, Easing.In);
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Skinning;
|
||||
@ -16,18 +19,27 @@ namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
// Some implementations of this element allow seeking during gameplay playback.
|
||||
// Set a sane default of never handling input to override the behaviour provided by OverlayContainer.
|
||||
public override bool HandleNonPositionalInput => false;
|
||||
public override bool HandlePositionalInput => false;
|
||||
public override bool HandleNonPositionalInput => Interactive.Value;
|
||||
public override bool HandlePositionalInput => Interactive.Value;
|
||||
|
||||
protected override bool BlockScrollInput => false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether interaction should be allowed (ie. seeking). If <c>false</c>, interaction controls will not be displayed.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// By default, this will be automatically decided based on the gameplay state.
|
||||
/// </remarks>
|
||||
public readonly Bindable<bool> Interactive = new Bindable<bool>();
|
||||
|
||||
[SettingSource("Show difficulty graph", "Whether a graph displaying difficulty throughout the beatmap should be shown")]
|
||||
public Bindable<bool> ShowGraph { get; } = new BindableBool(true);
|
||||
|
||||
public bool UsesFixedAnchor { get; set; }
|
||||
|
||||
[Resolved]
|
||||
protected IGameplayClock GameplayClock { get; private set; } = null!;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private DrawableRuleset? drawableRuleset { get; set; }
|
||||
|
||||
private IClock? referenceClock;
|
||||
private IEnumerable<HitObject>? objects;
|
||||
|
||||
@ -58,15 +70,22 @@ namespace osu.Game.Screens.Play.HUD
|
||||
protected virtual void UpdateObjects(IEnumerable<HitObject> objects) { }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(DrawableRuleset? drawableRuleset, Player? player)
|
||||
{
|
||||
if (drawableRuleset != null)
|
||||
{
|
||||
if (player?.Configuration.AllowUserInteraction == true)
|
||||
((IBindable<bool>)Interactive).BindTo(drawableRuleset.HasReplayLoaded);
|
||||
|
||||
Objects = drawableRuleset.Objects;
|
||||
referenceClock = drawableRuleset.FrameStableClock;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PopIn() => this.FadeIn(500, Easing.OutQuint);
|
||||
|
||||
protected override void PopOut() => this.FadeOut(100);
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
@ -15,6 +15,10 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
private CircularProgress circularProgress = null!;
|
||||
|
||||
// Legacy song progress doesn't support interaction for now.
|
||||
public override bool HandleNonPositionalInput => false;
|
||||
public override bool HandlePositionalInput => false;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -56,16 +60,6 @@ namespace osu.Game.Skinning
|
||||
};
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
this.FadeIn(500, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
this.FadeOut(100);
|
||||
}
|
||||
|
||||
protected override void UpdateProgress(double progress, bool isIntro)
|
||||
{
|
||||
if (isIntro)
|
||||
|
Loading…
Reference in New Issue
Block a user