1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08:00

Make reverting changes to a given skin into a "dangerous action"

This commit is contained in:
mk56-spn 2023-02-26 20:38:50 +01:00
parent d679703fa2
commit ff0d1aa9f7
2 changed files with 42 additions and 2 deletions

View File

@ -42,7 +42,17 @@ namespace osu.Game.Localisation
/// <summary>
/// "Currently editing"
/// </summary>
public static LocalisableString CurrentlyEditing => new TranslatableString(getKey(@"currently_editing"), "Currently editing");
public static LocalisableString CurrentlyEditing => new TranslatableString(getKey(@"currently_editing"), @"Currently editing");
/// <summary>
/// "Revert?"
/// </summary>
public static LocalisableString Revert => new TranslatableString(getKey(@"revert"), @"Revert?");
/// <summary>
/// "The skin will return to the state it was in upon import"
/// </summary>
public static LocalisableString ResetDialogue => new TranslatableString(getKey(@"the_skin_will_return_to"), @"The skin will return to the state it was in upon import");
private static string getKey(string key) => $@"{prefix}:{key}";
}

View File

@ -12,11 +12,13 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using web = osu.Game.Resources.Localisation.Web;
using osu.Framework.Testing;
using osu.Game.Database;
using osu.Game.Graphics;
@ -24,6 +26,7 @@ using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Overlays.Dialog;
using osu.Game.Overlays.OSD;
using osu.Game.Overlays.Settings;
using osu.Game.Screens.Edit;
@ -97,6 +100,9 @@ namespace osu.Game.Overlays.SkinEditor
[Resolved]
private OnScreenDisplay? onScreenDisplay { get; set; }
[Resolved]
private IDialogOverlay? dialogOverlay { get; set; }
public SkinEditor()
{
}
@ -148,7 +154,7 @@ namespace osu.Game.Overlays.SkinEditor
Items = new[]
{
new EditorMenuItem(Resources.Localisation.Web.CommonStrings.ButtonsSave, MenuItemType.Standard, () => Save()),
new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, revert),
new EditorMenuItem(CommonStrings.RevertToDefault, MenuItemType.Destructive, () => dialogOverlay?.Push(new ResetConfirmDialog(revert))),
new EditorMenuItemSpacer(),
new EditorMenuItem(CommonStrings.Exit, MenuItemType.Standard, () => skinEditorOverlay?.Hide()),
},
@ -625,6 +631,30 @@ namespace osu.Game.Overlays.SkinEditor
}
}
public partial class ResetConfirmDialog : PopupDialog
{
public ResetConfirmDialog(Action reset)
{
HeaderText = SkinEditorStrings.Revert;
BodyText = SkinEditorStrings.ResetDialogue;
Icon = FontAwesome.Solid.ExclamationTriangle;
Buttons = new PopupDialogButton[]
{
new PopupDialogDangerousButton
{
Text = BeatmapOverlayStrings.UserContentConfirmButtonText,
Action = reset
},
new PopupDialogCancelButton
{
Text = web.CommonStrings.ButtonsCancel,
},
};
}
}
#region Delegation of IEditorChangeHandler
public event Action? OnStateChange