mirror of
https://github.com/ppy/osu.git
synced 2026-05-20 01:19:52 +08:00
Fix hovering left area in song select not always activating reset action
This commit is contained in:
@@ -16,6 +16,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Logging;
|
||||
@@ -1137,6 +1138,10 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
private readonly Action? resetCarouselPosition;
|
||||
|
||||
private bool mouseContained;
|
||||
|
||||
private InputManager inputManager = null!;
|
||||
|
||||
public LeftSideInteractionContainer(Action resetCarouselPosition)
|
||||
{
|
||||
this.resetCarouselPosition = resetCarouselPosition;
|
||||
@@ -1149,10 +1154,30 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
resetCarouselPosition?.Invoke();
|
||||
return base.OnHover(e);
|
||||
inputManager = GetContainingInputManager()!;
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// We want to trigger an action whenever the cursor is in the left area of song select.
|
||||
// Other elements in song select handle input, so rather than using `OnHover` let's check the true mouse position.
|
||||
if (Contains(inputManager.CurrentState.Mouse.Position))
|
||||
{
|
||||
if (!mouseContained)
|
||||
{
|
||||
mouseContained = true;
|
||||
resetCarouselPosition?.Invoke();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mouseContained = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user