mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +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 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);
|
||||
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()
|
||||
{
|
||||
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play
|
||||
key.KeyUpTextColor = KeyUpTextColor;
|
||||
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());
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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