1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 12:07:23 +08:00

Encapsulate progress update logic better.

This commit is contained in:
Dean Herbert 2017-04-14 18:23:34 +09:00
parent acd7a5b254
commit ea0631ede8
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
3 changed files with 15 additions and 29 deletions

View File

@ -41,7 +41,6 @@ namespace osu.Desktop.VisualTests.Tests
objects.Add(new HitObject { StartTime = i });
progress.Objects = objects;
progress.Progress = RNG.NextDouble();
}
}
}

View File

@ -125,6 +125,7 @@ namespace osu.Game.Screens.Play
hudOverlay.BindHitRenderer(HitRenderer);
hudOverlay.Progress.Objects = HitRenderer.Objects;
hudOverlay.Progress.AudioClock = interpolatedSourceClock;
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
HitRenderer.OnAllJudged += onCompletion;
@ -175,13 +176,6 @@ namespace osu.Game.Screens.Play
};
}
protected override void Update()
{
base.Update();
hudOverlay.Progress.Progress = Beatmap.Track.CurrentTime / Beatmap.Track.Length;
}
private void initializeSkipButton()
{
const double skip_required_cutoff = 3000;

View File

@ -10,12 +10,13 @@ using System.Collections.Generic;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using System.Linq;
using osu.Framework.Timing;
using osu.Game.Modes.Objects;
using osu.Game.Modes.Objects.Types;
namespace osu.Game.Screens.Play
{
public class SongProgress : OverlayContainer
public class SongProgress : OverlayContainer
{
private const int progress_height = 5;
@ -30,27 +31,21 @@ namespace osu.Game.Screens.Play
public Action<double> OnSeek;
private double progress;
public double Progress
{
get { return progress; }
set
{
progress = value;
updateProgress();
}
}
public IClock AudioClock;
private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1;
private IEnumerable<HitObject> objects;
public IEnumerable<HitObject> Objects
{
set
{
var objects = value;
objects = value;
const int granularity = 200;
var lastHit = ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1;
var interval = lastHit / granularity;
var interval = lastHitTime / granularity;
var values = new int[granularity];
@ -108,12 +103,6 @@ namespace osu.Game.Screens.Play
State = Visibility.Visible;
}
private void updateProgress()
{
bar.UpdatePosition((float)progress);
graph.Progress = (int)(graph.ColumnCount * progress);
}
private bool barVisible;
public void ToggleBar()
@ -143,7 +132,11 @@ namespace osu.Game.Screens.Play
{
base.Update();
updateProgress();
double progress = (AudioClock?.CurrentTime ?? Time.Current) / lastHitTime;
bar.UpdatePosition((float)progress);
graph.Progress = (int)(graph.ColumnCount * progress);
}
}
}