mirror of
https://github.com/ppy/osu
synced 2025-01-21 21:33:13 +00:00
Merge pull request #26449 from peppy/playlist-room-buttons
Allow interacting with playlist item buttons when not selected
This commit is contained in:
commit
4d39c91972
@ -19,8 +19,10 @@ using osu.Game.Beatmaps.Drawables;
|
|||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Models;
|
using osu.Game.Models;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
@ -302,6 +304,37 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSelectableMouseHandling()
|
||||||
|
{
|
||||||
|
bool resultsRequested = false;
|
||||||
|
|
||||||
|
AddStep("reset flag", () => resultsRequested = false);
|
||||||
|
createPlaylist(p =>
|
||||||
|
{
|
||||||
|
p.AllowSelection = true;
|
||||||
|
p.AllowShowingResults = true;
|
||||||
|
p.RequestResults = _ => resultsRequested = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("move mouse to first item title", () =>
|
||||||
|
{
|
||||||
|
var drawQuad = playlist.ChildrenOfType<LinkFlowContainer>().First().ScreenSpaceDrawQuad;
|
||||||
|
var location = (drawQuad.TopLeft + drawQuad.BottomLeft) / 2 + new Vector2(drawQuad.Width * 0.2f, 0);
|
||||||
|
InputManager.MoveMouseTo(location);
|
||||||
|
});
|
||||||
|
AddUntilStep("wait for text load", () => playlist.ChildrenOfType<DrawableLinkCompiler>().Any());
|
||||||
|
AddAssert("first item title not hovered", () => playlist.ChildrenOfType<DrawableLinkCompiler>().First().IsHovered, () => Is.False);
|
||||||
|
AddStep("click left mouse", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddUntilStep("first item selected", () => playlist.ChildrenOfType<DrawableRoomPlaylistItem>().First().IsSelectedItem, () => Is.True);
|
||||||
|
// implies being clickable.
|
||||||
|
AddUntilStep("first item title hovered", () => playlist.ChildrenOfType<DrawableLinkCompiler>().First().IsHovered, () => Is.True);
|
||||||
|
|
||||||
|
AddStep("move mouse to second item results button", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<GrayButton>().ElementAt(5)));
|
||||||
|
AddStep("click left mouse", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddUntilStep("results requested", () => resultsRequested);
|
||||||
|
}
|
||||||
|
|
||||||
private void moveToItem(int index, Vector2? offset = null)
|
private void moveToItem(int index, Vector2? offset = null)
|
||||||
=> AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(index), offset));
|
=> AddStep($"move mouse to item {index}", () => InputManager.MoveMouseTo(playlist.ChildrenOfType<DrawableRoomPlaylistItem>().ElementAt(index), offset));
|
||||||
|
|
||||||
|
@ -165,7 +165,11 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
{
|
{
|
||||||
d.SelectedItem.BindTarget = SelectedItem;
|
d.SelectedItem.BindTarget = SelectedItem;
|
||||||
d.RequestDeletion = i => RequestDeletion?.Invoke(i);
|
d.RequestDeletion = i => RequestDeletion?.Invoke(i);
|
||||||
d.RequestResults = i => RequestResults?.Invoke(i);
|
d.RequestResults = i =>
|
||||||
|
{
|
||||||
|
SelectedItem.Value = i;
|
||||||
|
RequestResults?.Invoke(i);
|
||||||
|
};
|
||||||
d.RequestEdit = i => RequestEdit?.Invoke(i);
|
d.RequestEdit = i => RequestEdit?.Invoke(i);
|
||||||
d.AllowReordering = AllowReordering;
|
d.AllowReordering = AllowReordering;
|
||||||
d.AllowDeletion = AllowDeletion;
|
d.AllowDeletion = AllowDeletion;
|
||||||
|
@ -118,8 +118,6 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
|
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
|
||||||
|
|
||||||
protected override bool ShouldBeConsideredForInput(Drawable child) => AllowReordering || AllowDeletion || !AllowSelection || SelectedItem.Value == Model;
|
|
||||||
|
|
||||||
public DrawableRoomPlaylistItem(PlaylistItem item)
|
public DrawableRoomPlaylistItem(PlaylistItem item)
|
||||||
: base(item)
|
: base(item)
|
||||||
{
|
{
|
||||||
@ -367,7 +365,7 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Margin = new MarginPadding { Left = 8, Right = 8 },
|
Margin = new MarginPadding { Left = 8, Right = 8 },
|
||||||
},
|
},
|
||||||
mainFillFlow = new FillFlowContainer
|
mainFillFlow = new MainFlow(() => SelectedItem.Value == Model || !AllowSelection)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
@ -670,5 +668,17 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
public LocalisableString TooltipText => avatar.TooltipText;
|
public LocalisableString TooltipText => avatar.TooltipText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public partial class MainFlow : FillFlowContainer
|
||||||
|
{
|
||||||
|
private readonly Func<bool> allowInteraction;
|
||||||
|
|
||||||
|
public override bool PropagatePositionalInputSubTree => allowInteraction();
|
||||||
|
|
||||||
|
public MainFlow(Func<bool> allowInteraction)
|
||||||
|
{
|
||||||
|
this.allowInteraction = allowInteraction;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user