1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 00:47:26 +08:00
osu-lazer/osu.Game/Overlays/Settings/Sections/Maintenance/MigrationSelectScreen.cs

50 lines
1.5 KiB
C#
Raw Normal View History

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