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
1 changed files with 5 additions and 7 deletions

View File

@ -66,9 +66,6 @@ public partial class SkinEditor : VisibilityContainer, ICanAcceptFiles, IKeyBind
[Resolved]
private RealmAccess realm { get; set; } = null!;
[Resolved]
private EditorClipboard clipboard { get; set; } = null!;
[Resolved]
private SkinEditorOverlay? skinEditorOverlay { get; set; }
@ -114,7 +111,7 @@ public SkinEditor(Drawable targetScreen)
}
[BackgroundDependencyLoader]
private void load()
private void load(EditorClipboard clipboard)
{
RelativeSizeAxes = Axes.Both;
@ -225,6 +222,8 @@ private void load()
}
}
};
clipboardContent = clipboard.Content.GetBoundCopy();
}
protected override void LoadComplete()
@ -244,7 +243,6 @@ protected override void LoadComplete()
canCopy.Value = canCut.Value = SelectedComponents.Any();
}, true);
clipboardContent = clipboard.Content.GetBoundCopy();
clipboardContent.BindValueChanged(content => canPaste.Value = !string.IsNullOrEmpty(content.NewValue), true);
Show();
@ -497,7 +495,7 @@ protected void Cut()
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()
@ -517,7 +515,7 @@ protected void Paste()
changeHandler?.BeginChange();
var drawableInfo = JsonConvert.DeserializeObject<SerialisedDrawableInfo[]>(clipboard.Content.Value);
var drawableInfo = JsonConvert.DeserializeObject<SerialisedDrawableInfo[]>(clipboardContent.Value);
if (drawableInfo == null)
return;