Merge branch 'master' into muted-notification

This commit is contained in:
Craftplacer
2019-09-23 01:59:37 +02:00
committed by GitHub
101 changed files with 1809 additions and 406 deletions

View File

@ -42,5 +42,7 @@ namespace osu.Game.Screens.Play
public double FramesPerSecond => underlyingClock.FramesPerSecond;
public FrameTimeInfo TimeInfo => underlyingClock.TimeInfo;
public IClock Source => underlyingClock;
}
}

View File

@ -231,7 +231,6 @@ namespace osu.Game.Screens.Play
protected virtual KeyCounterDisplay CreateKeyCounter() => new KeyCounterDisplay
{
FadeTime = 50,
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Margin = new MarginPadding(10),

View File

@ -1,8 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -22,9 +20,6 @@ namespace osu.Game.Screens.Play
private Container textLayer;
private SpriteText countSpriteText;
private readonly List<KeyCounterState> states = new List<KeyCounterState>();
private KeyCounterState currentState;
public bool IsCounting { get; set; } = true;
private int countPresses;
@ -52,20 +47,30 @@ namespace osu.Game.Screens.Play
{
isLit = value;
updateGlowSprite(value);
if (value && IsCounting)
{
CountPresses++;
saveState();
}
}
}
}
public void Increment()
{
if (!IsCounting)
return;
CountPresses++;
}
public void Decrement()
{
if (!IsCounting)
return;
CountPresses--;
}
//further: change default values here and in KeyCounterCollection if needed, instead of passing them in every constructor
public Color4 KeyDownTextColor { get; set; } = Color4.DarkGray;
public Color4 KeyUpTextColor { get; set; } = Color4.White;
public int FadeTime { get; set; }
public double FadeTime { get; set; }
protected KeyCounter(string name)
{
@ -73,11 +78,8 @@ namespace osu.Game.Screens.Play
}
[BackgroundDependencyLoader(true)]
private void load(TextureStore textures, GameplayClock clock)
private void load(TextureStore textures)
{
if (clock != null)
Clock = clock;
Children = new Drawable[]
{
buttonSprite = new Sprite
@ -132,42 +134,16 @@ namespace osu.Game.Screens.Play
{
if (show)
{
glowSprite.FadeIn(FadeTime);
textLayer.FadeColour(KeyDownTextColor, FadeTime);
double remainingFadeTime = FadeTime * (1 - glowSprite.Alpha);
glowSprite.FadeIn(remainingFadeTime, Easing.OutQuint);
textLayer.FadeColour(KeyDownTextColor, remainingFadeTime, Easing.OutQuint);
}
else
{
glowSprite.FadeOut(FadeTime);
textLayer.FadeColour(KeyUpTextColor, FadeTime);
double remainingFadeTime = 8 * FadeTime * glowSprite.Alpha;
glowSprite.FadeOut(remainingFadeTime, Easing.OutQuint);
textLayer.FadeColour(KeyUpTextColor, remainingFadeTime, Easing.OutQuint);
}
}
public void ResetCount()
{
CountPresses = 0;
states.Clear();
}
protected override void Update()
{
base.Update();
if (currentState?.Time > Clock.CurrentTime)
restoreStateTo(Clock.CurrentTime);
}
private void saveState()
{
if (currentState == null || currentState.Time < Clock.CurrentTime)
states.Add(currentState = new KeyCounterState(Clock.CurrentTime, CountPresses));
}
private void restoreStateTo(double time)
{
states.RemoveAll(state => state.Time > time);
currentState = states.LastOrDefault();
CountPresses = currentState?.Count ?? 0;
}
}
}

View File

@ -1,11 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Input.Bindings;
namespace osu.Game.Screens.Play
{
public class KeyCounterAction<T> : KeyCounter, IKeyBindingHandler<T>
public class KeyCounterAction<T> : KeyCounter
where T : struct
{
public T Action { get; }
@ -16,15 +14,25 @@ namespace osu.Game.Screens.Play
Action = action;
}
public bool OnPressed(T action)
public bool OnPressed(T action, bool forwards)
{
if (action.Equals(Action)) IsLit = true;
if (!action.Equals(Action))
return false;
IsLit = true;
if (forwards)
Increment();
return false;
}
public bool OnReleased(T action)
public bool OnReleased(T action, bool forwards)
{
if (action.Equals(Action)) IsLit = false;
if (!action.Equals(Action))
return false;
IsLit = false;
if (!forwards)
Decrement();
return false;
}
}

