From ecd51d70f991bd204728c3a392ab4217c79af094 Mon Sep 17 00:00:00 2001 From: Roman Kapustin Date: Sun, 22 Jul 2018 23:13:06 +0300 Subject: [PATCH] Rename Memento class --- osu.Game/Screens/Play/KeyCounter.cs | 4 ++-- osu.Game/Screens/Play/KeyCounterCollection.cs | 6 +++--- osu.Game/Screens/Play/KeyCounterMemento.cs | 17 ----------------- osu.Game/Screens/Play/KeyCounterState.cs | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 osu.Game/Screens/Play/KeyCounterMemento.cs create mode 100644 osu.Game/Screens/Play/KeyCounterState.cs diff --git a/osu.Game/Screens/Play/KeyCounter.cs b/osu.Game/Screens/Play/KeyCounter.cs index 99685c238f..7e9c04110c 100644 --- a/osu.Game/Screens/Play/KeyCounter.cs +++ b/osu.Game/Screens/Play/KeyCounter.cs @@ -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; } } diff --git a/osu.Game/Screens/Play/KeyCounterCollection.cs b/osu.Game/Screens/Play/KeyCounterCollection.cs index 8978181ce4..cdb42ec514 100644 --- a/osu.Game/Screens/Play/KeyCounterCollection.cs +++ b/osu.Game/Screens/Play/KeyCounterCollection.cs @@ -24,7 +24,7 @@ namespace osu.Game.Screens.Play public readonly Bindable Visible = new Bindable(true); private readonly Bindable configVisibility = new Bindable(); - private readonly Dictionary> keyCountersState = new Dictionary>(); + private readonly Dictionary> keyCountersState = new Dictionary>(); public KeyCounterCollection() { @@ -43,7 +43,7 @@ namespace osu.Game.Screens.Play key.KeyUpTextColor = KeyUpTextColor; key.AudioClock = AudioClock; - keyCountersState.Add(key.Name, new List()); + keyCountersState.Add(key.Name, new List()); 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); } } diff --git a/osu.Game/Screens/Play/KeyCounterMemento.cs b/osu.Game/Screens/Play/KeyCounterMemento.cs deleted file mode 100644 index daf217cb62..0000000000 --- a/osu.Game/Screens/Play/KeyCounterMemento.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// 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; } - } -} diff --git a/osu.Game/Screens/Play/KeyCounterState.cs b/osu.Game/Screens/Play/KeyCounterState.cs new file mode 100644 index 0000000000..e5c0703319 --- /dev/null +++ b/osu.Game/Screens/Play/KeyCounterState.cs @@ -0,0 +1,17 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// 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; + } +}