osu/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs

54 lines
1.6 KiB
C#

// 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;
using System.IO;
using osu.Framework.Allocation;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.Settings.Sections.Maintenance
{
public class MigrationSelectScreen : DirectorySelectScreen
{
[Resolved]
private Storage storage { get; set; }
protected override OsuSpriteText CreateHeader() => new OsuSpriteText
{
Text = "Please select a new location",
Font = OsuFont.Default.With(size: 40)
};
protected override void OnSelection(DirectoryInfo directory)
{
var target = directory;
try
{
if (target.GetDirectories().Length > 0 || target.GetFiles().Length > 0)
target = target.CreateSubdirectory("osu-lazer");
}
catch (Exception e)
{
Logger.Log($"Error during migration: {e.Message}", level: LogLevel.Error);
return;
}
ValidForResume = false;
BeginMigration(target);
}
protected override void LoadComplete()
{
DirectorySelector.CurrentPath.Value = new DirectoryInfo(storage.GetFullPath(string.Empty)).Parent;
base.LoadComplete();
}
protected virtual void BeginMigration(DirectoryInfo target) => this.Push(new MigrationRunScreen(target));
}
}