1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +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.Diagnostics;
using System.Linq;
using System.Text;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -546,14 +547,24 @@ namespace osu.Game.Screens.Edit
protected void Copy()
{
var builder = new StringBuilder();
const string suffix = " - ";
if (editorBeatmap.SelectedHitObjects.Count == 0)
{
host.GetClipboard()?.SetText($"{clock.CurrentTime.ToEditorFormattedString()} - ");
return;
builder.Append(clock.CurrentTime.ToEditorFormattedString());
}
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()))}) - ");
clipboard.Value = new ClipboardContent(editorBeatmap).Serialize();
builder.Append(suffix);
host.GetClipboard()?.SetText(builder.ToString());
}
protected void Paste()