Update time info and add bpm

This commit is contained in:
Dean Herbert 2022-05-25 23:30:53 +09:00
parent 2c61a9d3d1
commit acd554d918
3 changed files with 27 additions and 7 deletions

View File

@ -12,7 +12,7 @@ using osuTK;
namespace osu.Game.Tests.Visual.Editing namespace osu.Game.Tests.Visual.Editing
{ {
[TestFixture] [TestFixture]
public class TestScenePlaybackControl : OsuTestScene public class TestScenePlaybackControl : EditorClockTestScene
{ {
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()

View File

@ -7,18 +7,23 @@ using osu.Framework.Allocation;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Overlays; using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Screens.Edit.Components namespace osu.Game.Screens.Edit.Components
{ {
public class TimeInfoContainer : BottomBarContainer public class TimeInfoContainer : BottomBarContainer
{ {
private OsuSpriteText trackTimer; private OsuSpriteText trackTimer;
private OsuSpriteText bpm;
[Resolved]
private EditorBeatmap editorBeatmap { get; set; }
[Resolved] [Resolved]
private EditorClock editorClock { get; set; } private EditorClock editorClock { get; set; }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load(OsuColour colours, OverlayColourProvider colourProvider)
{ {
Background.Colour = colourProvider.Background5; Background.Colour = colourProvider.Background5;
@ -28,10 +33,16 @@ namespace osu.Game.Screens.Edit.Components
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
// intentionally fudged centre to avoid movement of the number portion when Spacing = new Vector2(-2, 0),
// going negative. Font = OsuFont.Torus.With(size: 36, fixedWidth: true, weight: FontWeight.Light),
X = -35, Y = -10,
Font = OsuFont.GetFont(size: 25, fixedWidth: true), },
bpm = new OsuSpriteText
{
Colour = colours.Orange1,
Anchor = Anchor.CentreRight,
Font = OsuFont.Torus.With(size: 18, weight: FontWeight.SemiBold),
Y = 5,
} }
}; };
} }
@ -40,6 +51,8 @@ namespace osu.Game.Screens.Edit.Components
{ {
base.Update(); base.Update();
trackTimer.Text = editorClock.CurrentTime.ToEditorFormattedString(); trackTimer.Text = editorClock.CurrentTime.ToEditorFormattedString();
bpm.Text = @$"{editorBeatmap.ControlPointInfo.TimingPointAt(editorClock.CurrentTime).BPM:0} BPM";
bpm.X = 5 - trackTimer.DrawWidth;
} }
} }
} }

View File

@ -6,6 +6,7 @@ using osu.Framework.Bindables;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Rulesets.Edit;
using osu.Game.Screens.Edit; using osu.Game.Screens.Edit;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
@ -19,6 +20,10 @@ namespace osu.Game.Tests.Visual
[Cached] [Cached]
private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Aquamarine); private readonly OverlayColourProvider overlayColour = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
[Cached(typeof(EditorBeatmap))]
[Cached(typeof(IBeatSnapProvider))]
private readonly EditorBeatmap editorBeatmap;
protected readonly BindableBeatDivisor BeatDivisor = new BindableBeatDivisor(); protected readonly BindableBeatDivisor BeatDivisor = new BindableBeatDivisor();
protected new readonly EditorClock Clock; protected new readonly EditorClock Clock;
@ -26,7 +31,9 @@ namespace osu.Game.Tests.Visual
protected EditorClockTestScene() protected EditorClockTestScene()
{ {
Clock = new EditorClock(new Beatmap(), BeatDivisor) { IsCoupled = false }; editorBeatmap = new EditorBeatmap(new Beatmap());
Clock = new EditorClock(editorBeatmap, BeatDivisor) { IsCoupled = false };
} }
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)