set text to platform clipboard on copy

This commit is contained in:
Nathan Alo 2021-03-17 17:35:49 +08:00
parent 891e7aadb6
commit 8046b5a818

View File

@ -21,6 +21,7 @@ using osu.Framework.Screens;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.UserInterface;
@ -29,6 +30,7 @@ using osu.Game.IO.Serialization;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Screens.Edit.Components;
using osu.Game.Screens.Edit.Components.Menus;
using osu.Game.Screens.Edit.Components.Timelines.Summary;
@ -60,6 +62,9 @@ namespace osu.Game.Screens.Edit
protected bool HasUnsavedChanges => lastSavedHash != changeHandler.CurrentStateHash;
[Resolved]
private GameHost host { get; set; }
[Resolved]
private BeatmapManager beatmapManager { get; set; }
@ -104,7 +109,7 @@ namespace osu.Game.Screens.Edit
private MusicController music { get; set; }
[BackgroundDependencyLoader]
private void load(OsuColour colours, GameHost host, OsuConfigManager config)
private void load(OsuColour colours, OsuConfigManager config)
{
if (Beatmap.Value is DummyWorkingBeatmap)
{
@ -542,8 +547,12 @@ namespace osu.Game.Screens.Edit
protected void Copy()
{
if (editorBeatmap.SelectedHitObjects.Count == 0)
{
host.GetClipboard()?.SetText($"{clock.CurrentTime.ToEditorFormattedString()} - ");
return;
}
host.GetClipboard()?.SetText($"{editorBeatmap.SelectedHitObjects.FirstOrDefault().StartTime.ToEditorFormattedString()} ({string.Join(',', editorBeatmap.SelectedHitObjects.Select(h => ((h as IHasComboInformation)?.IndexInCurrentCombo + 1 ?? 0).ToString()))}) - ");
clipboard.Value = new ClipboardContent(editorBeatmap).Serialize();
}