View File

@ -17,6 +17,7 @@ namespace osu.Game.Screens.Play
public class KeyCounterDisplay : FillFlowContainer<KeyCounter>
{
private const int duration = 100;
private const double key_fade_time = 80;
public readonly Bindable<bool> Visible = new Bindable<bool>(true);
private readonly Bindable<bool> configVisibility = new Bindable<bool>();
@ -33,17 +34,11 @@ namespace osu.Game.Screens.Play
base.Add(key);
key.IsCounting = IsCounting;
key.FadeTime = FadeTime;
key.FadeTime = key_fade_time;
key.KeyDownTextColor = KeyDownTextColor;
key.KeyUpTextColor = KeyUpTextColor;
}
public void ResetCount()
{
foreach (var counter in Children)
counter.ResetCount();
}
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
@ -68,22 +63,6 @@ namespace osu.Game.Screens.Play
}
}
private int fadeTime;
public int FadeTime
{
get => fadeTime;
set
{
if (value != fadeTime)
{
fadeTime = value;
foreach (var child in Children)
child.FadeTime = value;
}
}
}
private Color4 keyDownTextColor = Color4.DarkGray;
public Color4 KeyDownTextColor
@ -123,11 +102,6 @@ namespace osu.Game.Screens.Play
private Receptor receptor;
public Receptor GetReceptor()
{
return receptor ?? (receptor = new Receptor(this));
}
public void SetReceptor(Receptor receptor)
{
if (this.receptor != null)

View File

@ -18,7 +18,12 @@ namespace osu.Game.Screens.Play
protected override bool OnKeyDown(KeyDownEvent e)
{
if (e.Key == Key) IsLit = true;
if (e.Key == Key)
{
IsLit = true;
Increment();
}
return base.OnKeyDown(e);
}

View File

@ -36,7 +36,12 @@ namespace osu.Game.Screens.Play
protected override bool OnMouseDown(MouseDownEvent e)
{
if (e.Button == Button) IsLit = true;
if (e.Button == Button)
{
IsLit = true;
Increment();
}
return base.OnMouseDown(e);
}

View File

@ -86,6 +86,12 @@ namespace osu.Game.Screens.Play
[Cached(Type = typeof(IBindable<IReadOnlyList<Mod>>))]
protected new readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
/// <summary>
/// Whether failing should be allowed.
/// By default, this checks whether all selected mods allow failing.
/// </summary>
protected virtual bool AllowFail => Mods.Value.OfType<IApplicableFailOverride>().All(m => m.AllowFail);
private readonly bool allowPause;
private readonly bool showResults;
@ -360,7 +366,7 @@ namespace osu.Game.Screens.Play
private bool onFail()
{
if (Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))
if (!AllowFail)
return false;
HasFailed = true;
@ -372,6 +378,10 @@ namespace osu.Game.Screens.Play
PauseOverlay.Hide();
failAnimation.Start();
if (Mods.Value.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
Restart();
return true;
}

View File

@ -9,6 +9,9 @@ namespace osu.Game.Screens.Play
{
private readonly Score score;
// Disallow replays from failing. (see https://github.com/ppy/osu/issues/6108)
protected override bool AllowFail => false;
public ReplayPlayer(Score score, bool allowPause = true, bool showResults = true)
: base(allowPause, showResults)
{

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.MathUtils;
using osu.Framework.Threading;
namespace osu.Game.Screens.Play
{
@ -121,6 +122,12 @@ namespace osu.Game.Screens.Play
handleBase.X = newX;
}
protected override void OnUserChange(double value) => OnSeek?.Invoke(value);
private ScheduledDelegate scheduledSeek;
protected override void OnUserChange(double value)
{
scheduledSeek?.Cancel();
scheduledSeek = Schedule(() => OnSeek?.Invoke(value));
}
}
}