2023-04-04 18:17:14 +08:00
|
|
|
// 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.Linq;
|
|
|
|
using osu.Framework.Extensions.TypeExtensions;
|
2023-04-06 22:39:36 +08:00
|
|
|
using osu.Framework.Threading;
|
2023-04-04 18:17:14 +08:00
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Edit
|
|
|
|
{
|
2023-05-05 14:40:34 +08:00
|
|
|
internal partial class HitObjectInspector : EditorInspector
|
2023-04-04 18:17:14 +08:00
|
|
|
{
|
2023-04-04 18:31:33 +08:00
|
|
|
protected override void LoadComplete()
|
2023-04-04 18:17:14 +08:00
|
|
|
{
|
2023-04-04 18:31:33 +08:00
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
EditorBeatmap.SelectedHitObjects.CollectionChanged += (_, _) => updateInspectorText();
|
|
|
|
EditorBeatmap.TransactionBegan += updateInspectorText;
|
|
|
|
EditorBeatmap.TransactionEnded += updateInspectorText;
|
2023-04-10 20:13:53 +08:00
|
|
|
updateInspectorText();
|
2023-04-04 18:17:14 +08:00
|
|
|
}
|
|
|
|
|
2023-04-06 22:39:36 +08:00
|
|
|
private ScheduledDelegate? rollingTextUpdate;
|
|
|
|
|
2023-04-04 18:17:14 +08:00
|
|
|
private void updateInspectorText()
|
|
|
|
{
|
2023-05-05 14:40:34 +08:00
|
|
|
InspectorText.Clear();
|
2023-04-06 22:39:36 +08:00
|
|
|
rollingTextUpdate?.Cancel();
|
|
|
|
rollingTextUpdate = null;
|
2023-04-04 18:17:14 +08:00
|
|
|
|
|
|
|
switch (EditorBeatmap.SelectedHitObjects.Count)
|
|
|
|
{
|
|
|
|
case 0:
|
2023-05-05 14:40:34 +08:00
|
|
|
AddValue("No selection");
|
2023-04-04 18:17:14 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
var selected = EditorBeatmap.SelectedHitObjects.Single();
|
|
|
|
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("Type");
|
|
|
|
AddValue($"{selected.GetType().ReadableName()}");
|
2023-04-04 18:17:14 +08:00
|
|
|
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("Time");
|
|
|
|
AddValue($"{selected.StartTime:#,0.##}ms");
|
2023-04-04 18:17:14 +08:00
|
|
|
|
|
|
|
switch (selected)
|
|
|
|
{
|
|
|
|
case IHasPosition pos:
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("Position");
|
|
|
|
AddValue($"x:{pos.X:#,0.##} y:{pos.Y:#,0.##}");
|
2023-04-04 18:17:14 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IHasXPosition x:
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("Position");
|
2023-04-04 18:17:14 +08:00
|
|
|
|
2023-05-05 14:40:34 +08:00
|
|
|
AddValue($"x:{x.X:#,0.##} ");
|
2023-04-04 18:17:14 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IHasYPosition y:
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("Position");
|
2023-04-04 18:17:14 +08:00
|
|
|
|
2023-05-05 14:40:34 +08:00
|
|
|
AddValue($"y:{y.Y:#,0.##}");
|
2023-04-04 18:17:14 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selected is IHasDistance distance)
|
|
|
|
{
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("Distance");
|
|
|
|
AddValue($"{distance.Distance:#,0.##}px");
|
2023-04-04 18:17:14 +08:00
|
|
|
}
|
|
|
|
|
2023-05-05 14:15:18 +08:00
|
|
|
if (selected is IHasSliderVelocity sliderVelocity)
|
|
|
|
{
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("Slider Velocity");
|
|
|
|
AddValue($"{sliderVelocity.SliderVelocity:#,0.00}x");
|
2023-05-05 14:15:18 +08:00
|
|
|
}
|
|
|
|
|
2023-04-04 18:17:14 +08:00
|
|
|
if (selected is IHasRepeats repeats)
|
|
|
|
{
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("Repeats");
|
|
|
|
AddValue($"{repeats.RepeatCount:#,0.##}");
|
2023-04-04 18:17:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (selected is IHasDuration duration)
|
|
|
|
{
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("End Time");
|
|
|
|
AddValue($"{duration.EndTime:#,0.##}ms");
|
|
|
|
AddHeader("Duration");
|
|
|
|
AddValue($"{duration.Duration:#,0.##}ms");
|
2023-04-04 18:17:14 +08:00
|
|
|
}
|
|
|
|
|
2023-04-05 12:45:24 +08:00
|
|
|
// 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.
|
2023-04-06 22:39:36 +08:00
|
|
|
rollingTextUpdate ??= Scheduler.AddDelayed(updateInspectorText, 250);
|
2023-04-04 18:17:14 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("Selected Objects");
|
|
|
|
AddValue($"{EditorBeatmap.SelectedHitObjects.Count:#,0.##}");
|
2023-04-04 18:17:14 +08:00
|
|
|
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("Start Time");
|
|
|
|
AddValue($"{EditorBeatmap.SelectedHitObjects.Min(o => o.StartTime):#,0.##}ms");
|
2023-04-04 18:17:14 +08:00
|
|
|
|
2023-05-05 14:40:34 +08:00
|
|
|
AddHeader("End Time");
|
|
|
|
AddValue($"{EditorBeatmap.SelectedHitObjects.Max(o => o.GetEndTime()):#,0.##}ms");
|
2023-04-04 18:17:14 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|