Rename Memento class

This commit is contained in:
Roman Kapustin 2018-07-22 23:13:06 +03:00
parent d387048057
commit ecd51d70f9
4 changed files with 22 additions and 22 deletions

View File

@ -139,8 +139,8 @@ private void updateGlowSprite(bool show)
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;
}
}

View File

@ -24,7 +24,7 @@ public class KeyCounterCollection : FillFlowContainer<KeyCounter>
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 @@ public override void Add(KeyCounter key)
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 @@ public void RestoreKeyCounterState(double time)
{
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);
}
}

View File

@ -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; }
}
}

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 KeyCounterState
{
public KeyCounterState(double time, int count)
{
Time = time;
Count = count;
}
public readonly double Time;
public readonly int Count;
}
}