mirror of
https://github.com/ppy/osu.git
synced 2024-11-15 13:47:24 +08:00
29b8948609
This removes the BPM display, which is commonly cited to have no functional purpose by users, and reduces the height of the bottom bar in exchange for more space for the playfield.
142 lines
4.6 KiB
C#
142 lines
4.6 KiB
C#
// 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 osu.Framework.Graphics;
|
|
using osu.Game.Graphics.Sprites;
|
|
using osu.Framework.Allocation;
|
|
using osu.Framework.Graphics.Containers;
|
|
using osu.Framework.Graphics.Shapes;
|
|
using osu.Game.Extensions;
|
|
using osu.Game.Graphics;
|
|
using osu.Game.Graphics.Containers;
|
|
using osu.Game.Graphics.UserInterface;
|
|
using osu.Game.Overlays;
|
|
using osuTK;
|
|
|
|
namespace osu.Game.Screens.Edit.Components
|
|
{
|
|
public partial class TimeInfoContainer : BottomBarContainer
|
|
{
|
|
[Resolved]
|
|
private EditorBeatmap editorBeatmap { get; set; } = null!;
|
|
|
|
[Resolved]
|
|
private EditorClock editorClock { get; set; } = null!;
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load(OverlayColourProvider colourProvider)
|
|
{
|
|
Background.Colour = colourProvider.Background5;
|
|
|
|
Children = new Drawable[]
|
|
{
|
|
new TimestampControl(),
|
|
};
|
|
}
|
|
|
|
private partial class TimestampControl : OsuClickableContainer
|
|
{
|
|
private Container hoverLayer = null!;
|
|
private OsuSpriteText trackTimer = null!;
|
|
private OsuTextBox inputTextBox = null!;
|
|
|
|
[Resolved]
|
|
private Editor? editor { get; set; }
|
|
|
|
[Resolved]
|
|
private EditorClock editorClock { get; set; } = null!;
|
|
|
|
public TimestampControl()
|
|
: base(HoverSampleSet.Button)
|
|
{
|
|
}
|
|
|
|
[BackgroundDependencyLoader]
|
|
private void load()
|
|
{
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
AddRangeInternal(new Drawable[]
|
|
{
|
|
hoverLayer = new Container
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
Padding = new MarginPadding
|
|
{
|
|
Top = 5,
|
|
Horizontal = -2
|
|
},
|
|
Child = new Container
|
|
{
|
|
RelativeSizeAxes = Axes.Both,
|
|
CornerRadius = 5,
|
|
Masking = true,
|
|
Children = new Drawable[]
|
|
{
|
|
new Box { RelativeSizeAxes = Axes.Both, },
|
|
}
|
|
},
|
|
Alpha = 0,
|
|
},
|
|
trackTimer = new OsuSpriteText
|
|
{
|
|
Anchor = Anchor.CentreLeft,
|
|
Origin = Anchor.CentreLeft,
|
|
Spacing = new Vector2(-2, 0),
|
|
Font = OsuFont.Torus.With(size: 36, fixedWidth: true, weight: FontWeight.Light),
|
|
},
|
|
inputTextBox = new OsuTextBox
|
|
{
|
|
Width = 150,
|
|
Height = 36,
|
|
Alpha = 0,
|
|
CommitOnFocusLost = true,
|
|
},
|
|
});
|
|
|
|
Action = () =>
|
|
{
|
|
trackTimer.Alpha = 0;
|
|
inputTextBox.Alpha = 1;
|
|
inputTextBox.Text = editorClock.CurrentTime.ToEditorFormattedString();
|
|
Schedule(() =>
|
|
{
|
|
GetContainingFocusManager()!.ChangeFocus(inputTextBox);
|
|
inputTextBox.SelectAll();
|
|
});
|
|
};
|
|
|
|
inputTextBox.Current.BindValueChanged(val => editor?.HandleTimestamp(val.NewValue));
|
|
|
|
inputTextBox.OnCommit += (_, __) =>
|
|
{
|
|
trackTimer.Alpha = 1;
|
|
inputTextBox.Alpha = 0;
|
|
};
|
|
}
|
|
|
|
private double? lastTime;
|
|
private bool showingHoverLayer;
|
|
|
|
protected override void Update()
|
|
{
|
|
base.Update();
|
|
|
|
if (lastTime != editorClock.CurrentTime)
|
|
{
|
|
lastTime = editorClock.CurrentTime;
|
|
trackTimer.Text = editorClock.CurrentTime.ToEditorFormattedString();
|
|
}
|
|
|
|
bool shouldShowHoverLayer = IsHovered && inputTextBox.Alpha == 0;
|
|
|
|
if (shouldShowHoverLayer != showingHoverLayer)
|
|
{
|
|
hoverLayer.FadeTo(shouldShowHoverLayer ? 0.2f : 0, 400, Easing.OutQuint);
|
|
showingHoverLayer = shouldShowHoverLayer;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|