PaginatedBeatmapContainer.BeganPlayingPreview

This commit is contained in:
TocoToucan 2018-04-11 16:19:21 +03:00
parent 640be621ac
commit 6cdfaffcf7
2 changed files with 16 additions and 11 deletions

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
private DirectPanel currentlyPlaying;
public event Action<DirectGridPanel> BeatmapAdded;
public event Action<PaginatedBeatmapContainer> BeganPlayingPreview;
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string header, string missing = "None... yet.")
: base(user, header, missing)
@ -61,16 +61,22 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
{
if (!isPlaying) return;
BeganPlayingPreview?.Invoke(this);
if (currentlyPlaying != null && currentlyPlaying != panel)
currentlyPlaying.PreviewPlaying.Value = false;
StopPlayingPreview();
currentlyPlaying = panel;
};
BeatmapAdded?.Invoke(panel);
}
};
Api.Queue(req);
}
public void StopPlayingPreview()
{
if (currentlyPlaying != null)
currentlyPlaying.PreviewPlaying.Value = false;
}
}
}

View File

@ -26,16 +26,15 @@ namespace osu.Game.Overlays.Profile.Sections
new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User, "Graveyarded Beatmaps"),
};
foreach (var beatmapContainer in Children.OfType<PaginatedBeatmapContainer>())
foreach (var paginatedBeatmapContainer in Children.OfType<PaginatedBeatmapContainer>())
{
beatmapContainer.BeatmapAdded += panel => panel.PreviewPlaying.ValueChanged += isPlaying =>
paginatedBeatmapContainer.BeganPlayingPreview += (BeatmapContainer) =>
{
if (!isPlaying) return;
if (currentlyPlaying != null && currentlyPlaying != panel)
currentlyPlaying.PreviewPlaying.Value = false;
currentlyPlaying = panel;
foreach (var bc in Children.OfType<PaginatedBeatmapContainer>())
{
if (bc != BeatmapContainer)
bc.StopPlayingPreview();
}
};
}
}