mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:03:08 +08:00
Merge pull request #18609 from ALANVF/settings-delete-skin
Add button to delete the current skin
This commit is contained in:
commit
187086e4ec
@ -54,6 +54,11 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString ExportSkinButton => new TranslatableString(getKey(@"export_skin_button"), @"Export selected skin");
|
public static LocalisableString ExportSkinButton => new TranslatableString(getKey(@"export_skin_button"), @"Export selected skin");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Delete selected skin"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString DeleteSkinButton => new TranslatableString(getKey(@"delete_skin_button"), @"Delete selected skin");
|
||||||
|
|
||||||
private static string getKey(string key) => $"{prefix}:{key}";
|
private static string getKey(string key) => $"{prefix}:{key}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ using osu.Game.Configuration;
|
|||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
|
using osu.Game.Screens.Select;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osu.Game.Skinning.Editor;
|
using osu.Game.Skinning.Editor;
|
||||||
using Realms;
|
using Realms;
|
||||||
@ -67,6 +68,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
Action = () => skinEditor?.ToggleVisibility(),
|
Action = () => skinEditor?.ToggleVisibility(),
|
||||||
},
|
},
|
||||||
new ExportSkinButton(),
|
new ExportSkinButton(),
|
||||||
|
new DeleteSkinButton(),
|
||||||
};
|
};
|
||||||
|
|
||||||
config.BindWith(OsuSetting.Skin, configBindable);
|
config.BindWith(OsuSetting.Skin, configBindable);
|
||||||
@ -202,5 +204,36 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class DeleteSkinButton : DangerousSettingsButton
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private SkinManager skins { get; set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
private IDialogOverlay dialogOverlay { get; set; }
|
||||||
|
|
||||||
|
private Bindable<Skin> currentSkin;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Text = SkinSettingsStrings.DeleteSkinButton;
|
||||||
|
Action = delete;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
currentSkin = skins.CurrentSkin.GetBoundCopy();
|
||||||
|
currentSkin.BindValueChanged(skin => Enabled.Value = skin.NewValue.SkinInfo.PerformRead(s => !s.Protected), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void delete()
|
||||||
|
{
|
||||||
|
dialogOverlay?.Push(new SkinDeleteDialog(currentSkin.Value));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
42
osu.Game/Screens/Select/SkinDeleteDialog.cs
Normal file
42
osu.Game/Screens/Select/SkinDeleteDialog.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// 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.Allocation;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
using osu.Game.Overlays.Dialog;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Select
|
||||||
|
{
|
||||||
|
public class SkinDeleteDialog : PopupDialog
|
||||||
|
{
|
||||||
|
[Resolved]
|
||||||
|
private SkinManager manager { get; set; }
|
||||||
|
|
||||||
|
public SkinDeleteDialog(Skin skin)
|
||||||
|
{
|
||||||
|
BodyText = skin.SkinInfo.Value.Name;
|
||||||
|
Icon = FontAwesome.Regular.TrashAlt;
|
||||||
|
HeaderText = @"Confirm deletion of";
|
||||||
|
Buttons = new PopupDialogButton[]
|
||||||
|
{
|
||||||
|
new PopupDialogDangerousButton
|
||||||
|
{
|
||||||
|
Text = @"Yes. Totally. Delete it.",
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
if (manager == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
manager.Delete(skin.SkinInfo.Value);
|
||||||
|
manager.CurrentSkinInfo.SetDefault();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new PopupDialogCancelButton
|
||||||
|
{
|
||||||
|
Text = @"Firetruck, I didn't mean to!",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user