mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
Add the ability to click completed download notifications to select beatmap
Closes #2731.
This commit is contained in:
parent
a36dbc3b93
commit
1418d1369f
@ -45,6 +45,11 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
public event Action<DownloadBeatmapSetRequest> BeatmapDownloadBegan;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when a beatmap load is requested (into the interactive game UI).
|
||||
/// </summary>
|
||||
public Action<BeatmapSetInfo> PresentBeatmap;
|
||||
|
||||
/// <summary>
|
||||
/// A default representation of a WorkingBeatmap to use when no beatmap is available.
|
||||
/// </summary>
|
||||
@ -163,12 +168,20 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
BeatmapSetInfo importedBeatmap;
|
||||
|
||||
// This gets scheduled back to the update thread, but we want the import to run in the background.
|
||||
using (var stream = new MemoryStream(data))
|
||||
using (var archive = new ZipArchiveReader(stream, beatmapSetInfo.ToString()))
|
||||
Import(archive);
|
||||
importedBeatmap = Import(archive);
|
||||
|
||||
downloadNotification.CompletionClickAction = () =>
|
||||
{
|
||||
PresentBeatmap?.Invoke(importedBeatmap);
|
||||
return true;
|
||||
};
|
||||
downloadNotification.State = ProgressNotificationState.Completed;
|
||||
|
||||
currentDownloads.Remove(request);
|
||||
}, TaskCreationOptions.LongRunning);
|
||||
};
|
||||
|
@ -23,6 +23,7 @@ using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
@ -33,6 +34,7 @@ using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Skinning;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Overlays.Volume;
|
||||
using osu.Game.Screens.Select;
|
||||
|
||||
namespace osu.Game
|
||||
{
|
||||
@ -178,6 +180,30 @@ namespace osu.Game
|
||||
/// <param name="setId">The set to display.</param>
|
||||
public void ShowBeatmapSet(int setId) => beatmapSetOverlay.FetchAndShowBeatmapSet(setId);
|
||||
|
||||
/// <summary>
|
||||
/// Present a beatmap at song select.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The beatmap to select.</param>
|
||||
public void PresentBeatmap(BeatmapSetInfo beatmap)
|
||||
{
|
||||
CloseAllOverlays();
|
||||
|
||||
Beatmap.Value = BeatmapManager.GetWorkingBeatmap(beatmap.Beatmaps.First());
|
||||
|
||||
switch (currentScreen)
|
||||
{
|
||||
case SongSelect _:
|
||||
break;
|
||||
default:
|
||||
// navigate to song select if we are not already there.
|
||||
var menu = (MainMenu)intro.ChildScreen;
|
||||
|
||||
menu.MakeCurrent();
|
||||
menu.LoadToSolo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a user's profile as an overlay.
|
||||
/// </summary>
|
||||
@ -244,6 +270,7 @@ namespace osu.Game
|
||||
BeatmapManager.PostNotification = n => notifications?.Post(n);
|
||||
|
||||
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
|
||||
BeatmapManager.PresentBeatmap = PresentBeatmap;
|
||||
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Menu
|
||||
OnChart = delegate { Push(new ChartListing()); },
|
||||
OnDirect = delegate { Push(new OnlineListing()); },
|
||||
OnEdit = delegate { Push(new Editor()); },
|
||||
OnSolo = delegate { Push(consumeSongSelect()); },
|
||||
OnSolo = onSolo,
|
||||
OnMulti = delegate { Push(new Multiplayer()); },
|
||||
OnExit = Exit,
|
||||
}
|
||||
@ -85,6 +85,10 @@ namespace osu.Game.Screens.Menu
|
||||
LoadComponentAsync(songSelect = new PlaySongSelect());
|
||||
}
|
||||
|
||||
public void LoadToSolo() => Schedule(onSolo);
|
||||
|
||||
private void onSolo() => Push(consumeSongSelect());
|
||||
|
||||
private Screen consumeSongSelect()
|
||||
{
|
||||
var s = songSelect;
|
||||
|
Loading…
Reference in New Issue
Block a user