mirror of
https://github.com/osukey/osukey.git
synced 2025-05-24 15:07:20 +09: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>
|
/// </summary>
|
||||||
public event Action<DownloadBeatmapSetRequest> BeatmapDownloadBegan;
|
public event Action<DownloadBeatmapSetRequest> BeatmapDownloadBegan;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fired when a beatmap load is requested (into the interactive game UI).
|
||||||
|
/// </summary>
|
||||||
|
public Action<BeatmapSetInfo> PresentBeatmap;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A default representation of a WorkingBeatmap to use when no beatmap is available.
|
/// A default representation of a WorkingBeatmap to use when no beatmap is available.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -163,12 +168,20 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
|
BeatmapSetInfo importedBeatmap;
|
||||||
|
|
||||||
// This gets scheduled back to the update thread, but we want the import to run in the background.
|
// 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 stream = new MemoryStream(data))
|
||||||
using (var archive = new ZipArchiveReader(stream, beatmapSetInfo.ToString()))
|
using (var archive = new ZipArchiveReader(stream, beatmapSetInfo.ToString()))
|
||||||
Import(archive);
|
importedBeatmap = Import(archive);
|
||||||
|
|
||||||
|
downloadNotification.CompletionClickAction = () =>
|
||||||
|
{
|
||||||
|
PresentBeatmap?.Invoke(importedBeatmap);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
downloadNotification.State = ProgressNotificationState.Completed;
|
downloadNotification.State = ProgressNotificationState.Completed;
|
||||||
|
|
||||||
currentDownloads.Remove(request);
|
currentDownloads.Remove(request);
|
||||||
}, TaskCreationOptions.LongRunning);
|
}, TaskCreationOptions.LongRunning);
|
||||||
};
|
};
|
||||||
|
@ -23,6 +23,7 @@ using osu.Framework.Input;
|
|||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
@ -33,6 +34,7 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Game.Overlays.Volume;
|
using osu.Game.Overlays.Volume;
|
||||||
|
using osu.Game.Screens.Select;
|
||||||
|
|
||||||
namespace osu.Game
|
namespace osu.Game
|
||||||
{
|
{
|
||||||
@ -178,6 +180,30 @@ namespace osu.Game
|
|||||||
/// <param name="setId">The set to display.</param>
|
/// <param name="setId">The set to display.</param>
|
||||||
public void ShowBeatmapSet(int setId) => beatmapSetOverlay.FetchAndShowBeatmapSet(setId);
|
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>
|
/// <summary>
|
||||||
/// Show a user's profile as an overlay.
|
/// Show a user's profile as an overlay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -244,6 +270,7 @@ namespace osu.Game
|
|||||||
BeatmapManager.PostNotification = n => notifications?.Post(n);
|
BeatmapManager.PostNotification = n => notifications?.Post(n);
|
||||||
|
|
||||||
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
|
BeatmapManager.GetStableStorage = GetStorageForStableInstall;
|
||||||
|
BeatmapManager.PresentBeatmap = PresentBeatmap;
|
||||||
|
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Screens.Menu
|
|||||||
OnChart = delegate { Push(new ChartListing()); },
|
OnChart = delegate { Push(new ChartListing()); },
|
||||||
OnDirect = delegate { Push(new OnlineListing()); },
|
OnDirect = delegate { Push(new OnlineListing()); },
|
||||||
OnEdit = delegate { Push(new Editor()); },
|
OnEdit = delegate { Push(new Editor()); },
|
||||||
OnSolo = delegate { Push(consumeSongSelect()); },
|
OnSolo = onSolo,
|
||||||
OnMulti = delegate { Push(new Multiplayer()); },
|
OnMulti = delegate { Push(new Multiplayer()); },
|
||||||
OnExit = Exit,
|
OnExit = Exit,
|
||||||
}
|
}
|
||||||
@ -85,6 +85,10 @@ namespace osu.Game.Screens.Menu
|
|||||||
LoadComponentAsync(songSelect = new PlaySongSelect());
|
LoadComponentAsync(songSelect = new PlaySongSelect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void LoadToSolo() => Schedule(onSolo);
|
||||||
|
|
||||||
|
private void onSolo() => Push(consumeSongSelect());
|
||||||
|
|
||||||
private Screen consumeSongSelect()
|
private Screen consumeSongSelect()
|
||||||
{
|
{
|
||||||
var s = songSelect;
|
var s = songSelect;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user