2021-05-08 17:00:22 +08:00
|
|
|
|
// 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.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2021-05-17 19:04:49 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-05-08 17:00:22 +08:00
|
|
|
|
using osu.Framework.Screens;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|
|
|
|
{
|
|
|
|
|
public partial class StableDirectorySelectScreen : DirectorySelectScreen
|
|
|
|
|
{
|
|
|
|
|
private readonly TaskCompletionSource<string> taskCompletionSource;
|
|
|
|
|
|
2021-05-17 19:28:59 +08:00
|
|
|
|
protected override OverlayActivation InitialOverlayActivationMode => OverlayActivation.Disabled;
|
|
|
|
|
|
2023-06-23 23:59:36 +08:00
|
|
|
|
protected override bool IsValidDirectory(DirectoryInfo? info) => info?.GetFiles("osu!.*.cfg").Any() ?? false;
|
2021-05-08 17:00:22 +08:00
|
|
|
|
|
2021-05-17 19:04:49 +08:00
|
|
|
|
public override LocalisableString HeaderText => "Please select your osu!stable install location";
|
2021-05-08 17:00:22 +08:00
|
|
|
|
|
|
|
|
|
public StableDirectorySelectScreen(TaskCompletionSource<string> taskCompletionSource)
|
|
|
|
|
{
|
|
|
|
|
this.taskCompletionSource = taskCompletionSource;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnSelection(DirectoryInfo directory)
|
2021-05-10 18:21:51 +08:00
|
|
|
|
{
|
2021-05-08 17:00:22 +08:00
|
|
|
|
taskCompletionSource.TrySetResult(directory.FullName);
|
|
|
|
|
this.Exit();
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-21 23:52:44 +08:00
|
|
|
|
public override bool OnExiting(ScreenExitEvent e)
|
2021-05-08 17:00:22 +08:00
|
|
|
|
{
|
|
|
|
|
taskCompletionSource.TrySetCanceled();
|
2022-04-21 23:52:44 +08:00
|
|
|
|
return base.OnExiting(e);
|
2021-05-08 17:00:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|