1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Call KeyCounter.RestoreState itself

This commit is contained in:
Roman Kapustin 2018-07-28 13:22:52 +03:00
parent e7591a9214
commit 1e6220e3c0
3 changed files with 12 additions and 18 deletions

View File

@ -82,11 +82,7 @@ namespace osu.Game.Screens.Play
Progress.Objects = rulesetContainer.Objects;
Progress.AudioClock = offsetClock;
Progress.AllowSeeking = rulesetContainer.HasReplayLoaded;
Progress.OnSeek = pos =>
{
adjustableClock.Seek(pos);
KeyCounter.RestoreKeyCounterState(pos);
};
Progress.OnSeek = pos => adjustableClock.Seek(pos);
ModDisplay.Current.BindTo(working.Mods);

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Timing;
using osu.Game.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
@ -23,6 +22,7 @@ namespace osu.Game.Screens.Play
private SpriteText countSpriteText;
private readonly List<KeyCounterState> states = new List<KeyCounterState>();
private KeyCounterState lastState;
public bool IsCounting { get; set; } = true;
private int countPresses;
@ -63,8 +63,6 @@ namespace osu.Game.Screens.Play
public Color4 KeyUpTextColor { get; set; } = Color4.White;
public int FadeTime { get; set; }
public IClock AudioClock { get; set; }
protected KeyCounter(string name)
{
Name = name;
@ -142,10 +140,16 @@ namespace osu.Game.Screens.Play
public void SaveState()
{
var lastState = states.LastOrDefault();
if (lastState == null || lastState.Time < Clock.CurrentTime)
states.Add(lastState = new KeyCounterState(Clock.CurrentTime, CountPresses));
}
if (lastState == null || lastState.Time < AudioClock.CurrentTime)
states.Add(new KeyCounterState(AudioClock.CurrentTime, CountPresses));
protected override void Update()
{
base.Update();
if (lastState?.Time > Clock.CurrentTime)
RestoreState(Clock.CurrentTime);
}
public void RestoreState(double time)

View File

@ -38,13 +38,7 @@ namespace osu.Game.Screens.Play
key.FadeTime = FadeTime;
key.KeyDownTextColor = KeyDownTextColor;
key.KeyUpTextColor = KeyUpTextColor;
key.AudioClock = AudioClock;
}
public void RestoreKeyCounterState(double time)
{
foreach (var counter in Children)
counter.RestoreState(time);
key.Clock = (IFrameBasedClock)AudioClock;
}
public void ResetCount()