1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 22:07:25 +08:00

Merge pull request #2360 from UselessToucan/profile_multiple_audio_previews

Handle multiple song previews playing in different beatmap categories…
This commit is contained in:
Dean Herbert 2018-04-15 16:22:52 +09:00 committed by GitHub
commit e512e4bacb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 6 deletions

View File

@ -173,8 +173,9 @@ namespace osu.Game.Overlays.Direct
if (trackLoader != d) return;
Preview = d?.Preview;
Playing.TriggerChange();
updatePreviewTrack(Playing);
loading = false;
Add(trackLoader);
});
}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
@ -19,6 +20,8 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
private DirectPanel currentlyPlaying;
public event Action<PaginatedBeatmapContainer> BeganPlayingPreview;
public PaginatedBeatmapContainer(BeatmapSetType type, Bindable<User> user, string header, string missing = "None... yet.")
: base(user, header, missing)
{
@ -56,17 +59,25 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
panel.PreviewPlaying.ValueChanged += isPlaying =>
{
if (!isPlaying) return;
StopPlayingPreview();
if (currentlyPlaying != null && currentlyPlaying != panel)
currentlyPlaying.PreviewPlaying.Value = false;
currentlyPlaying = panel;
if (isPlaying)
{
BeganPlayingPreview?.Invoke(this);
currentlyPlaying = panel;
}
};
}
};
Api.Queue(req);
}
public void StopPlayingPreview()
{
if (currentlyPlaying == null) return;
currentlyPlaying.PreviewPlaying.Value = false;
currentlyPlaying = null;
}
}
}

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Linq;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.Profile.Sections.Beatmaps;
@ -21,6 +22,15 @@ namespace osu.Game.Overlays.Profile.Sections
new PaginatedBeatmapContainer(BeatmapSetType.Unranked, User, "Pending Beatmaps"),
new PaginatedBeatmapContainer(BeatmapSetType.Graveyard, User, "Graveyarded Beatmaps"),
};
foreach (var paginatedBeatmapContainer in Children.OfType<PaginatedBeatmapContainer>())
{
paginatedBeatmapContainer.BeganPlayingPreview += _ =>
{
foreach (var bc in Children.OfType<PaginatedBeatmapContainer>())
bc.StopPlayingPreview();
};
}
}
}
}