mirror of
https://github.com/ppy/osu.git
synced 2025-02-06 08:12:55 +08:00
Call KeyCounter.RestoreState itself
This commit is contained in:
parent
e7591a9214
commit
1e6220e3c0
@ -82,11 +82,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Progress.Objects = rulesetContainer.Objects;
|
Progress.Objects = rulesetContainer.Objects;
|
||||||
Progress.AudioClock = offsetClock;
|
Progress.AudioClock = offsetClock;
|
||||||
Progress.AllowSeeking = rulesetContainer.HasReplayLoaded;
|
Progress.AllowSeeking = rulesetContainer.HasReplayLoaded;
|
||||||
Progress.OnSeek = pos =>
|
Progress.OnSeek = pos => adjustableClock.Seek(pos);
|
||||||
{
|
|
||||||
adjustableClock.Seek(pos);
|
|
||||||
KeyCounter.RestoreKeyCounterState(pos);
|
|
||||||
};
|
|
||||||
|
|
||||||
ModDisplay.Current.BindTo(working.Mods);
|
ModDisplay.Current.BindTo(working.Mods);
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
using osu.Framework.Timing;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
@ -23,6 +22,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private SpriteText countSpriteText;
|
private SpriteText countSpriteText;
|
||||||
|
|
||||||
private readonly List<KeyCounterState> states = new List<KeyCounterState>();
|
private readonly List<KeyCounterState> states = new List<KeyCounterState>();
|
||||||
|
private KeyCounterState lastState;
|
||||||
|
|
||||||
public bool IsCounting { get; set; } = true;
|
public bool IsCounting { get; set; } = true;
|
||||||
private int countPresses;
|
private int countPresses;
|
||||||
@ -63,8 +63,6 @@ namespace osu.Game.Screens.Play
|
|||||||
public Color4 KeyUpTextColor { get; set; } = Color4.White;
|
public Color4 KeyUpTextColor { get; set; } = Color4.White;
|
||||||
public int FadeTime { get; set; }
|
public int FadeTime { get; set; }
|
||||||
|
|
||||||
public IClock AudioClock { get; set; }
|
|
||||||
|
|
||||||
protected KeyCounter(string name)
|
protected KeyCounter(string name)
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
@ -142,10 +140,16 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public void SaveState()
|
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)
|
protected override void Update()
|
||||||
states.Add(new KeyCounterState(AudioClock.CurrentTime, CountPresses));
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (lastState?.Time > Clock.CurrentTime)
|
||||||
|
RestoreState(Clock.CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RestoreState(double time)
|
public void RestoreState(double time)
|
||||||
|
@ -38,13 +38,7 @@ namespace osu.Game.Screens.Play
|
|||||||
key.FadeTime = FadeTime;
|
key.FadeTime = FadeTime;
|
||||||
key.KeyDownTextColor = KeyDownTextColor;
|
key.KeyDownTextColor = KeyDownTextColor;
|
||||||
key.KeyUpTextColor = KeyUpTextColor;
|
key.KeyUpTextColor = KeyUpTextColor;
|
||||||
key.AudioClock = AudioClock;
|
key.Clock = (IFrameBasedClock)AudioClock;
|
||||||
}
|
|
||||||
|
|
||||||
public void RestoreKeyCounterState(double time)
|
|
||||||
{
|
|
||||||
foreach (var counter in Children)
|
|
||||||
counter.RestoreState(time);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetCount()
|
public void ResetCount()
|
||||||
|
Loading…
Reference in New Issue
Block a user