Move inline class to end and apply NRT

This commit is contained in:
Dean Herbert 2022-06-02 13:10:50 +09:00
parent d99d37c0a6
commit ac3793f340

View File

@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable enable
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
@ -21,17 +23,17 @@ namespace osu.Game.Screens.Edit.Timing
public class TapTimingControl : CompositeDrawable public class TapTimingControl : CompositeDrawable
{ {
[Resolved] [Resolved]
private EditorClock editorClock { get; set; } private EditorClock editorClock { get; set; } = null!;
[Resolved] [Resolved]
private EditorBeatmap beatmap { get; set; } private EditorBeatmap beatmap { get; set; } = null!;
[Resolved] [Resolved]
private Bindable<ControlPointGroup> selectedGroup { get; set; } private Bindable<ControlPointGroup> selectedGroup { get; set; } = null!;
private readonly BindableBool isHandlingTapping = new BindableBool(); private readonly BindableBool isHandlingTapping = new BindableBool();
private MetronomeDisplay metronome; private MetronomeDisplay metronome = null!;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, OsuColour colours) private void load(OverlayColourProvider colourProvider, OsuColour colours)
@ -141,14 +143,14 @@ namespace osu.Game.Screens.Edit.Timing
CornerRadius = 15, CornerRadius = 15,
Children = new Drawable[] Children = new Drawable[]
{ {
new LessRoundedButton(FontAwesome.Solid.Stop, Anchor.TopLeft) new InlineButton(FontAwesome.Solid.Stop, Anchor.TopLeft)
{ {
BackgroundColour = colourProvider.Background1, BackgroundColour = colourProvider.Background1,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Height = 0.49f, Height = 0.49f,
Action = reset, Action = reset,
}, },
new LessRoundedButton(FontAwesome.Solid.Play, Anchor.BottomLeft) new InlineButton(FontAwesome.Solid.Play, Anchor.BottomLeft)
{ {
BackgroundColour = colourProvider.Background1, BackgroundColour = colourProvider.Background1,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
@ -181,22 +183,63 @@ namespace osu.Game.Screens.Edit.Timing
}, true); }, true);
} }
private class LessRoundedButton : OsuButton private void start()
{
editorClock.Seek(selectedGroup.Value.Time);
editorClock.Start();
}
private void reset()
{
editorClock.Stop();
editorClock.Seek(selectedGroup.Value.Time);
}
private void adjustOffset(double adjust)
{
// VERY TEMPORARY
var currentGroupItems = selectedGroup.Value.ControlPoints.ToArray();
beatmap.ControlPointInfo.RemoveGroup(selectedGroup.Value);
double newOffset = selectedGroup.Value.Time + adjust;
foreach (var cp in currentGroupItems)
beatmap.ControlPointInfo.Add(newOffset, cp);
// the control point might not necessarily exist yet, if currentGroupItems was empty.
selectedGroup.Value = beatmap.ControlPointInfo.GroupAt(newOffset, true);
if (!editorClock.IsRunning)
editorClock.Seek(newOffset);
}
private void adjustBpm(double adjust)
{
var timing = selectedGroup.Value.ControlPoints.OfType<TimingControlPoint>().FirstOrDefault();
if (timing == null)
return;
timing.BeatLength = 60000 / (timing.BPM + adjust);
}
private class InlineButton : OsuButton
{ {
private readonly IconUsage icon; private readonly IconUsage icon;
private readonly Anchor anchor; private readonly Anchor anchor;
private SpriteIcon spriteIcon; private SpriteIcon spriteIcon = null!;
public LessRoundedButton(IconUsage icon, Anchor anchor) [Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
public InlineButton(IconUsage icon, Anchor anchor)
{ {
this.icon = icon; this.icon = icon;
this.anchor = anchor; this.anchor = anchor;
} }
[Resolved]
private OverlayColourProvider colourProvider { get; set; }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
@ -242,46 +285,5 @@ namespace osu.Game.Screens.Edit.Timing
base.OnHoverLost(e); base.OnHoverLost(e);
} }
} }
private void start()
{
editorClock.Seek(selectedGroup.Value.Time);
editorClock.Start();
}
private void adjustOffset(double adjust)
{
// VERY TEMPORARY
var currentGroupItems = selectedGroup.Value.ControlPoints.ToArray();
beatmap.ControlPointInfo.RemoveGroup(selectedGroup.Value);
double newOffset = selectedGroup.Value.Time + adjust;
foreach (var cp in currentGroupItems)
beatmap.ControlPointInfo.Add(newOffset, cp);
// the control point might not necessarily exist yet, if currentGroupItems was empty.
selectedGroup.Value = beatmap.ControlPointInfo.GroupAt(newOffset, true);
if (!editorClock.IsRunning)
editorClock.Seek(newOffset);
}
private void adjustBpm(double adjust)
{
var timing = selectedGroup.Value.ControlPoints.OfType<TimingControlPoint>().FirstOrDefault();
if (timing == null)
return;
timing.BeatLength = 60000 / (timing.BPM + adjust);
}
private void reset()
{
editorClock.Stop();
editorClock.Seek(selectedGroup.Value.Time);
}
} }
} }