mirror of
https://github.com/ppy/osu.git
synced 2025-03-11 07:17:18 +08:00
Fix broken input handling with structural changes
This commit is contained in:
parent
e1d6ce5ff4
commit
78cd093a47
@ -9,7 +9,6 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
@ -64,16 +63,6 @@ namespace osu.Game.Screens.SelectV2
|
||||
[Resolved]
|
||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; } = null!;
|
||||
|
||||
protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos)
|
||||
{
|
||||
var inputRectangle = panel.TopLevelContent.DrawRectangle;
|
||||
|
||||
// Cover the gaps introduced by the spacing between BeatmapPanels.
|
||||
inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapCarousel.SPACING / 2f });
|
||||
|
||||
return inputRectangle.Contains(panel.TopLevelContent.ToLocalSpace(screenSpacePos));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
@ -86,6 +75,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
InternalChild = panel = new CarouselPanelPiece(difficulty_x_offset)
|
||||
{
|
||||
Action = onAction,
|
||||
Icon = difficultyIcon = new ConstrainedIconContainer
|
||||
{
|
||||
Size = new Vector2(20),
|
||||
@ -261,19 +251,15 @@ namespace osu.Game.Screens.SelectV2
|
||||
panel.AccentColour = starRatingColour;
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
private void onAction()
|
||||
{
|
||||
if (carousel == null)
|
||||
return true;
|
||||
return;
|
||||
|
||||
if (carousel.CurrentSelection != Item!.Model)
|
||||
{
|
||||
carousel.CurrentSelection = Item!.Model;
|
||||
return true;
|
||||
}
|
||||
|
||||
carousel.TryActivateSelection();
|
||||
return true;
|
||||
else
|
||||
carousel.TryActivateSelection();
|
||||
}
|
||||
|
||||
#region ICarouselPanel
|
||||
|
@ -10,7 +10,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
@ -50,16 +49,6 @@ namespace osu.Game.Screens.SelectV2
|
||||
[Resolved]
|
||||
private BeatmapManager beatmaps { get; set; } = null!;
|
||||
|
||||
protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos)
|
||||
{
|
||||
var inputRectangle = panel.TopLevelContent.DrawRectangle;
|
||||
|
||||
// Cover a gap introduced by the spacing between a BeatmapSetPanel and a BeatmapPanel either above it or below it.
|
||||
inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapCarousel.SPACING / 2f });
|
||||
|
||||
return inputRectangle.Contains(panel.TopLevelContent.ToLocalSpace(screenSpacePos));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -70,6 +59,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
InternalChild = panel = new CarouselPanelPiece(set_x_offset)
|
||||
{
|
||||
Action = onAction,
|
||||
Icon = chevronIcon = new Container
|
||||
{
|
||||
Size = new Vector2(22),
|
||||
@ -183,12 +173,10 @@ namespace osu.Game.Screens.SelectV2
|
||||
difficultiesDisplay.BeatmapSet = null;
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
private void onAction()
|
||||
{
|
||||
if (carousel != null)
|
||||
carousel.CurrentSelection = Item!.Model;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#region ICarouselPanel
|
||||
|
@ -11,7 +11,6 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
@ -76,16 +75,6 @@ namespace osu.Game.Screens.SelectV2
|
||||
private OsuSpriteText difficultyName = null!;
|
||||
private OsuSpriteText difficultyAuthor = null!;
|
||||
|
||||
protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos)
|
||||
{
|
||||
var inputRectangle = panel.TopLevelContent.DrawRectangle;
|
||||
|
||||
// Cover a gap introduced by the spacing between a BeatmapSetPanel and a BeatmapPanel either above it or below it.
|
||||
inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapCarousel.SPACING / 2f });
|
||||
|
||||
return inputRectangle.Contains(panel.TopLevelContent.ToLocalSpace(screenSpacePos));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -97,6 +86,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
InternalChild = panel = new CarouselPanelPiece(standalone_x_offset)
|
||||
{
|
||||
Action = onAction,
|
||||
Icon = difficultyIcon = new ConstrainedIconContainer
|
||||
{
|
||||
Size = new Vector2(20),
|
||||
@ -304,12 +294,15 @@ namespace osu.Game.Screens.SelectV2
|
||||
difficultyStarRating.Current.Value = starDifficulty;
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
private void onAction()
|
||||
{
|
||||
if (carousel != null)
|
||||
carousel.CurrentSelection = Item!.Model;
|
||||
if (carousel == null)
|
||||
return;
|
||||
|
||||
return true;
|
||||
if (carousel.CurrentSelection != Item!.Model)
|
||||
carousel.CurrentSelection = Item!.Model;
|
||||
else
|
||||
carousel.TryActivateSelection();
|
||||
}
|
||||
|
||||
#region ICarouselPanel
|
||||
|
@ -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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
@ -69,6 +70,18 @@ namespace osu.Game.Screens.SelectV2
|
||||
public readonly BindableBool Active = new BindableBool();
|
||||
public readonly BindableBool KeyboardActive = new BindableBool();
|
||||
|
||||
public Action? Action;
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
|
||||
{
|
||||
var inputRectangle = TopLevelContent.DrawRectangle;
|
||||
|
||||
// Cover potential gaps introduced by the spacing between panels.
|
||||
inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapCarousel.SPACING / 2f });
|
||||
|
||||
return inputRectangle.Contains(TopLevelContent.ToLocalSpace(screenSpacePos));
|
||||
}
|
||||
|
||||
public CarouselPanelPiece(float panelXOffset)
|
||||
{
|
||||
this.panelXOffset = panelXOffset;
|
||||
@ -221,7 +234,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
updateDisplay();
|
||||
return base.OnHover(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
@ -230,6 +243,12 @@ namespace osu.Game.Screens.SelectV2
|
||||
base.OnHoverLost(e);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
Action?.Invoke();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
@ -33,16 +32,6 @@ namespace osu.Game.Screens.SelectV2
|
||||
private Drawable chevronIcon = null!;
|
||||
private OsuSpriteText titleText = null!;
|
||||
|
||||
protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos)
|
||||
{
|
||||
var inputRectangle = panel.TopLevelContent.DrawRectangle;
|
||||
|
||||
// Cover a gap introduced by the spacing between a GroupPanel and other panel types either below/above it.
|
||||
inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapCarousel.SPACING / 2f });
|
||||
|
||||
return inputRectangle.Contains(panel.TopLevelContent.ToLocalSpace(screenSpacePos));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
@ -53,6 +42,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
InternalChild = panel = new CarouselPanelPiece(0)
|
||||
{
|
||||
Action = onAction,
|
||||
Icon = chevronIcon = new SpriteIcon
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
@ -136,12 +126,10 @@ namespace osu.Game.Screens.SelectV2
|
||||
this.FadeInFromZero(500, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
private void onAction()
|
||||
{
|
||||
if (carousel != null)
|
||||
carousel.CurrentSelection = Item!.Model;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#region ICarouselPanel
|
||||
|
@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics;
|
||||
@ -44,16 +43,6 @@ namespace osu.Game.Screens.SelectV2
|
||||
private StarRatingDisplay starRatingDisplay = null!;
|
||||
private StarCounter starCounter = null!;
|
||||
|
||||
protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos)
|
||||
{
|
||||
var inputRectangle = panel.TopLevelContent.DrawRectangle;
|
||||
|
||||
// Cover a gap introduced by the spacing between a GroupPanel and other panel types either below/above it.
|
||||
inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapCarousel.SPACING / 2f });
|
||||
|
||||
return inputRectangle.Contains(panel.TopLevelContent.ToLocalSpace(screenSpacePos));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -64,6 +53,7 @@ namespace osu.Game.Screens.SelectV2
|
||||
|
||||
InternalChild = panel = new CarouselPanelPiece(0)
|
||||
{
|
||||
Action = onAction,
|
||||
Icon = chevronIcon = new SpriteIcon
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
@ -171,12 +161,10 @@ namespace osu.Game.Screens.SelectV2
|
||||
this.FadeInFromZero(500, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
private void onAction()
|
||||
{
|
||||
if (carousel != null)
|
||||
carousel.CurrentSelection = Item!.Model;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#region ICarouselPanel
|
||||
|
Loading…
x
Reference in New Issue
Block a user