mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 04:32:55 +08:00
Refactor the code to follow IoC principle and more flexible
This commit is contained in:
parent
27d6c4cecb
commit
3cc5466774
@ -23,7 +23,6 @@ using osu.Framework.Testing;
|
|||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Cursor;
|
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Overlays.Dialog;
|
using osu.Game.Overlays.Dialog;
|
||||||
@ -101,6 +100,12 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IDialogOverlay? dialogOverlay { get; set; }
|
private IDialogOverlay? dialogOverlay { get; set; }
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
public EditorContextMenuContainer ContextMenuContainer { get; private set; } = new EditorContextMenuContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
};
|
||||||
|
|
||||||
public SkinEditor()
|
public SkinEditor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -115,10 +120,7 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
InternalChild = new EditorContextMenuContainer
|
ContextMenuContainer.Child = new GridContainer
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Child = new GridContainer
|
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
RowDimensions = new[]
|
RowDimensions = new[]
|
||||||
@ -127,7 +129,6 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
new Dimension(GridSizeMode.AutoSize),
|
new Dimension(GridSizeMode.AutoSize),
|
||||||
new Dimension(),
|
new Dimension(),
|
||||||
},
|
},
|
||||||
|
|
||||||
Content = new[]
|
Content = new[]
|
||||||
{
|
{
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
@ -220,9 +221,10 @@ namespace osu.Game.Overlays.SkinEditor
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AddInternal(ContextMenuContainer);
|
||||||
|
|
||||||
clipboardContent = clipboard.Content.GetBoundCopy();
|
clipboardContent = clipboard.Content.GetBoundCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Input;
|
|
||||||
using osu.Framework.Input.Bindings;
|
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Components
|
namespace osu.Game.Screens.Edit.Components
|
||||||
{
|
{
|
||||||
public partial class EditorContextMenuContainer : OsuContextMenuContainer, IKeyBindingHandler<PlatformAction>
|
public partial class EditorContextMenuContainer : OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
public override bool ChangeFocusOnClick => true;
|
public override bool ChangeFocusOnClick => true;
|
||||||
|
|
||||||
@ -17,20 +14,14 @@ namespace osu.Game.Screens.Edit.Components
|
|||||||
|
|
||||||
protected override Framework.Graphics.UserInterface.Menu CreateMenu() => menu = new OsuContextMenu(true);
|
protected override Framework.Graphics.UserInterface.Menu CreateMenu() => menu = new OsuContextMenu(true);
|
||||||
|
|
||||||
public bool OnPressed(KeyBindingPressEvent<PlatformAction> e)
|
public void ShowMenu()
|
||||||
{
|
{
|
||||||
switch (e.Action)
|
menu.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseMenu()
|
||||||
{
|
{
|
||||||
case PlatformAction.Delete:
|
|
||||||
menu.Close();
|
menu.Close();
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnReleased(KeyBindingReleaseEvent<PlatformAction> e)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ using osu.Game.Graphics.UserInterface;
|
|||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
using osu.Game.Rulesets.Edit;
|
using osu.Game.Rulesets.Edit;
|
||||||
|
using osu.Game.Screens.Edit.Components;
|
||||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -59,6 +60,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
public SelectionScaleHandler ScaleHandler { get; private set; }
|
public SelectionScaleHandler ScaleHandler { get; private set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private EditorContextMenuContainer editorContextMenuContainer { get; set; }
|
||||||
|
|
||||||
protected SelectionHandler()
|
protected SelectionHandler()
|
||||||
{
|
{
|
||||||
selectedBlueprints = new List<SelectionBlueprint<T>>();
|
selectedBlueprints = new List<SelectionBlueprint<T>>();
|
||||||
@ -230,7 +234,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deselect all selected items.
|
/// Deselect all selected items.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void DeselectAll() => SelectedItems.Clear();
|
protected void DeselectAll()
|
||||||
|
{
|
||||||
|
SelectedItems.Clear();
|
||||||
|
editorContextMenuContainer.CloseMenu();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle a blueprint becoming selected.
|
/// Handle a blueprint becoming selected.
|
||||||
|
@ -77,6 +77,12 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public const float WAVEFORM_VISUAL_OFFSET = 20;
|
public const float WAVEFORM_VISUAL_OFFSET = 20;
|
||||||
|
|
||||||
|
[Cached]
|
||||||
|
public EditorContextMenuContainer ContextMenuContainer { get; private set; } = new EditorContextMenuContainer()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
};
|
||||||
|
|
||||||
public override float BackgroundParallaxAmount => 0.1f;
|
public override float BackgroundParallaxAmount => 0.1f;
|
||||||
|
|
||||||
public override bool AllowBackButton => false;
|
public override bool AllowBackButton => false;
|
||||||
@ -320,10 +326,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
editorTimelineShowTimingChanges = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTimingChanges);
|
editorTimelineShowTimingChanges = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTimingChanges);
|
||||||
editorTimelineShowTicks = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTicks);
|
editorTimelineShowTicks = config.GetBindable<bool>(OsuSetting.EditorTimelineShowTicks);
|
||||||
|
|
||||||
AddInternal(new EditorContextMenuContainer
|
ContextMenuContainer.AddRange(new Drawable[]
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
{
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -421,8 +424,10 @@ namespace osu.Game.Screens.Edit
|
|||||||
},
|
},
|
||||||
bottomBar = new BottomBar(),
|
bottomBar = new BottomBar(),
|
||||||
MutationTracker,
|
MutationTracker,
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddInternal(ContextMenuContainer);
|
||||||
|
|
||||||
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
changeHandler?.CanUndo.BindValueChanged(v => undoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
changeHandler?.CanRedo.BindValueChanged(v => redoMenuItem.Action.Disabled = !v.NewValue, true);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user