1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 04:13:11 +08:00

Merge pull request #4130 from peppy/fix-key-counter

Fix key counter not counting
This commit is contained in:
Dean Herbert 2019-01-23 18:38:02 +09:00 committed by GitHub
commit f6fbb77ecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 22 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using osu.Game.Rulesets; using osu.Game.Rulesets;
@ -23,11 +24,17 @@ namespace osu.Game.Tests.Visual
}; };
} }
protected override bool ContinueCondition(Player player) => base.ContinueCondition(player) && ((ScoreAccessiblePlayer)player).ScoreProcessor.TotalScore > 0; protected override void AddCheckSteps(Func<Player> player)
{
base.AddCheckSteps(player);
AddUntilStep(() => ((ScoreAccessiblePlayer)player()).ScoreProcessor.TotalScore > 0, "score above zero");
AddUntilStep(() => ((ScoreAccessiblePlayer)player()).HUDOverlay.KeyCounter.Children.Any(kc => kc.CountPresses > 0), "key counter counted keys");
}
private class ScoreAccessiblePlayer : Player private class ScoreAccessiblePlayer : Player
{ {
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor; public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
public new HUDOverlay HUDOverlay => base.HUDOverlay;
} }
} }
} }

View File

@ -250,14 +250,14 @@ namespace osu.Game.Rulesets.UI
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config) private void load(OsuConfigManager config)
{ {
KeyBindingInputManager.Children = new Drawable[] KeyBindingInputManager.AddRange(new Drawable[]
{ {
content = new Container content = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
Playfield Playfield
}; });
if (Cursor != null) if (Cursor != null)
KeyBindingInputManager.Add(Cursor); KeyBindingInputManager.Add(Cursor);

View File

@ -27,14 +27,6 @@ namespace osu.Game.Rulesets.UI
public abstract class RulesetInputManager<T> : PassThroughInputManager, ICanAttachKeyCounter, IHasReplayHandler public abstract class RulesetInputManager<T> : PassThroughInputManager, ICanAttachKeyCounter, IHasReplayHandler
where T : struct where T : struct
{ {
public class RulesetKeyBindingContainer : DatabasedKeyBindingContainer<T>
{
public RulesetKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
: base(ruleset, variant, unique)
{
}
}
protected override InputState CreateInitialState() protected override InputState CreateInitialState()
{ {
var state = base.CreateInitialState(); var state = base.CreateInitialState();
@ -251,6 +243,14 @@ namespace osu.Game.Rulesets.UI
protected virtual RulesetKeyBindingContainer CreateKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique) protected virtual RulesetKeyBindingContainer CreateKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
=> new RulesetKeyBindingContainer(ruleset, variant, unique); => new RulesetKeyBindingContainer(ruleset, variant, unique);
public class RulesetKeyBindingContainer : DatabasedKeyBindingContainer<T>
{
public RulesetKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique)
: base(ruleset, variant, unique)
{
}
}
} }
/// <summary> /// <summary>

View File

@ -46,17 +46,21 @@ namespace osu.Game.Screens.Play
Children = new Drawable[] Children = new Drawable[]
{ {
visibilityContainer = new Container { visibilityContainer = new Container
{
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] { Children = new Drawable[]
new Container { {
new Container
{
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
Y = 30, Y = 30,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
AutoSizeDuration = 200, AutoSizeDuration = 200,
AutoSizeEasing = Easing.Out, AutoSizeEasing = Easing.Out,
Children = new Drawable[] { Children = new Drawable[]
{
AccuracyCounter = CreateAccuracyCounter(), AccuracyCounter = CreateAccuracyCounter(),
ScoreCounter = CreateScoreCounter(), ScoreCounter = CreateScoreCounter(),
ComboCounter = CreateComboCounter(), ComboCounter = CreateComboCounter(),

View File

@ -83,7 +83,7 @@ namespace osu.Game.Screens.Play
protected ScoreProcessor ScoreProcessor; protected ScoreProcessor ScoreProcessor;
protected RulesetContainer RulesetContainer; protected RulesetContainer RulesetContainer;
private HUDOverlay hudOverlay; protected HUDOverlay HUDOverlay;
private FailOverlay failOverlay; private FailOverlay failOverlay;
private DrawableStoryboard storyboard; private DrawableStoryboard storyboard;
@ -200,7 +200,7 @@ namespace osu.Game.Screens.Play
{ {
Child = RulesetContainer.Cursor?.CreateProxy() ?? new Container(), Child = RulesetContainer.Cursor?.CreateProxy() ?? new Container(),
}, },
hudOverlay = new HUDOverlay(ScoreProcessor, RulesetContainer, working, offsetClock, adjustableClock) HUDOverlay = new HUDOverlay(ScoreProcessor, RulesetContainer, working, offsetClock, adjustableClock)
{ {
Clock = Clock, // hud overlay doesn't want to use the audio clock directly Clock = Clock, // hud overlay doesn't want to use the audio clock directly
ProcessCustomClock = false, ProcessCustomClock = false,
@ -233,8 +233,8 @@ namespace osu.Game.Screens.Play
} }
}; };
hudOverlay.HoldToQuit.Action = performUserRequestedExit; HUDOverlay.HoldToQuit.Action = performUserRequestedExit;
hudOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded); HUDOverlay.KeyCounter.Visible.BindTo(RulesetContainer.HasReplayLoaded);
RulesetContainer.IsPaused.BindTo(pauseContainer.IsPaused); RulesetContainer.IsPaused.BindTo(pauseContainer.IsPaused);

View File

@ -44,7 +44,7 @@ namespace osu.Game.Tests.Visual
{ {
Player p = null; Player p = null;
AddStep(ruleset.RulesetInfo.Name, () => p = loadPlayerFor(ruleset)); AddStep(ruleset.RulesetInfo.Name, () => p = loadPlayerFor(ruleset));
AddUntilStep(() => ContinueCondition(p)); AddCheckSteps(() => p);
} }
else else
{ {
@ -52,7 +52,7 @@ namespace osu.Game.Tests.Visual
{ {
Player p = null; Player p = null;
AddStep(r.Name, () => p = loadPlayerFor(r)); AddStep(r.Name, () => p = loadPlayerFor(r));
AddUntilStep(() => ContinueCondition(p)); AddCheckSteps(() => p);
AddUntilStep(() => AddUntilStep(() =>
{ {
@ -79,7 +79,10 @@ namespace osu.Game.Tests.Visual
} }
} }
protected virtual bool ContinueCondition(Player player) => player.IsLoaded; protected virtual void AddCheckSteps(Func<Player> player)
{
AddUntilStep(() => player().IsLoaded, "player loaded");
}
protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo); protected virtual IBeatmap CreateBeatmap(Ruleset ruleset) => new TestBeatmap(ruleset.RulesetInfo);