1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00

refactor code

This commit is contained in:
Nathan Alo 2021-03-17 18:06:40 +08:00
parent 8046b5a818
commit 133ff085a5

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text;
using osu.Framework; using osu.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -546,14 +547,24 @@ namespace osu.Game.Screens.Edit
protected void Copy() protected void Copy()
{ {
var builder = new StringBuilder();
const string suffix = " - ";
if (editorBeatmap.SelectedHitObjects.Count == 0) if (editorBeatmap.SelectedHitObjects.Count == 0)
{ {
host.GetClipboard()?.SetText($"{clock.CurrentTime.ToEditorFormattedString()} - "); builder.Append(clock.CurrentTime.ToEditorFormattedString());
return; }
else
{
var orderedHitObjects = editorBeatmap.SelectedHitObjects.OrderBy(h => h.StartTime);
builder.Append(orderedHitObjects.FirstOrDefault().StartTime.ToEditorFormattedString());
builder.Append($" ({string.Join(',', orderedHitObjects.Cast<IHasComboInformation>().Select(h => h.IndexInCurrentCombo + 1))})");
clipboard.Value = new ClipboardContent(editorBeatmap).Serialize();
} }
host.GetClipboard()?.SetText($"{editorBeatmap.SelectedHitObjects.FirstOrDefault().StartTime.ToEditorFormattedString()} ({string.Join(',', editorBeatmap.SelectedHitObjects.Select(h => ((h as IHasComboInformation)?.IndexInCurrentCombo + 1 ?? 0).ToString()))}) - "); builder.Append(suffix);
clipboard.Value = new ClipboardContent(editorBeatmap).Serialize(); host.GetClipboard()?.SetText(builder.ToString());
} }
protected void Paste() protected void Paste()