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

Slider press fix

This commit is contained in:
Dean Herbert 2019-01-21 10:57:14 +09:00
parent 89a05c086c
commit 7566fcf536
4 changed files with 39 additions and 7 deletions

View File

@ -28,6 +28,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
private readonly IBindable<float> scaleBindable = new Bindable<float>();
public OsuAction? HitAction => circle.HitAction;
private readonly Container explodeContainer;
private readonly Container scaleContainer;
@ -150,6 +152,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
Expire(true);
circle.HitAction = null;
// override lifetime end as FadeIn may have been changed externally, causing out expiration to be too early.
LifetimeEnd = HitObject.StartTime + HitObject.HitWindows.HalfWindowFor(HitResult.Miss);
break;

View File

@ -53,6 +53,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
repeatPoints = new Container<DrawableRepeatPoint> { RelativeSizeAxes = Axes.Both },
Ball = new SliderBall(s, this)
{
GetInitialHitAction = () => HeadCircle.HitAction,
BypassAutoSizeAxes = Axes.Both,
Scale = new Vector2(s.Scale),
AlwaysPresent = true,

View File

@ -17,6 +17,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
public Func<bool> Hit;
public OsuAction? HitAction;
public CirclePiece()
{
Size = new Vector2((float)OsuHitObject.OBJECT_RADIUS * 2);
@ -35,7 +37,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
case OsuAction.LeftButton:
case OsuAction.RightButton:
return IsHovered && (Hit?.Invoke() ?? false);
if (IsHovered && (Hit?.Invoke() ?? false))
{
HitAction = action;
return true;
}
break;
}
return false;

View File

@ -1,6 +1,7 @@
// 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;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -19,6 +20,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
private Color4 accentColour = Color4.Black;
public Func<OsuAction?> GetInitialHitAction;
/// <summary>
/// The colour that is used for the slider ball.
/// </summary>
@ -145,19 +148,35 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
}
}
private bool canCurrentlyTrack => Time.Current >= slider.StartTime && Time.Current < slider.EndTime;
private bool canCurrentlyTrack => Time.Current >= slider.StartTime && Time.Current < slider.EndTime && lastScreenSpaceMousePosition.HasValue && base.ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value);
/// <summary>
/// The point in time up to which we need to include the key which was used to press the head circle in tracking conditions.
/// </summary>
private double? initialHitConditionDismissed;
protected override void Update()
{
base.Update();
if (Time.Current < slider.EndTime)
var initialHitAction = GetInitialHitAction();
if (initialHitAction == null)
initialHitConditionDismissed = null;
if (canCurrentlyTrack)
{
var pressed = drawableSlider?.OsuActionInputManager?.PressedActions;
if (initialHitConditionDismissed == null && !pressed.Contains(initialHitAction == OsuAction.RightButton ? OsuAction.LeftButton : OsuAction.RightButton))
initialHitConditionDismissed = Time.Current;
// Make sure to use the base version of ReceivePositionalInputAt so that we correctly check the position.
Tracking = canCurrentlyTrack
&& lastScreenSpaceMousePosition.HasValue
&& ReceivePositionalInputAt(lastScreenSpaceMousePosition.Value)
&& (drawableSlider?.OsuActionInputManager?.PressedActions.Any(x => x == OsuAction.LeftButton || x == OsuAction.RightButton) ?? false);
Tracking = drawableSlider?.OsuActionInputManager?.PressedActions.Any(x => !initialHitConditionDismissed.HasValue || initialHitConditionDismissed.Value < Time.Current ? x == OsuAction.LeftButton || x == OsuAction.RightButton : x == initialHitAction) ?? false;
}
else
{
Tracking = false;
}
}