1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 19:27:24 +08:00

Merge pull request #26545 from frenzibyte/fix-resume-cursor-transition-abused

Fix pop-in scale transition in resume overlay affecting input area
This commit is contained in:
Bartłomiej Dach 2024-01-15 20:06:16 +01:00 committed by GitHub
commit 71d0543213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 16 deletions

View File

@ -57,17 +57,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
InternalChild = cursorScaleContainer = new Container InternalChild = CreateCursorContent();
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Child = cursorSprite = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
}
};
userCursorScale = config.GetBindable<float>(OsuSetting.GameplayCursorSize); userCursorScale = config.GetBindable<float>(OsuSetting.GameplayCursorSize);
userCursorScale.ValueChanged += _ => cursorScale.Value = CalculateCursorScale(); userCursorScale.ValueChanged += _ => cursorScale.Value = CalculateCursorScale();
@ -84,6 +74,18 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
cursorScale.Value = CalculateCursorScale(); cursorScale.Value = CalculateCursorScale();
} }
protected virtual Drawable CreateCursorContent() => cursorScaleContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Child = cursorSprite = new SkinnableDrawable(new OsuSkinComponentLookup(OsuSkinComponents.Cursor), _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
},
};
protected virtual float CalculateCursorScale() protected virtual float CalculateCursorScale()
{ {
float scale = userCursorScale.Value; float scale = userCursorScale.Value;

View File

@ -65,17 +65,24 @@ namespace osu.Game.Rulesets.Osu.UI
public override bool HandlePositionalInput => true; public override bool HandlePositionalInput => true;
public Action ResumeRequested; public Action ResumeRequested;
private Container scaleTransitionContainer;
public OsuClickToResumeCursor() public OsuClickToResumeCursor()
{ {
RelativePositionAxes = Axes.Both; RelativePositionAxes = Axes.Both;
} }
protected override float CalculateCursorScale() protected override Container CreateCursorContent() => scaleTransitionContainer = new Container
{ {
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Child = base.CreateCursorContent(),
};
protected override float CalculateCursorScale() =>
// Force minimum cursor size so it's easily clickable // Force minimum cursor size so it's easily clickable
return Math.Max(1f, base.CalculateCursorScale()); Math.Max(1f, base.CalculateCursorScale());
}
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
@ -98,7 +105,7 @@ namespace osu.Game.Rulesets.Osu.UI
if (!IsHovered) if (!IsHovered)
return false; return false;
this.ScaleTo(2, TRANSITION_TIME, Easing.OutQuint); scaleTransitionContainer.ScaleTo(2, TRANSITION_TIME, Easing.OutQuint);
ResumeRequested?.Invoke(); ResumeRequested?.Invoke();
return true; return true;
@ -114,7 +121,10 @@ namespace osu.Game.Rulesets.Osu.UI
public void Appear() => Schedule(() => public void Appear() => Schedule(() =>
{ {
updateColour(); updateColour();
this.ScaleTo(4).Then().ScaleTo(1, 1000, Easing.OutQuint);
// importantly, we perform the scale transition on an underlying container rather than the whole cursor
// to prevent attempts of abuse by the scale change in the cursor's hitbox (see: https://github.com/ppy/osu/issues/26477).
scaleTransitionContainer.ScaleTo(4).Then().ScaleTo(1, 1000, Easing.OutQuint);
}); });
private void updateColour() private void updateColour()