Skip to content

Commit

Permalink
Adjust visuals slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jan 21, 2025
1 parent 8f33b4c commit a7c9f84
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions osu.Game/Screens/Edit/Timing/MetronomeDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
using osu.Framework.Timing;
using osu.Framework.Utils;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Utils;
using osuTK;

namespace osu.Game.Screens.Edit.Timing
Expand All @@ -28,7 +29,7 @@ public partial class MetronomeDisplay : BeatSyncedContainer
{
private Container swing = null!;

private OsuSpriteText bpmText = null!;
private OsuTextFlowContainer bpmText = null!;

private Drawable weight = null!;
private Drawable stick = null!;
Expand Down Expand Up @@ -213,10 +214,15 @@ private void load(AudioManager audio)
},
}
},
bpmText = new OsuSpriteText
bpmText = new OsuTextFlowContainer(st =>
{
st.Font = OsuFont.Default.With(fixedWidth: true);
st.Spacing = new Vector2(-2.2f, 0);
})
{
Name = @"BPM display",
Colour = overlayColourProvider.Content1,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Y = -3,
Expand Down Expand Up @@ -262,13 +268,20 @@ protected override void LoadComplete()

private void updateBpmText()
{
int intPart = (int)interpolatedBpm.Value;

bpmText.Text = intPart.ToLocalisableString();

// While interpolating between two integer values, showing the decimal places would look a bit odd
// so rounding is applied until we're close to the final value.
double bpm = Precision.AlmostEquals(interpolatedBpm.Value, effectiveBpm, 1.0)
? effectiveBpm
: Math.Round(interpolatedBpm.Value);
int decimalPlaces = FormatUtils.FindPrecision((decimal)effectiveBpm);

bpmText.Text = bpm.ToLocalisableString("0.##");
if (decimalPlaces > 0)
{
bool reachedFinalNumber = intPart == (int)effectiveBpm;

bpmText.AddText((effectiveBpm % 1).ToLocalisableString("." + new string('0', decimalPlaces)), cp => cp.Alpha = reachedFinalNumber ? 0.5f : 0.1f);
}
}

protected override void Update()
Expand All @@ -294,7 +307,7 @@ protected override void Update()

weight.MoveToY((float)Interpolation.Lerp(0.1f, 0.83f, bpmRatio), 600, Easing.OutQuint);

this.TransformBindableTo(interpolatedBpm, effectiveBpm, 600, Easing.OutQuint);
this.TransformBindableTo(interpolatedBpm, effectiveBpm, 300, Easing.OutExpo);
}

if (!BeatSyncSource.Clock.IsRunning && isSwinging)
Expand Down

0 comments on commit a7c9f84

Please sign in to comment.