2020-07-06 14:44:26 +00: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.Collections.Generic;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Game.IO;
|
2024-02-02 12:32:55 +00:00
|
|
|
|
using osu.Game.Localisation;
|
2020-07-06 14:44:26 +00:00
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
using osu.Game.Overlays.Dialog;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Menu
|
|
|
|
|
{
|
|
|
|
|
public partial class StorageErrorDialog : PopupDialog
|
|
|
|
|
{
|
|
|
|
|
[Resolved]
|
2022-04-18 09:09:14 +00:00
|
|
|
|
private IDialogOverlay dialogOverlay { get; set; } = null!;
|
2020-07-06 14:44:26 +00:00
|
|
|
|
|
|
|
|
|
public StorageErrorDialog(OsuStorage storage, OsuStorageError error)
|
|
|
|
|
{
|
2024-02-02 12:32:55 +00:00
|
|
|
|
HeaderText = StorageErrorDialogStrings.StorageError;
|
2020-07-06 14:44:26 +00:00
|
|
|
|
Icon = FontAwesome.Solid.ExclamationTriangle;
|
|
|
|
|
|
|
|
|
|
var buttons = new List<PopupDialogButton>();
|
|
|
|
|
|
|
|
|
|
switch (error)
|
|
|
|
|
{
|
|
|
|
|
case OsuStorageError.NotAccessible:
|
2024-02-02 12:32:55 +00:00
|
|
|
|
BodyText = StorageErrorDialogStrings.LocationIsNotAccessible(storage.CustomStoragePath);
|
2020-07-06 14:44:26 +00:00
|
|
|
|
|
|
|
|
|
buttons.AddRange(new PopupDialogButton[]
|
|
|
|
|
{
|
2020-07-06 14:51:16 +00:00
|
|
|
|
new PopupDialogCancelButton
|
2020-07-06 14:44:26 +00:00
|
|
|
|
{
|
2024-02-02 12:32:55 +00:00
|
|
|
|
Text = StorageErrorDialogStrings.TryAgain,
|
2020-07-06 14:44:26 +00:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
if (!storage.TryChangeToCustomStorage(out var nextError))
|
|
|
|
|
dialogOverlay.Push(new StorageErrorDialog(storage, nextError));
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-07-06 14:51:16 +00:00
|
|
|
|
new PopupDialogCancelButton
|
|
|
|
|
{
|
2024-02-02 12:32:55 +00:00
|
|
|
|
Text = StorageErrorDialogStrings.UseDefaultLocation,
|
2020-07-06 14:51:16 +00:00
|
|
|
|
},
|
2020-07-06 14:44:26 +00:00
|
|
|
|
new PopupDialogOkButton
|
|
|
|
|
{
|
2024-02-02 12:32:55 +00:00
|
|
|
|
Text = StorageErrorDialogStrings.ResetToDefaultLocation,
|
2020-07-06 14:44:26 +00:00
|
|
|
|
Action = storage.ResetCustomStoragePath
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case OsuStorageError.AccessibleButEmpty:
|
2024-02-02 12:32:55 +00:00
|
|
|
|
BodyText = StorageErrorDialogStrings.LocationIsEmpty(storage.CustomStoragePath);
|
2020-07-06 14:44:26 +00:00
|
|
|
|
|
|
|
|
|
// Todo: Provide the option to search for the files similar to migration.
|
|
|
|
|
buttons.AddRange(new PopupDialogButton[]
|
|
|
|
|
{
|
|
|
|
|
new PopupDialogCancelButton
|
|
|
|
|
{
|
2024-02-02 12:32:55 +00:00
|
|
|
|
Text = StorageErrorDialogStrings.StartFresh
|
2020-07-06 14:44:26 +00:00
|
|
|
|
},
|
|
|
|
|
new PopupDialogOkButton
|
|
|
|
|
{
|
2024-02-02 12:32:55 +00:00
|
|
|
|
Text = StorageErrorDialogStrings.ResetToDefaultLocation,
|
2020-07-06 14:44:26 +00:00
|
|
|
|
Action = storage.ResetCustomStoragePath
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Buttons = buttons;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|