Restore keycounter state on replay seek

This commit is contained in:
Roman Kapustin 2018-07-22 19:42:18 +03:00
parent 1d9bf42082
commit 7f3ad37ede
2 changed files with 15 additions and 2 deletions

View File

@ -68,7 +68,7 @@ namespace osu.Game.Screens.Play
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
KeyCounter = CreateKeyCounter(offsetClock),
KeyCounter = CreateKeyCounter(adjustableClock),
HoldToQuit = CreateQuitButton(),
}
}
@ -81,7 +81,11 @@ namespace osu.Game.Screens.Play
Progress.Objects = rulesetContainer.Objects;
Progress.AudioClock = offsetClock;
Progress.AllowSeeking = rulesetContainer.HasReplayLoaded;
Progress.OnSeek = pos => adjustableClock.Seek(pos);
Progress.OnSeek = pos =>
{
adjustableClock.Seek(pos);
KeyCounter.RestoreKeyCounterState(pos);
};
ModDisplay.Current.BindTo(working.Mods);

View File

@ -46,6 +46,15 @@ namespace osu.Game.Screens.Play
key.KeyPressed += () => keyCountersState[key.Name].Add(key.SaveState());
}
public void RestoreKeyCounterState(double time)
{
foreach (var counter in Children)
{
var targetState = keyCountersState[counter.Name].LastOrDefault(state => state.CurrentTime <= time);
counter.RestoreState(targetState);
}
}
public void ResetCount()
{
foreach (var counter in Children)