1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00

Save KeyCounter state when keypress happens

This commit is contained in:
Roman Kapustin 2018-07-22 17:35:42 +03:00
parent 72959691e9
commit 0632c59e60
2 changed files with 12 additions and 0 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -15,6 +16,8 @@ namespace osu.Game.Screens.Play
{
public abstract class KeyCounter : Container
{
public event Action KeyPressed;
private Sprite buttonSprite;
private Sprite glowSprite;
private Container textLayer;
@ -46,7 +49,10 @@ namespace osu.Game.Screens.Play
isLit = value;
updateGlowSprite(value);
if (value && IsCounting)
{
CountPresses++;
KeyPressed?.Invoke();
}
}
}
}

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
@ -22,6 +23,8 @@ 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>>();
public KeyCounterCollection()
{
Direction = FillDirection.Horizontal;
@ -38,6 +41,9 @@ namespace osu.Game.Screens.Play
key.KeyDownTextColor = KeyDownTextColor;
key.KeyUpTextColor = KeyUpTextColor;
key.AudioClock = AudioClock;
keyCountersState.Add(key.Name, new List<KeyCounterMemento>());
key.KeyPressed += () => keyCountersState[key.Name].Add(key.SaveState());
}
public void ResetCount()