Implement mod preset deletion flow

This commit is contained in:
Bartłomiej Dach
2022-07-23 22:03:31 +02:00
parent 26b9adbe0c
commit 9b3183b2b4
3 changed files with 53 additions and 4 deletions

View File

@ -4,18 +4,24 @@
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Overlays.Mods
{
public class ModPresetPanel : ModSelectPanel, IHasCustomTooltip<ModPreset>
public class ModPresetPanel : ModSelectPanel, IHasCustomTooltip<ModPreset>, IHasContextMenu
{
public readonly Live<ModPreset> Preset;
public override BindableBool Active { get; } = new BindableBool();
[Resolved]
private IDialogOverlay? dialogOverlay { get; set; }
public ModPresetPanel(Live<ModPreset> preset)
{
Preset = preset;
@ -30,7 +36,20 @@ namespace osu.Game.Overlays.Mods
AccentColour = colours.Orange1;
}
#region IHasCustomTooltip
public ModPreset TooltipContent => Preset.Value;
public ITooltip<ModPreset> GetCustomTooltip() => new ModPresetTooltip(ColourProvider);
#endregion
#region IHasContextMenu
public MenuItem[] ContextMenuItems => new MenuItem[]
{
new OsuMenuItem(CommonStrings.ButtonsDelete, MenuItemType.Destructive, () => dialogOverlay?.Push(new DeleteModPresetDialog(Preset)))
};
#endregion
}
}