1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 00:12:59 +08:00

Introduce KeyCounterMemento

This commit is contained in:
Roman Kapustin 2018-07-22 17:16:17 +03:00
parent 1796ffde14
commit 72959691e9
4 changed files with 32 additions and 4 deletions

View File

@ -79,7 +79,7 @@ namespace osu.Game.Screens.Play
BindRulesetContainer(rulesetContainer);
Progress.Objects = rulesetContainer.Objects;
Progress.AudioClock = offsetClock;
Progress.AudioClock = KeyCounter.AudioClock = offsetClock;
Progress.AllowSeeking = rulesetContainer.HasReplayLoaded;
Progress.OnSeek = pos => adjustableClock.Seek(pos);

View File

@ -6,6 +6,7 @@ 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;
@ -55,6 +56,8 @@ 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;
@ -129,5 +132,9 @@ namespace osu.Game.Screens.Play
}
public void ResetCount() => CountPresses = 0;
public KeyCounterMemento SaveState() => new KeyCounterMemento(AudioClock.CurrentTime, CountPresses);
public void RestoreState(KeyCounterMemento memento) => CountPresses = memento.CountPresses;
}
}

View File

@ -3,14 +3,15 @@
using System;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using OpenTK.Graphics;
using osu.Framework.Input;
using osu.Framework.Configuration;
using osu.Framework.Allocation;
using osu.Framework.Timing;
using osu.Game.Configuration;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Screens.Play
{
@ -36,6 +37,7 @@ namespace osu.Game.Screens.Play
key.FadeTime = FadeTime;
key.KeyDownTextColor = KeyDownTextColor;
key.KeyUpTextColor = KeyUpTextColor;
key.AudioClock = AudioClock;
}
public void ResetCount()
@ -117,6 +119,8 @@ namespace osu.Game.Screens.Play
public override bool HandleKeyboardInput => receptor == null;
public override bool HandleMouseInput => receptor == null;
public IClock AudioClock { get; set; }
private Receptor receptor;
public Receptor GetReceptor()

View File

@ -0,0 +1,17 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Screens.Play
{
public class KeyCounterMemento
{
public KeyCounterMemento(double currentTime, int countPresses)
{
CurrentTime = currentTime;
CountPresses = countPresses;
}
public double CurrentTime { get; }
public int CountPresses { get; }
}
}