mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 06:52:55 +08:00
Use left aligned text for non-rotate key counter
This commit is contained in:
parent
3f8baf913b
commit
0915ac8891
@ -1,6 +1,7 @@
|
|||||||
// 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.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -18,6 +19,8 @@ namespace osu.Game.Screens.Play
|
|||||||
private OsuSpriteText keyNameText = null!;
|
private OsuSpriteText keyNameText = null!;
|
||||||
private OsuSpriteText countText = null!;
|
private OsuSpriteText countText = null!;
|
||||||
|
|
||||||
|
private UprightAspectMaintainingContainer uprightContainer = null!;
|
||||||
|
|
||||||
// These values were taken from Figma
|
// These values were taken from Figma
|
||||||
private const float line_height = 3;
|
private const float line_height = 3;
|
||||||
private const float name_font_size = 10;
|
private const float name_font_size = 10;
|
||||||
@ -53,7 +56,7 @@ namespace osu.Game.Screens.Play
|
|||||||
Padding = new MarginPadding { Top = line_height * scale_factor + indicator_press_offset },
|
Padding = new MarginPadding { Top = line_height * scale_factor + indicator_press_offset },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new UprightAspectMaintainingContainer
|
uprightContainer = new UprightAspectMaintainingContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
@ -62,16 +65,16 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
keyNameText = new OsuSpriteText
|
keyNameText = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopLeft,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopLeft,
|
||||||
Font = OsuFont.Torus.With(size: name_font_size * scale_factor, weight: FontWeight.Bold),
|
Font = OsuFont.Torus.With(size: name_font_size * scale_factor, weight: FontWeight.Bold),
|
||||||
Colour = colours.Blue0,
|
Colour = colours.Blue0,
|
||||||
Text = Trigger.Name
|
Text = Trigger.Name
|
||||||
},
|
},
|
||||||
countText = new OsuSpriteText
|
countText = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomCentre,
|
Origin = Anchor.BottomLeft,
|
||||||
Font = OsuFont.Torus.With(size: count_font_size * scale_factor, weight: FontWeight.Bold),
|
Font = OsuFont.Torus.With(size: count_font_size * scale_factor, weight: FontWeight.Bold),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -93,6 +96,21 @@ namespace osu.Game.Screens.Play
|
|||||||
CountPresses.BindValueChanged(e => countText.Text = e.NewValue.ToString(@"#,0"), true);
|
CountPresses.BindValueChanged(e => countText.Text = e.NewValue.ToString(@"#,0"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
const float allowance = 6;
|
||||||
|
float absRotation = Math.Abs(uprightContainer.Rotation) % 180;
|
||||||
|
bool isRotated = absRotation > allowance && absRotation < (180 - allowance);
|
||||||
|
|
||||||
|
keyNameText.Anchor =
|
||||||
|
keyNameText.Origin = isRotated ? Anchor.TopCentre : Anchor.TopLeft;
|
||||||
|
|
||||||
|
countText.Anchor =
|
||||||
|
countText.Origin = isRotated ? Anchor.BottomCentre : Anchor.BottomLeft;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Activate(bool forwardPlayback = true)
|
protected override void Activate(bool forwardPlayback = true)
|
||||||
{
|
{
|
||||||
base.Activate(forwardPlayback);
|
base.Activate(forwardPlayback);
|
||||||
|
Loading…
Reference in New Issue
Block a user