Make skin editor clipboard shared between screens and skins to allow moving elements over

This commit is contained in:
Dean Herbert 2023-02-15 19:35:37 +09:00
parent bc83b0c264
commit 925deb7ca5
2 changed files with 9 additions and 5 deletions

View File

@ -49,9 +49,6 @@ namespace osu.Game.Overlays.SkinEditor
private Bindable<Skin> currentSkin = null!;
[Cached]
public readonly EditorClipboard Clipboard = new EditorClipboard();
[Resolved]
private OsuGame? game { get; set; }
@ -64,6 +61,9 @@ namespace osu.Game.Overlays.SkinEditor
[Resolved]
private RealmAccess realm { get; set; } = null!;
[Resolved]
private EditorClipboard clipboard { get; set; } = null!;
[Resolved]
private SkinEditorOverlay? skinEditorOverlay { get; set; }
@ -232,7 +232,7 @@ namespace osu.Game.Overlays.SkinEditor
canCopy.Value = canCut.Value = SelectedComponents.Any();
}, true);
Clipboard.Content.BindValueChanged(content => canPaste.Value = !string.IsNullOrEmpty(content.NewValue), true);
clipboard.Content.BindValueChanged(content => canPaste.Value = !string.IsNullOrEmpty(content.NewValue), true);
Show();
@ -414,7 +414,7 @@ namespace osu.Game.Overlays.SkinEditor
protected void Copy()
{
Clipboard.Content.Value = JsonConvert.SerializeObject(SelectedComponents.Cast<Drawable>().Select(s => s.CreateSerialisedInfo()).ToArray());
clipboard.Content.Value = JsonConvert.SerializeObject(SelectedComponents.Cast<Drawable>().Select(s => s.CreateSerialisedInfo()).ToArray());
}
protected void Clone()

View File

@ -11,6 +11,7 @@ using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Screens;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Components;
using osuTK;
@ -28,6 +29,9 @@ namespace osu.Game.Overlays.SkinEditor
private SkinEditor? skinEditor;
[Cached]
public readonly EditorClipboard Clipboard = new EditorClipboard();
[Resolved]
private OsuGame game { get; set; } = null!;