1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:12:57 +08:00

Add StableDirectoryLocationDialog

This commit is contained in:
Lucas A 2021-05-09 19:50:43 +02:00
parent 325a689d65
commit 481b0a0125
2 changed files with 43 additions and 5 deletions

View File

@ -9,16 +9,16 @@ using osu.Framework.Allocation;
using osu.Framework.Extensions.EnumExtensions; using osu.Framework.Extensions.EnumExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Collections; using osu.Game.Collections;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Overlays;
using osu.Game.Overlays.Settings.Sections.Maintenance; using osu.Game.Overlays.Settings.Sections.Maintenance;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Skinning; using osu.Game.Skinning;
namespace osu.Game.Database namespace osu.Game.Database
{ {
public class StableImportManager : Component public class StableImportManager : Component
{ {
[Resolved] [Resolved]
@ -34,7 +34,7 @@ namespace osu.Game.Database
private CollectionManager collections { get; set; } private CollectionManager collections { get; set; }
[Resolved] [Resolved]
private OsuGame game { get; set; } private DialogOverlay dialogOverlay { get; set; }
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private DesktopGameHost desktopGameHost { get; set; } private DesktopGameHost desktopGameHost { get; set; }
@ -83,8 +83,8 @@ namespace osu.Game.Database
if (cachedStorage != null) if (cachedStorage != null)
return cachedStorage; return cachedStorage;
var taskCompletionSource = new TaskCompletionSource<string>(); var taskCompletionSource = new TaskCompletionSource<string>(TaskCreationOptions.RunContinuationsAsynchronously);
Schedule(() => game.PerformFromScreen(t => t.Push(new StableDirectorySelectScreen(taskCompletionSource)))); dialogOverlay.Push(new StableDirectoryLocationDialog(taskCompletionSource));
var stablePath = await taskCompletionSource.Task.ConfigureAwait(false); var stablePath = await taskCompletionSource.Task.ConfigureAwait(false);
return cachedStorage = new StableStorage(stablePath, desktopGameHost); return cachedStorage = new StableStorage(stablePath, desktopGameHost);

View File

@ -0,0 +1,38 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Screens;
using osu.Game.Overlays.Dialog;
namespace osu.Game.Overlays.Settings.Sections.Maintenance
{
public class StableDirectoryLocationDialog : PopupDialog
{
[Resolved]
private OsuGame game { get; set; }
public StableDirectoryLocationDialog(TaskCompletionSource<string> taskCompletionSource)
{
HeaderText = "Failed to automatically locate a stable installation.";
BodyText = "osu! failed to automatically locate a stable installation. Maybe you can tell osu! where it is located?";
Icon = FontAwesome.Solid.QuestionCircle;
Buttons = new PopupDialogButton[]
{
new PopupDialogOkButton
{
Text = "Sure! I know where it is located!",
Action = () => Schedule(() => game.PerformFromScreen(screen => screen.Push(new StableDirectorySelectScreen(taskCompletionSource))))
},
new PopupDialogCancelButton
{
Text = "Actually I don't have osu!stable installed.",
Action = () => taskCompletionSource.TrySetCanceled()
}
};
}
}
}