Merge branch 'master' into fix-timeline-depth-ordering

This commit is contained in:
Dan Balasescu
2021-03-29 20:47:47 +09:00
committed by GitHub
27 changed files with 214 additions and 124 deletions

View File

@ -2,11 +2,16 @@
// See the LICENCE file in the repository root for full licence text.
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Platform;
using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Edit;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
@ -14,11 +19,17 @@ using osu.Game.Skinning;
namespace osu.Game.Screens.Edit.Compose
{
public class ComposeScreen : EditorScreenWithTimeline
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; }
private HitObjectComposer composer;
public ComposeScreen()
@ -72,5 +83,34 @@ namespace osu.Game.Screens.Edit.Compose
// this is intentionally done in two stages to ensure things are in a loaded state before exposing the ruleset to skin sources.
return beatmapSkinProvider.WithChild(rulesetSkinProvider.WithChild(content));
}
#region Input Handling
public bool OnPressed(PlatformAction action)
{
if (action.ActionType == PlatformActionType.Copy)
host.GetClipboard().SetText(formatSelectionAsString());
return false;
}
public void OnReleased(PlatformAction action)
{
}
private string formatSelectionAsString()
{
if (composer == null)
return string.Empty;
double displayTime = EditorBeatmap.SelectedHitObjects.OrderBy(h => h.StartTime).FirstOrDefault()?.StartTime ?? clock.CurrentTime;
string selectionAsString = composer.ConvertSelectionToString();
return !string.IsNullOrEmpty(selectionAsString)
? $"{displayTime.ToEditorFormattedString()} ({selectionAsString}) - "
: $"{displayTime.ToEditorFormattedString()} - ";
}
#endregion
}
}