mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 03:02:54 +08:00
Move metronome into own class and rename to avoid conflict with mod sounds
This commit is contained in:
parent
cf97f4e409
commit
2e21d75b10
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Mods
|
|||||||
MuteComboCount = { Value = 0 },
|
MuteComboCount = { Value = 0 },
|
||||||
},
|
},
|
||||||
PassCondition = () => Beatmap.Value.Track.AggregateVolume.Value == 0.0 &&
|
PassCondition = () => Beatmap.Value.Track.AggregateVolume.Value == 0.0 &&
|
||||||
Player.ChildrenOfType<Metronome>().SingleOrDefault()?.AggregateVolume.Value == 1.0,
|
Player.ChildrenOfType<MetronomeBeat>().SingleOrDefault()?.AggregateVolume.Value == 1.0,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -339,7 +339,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
|
|
||||||
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
|
||||||
{
|
{
|
||||||
drawableRuleset.Overlays.Add(new Metronome(drawableRuleset.Beatmap.HitObjects.First().StartTime));
|
drawableRuleset.Overlays.Add(new MetronomeBeat(drawableRuleset.Beatmap.HitObjects.First().StartTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -73,7 +73,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("click tap button", () =>
|
AddStep("click tap button", () =>
|
||||||
{
|
{
|
||||||
control.ChildrenOfType<RoundedButton>()
|
control.ChildrenOfType<RoundedButton>()
|
||||||
.First(b => b.Text == "Tap to beat")
|
.Last()
|
||||||
.TriggerClick();
|
.TriggerClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("click reset button", () =>
|
AddStep("click reset button", () =>
|
||||||
{
|
{
|
||||||
control.ChildrenOfType<RoundedButton>()
|
control.ChildrenOfType<RoundedButton>()
|
||||||
.First(b => b.Text == "Reset")
|
.First()
|
||||||
.TriggerClick();
|
.TriggerClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("click tap button", () =>
|
AddStep("click tap button", () =>
|
||||||
{
|
{
|
||||||
control.ChildrenOfType<RoundedButton>()
|
control.ChildrenOfType<RoundedButton>()
|
||||||
.First(b => b.Text == "Tap to beat")
|
.Last()
|
||||||
.TriggerClick();
|
.TriggerClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -11,14 +11,14 @@ using osu.Game.Skinning;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public class Metronome : BeatSyncedContainer, IAdjustableAudioComponent
|
public class MetronomeBeat : BeatSyncedContainer, IAdjustableAudioComponent
|
||||||
{
|
{
|
||||||
private readonly double firstHitTime;
|
private readonly double firstHitTime;
|
||||||
|
|
||||||
private readonly PausableSkinnableSound sample;
|
private readonly PausableSkinnableSound sample;
|
||||||
|
|
||||||
/// <param name="firstHitTime">Start time of the first hit object, used for providing a count down.</param>
|
/// <param name="firstHitTime">Start time of the first hit object, used for providing a count down.</param>
|
||||||
public Metronome(double firstHitTime)
|
public MetronomeBeat(double firstHitTime)
|
||||||
{
|
{
|
||||||
this.firstHitTime = firstHitTime;
|
this.firstHitTime = firstHitTime;
|
||||||
AllowMistimedEventFiring = false;
|
AllowMistimedEventFiring = false;
|
@ -79,11 +79,11 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
{
|
{
|
||||||
if (EnableMetronome.Value)
|
if (EnableMetronome.Value)
|
||||||
{
|
{
|
||||||
Metronome metronome;
|
MetronomeBeat metronomeBeat;
|
||||||
|
|
||||||
drawableRuleset.Overlays.Add(metronome = new Metronome(drawableRuleset.Beatmap.HitObjects.First().StartTime));
|
drawableRuleset.Overlays.Add(metronomeBeat = new MetronomeBeat(drawableRuleset.Beatmap.HitObjects.First().StartTime));
|
||||||
|
|
||||||
metronome.AddAdjustment(AdjustableProperty.Volume, metronomeVolumeAdjust);
|
metronomeBeat.AddAdjustment(AdjustableProperty.Volume, metronomeVolumeAdjust);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AffectsHitSounds.Value)
|
if (AffectsHitSounds.Value)
|
||||||
|
255
osu.Game/Screens/Edit/Timing/MetronomeDisplay.cs
Normal file
255
osu.Game/Screens/Edit/Timing/MetronomeDisplay.cs
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
// 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 osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio.Track;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Overlays;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Timing
|
||||||
|
{
|
||||||
|
public class MetronomeDisplay : BeatSyncedContainer
|
||||||
|
{
|
||||||
|
private Container swing;
|
||||||
|
|
||||||
|
private OsuSpriteText bpmText;
|
||||||
|
|
||||||
|
private Drawable weight;
|
||||||
|
private Drawable stick;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OverlayColourProvider overlayColourProvider { get; set; }
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
const float taper = 25;
|
||||||
|
const float swing_vertical_offset = -23;
|
||||||
|
const float lower_cover_height = 32;
|
||||||
|
|
||||||
|
var triangleSize = new Vector2(90, 120 + taper);
|
||||||
|
|
||||||
|
Margin = new MarginPadding(10);
|
||||||
|
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Name = @"Taper adjust",
|
||||||
|
Masking = true,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Size = new Vector2(triangleSize.X, triangleSize.Y - taper),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Triangle
|
||||||
|
{
|
||||||
|
Name = @"Main body",
|
||||||
|
EdgeSmoothness = new Vector2(1),
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Size = triangleSize,
|
||||||
|
Colour = overlayColourProvider.Background3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new Circle
|
||||||
|
{
|
||||||
|
Name = "Centre marker",
|
||||||
|
Colour = overlayColourProvider.Background5,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Width = 2,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Y = -(lower_cover_height + 3),
|
||||||
|
Height = 0.65f,
|
||||||
|
},
|
||||||
|
swing = new Container
|
||||||
|
{
|
||||||
|
Name = @"Swing",
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Y = swing_vertical_offset,
|
||||||
|
Height = 0.80f,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
stick = new Circle
|
||||||
|
{
|
||||||
|
Name = @"Stick",
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Colour = overlayColourProvider.Colour2,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Width = 4,
|
||||||
|
},
|
||||||
|
weight = new Container
|
||||||
|
{
|
||||||
|
Name = @"Weight",
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Colour = overlayColourProvider.Colour0,
|
||||||
|
Size = new Vector2(10),
|
||||||
|
Rotation = 180,
|
||||||
|
RelativePositionAxes = Axes.Y,
|
||||||
|
Y = 0.4f,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Shear = new Vector2(0.2f, 0),
|
||||||
|
EdgeSmoothness = new Vector2(1),
|
||||||
|
},
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Shear = new Vector2(-0.2f, 0),
|
||||||
|
EdgeSmoothness = new Vector2(1),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Name = @"Taper adjust",
|
||||||
|
Masking = true,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Size = new Vector2(triangleSize.X, triangleSize.Y - taper),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Circle
|
||||||
|
{
|
||||||
|
Name = @"Locking wedge",
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Colour = overlayColourProvider.Background1,
|
||||||
|
Size = new Vector2(8),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new Circle
|
||||||
|
{
|
||||||
|
Name = @"Swing connection point",
|
||||||
|
Y = swing_vertical_offset,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Colour = overlayColourProvider.Colour0,
|
||||||
|
Size = new Vector2(8)
|
||||||
|
},
|
||||||
|
new Container
|
||||||
|
{
|
||||||
|
Name = @"Lower cover",
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Masking = true,
|
||||||
|
Height = lower_cover_height,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Triangle
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Size = triangleSize,
|
||||||
|
Colour = overlayColourProvider.Background2,
|
||||||
|
EdgeSmoothness = new Vector2(1),
|
||||||
|
Alpha = 0.8f
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
bpmText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Name = @"BPM display",
|
||||||
|
Colour = overlayColourProvider.Content1,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Y = -3,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private double beatLength;
|
||||||
|
|
||||||
|
private TimingControlPoint timingPoint;
|
||||||
|
|
||||||
|
private bool isSwinging;
|
||||||
|
|
||||||
|
private readonly BindableInt interpolatedBpm = new BindableInt();
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
interpolatedBpm.BindValueChanged(bpm => bpmText.Text = bpm.NewValue.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
timingPoint = Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(BeatSyncClock.CurrentTime);
|
||||||
|
|
||||||
|
if (beatLength != timingPoint.BeatLength)
|
||||||
|
{
|
||||||
|
beatLength = timingPoint.BeatLength;
|
||||||
|
|
||||||
|
EarlyActivationMilliseconds = timingPoint.BeatLength / 2;
|
||||||
|
|
||||||
|
float bpmRatio = (float)Interpolation.ApplyEasing(Easing.OutQuad, Math.Clamp((timingPoint.BPM - 30) / 480, 0, 1));
|
||||||
|
|
||||||
|
weight.MoveToY((float)Interpolation.Lerp(0.1f, 0.83f, bpmRatio), 600, Easing.OutQuint);
|
||||||
|
this.TransformBindableTo(interpolatedBpm, (int)timingPoint.BPM, 600, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BeatSyncClock?.IsRunning != true && isSwinging)
|
||||||
|
{
|
||||||
|
swing.ClearTransforms(true);
|
||||||
|
|
||||||
|
using (swing.BeginDelayedSequence(350))
|
||||||
|
{
|
||||||
|
swing.RotateTo(0, 1000, Easing.OutQuint);
|
||||||
|
stick.FadeColour(overlayColourProvider.Colour2, 1000, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
isSwinging = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
||||||
|
{
|
||||||
|
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
||||||
|
|
||||||
|
const float angle = 27.5f;
|
||||||
|
|
||||||
|
if (!IsBeatSyncedWithTrack)
|
||||||
|
return;
|
||||||
|
|
||||||
|
isSwinging = true;
|
||||||
|
|
||||||
|
float currentAngle = swing.Rotation;
|
||||||
|
float targetAngle = currentAngle > 0 ? -angle : angle;
|
||||||
|
|
||||||
|
swing.RotateTo(targetAngle, beatLength, Easing.InOutQuad);
|
||||||
|
|
||||||
|
if (currentAngle != 0 && Math.Abs(currentAngle - targetAngle) > angle * 1.8f && isSwinging)
|
||||||
|
{
|
||||||
|
using (stick.BeginDelayedSequence(beatLength / 2))
|
||||||
|
stick.FlashColour(overlayColourProvider.Content1, beatLength, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +1,15 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio.Track;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
|
||||||
using osu.Game.Graphics.Sprites;
|
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osuTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Timing
|
namespace osu.Game.Screens.Edit.Timing
|
||||||
{
|
{
|
||||||
@ -24,6 +18,9 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private EditorClock editorClock { get; set; }
|
private EditorClock editorClock { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private Bindable<ControlPointGroup> selectedGroup { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OverlayColourProvider colourProvider, OsuColour colours)
|
private void load(OverlayColourProvider colourProvider, OsuColour colours)
|
||||||
{
|
{
|
||||||
@ -52,7 +49,11 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
{
|
{
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
new Metronome()
|
new MetronomeDisplay
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
@ -74,7 +75,7 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
Text = "Tap to beat",
|
Text = "Play from start",
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
BackgroundColour = colourProvider.Background1,
|
BackgroundColour = colourProvider.Background1,
|
||||||
Width = 0.68f,
|
Width = 0.68f,
|
||||||
@ -90,252 +91,14 @@ namespace osu.Game.Screens.Edit.Timing
|
|||||||
|
|
||||||
private void tap()
|
private void tap()
|
||||||
{
|
{
|
||||||
if (!editorClock.IsRunning)
|
editorClock.Seek(selectedGroup.Value.Time);
|
||||||
{
|
editorClock.Start();
|
||||||
editorClock.Seek(0);
|
|
||||||
editorClock.Start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reset()
|
private void reset()
|
||||||
{
|
{
|
||||||
editorClock.Stop();
|
editorClock.Stop();
|
||||||
}
|
editorClock.Seek(selectedGroup.Value.Time);
|
||||||
|
|
||||||
private class Metronome : BeatSyncedContainer
|
|
||||||
{
|
|
||||||
private Container swing;
|
|
||||||
|
|
||||||
private OsuSpriteText bpmText;
|
|
||||||
|
|
||||||
private Drawable weight;
|
|
||||||
private Drawable stick;
|
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private OverlayColourProvider overlayColourProvider { get; set; }
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
const float taper = 25;
|
|
||||||
const float swing_vertical_offset = -23;
|
|
||||||
const float lower_cover_height = 32;
|
|
||||||
|
|
||||||
var triangleSize = new Vector2(90, 120 + taper);
|
|
||||||
|
|
||||||
Margin = new MarginPadding(10);
|
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
Name = @"Taper adjust",
|
|
||||||
Masking = true,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Size = new Vector2(triangleSize.X, triangleSize.Y - taper),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Triangle
|
|
||||||
{
|
|
||||||
Name = @"Main body",
|
|
||||||
EdgeSmoothness = new Vector2(1),
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Size = triangleSize,
|
|
||||||
Colour = overlayColourProvider.Background3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new Circle
|
|
||||||
{
|
|
||||||
Name = "Centre marker",
|
|
||||||
Colour = overlayColourProvider.Background5,
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
Width = 2,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Y = -(lower_cover_height + 3),
|
|
||||||
Height = 0.65f,
|
|
||||||
},
|
|
||||||
swing = new Container
|
|
||||||
{
|
|
||||||
Name = @"Swing",
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Y = swing_vertical_offset,
|
|
||||||
Height = 0.80f,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Children = new[]
|
|
||||||
{
|
|
||||||
stick = new Circle
|
|
||||||
{
|
|
||||||
Name = @"Stick",
|
|
||||||
RelativeSizeAxes = Axes.Y,
|
|
||||||
Colour = overlayColourProvider.Colour2,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Width = 4,
|
|
||||||
},
|
|
||||||
weight = new Container
|
|
||||||
{
|
|
||||||
Name = @"Weight",
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Colour = overlayColourProvider.Colour0,
|
|
||||||
Size = new Vector2(10),
|
|
||||||
Rotation = 180,
|
|
||||||
RelativePositionAxes = Axes.Y,
|
|
||||||
Y = 0.4f,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Shear = new Vector2(0.2f, 0),
|
|
||||||
EdgeSmoothness = new Vector2(1),
|
|
||||||
},
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Shear = new Vector2(-0.2f, 0),
|
|
||||||
EdgeSmoothness = new Vector2(1),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
Name = @"Taper adjust",
|
|
||||||
Masking = true,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Size = new Vector2(triangleSize.X, triangleSize.Y - taper),
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Circle
|
|
||||||
{
|
|
||||||
Name = @"Locking wedge",
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Colour = overlayColourProvider.Background1,
|
|
||||||
Size = new Vector2(8),
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new Circle
|
|
||||||
{
|
|
||||||
Name = @"Swing connection point",
|
|
||||||
Y = swing_vertical_offset,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Colour = overlayColourProvider.Colour0,
|
|
||||||
Size = new Vector2(8)
|
|
||||||
},
|
|
||||||
new Container
|
|
||||||
{
|
|
||||||
Name = @"Lower cover",
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Masking = true,
|
|
||||||
Height = lower_cover_height,
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Triangle
|
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Size = triangleSize,
|
|
||||||
Colour = overlayColourProvider.Background2,
|
|
||||||
EdgeSmoothness = new Vector2(1),
|
|
||||||
Alpha = 0.8f
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
bpmText = new OsuSpriteText
|
|
||||||
{
|
|
||||||
Name = @"BPM display",
|
|
||||||
Colour = overlayColourProvider.Content1,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Y = -3,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private double beatLength;
|
|
||||||
|
|
||||||
private TimingControlPoint timingPoint;
|
|
||||||
|
|
||||||
private bool isSwinging;
|
|
||||||
|
|
||||||
private readonly BindableInt interpolatedBpm = new BindableInt();
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
interpolatedBpm.BindValueChanged(bpm => bpmText.Text = bpm.NewValue.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
timingPoint = Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(BeatSyncClock.CurrentTime);
|
|
||||||
|
|
||||||
if (beatLength != timingPoint.BeatLength)
|
|
||||||
{
|
|
||||||
beatLength = timingPoint.BeatLength;
|
|
||||||
|
|
||||||
EarlyActivationMilliseconds = timingPoint.BeatLength / 2;
|
|
||||||
|
|
||||||
float bpmRatio = (float)Interpolation.ApplyEasing(Easing.OutQuad, Math.Clamp((timingPoint.BPM - 30) / 480, 0, 1));
|
|
||||||
|
|
||||||
weight.MoveToY((float)Interpolation.Lerp(0.1f, 0.83f, bpmRatio), 600, Easing.OutQuint);
|
|
||||||
this.TransformBindableTo(interpolatedBpm, (int)timingPoint.BPM, 600, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BeatSyncClock?.IsRunning != true && isSwinging)
|
|
||||||
{
|
|
||||||
swing.ClearTransforms(true);
|
|
||||||
|
|
||||||
using (swing.BeginDelayedSequence(350))
|
|
||||||
{
|
|
||||||
swing.RotateTo(0, 1000, Easing.OutQuint);
|
|
||||||
stick.FadeColour(overlayColourProvider.Colour2, 1000, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
|
|
||||||
isSwinging = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
|
|
||||||
{
|
|
||||||
base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes);
|
|
||||||
|
|
||||||
const float angle = 27.5f;
|
|
||||||
|
|
||||||
if (!IsBeatSyncedWithTrack)
|
|
||||||
return;
|
|
||||||
|
|
||||||
isSwinging = true;
|
|
||||||
|
|
||||||
float currentAngle = swing.Rotation;
|
|
||||||
float targetAngle = currentAngle > 0 ? -angle : angle;
|
|
||||||
|
|
||||||
swing.RotateTo(targetAngle, beatLength, Easing.InOutQuad);
|
|
||||||
|
|
||||||
if (currentAngle != 0 && Math.Abs(currentAngle - targetAngle) > angle * 1.8f && isSwinging)
|
|
||||||
{
|
|
||||||
using (stick.BeginDelayedSequence(beatLength / 2))
|
|
||||||
stick.FlashColour(overlayColourProvider.Content1, beatLength, Easing.OutQuint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user