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

Add test for disabled keycounter, don't discard change event values

This commit is contained in:
naoey 2020-03-03 06:17:25 +05:30
parent 1ce972dd5b
commit 3d344a076d
No known key found for this signature in database
GPG Key ID: 670DA9BE3DF7EE60
2 changed files with 23 additions and 19 deletions

View File

@ -47,21 +47,22 @@ namespace osu.Game.Tests.Visual.Gameplay
Key testKey = ((KeyCounterKeyboard)kc.Children.First()).Key;
AddStep($"Press {testKey} key", () =>
void addPressKeyStep()
{
InputManager.PressKey(testKey);
InputManager.ReleaseKey(testKey);
});
AddStep($"Press {testKey} key", () =>
{
InputManager.PressKey(testKey);
InputManager.ReleaseKey(testKey);
});
}
addPressKeyStep();
AddAssert($"Check {testKey} counter after keypress", () => testCounter.CountPresses == 1);
AddStep($"Press {testKey} key", () =>
{
InputManager.PressKey(testKey);
InputManager.ReleaseKey(testKey);
});
addPressKeyStep();
AddAssert($"Check {testKey} counter after keypress", () => testCounter.CountPresses == 2);
AddStep($"Disable counting", () => testCounter.IsCounting = false);
addPressKeyStep();
AddAssert($"Check {testKey} count has not changed", () => testCounter.CountPresses == 2);
Add(kc);
}

View File

@ -157,7 +157,10 @@ namespace osu.Game.Screens.Play
addGameplayComponents(GameplayClockContainer, Beatmap.Value);
addOverlayComponents(GameplayClockContainer, Beatmap.Value);
DrawableRuleset.HasReplayLoaded.BindValueChanged(_ => updatePauseOnFocusLostState(), true);
DrawableRuleset.HasReplayLoaded.BindValueChanged(e =>
{
updatePauseOnFocusLostState(e.NewValue, BreakOverlay.IsBreakTime.Value);
}, true);
// bind clock into components that require it
DrawableRuleset.IsPaused.BindTo(GameplayClockContainer.IsPaused);
@ -184,7 +187,7 @@ namespace osu.Game.Screens.Play
foreach (var mod in Mods.Value.OfType<IApplicableToHealthProcessor>())
mod.ApplyToHealthProcessor(HealthProcessor);
BreakOverlay.IsBreakTime.BindValueChanged(_ => onBreakTimeChanged(), true);
BreakOverlay.IsBreakTime.BindValueChanged(onBreakTimeChanged, true);
}
private void addUnderlayComponents(Container target)
@ -286,16 +289,16 @@ namespace osu.Game.Screens.Play
HealthProcessor.IsBreakTime.BindTo(BreakOverlay.IsBreakTime);
}
private void onBreakTimeChanged()
private void onBreakTimeChanged(ValueChangedEvent<bool> changeEvent)
{
updatePauseOnFocusLostState();
HUDOverlay.KeyCounter.IsCounting = !BreakOverlay.IsBreakTime.Value;
updatePauseOnFocusLostState(DrawableRuleset.HasReplayLoaded.Value, changeEvent.NewValue);
HUDOverlay.KeyCounter.IsCounting = !changeEvent.NewValue;
}
private void updatePauseOnFocusLostState() =>
private void updatePauseOnFocusLostState(bool replayLoaded, bool isBreakTime) =>
HUDOverlay.HoldToQuit.PauseOnFocusLost = PauseOnFocusLost
&& !DrawableRuleset.HasReplayLoaded.Value
&& !BreakOverlay.IsBreakTime.Value;
&& !replayLoaded
&& !isBreakTime;
private IBeatmap loadPlayableBeatmap()
{