mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Merge pull request #29366 from peppy/editor-inspector-during-placement
Show object inspector values during placement
This commit is contained in:
commit
dc3e6c1e6b
@ -11,14 +11,14 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
public partial class OsuHitObjectInspector : HitObjectInspector
|
||||
{
|
||||
protected override void AddInspectorValues()
|
||||
protected override void AddInspectorValues(HitObject[] objects)
|
||||
{
|
||||
base.AddInspectorValues();
|
||||
base.AddInspectorValues(objects);
|
||||
|
||||
if (EditorBeatmap.SelectedHitObjects.Count > 0)
|
||||
if (objects.Length > 0)
|
||||
{
|
||||
var firstInSelection = (OsuHitObject)EditorBeatmap.SelectedHitObjects.MinBy(ho => ho.StartTime)!;
|
||||
var lastInSelection = (OsuHitObject)EditorBeatmap.SelectedHitObjects.MaxBy(ho => ho.GetEndTime())!;
|
||||
var firstInSelection = (OsuHitObject)objects.MinBy(ho => ho.StartTime)!;
|
||||
var lastInSelection = (OsuHitObject)objects.MaxBy(ho => ho.GetEndTime())!;
|
||||
|
||||
Debug.Assert(firstInSelection != null && lastInSelection != null);
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Threading;
|
||||
@ -16,6 +17,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
base.LoadComplete();
|
||||
|
||||
EditorBeatmap.SelectedHitObjects.CollectionChanged += (_, _) => updateInspectorText();
|
||||
EditorBeatmap.PlacementObject.BindValueChanged(_ => updateInspectorText());
|
||||
EditorBeatmap.TransactionBegan += updateInspectorText;
|
||||
EditorBeatmap.TransactionEnded += updateInspectorText;
|
||||
updateInspectorText();
|
||||
@ -29,24 +31,33 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
rollingTextUpdate?.Cancel();
|
||||
rollingTextUpdate = null;
|
||||
|
||||
AddInspectorValues();
|
||||
HitObject[] objects;
|
||||
|
||||
if (EditorBeatmap.SelectedHitObjects.Count > 0)
|
||||
objects = EditorBeatmap.SelectedHitObjects.ToArray();
|
||||
else if (EditorBeatmap.PlacementObject.Value != null)
|
||||
objects = new[] { EditorBeatmap.PlacementObject.Value };
|
||||
else
|
||||
objects = Array.Empty<HitObject>();
|
||||
|
||||
AddInspectorValues(objects);
|
||||
|
||||
// I'd hope there's a better way to do this, but I don't want to bind to each and every property above to watch for changes.
|
||||
// This is a good middle-ground for the time being.
|
||||
if (EditorBeatmap.SelectedHitObjects.Count > 0)
|
||||
if (objects.Length > 0)
|
||||
rollingTextUpdate ??= Scheduler.AddDelayed(updateInspectorText, 250);
|
||||
}
|
||||
|
||||
protected virtual void AddInspectorValues()
|
||||
protected virtual void AddInspectorValues(HitObject[] objects)
|
||||
{
|
||||
switch (EditorBeatmap.SelectedHitObjects.Count)
|
||||
switch (objects.Length)
|
||||
{
|
||||
case 0:
|
||||
AddValue("No selection");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
var selected = EditorBeatmap.SelectedHitObjects.Single();
|
||||
var selected = objects.Single();
|
||||
|
||||
AddHeader("Type");
|
||||
AddValue($"{selected.GetType().ReadableName()}");
|
||||
@ -105,13 +116,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
default:
|
||||
AddHeader("Selected Objects");
|
||||
AddValue($"{EditorBeatmap.SelectedHitObjects.Count:#,0.##}");
|
||||
AddValue($"{objects.Length:#,0.##}");
|
||||
|
||||
AddHeader("Start Time");
|
||||
AddValue($"{EditorBeatmap.SelectedHitObjects.Min(o => o.StartTime):#,0.##}ms");
|
||||
AddValue($"{objects.Min(o => o.StartTime):#,0.##}ms");
|
||||
|
||||
AddHeader("End Time");
|
||||
AddValue($"{EditorBeatmap.SelectedHitObjects.Max(o => o.GetEndTime()):#,0.##}ms");
|
||||
AddValue($"{objects.Max(o => o.GetEndTime()):#,0.##}ms");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user