mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 17:32:54 +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 });
|
objects.Add(new HitObject { StartTime = i });
|
||||||
|
|
||||||
progress.Objects = objects;
|
progress.Objects = objects;
|
||||||
progress.Progress = RNG.NextDouble();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,7 @@ namespace osu.Game.Screens.Play
|
|||||||
hudOverlay.BindHitRenderer(HitRenderer);
|
hudOverlay.BindHitRenderer(HitRenderer);
|
||||||
|
|
||||||
hudOverlay.Progress.Objects = HitRenderer.Objects;
|
hudOverlay.Progress.Objects = HitRenderer.Objects;
|
||||||
|
hudOverlay.Progress.AudioClock = interpolatedSourceClock;
|
||||||
|
|
||||||
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
|
//bind HitRenderer to ScoreProcessor and ourselves (for a pass situation)
|
||||||
HitRenderer.OnAllJudged += onCompletion;
|
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()
|
private void initializeSkipButton()
|
||||||
{
|
{
|
||||||
const double skip_required_cutoff = 3000;
|
const double skip_required_cutoff = 3000;
|
||||||
|
@ -10,6 +10,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
using osu.Game.Modes.Objects.Types;
|
using osu.Game.Modes.Objects.Types;
|
||||||
|
|
||||||
@ -30,27 +31,21 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public Action<double> OnSeek;
|
public Action<double> OnSeek;
|
||||||
|
|
||||||
private double progress;
|
public IClock AudioClock;
|
||||||
public double Progress
|
|
||||||
{
|
private double lastHitTime => ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1;
|
||||||
get { return progress; }
|
|
||||||
set
|
private IEnumerable<HitObject> objects;
|
||||||
{
|
|
||||||
progress = value;
|
|
||||||
updateProgress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<HitObject> Objects
|
public IEnumerable<HitObject> Objects
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
var objects = value;
|
objects = value;
|
||||||
|
|
||||||
const int granularity = 200;
|
const int granularity = 200;
|
||||||
|
|
||||||
var lastHit = ((objects.Last() as IHasEndTime)?.EndTime ?? objects.Last().StartTime) + 1;
|
var interval = lastHitTime / granularity;
|
||||||
var interval = lastHit / granularity;
|
|
||||||
|
|
||||||
var values = new int[granularity];
|
var values = new int[granularity];
|
||||||
|
|
||||||
@ -108,12 +103,6 @@ namespace osu.Game.Screens.Play
|
|||||||
State = Visibility.Visible;
|
State = Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProgress()
|
|
||||||
{
|
|
||||||
bar.UpdatePosition((float)progress);
|
|
||||||
graph.Progress = (int)(graph.ColumnCount * progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool barVisible;
|
private bool barVisible;
|
||||||
|
|
||||||
public void ToggleBar()
|
public void ToggleBar()
|
||||||
@ -143,7 +132,11 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
base.Update();
|
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