Skip to content

Commit

Permalink
Merge pull request ppy#29244 from Joehuu/fix-double-sounds-playlist-item
Browse files Browse the repository at this point in the history
Fix click sounds playing twice on `OsuRearrangeableListItem`
  • Loading branch information
peppy authored Aug 2, 2024
2 parents cd28fa7 + 1e38d1f commit 4c15485
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
27 changes: 16 additions & 11 deletions osu.Game/Collections/DrawableCollectionListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ public DrawableCollectionListItem(Live<BeatmapCollection> item, bool isCreated)
//
// if we want to support user sorting (but changes will need to be made to realm to persist).
ShowDragHandle.Value = false;

Masking = true;
CornerRadius = item_height / 2;
}

protected override Drawable CreateContent() => new ItemContent(Model);

/// <summary>
/// The main content of the <see cref="DrawableCollectionListItem"/>.
/// </summary>
private partial class ItemContent : CircularContainer
private partial class ItemContent : CompositeDrawable
{
private readonly Live<BeatmapCollection> collection;

Expand All @@ -65,13 +68,12 @@ public ItemContent(Live<BeatmapCollection> collection)

RelativeSizeAxes = Axes.X;
Height = item_height;
Masking = true;
}

[BackgroundDependencyLoader]
private void load()
{
Children = new[]
InternalChildren = new[]
{
collection.IsManaged
? new DeleteButton(collection)
Expand Down Expand Up @@ -132,7 +134,7 @@ private void load(OsuColour colours)
}
}

public partial class DeleteButton : CompositeDrawable
public partial class DeleteButton : OsuClickableContainer
{
public Func<Vector2, bool> IsTextBoxHovered = null!;

Expand All @@ -155,7 +157,7 @@ public DeleteButton(Live<BeatmapCollection> collection)
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
InternalChild = fadeContainer = new Container
Child = fadeContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.1f,
Expand All @@ -176,6 +178,14 @@ private void load(OsuColour colours)
}
}
};

Action = () =>
{
if (collection.PerformRead(c => c.BeatmapMD5Hashes.Count) == 0)
deleteCollection();
else
dialogOverlay?.Push(new DeleteCollectionDialog(collection, deleteCollection));
};
}

public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => base.ReceivePositionalInputAt(screenSpacePos) && !IsTextBoxHovered(screenSpacePos);
Expand All @@ -195,12 +205,7 @@ protected override bool OnClick(ClickEvent e)
{
background.FlashColour(Color4.White, 150);

if (collection.PerformRead(c => c.BeatmapMD5Hashes.Count) == 0)
deleteCollection();
else
dialogOverlay?.Push(new DeleteCollectionDialog(collection, deleteCollection));

return true;
return base.OnClick(e);
}

private void deleteCollection() => collection.PerformWrite(c => c.Realm!.Remove(c));
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Graphics/Containers/OsuRearrangeableListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private void load()
{
InternalChildren = new Drawable[]
{
new HoverClickSounds(),
new GridContainer
{
RelativeSizeAxes = Axes.X,
Expand Down Expand Up @@ -92,7 +93,6 @@ private void load()
ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
},
new HoverClickSounds()
};
}

Expand Down

0 comments on commit 4c15485

Please sign in to comment.