Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SkinEditor binding event to external bindable #27779

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions osu.Game/Overlays/SkinEditor/SkinEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public partial class SkinEditor : VisibilityContainer, ICanAcceptFiles, IKeyBind
private OsuTextFlowContainer headerText = null!;

private Bindable<Skin> currentSkin = null!;
private Bindable<string> clipboardContent = null!;

[Resolved]
private OsuGame? game { get; set; }
Expand All @@ -65,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; }

Expand Down Expand Up @@ -113,7 +111,7 @@ public SkinEditor(Drawable targetScreen)
}

[BackgroundDependencyLoader]
private void load()
private void load(EditorClipboard clipboard)
{
RelativeSizeAxes = Axes.Both;

Expand Down Expand Up @@ -224,6 +222,8 @@ private void load()
}
}
};

clipboardContent = clipboard.Content.GetBoundCopy();
}

protected override void LoadComplete()
Expand All @@ -243,7 +243,7 @@ protected override void LoadComplete()
canCopy.Value = canCut.Value = SelectedComponents.Any();
}, true);

clipboard.Content.BindValueChanged(content => canPaste.Value = !string.IsNullOrEmpty(content.NewValue), true);
clipboardContent.BindValueChanged(content => canPaste.Value = !string.IsNullOrEmpty(content.NewValue), true);

Show();

Expand Down Expand Up @@ -495,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()
Expand All @@ -515,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;
Expand Down
Loading