Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localise storage error popup dialog #27258

Merged
merged 1 commit into from Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions osu.Game/Localisation/StorageErrorDialogStrings.cs
@@ -0,0 +1,49 @@
// 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 osu.Framework.Localisation;

namespace osu.Game.Localisation
{
public static class StorageErrorDialogStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.StorageErrorDialog";

/// <summary>
/// "osu! storage error"
/// </summary>
public static LocalisableString StorageError => new TranslatableString(getKey(@"storage_error"), @"osu! storage error");

/// <summary>
/// "The specified osu! data location (&quot;{0}&quot;) is not accessible. If it is on external storage, please reconnect the device and try again."
/// </summary>
public static LocalisableString LocationIsNotAccessible(string? loc) => new TranslatableString(getKey(@"location_is_not_accessible"), @"The specified osu! data location (""{0}"") is not accessible. If it is on external storage, please reconnect the device and try again.", loc);

/// <summary>
/// "The specified osu! data location (&quot;{0}&quot;) is empty. If you have moved the files, please close osu! and move them back."
/// </summary>
public static LocalisableString LocationIsEmpty(string? loc2) => new TranslatableString(getKey(@"location_is_empty"), @"The specified osu! data location (""{0}"") is empty. If you have moved the files, please close osu! and move them back.", loc2);

/// <summary>
/// "Try again"
/// </summary>
public static LocalisableString TryAgain => new TranslatableString(getKey(@"try_again"), @"Try again");

/// <summary>
/// "Use default location until restart"
/// </summary>
public static LocalisableString UseDefaultLocation => new TranslatableString(getKey(@"use_default_location"), @"Use default location until restart");

/// <summary>
/// "Reset to default location"
/// </summary>
public static LocalisableString ResetToDefaultLocation => new TranslatableString(getKey(@"reset_to_default_location"), @"Reset to default location");

/// <summary>
/// "Start fresh at specified location"
/// </summary>
public static LocalisableString StartFresh => new TranslatableString(getKey(@"start_fresh"), @"Start fresh at specified location");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
17 changes: 9 additions & 8 deletions osu.Game/Screens/Menu/StorageErrorDialog.cs
Expand Up @@ -5,6 +5,7 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Game.IO;
using osu.Game.Localisation;
using osu.Game.Overlays;
using osu.Game.Overlays.Dialog;

Expand All @@ -17,21 +18,21 @@ public partial class StorageErrorDialog : PopupDialog

public StorageErrorDialog(OsuStorage storage, OsuStorageError error)
{
HeaderText = "osu! storage error";
HeaderText = StorageErrorDialogStrings.StorageError;
Icon = FontAwesome.Solid.ExclamationTriangle;

var buttons = new List<PopupDialogButton>();

switch (error)
{
case OsuStorageError.NotAccessible:
BodyText = $"The specified osu! data location (\"{storage.CustomStoragePath}\") is not accessible. If it is on external storage, please reconnect the device and try again.";
BodyText = StorageErrorDialogStrings.LocationIsNotAccessible(storage.CustomStoragePath);

buttons.AddRange(new PopupDialogButton[]
{
new PopupDialogCancelButton
{
Text = "Try again",
Text = StorageErrorDialogStrings.TryAgain,
Action = () =>
{
if (!storage.TryChangeToCustomStorage(out var nextError))
Expand All @@ -40,29 +41,29 @@ public StorageErrorDialog(OsuStorage storage, OsuStorageError error)
},
new PopupDialogCancelButton
{
Text = "Use default location until restart",
Text = StorageErrorDialogStrings.UseDefaultLocation,
},
new PopupDialogOkButton
{
Text = "Reset to default location",
Text = StorageErrorDialogStrings.ResetToDefaultLocation,
Action = storage.ResetCustomStoragePath
},
});
break;

case OsuStorageError.AccessibleButEmpty:
BodyText = $"The specified osu! data location (\"{storage.CustomStoragePath}\") is empty. If you have moved the files, please close osu! and move them back.";
BodyText = StorageErrorDialogStrings.LocationIsEmpty(storage.CustomStoragePath);

// Todo: Provide the option to search for the files similar to migration.
buttons.AddRange(new PopupDialogButton[]
{
new PopupDialogCancelButton
{
Text = "Start fresh at specified location"
Text = StorageErrorDialogStrings.StartFresh
},
new PopupDialogOkButton
{
Text = "Reset to default location",
Text = StorageErrorDialogStrings.ResetToDefaultLocation,
Action = storage.ResetCustomStoragePath
},
});
Expand Down