1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 23:12:56 +08:00

Only interact with clipboard via bound copy

This commit is contained in:
Bartłomiej Dach 2024-04-03 11:39:12 +02:00
parent ce68f6adb7
commit 05fe8968d8
No known key found for this signature in database

View File

@ -66,9 +66,6 @@ namespace osu.Game.Overlays.SkinEditor
[Resolved] [Resolved]
private RealmAccess realm { get; set; } = null!; private RealmAccess realm { get; set; } = null!;
[Resolved]
private EditorClipboard clipboard { get; set; } = null!;
[Resolved] [Resolved]
private SkinEditorOverlay? skinEditorOverlay { get; set; } private SkinEditorOverlay? skinEditorOverlay { get; set; }
@ -114,7 +111,7 @@ namespace osu.Game.Overlays.SkinEditor
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load(EditorClipboard clipboard)
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
@ -225,6 +222,8 @@ namespace osu.Game.Overlays.SkinEditor
} }
} }
}; };
clipboardContent = clipboard.Content.GetBoundCopy();
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -244,7 +243,6 @@ namespace osu.Game.Overlays.SkinEditor
canCopy.Value = canCut.Value = SelectedComponents.Any(); canCopy.Value = canCut.Value = SelectedComponents.Any();
}, true); }, true);
clipboardContent = clipboard.Content.GetBoundCopy();
clipboardContent.BindValueChanged(content => canPaste.Value = !string.IsNullOrEmpty(content.NewValue), true); clipboardContent.BindValueChanged(content => canPaste.Value = !string.IsNullOrEmpty(content.NewValue), true);
Show(); Show();
@ -497,7 +495,7 @@ namespace osu.Game.Overlays.SkinEditor
protected void Copy() protected void Copy()
{ {
clipboard.Content.Value = JsonConvert.SerializeObject(SelectedComponents.Cast<Drawable>().Select(s => s.CreateSerialisedInfo()).ToArray()); clipboardContent.Value = JsonConvert.SerializeObject(SelectedComponents.Cast<Drawable>().Select(s => s.CreateSerialisedInfo()).ToArray());
} }
protected void Clone() protected void Clone()
@ -517,7 +515,7 @@ namespace osu.Game.Overlays.SkinEditor
changeHandler?.BeginChange(); changeHandler?.BeginChange();
var drawableInfo = JsonConvert.DeserializeObject<SerialisedDrawableInfo[]>(clipboard.Content.Value); var drawableInfo = JsonConvert.DeserializeObject<SerialisedDrawableInfo[]>(clipboardContent.Value);
if (drawableInfo == null) if (drawableInfo == null)
return; return;