mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
Add ability to lock the WaveformComparison
display to a current location
This commit is contained in:
@ -14,6 +14,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -26,6 +27,8 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
{
|
{
|
||||||
private const int total_waveforms = 8;
|
private const int total_waveforms = 8;
|
||||||
|
|
||||||
|
private const float corner_radius = LabelledDrawable<Drawable>.CORNER_RADIUS;
|
||||||
|
|
||||||
private readonly BindableNumber<double> beatLength = new BindableDouble();
|
private readonly BindableNumber<double> beatLength = new BindableDouble();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -49,11 +52,18 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
private readonly IBindableList<ControlPointGroup> controlPointGroups = new BindableList<ControlPointGroup>();
|
private readonly IBindableList<ControlPointGroup> controlPointGroups = new BindableList<ControlPointGroup>();
|
||||||
|
|
||||||
|
private readonly BindableBool displayLocked = new BindableBool();
|
||||||
|
|
||||||
|
private LockedOverlay lockedOverlay = null!;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; } = null!;
|
||||||
|
|
||||||
public WaveformComparisonDisplay()
|
public WaveformComparisonDisplay()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
CornerRadius = LabelledDrawable<Drawable>.CORNER_RADIUS;
|
CornerRadius = corner_radius;
|
||||||
Masking = true;
|
Masking = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,12 +91,19 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
Width = 3,
|
Width = 3,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddInternal(lockedOverlay = new LockedOverlay());
|
||||||
|
|
||||||
selectedGroup.BindValueChanged(_ => updateTimingGroup(), true);
|
selectedGroup.BindValueChanged(_ => updateTimingGroup(), true);
|
||||||
|
|
||||||
controlPointGroups.BindTo(editorBeatmap.ControlPointInfo.Groups);
|
controlPointGroups.BindTo(editorBeatmap.ControlPointInfo.Groups);
|
||||||
controlPointGroups.BindCollectionChanged((_, __) => updateTimingGroup());
|
controlPointGroups.BindCollectionChanged((_, __) => updateTimingGroup());
|
||||||
|
|
||||||
beatLength.BindValueChanged(_ => showFrom(lastDisplayedBeatIndex), true);
|
beatLength.BindValueChanged(_ => showFrom(lastDisplayedBeatIndex), true);
|
||||||
|
|
||||||
|
displayLocked.BindValueChanged(locked =>
|
||||||
|
{
|
||||||
|
lockedOverlay.FadeTo(locked.NewValue ? 1 : 0, 200, Easing.OutQuint);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTimingGroup()
|
private void updateTimingGroup()
|
||||||
@ -130,6 +147,12 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
return base.OnMouseMove(e);
|
return base.OnMouseMove(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
displayLocked.Toggle();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
@ -147,6 +170,9 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
if (lastDisplayedBeatIndex == beatIndex)
|
if (lastDisplayedBeatIndex == beatIndex)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (displayLocked.Value)
|
||||||
|
return;
|
||||||
|
|
||||||
// Chosen as a pretty usable number across all BPMs.
|
// Chosen as a pretty usable number across all BPMs.
|
||||||
// Optimally we'd want this to scale with the BPM in question, but performing
|
// Optimally we'd want this to scale with the BPM in question, but performing
|
||||||
// scaling of the display is both expensive in resampling, and decreases usability
|
// scaling of the display is both expensive in resampling, and decreases usability
|
||||||
@ -175,6 +201,64 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
lastDisplayedBeatIndex = beatIndex;
|
lastDisplayedBeatIndex = beatIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class LockedOverlay : CompositeDrawable
|
||||||
|
{
|
||||||
|
private OsuSpriteText text = null!;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
Masking = true;
|
||||||
|
CornerRadius = corner_radius;
|
||||||
|
BorderColour = colours.Red;
|
||||||
|
BorderThickness = 3;
|
||||||
|
Alpha = 0;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
AlwaysPresent = true,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
Colour = colours.Red,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
},
|
||||||
|
text = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Colour = colours.GrayF,
|
||||||
|
Text = "Locked",
|
||||||
|
Margin = new MarginPadding(5),
|
||||||
|
Shadow = false,
|
||||||
|
Font = OsuFont.Default.With(size: 12, weight: FontWeight.SemiBold),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
text
|
||||||
|
.FadeIn().Then().Delay(500)
|
||||||
|
.FadeOut().Then().Delay(500)
|
||||||
|
.Loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal class WaveformRow : CompositeDrawable
|
internal class WaveformRow : CompositeDrawable
|
||||||
{
|
{
|
||||||
private OsuSpriteText beatIndexText = null!;
|
private OsuSpriteText beatIndexText = null!;
|
||||||
|
Reference in New Issue
Block a user