mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 14:53:01 +08:00
Rename Memento class
This commit is contained in:
parent
d387048057
commit
ecd51d70f9
@ -139,8 +139,8 @@ namespace osu.Game.Screens.Play
|
|||||||
|
|
||||||
public void ResetCount() => CountPresses = 0;
|
public void ResetCount() => CountPresses = 0;
|
||||||
|
|
||||||
public KeyCounterMemento SaveState() => new KeyCounterMemento(AudioClock.CurrentTime, CountPresses);
|
public KeyCounterState SaveState() => new KeyCounterState(AudioClock.CurrentTime, CountPresses);
|
||||||
|
|
||||||
public void RestoreState(KeyCounterMemento memento) => CountPresses = memento.CountPresses;
|
public void RestoreState(KeyCounterState state) => CountPresses = state.Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Screens.Play
|
|||||||
public readonly Bindable<bool> Visible = new Bindable<bool>(true);
|
public readonly Bindable<bool> Visible = new Bindable<bool>(true);
|
||||||
private readonly Bindable<bool> configVisibility = new Bindable<bool>();
|
private readonly Bindable<bool> configVisibility = new Bindable<bool>();
|
||||||
|
|
||||||
private readonly Dictionary<string, List<KeyCounterMemento>> keyCountersState = new Dictionary<string, List<KeyCounterMemento>>();
|
private readonly Dictionary<string, List<KeyCounterState>> keyCountersState = new Dictionary<string, List<KeyCounterState>>();
|
||||||
|
|
||||||
public KeyCounterCollection()
|
public KeyCounterCollection()
|
||||||
{
|
{
|
||||||
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play
|
|||||||
key.KeyUpTextColor = KeyUpTextColor;
|
key.KeyUpTextColor = KeyUpTextColor;
|
||||||
key.AudioClock = AudioClock;
|
key.AudioClock = AudioClock;
|
||||||
|
|
||||||
keyCountersState.Add(key.Name, new List<KeyCounterMemento>());
|
keyCountersState.Add(key.Name, new List<KeyCounterState>());
|
||||||
key.KeyPressed += () => keyCountersState[key.Name].Add(key.SaveState());
|
key.KeyPressed += () => keyCountersState[key.Name].Add(key.SaveState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
foreach (var counter in Children)
|
foreach (var counter in Children)
|
||||||
{
|
{
|
||||||
var targetState = keyCountersState[counter.Name].LastOrDefault(state => state.CurrentTime <= time);
|
var targetState = keyCountersState[counter.Name].LastOrDefault(state => state.Time <= time);
|
||||||
counter.RestoreState(targetState);
|
counter.RestoreState(targetState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
// 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; }
|
|
||||||
}
|
|
||||||
}
|
|
17
osu.Game/Screens/Play/KeyCounterState.cs
Normal file
17
osu.Game/Screens/Play/KeyCounterState.cs
Normal 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 KeyCounterState
|
||||||
|
{
|
||||||
|
public KeyCounterState(double time, int count)
|
||||||
|
{
|
||||||
|
Time = time;
|
||||||
|
Count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly double Time;
|
||||||
|
public readonly int Count;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user