mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 05:43:21 +08:00
Merge pull request #28640 from bdach/osu-inspector-distance
Show distance in pixels to previous/next object in osu! hitobject inspector
This commit is contained in:
commit
8598e8bf34
@ -51,6 +51,8 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
private readonly Bindable<TernaryState> rectangularGridSnapToggle = new Bindable<TernaryState>();
|
||||
|
||||
protected override Drawable CreateHitObjectInspector() => new OsuHitObjectInspector();
|
||||
|
||||
protected override IEnumerable<TernaryButton> CreateTernaryButtons()
|
||||
=> base.CreateTernaryButtons()
|
||||
.Concat(DistanceSnapProvider.CreateTernaryButtons())
|
||||
@ -101,7 +103,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
|
||||
updatePositionSnapGrid();
|
||||
|
||||
RightToolbox.AddRange(new EditorToolboxGroup[]
|
||||
RightToolbox.AddRange(new Drawable[]
|
||||
{
|
||||
OsuGridToolboxGroup,
|
||||
new TransformToolboxGroup
|
||||
|
42
osu.Game.Rulesets.Osu/Edit/OsuHitObjectInspector.cs
Normal file
42
osu.Game.Rulesets.Osu/Edit/OsuHitObjectInspector.cs
Normal file
@ -0,0 +1,42 @@
|
||||
// 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.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Screens.Edit.Compose.Components;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Edit
|
||||
{
|
||||
public partial class OsuHitObjectInspector : HitObjectInspector
|
||||
{
|
||||
protected override void AddInspectorValues()
|
||||
{
|
||||
base.AddInspectorValues();
|
||||
|
||||
if (EditorBeatmap.SelectedHitObjects.Count > 0)
|
||||
{
|
||||
var firstInSelection = (OsuHitObject)EditorBeatmap.SelectedHitObjects.MinBy(ho => ho.StartTime)!;
|
||||
var lastInSelection = (OsuHitObject)EditorBeatmap.SelectedHitObjects.MaxBy(ho => ho.GetEndTime())!;
|
||||
|
||||
Debug.Assert(firstInSelection != null && lastInSelection != null);
|
||||
|
||||
var precedingObject = (OsuHitObject?)EditorBeatmap.HitObjects.LastOrDefault(ho => ho.GetEndTime() < firstInSelection.StartTime);
|
||||
var nextObject = (OsuHitObject?)EditorBeatmap.HitObjects.FirstOrDefault(ho => ho.StartTime > lastInSelection.GetEndTime());
|
||||
|
||||
if (precedingObject != null && precedingObject is not Spinner)
|
||||
{
|
||||
AddHeader("To previous");
|
||||
AddValue($"{(firstInSelection.StackedPosition - precedingObject.StackedEndPosition).Length:#,0.##}px");
|
||||
}
|
||||
|
||||
if (nextObject != null && nextObject is not Spinner)
|
||||
{
|
||||
AddHeader("To next");
|
||||
AddValue($"{(nextObject.StackedPosition - lastInSelection.StackedEndPosition).Length:#,0.##}px");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -207,7 +207,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
Child = new EditorToolboxGroup("inspector")
|
||||
{
|
||||
Child = new HitObjectInspector()
|
||||
Child = CreateHitObjectInspector()
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -329,6 +329,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// </summary>
|
||||
protected virtual ComposeBlueprintContainer CreateBlueprintContainer() => new ComposeBlueprintContainer(this);
|
||||
|
||||
protected virtual Drawable CreateHitObjectInspector() => new HitObjectInspector();
|
||||
|
||||
/// <summary>
|
||||
/// Construct a drawable ruleset for the provided ruleset.
|
||||
/// </summary>
|
||||
|
@ -10,7 +10,7 @@ using osu.Game.Overlays;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
internal partial class EditorInspector : CompositeDrawable
|
||||
public partial class EditorInspector : CompositeDrawable
|
||||
{
|
||||
protected OsuTextFlowContainer InspectorText = null!;
|
||||
|
||||
|
@ -9,7 +9,7 @@ using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
internal partial class HitObjectInspector : EditorInspector
|
||||
public partial class HitObjectInspector : EditorInspector
|
||||
{
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
@ -29,6 +29,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
rollingTextUpdate?.Cancel();
|
||||
rollingTextUpdate = null;
|
||||
|
||||
AddInspectorValues();
|
||||
|
||||
// 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)
|
||||
rollingTextUpdate ??= Scheduler.AddDelayed(updateInspectorText, 250);
|
||||
}
|
||||
|
||||
protected virtual void AddInspectorValues()
|
||||
{
|
||||
switch (EditorBeatmap.SelectedHitObjects.Count)
|
||||
{
|
||||
case 0:
|
||||
@ -90,9 +100,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
AddValue($"{duration.Duration:#,0.##}ms");
|
||||
}
|
||||
|
||||
// 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.
|
||||
rollingTextUpdate ??= Scheduler.AddDelayed(updateInspectorText, 250);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user