mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:32:55 +08:00
Encapsulate progress update logic better.
This commit is contained in:
parent
acd7a5b254
commit
ea0631ede8
@ -41,7 +41,6 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
objects.Add(new HitObject { StartTime = i });
|
||||
|
||||
progress.Objects = objects;
|
||||
progress.Progress = RNG.NextDouble();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -10,6 +10,7 @@ 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;
|
||||
|
||||
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user