mirror of
https://github.com/ppy/osu
synced 2024-12-24 15:53:37 +00:00
Implement mod preset deletion flow
This commit is contained in:
parent
26b9adbe0c
commit
9b3183b2b4
@ -11,6 +11,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Overlays;
|
||||
@ -35,16 +36,27 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
|
||||
|
||||
[Cached(typeof(IDialogOverlay))]
|
||||
private readonly DialogOverlay dialogOverlay = new DialogOverlay();
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Dependencies.Cache(rulesets = new RealmRulesetStore(Realm));
|
||||
Dependencies.Cache(Realm);
|
||||
|
||||
base.Content.Add(content = new PopoverContainer
|
||||
base.Content.AddRange(new Drawable[]
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(30),
|
||||
new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = content = new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Padding = new MarginPadding(30),
|
||||
}
|
||||
},
|
||||
dialogOverlay
|
||||
});
|
||||
}
|
||||
|
||||
|
18
osu.Game/Overlays/Mods/DeleteModPresetDialog.cs
Normal file
18
osu.Game/Overlays/Mods/DeleteModPresetDialog.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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.Game.Database;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public class DeleteModPresetDialog : DeleteConfirmationDialog
|
||||
{
|
||||
public DeleteModPresetDialog(Live<ModPreset> modPreset)
|
||||
{
|
||||
BodyText = modPreset.PerformRead(preset => preset.Name);
|
||||
DeleteAction = () => modPreset.PerformWrite(preset => preset.DeletePending = true);
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user