mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 09:20:02 +09:00
Move clipboard operation implementation down to current screen
This commit is contained in:
@ -13,6 +13,7 @@ using osu.Framework.Input.Events;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.IO.Serialization;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Screens.Edit.Compose.Components.Timeline;
|
||||
@ -21,15 +22,15 @@ namespace osu.Game.Screens.Edit.Compose
|
||||
{
|
||||
public class ComposeScreen : EditorScreenWithTimeline, IKeyBindingHandler<PlatformAction>
|
||||
{
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private EditorClock clock { get; set; }
|
||||
|
||||
[Resolved(Name = nameof(Editor.Clipboard))]
|
||||
private Bindable<string> clipboard { get; set; }
|
||||
|
||||
private HitObjectComposer composer;
|
||||
|
||||
public ComposeScreen()
|
||||
@ -104,5 +105,53 @@ namespace osu.Game.Screens.Edit.Compose
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Clipboard operations
|
||||
|
||||
public override void Cut()
|
||||
{
|
||||
base.Cut();
|
||||
|
||||
Copy();
|
||||
EditorBeatmap.RemoveRange(EditorBeatmap.SelectedHitObjects.ToArray());
|
||||
}
|
||||
|
||||
public override void Copy()
|
||||
{
|
||||
base.Copy();
|
||||
|
||||
if (EditorBeatmap.SelectedHitObjects.Count == 0)
|
||||
return;
|
||||
|
||||
clipboard.Value = new ClipboardContent(EditorBeatmap).Serialize();
|
||||
}
|
||||
|
||||
public override void Paste()
|
||||
{
|
||||
base.Paste();
|
||||
|
||||
if (string.IsNullOrEmpty(clipboard.Value))
|
||||
return;
|
||||
|
||||
var objects = clipboard.Value.Deserialize<ClipboardContent>().HitObjects;
|
||||
|
||||
Debug.Assert(objects.Any());
|
||||
|
||||
double timeOffset = clock.CurrentTime - objects.Min(o => o.StartTime);
|
||||
|
||||
foreach (var h in objects)
|
||||
h.StartTime += timeOffset;
|
||||
|
||||
EditorBeatmap.BeginChange();
|
||||
|
||||
EditorBeatmap.SelectedHitObjects.Clear();
|
||||
|
||||
EditorBeatmap.AddRange(objects);
|
||||
EditorBeatmap.SelectedHitObjects.AddRange(objects);
|
||||
|
||||
EditorBeatmap.EndChange();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user