Close #5820 (Ability to delete a single skin)

This commit is contained in:
theangryepicbanana
2022-06-07 18:01:40 -04:00
parent 5b4954aac1
commit 6c05329144
3 changed files with 87 additions and 0 deletions

View File

@ -16,6 +16,7 @@ using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Screens.Select;
using osu.Game.Skinning;
using osu.Game.Skinning.Editor;
using Realms;
@ -67,6 +68,7 @@ namespace osu.Game.Overlays.Settings.Sections
Action = () => skinEditor?.ToggleVisibility(),
},
new ExportSkinButton(),
new DeleteSkinButton(),
};
config.BindWith(OsuSetting.Skin, configBindable);
@ -202,5 +204,37 @@ 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()
{
if (dialogOverlay != null)
dialogOverlay.Push(new SkinDeleteDialog(currentSkin.Value));
}
}
}
}