mirror of
https://github.com/ppy/osu.git
synced 2025-01-06 08:22:56 +08:00
Fix various inconsistencies and document better
This commit is contained in:
parent
23f12e1ea3
commit
f4dd84fa77
@ -114,7 +114,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
protected override void UpdateProgress(double progress, bool isIntro)
|
protected override void UpdateProgress(double progress, bool isIntro)
|
||||||
{
|
{
|
||||||
bar.CurrentTime = GameplayClock.CurrentTime;
|
|
||||||
bar.Progress = isIntro ? 0 : progress;
|
bar.Progress = isIntro ? 0 : progress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Colour = OsuColour.Gray(0.2f),
|
Colour = OsuColour.Gray(0.2f),
|
||||||
|
Depth = float.MaxValue,
|
||||||
},
|
},
|
||||||
audioBar = new RoundedBar
|
audioBar = new RoundedBar
|
||||||
{
|
{
|
||||||
@ -102,14 +103,14 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
playfieldBar.Length = (float)Interpolation.Lerp(playfieldBar.Length, Progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
playfieldBar.Length = (float)Interpolation.Lerp(playfieldBar.Length, Progress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
||||||
audioBar.Length = (float)Interpolation.Lerp(audioBar.Length, NormalizedValue, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
audioBar.Length = (float)Interpolation.Lerp(audioBar.Length, AudioProgress, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
||||||
|
|
||||||
if (trackTime > CurrentTime)
|
if (trackTime > AudioTime)
|
||||||
ChangeInternalChildDepth(audioBar, -1);
|
ChangeInternalChildDepth(audioBar, -1);
|
||||||
else
|
else
|
||||||
ChangeInternalChildDepth(audioBar, 0);
|
ChangeInternalChildDepth(audioBar, 1);
|
||||||
|
|
||||||
float timeDelta = (float)Math.Abs(CurrentTime - trackTime);
|
float timeDelta = (float)Math.Abs(AudioTime - trackTime);
|
||||||
|
|
||||||
const float colour_transition_threshold = 20000;
|
const float colour_transition_threshold = 20000;
|
||||||
|
|
||||||
|
@ -98,7 +98,6 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
protected override void UpdateProgress(double progress, bool isIntro)
|
protected override void UpdateProgress(double progress, bool isIntro)
|
||||||
{
|
{
|
||||||
bar.CurrentTime = GameplayClock.CurrentTime;
|
|
||||||
graph.Progress = isIntro ? 0 : (int)(graph.ColumnCount * progress);
|
graph.Progress = isIntro ? 0 : (int)(graph.ColumnCount * progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
handleBase.Height = Height - handleContainer.Height;
|
handleBase.Height = Height - handleContainer.Height;
|
||||||
float newX = (float)Interpolation.Lerp(handleBase.X, NormalizedValue * DrawWidth, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
float newX = (float)Interpolation.Lerp(handleBase.X, AudioProgress * DrawWidth, Math.Clamp(Time.Elapsed / 40, 0, 1));
|
||||||
|
|
||||||
fill.Width = newX;
|
fill.Width = newX;
|
||||||
handleBase.X = newX;
|
handleBase.X = newX;
|
||||||
|
@ -71,7 +71,13 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
protected double LastHitTime { get; private set; }
|
protected double LastHitTime { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called every update frame with current progress information.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="progress">Current (visual) progress through the beatmap (0..1).</param>
|
||||||
|
/// <param name="isIntro">If <c>true</c>, progress is (0..1) through the intro.</param>
|
||||||
protected abstract void UpdateProgress(double progress, bool isIntro);
|
protected abstract void UpdateProgress(double progress, bool isIntro);
|
||||||
|
|
||||||
protected virtual void UpdateObjects(IEnumerable<HitObject> objects) { }
|
protected virtual void UpdateObjects(IEnumerable<HitObject> objects) { }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
@ -12,6 +13,20 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
{
|
{
|
||||||
public abstract partial class SongProgressBar : CompositeDrawable
|
public abstract partial class SongProgressBar : CompositeDrawable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The current seek position of the audio, on a (0..1) range.
|
||||||
|
/// This is generally the seek target, which will eventually match the gameplay clock when it catches up.
|
||||||
|
/// </summary>
|
||||||
|
protected double AudioProgress => length == 0 ? 1 : AudioTime / length;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The current (non-frame-stable) audio time.
|
||||||
|
/// </summary>
|
||||||
|
protected double AudioTime => Math.Clamp(GameplayClock.CurrentTime - StartTime, 0.0, length);
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
protected IGameplayClock GameplayClock { get; private set; } = null!;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Action which is invoked when a seek is requested, with the proposed millisecond value for the seek operation.
|
/// Action which is invoked when a seek is requested, with the proposed millisecond value for the seek operation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -32,12 +47,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
|
|
||||||
public double EndTime { get; set; } = 1.0;
|
public double EndTime { get; set; } = 1.0;
|
||||||
|
|
||||||
public double CurrentTime { get; set; }
|
|
||||||
|
|
||||||
private double length => EndTime - StartTime;
|
private double length => EndTime - StartTime;
|
||||||
|
|
||||||
protected double NormalizedValue => length == 0 ? 1 : Math.Clamp(CurrentTime - StartTime, 0.0, length) / length;
|
|
||||||
|
|
||||||
private bool handleClick;
|
private bool handleClick;
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e)
|
protected override bool OnMouseDown(MouseDownEvent e)
|
||||||
|
Loading…
Reference in New Issue
Block a user