mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:43:20 +08:00
Fix footer random button autosizing to text length
This commit is contained in:
parent
62951066bb
commit
18852b2509
@ -5,6 +5,7 @@ using System;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
@ -19,6 +20,9 @@ namespace osu.Game.Screens.Select
|
|||||||
public Action NextRandom { get; set; }
|
public Action NextRandom { get; set; }
|
||||||
public Action PreviousRandom { get; set; }
|
public Action PreviousRandom { get; set; }
|
||||||
|
|
||||||
|
private Container persistentText;
|
||||||
|
private OsuSpriteText randomSpriteText;
|
||||||
|
private OsuSpriteText rewindSpriteText;
|
||||||
private bool rewindSearch;
|
private bool rewindSearch;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -26,7 +30,32 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
SelectedColour = colours.Green;
|
SelectedColour = colours.Green;
|
||||||
DeselectedColour = SelectedColour.Opacity(0.5f);
|
DeselectedColour = SelectedColour.Opacity(0.5f);
|
||||||
updateText();
|
|
||||||
|
TextContainer.Add(persistentText = new Container
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
AlwaysPresent = true,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
randomSpriteText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
AlwaysPresent = true,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Text = "random",
|
||||||
|
},
|
||||||
|
rewindSpriteText = new OsuSpriteText
|
||||||
|
{
|
||||||
|
AlwaysPresent = true,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Text = "rewind",
|
||||||
|
Alpha = 0f,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
@ -34,22 +63,22 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
const double fade_time = 500;
|
const double fade_time = 500;
|
||||||
|
|
||||||
OsuSpriteText rewindSpriteText;
|
OsuSpriteText fallingRewind;
|
||||||
|
|
||||||
TextContainer.Add(rewindSpriteText = new OsuSpriteText
|
TextContainer.Add(fallingRewind = new OsuSpriteText
|
||||||
{
|
{
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Text = @"rewind",
|
Text = rewindSpriteText.Text,
|
||||||
AlwaysPresent = true, // make sure the button is sized large enough to always show this
|
AlwaysPresent = true, // make sure the button is sized large enough to always show this
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
});
|
});
|
||||||
|
|
||||||
rewindSpriteText.FadeOutFromOne(fade_time, Easing.In);
|
fallingRewind.FadeOutFromOne(fade_time, Easing.In);
|
||||||
rewindSpriteText.MoveTo(Vector2.Zero).MoveTo(new Vector2(0, 10), fade_time, Easing.In);
|
fallingRewind.MoveTo(Vector2.Zero).MoveTo(new Vector2(0, 10), fade_time, Easing.In);
|
||||||
rewindSpriteText.Expire();
|
fallingRewind.Expire();
|
||||||
|
|
||||||
SpriteText.FadeInFromZero(fade_time, Easing.In);
|
persistentText.FadeInFromZero(fade_time, Easing.In);
|
||||||
|
|
||||||
PreviousRandom.Invoke();
|
PreviousRandom.Invoke();
|
||||||
}
|
}
|
||||||
@ -119,6 +148,10 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateText(bool rewind = false) => Text = rewind ? "rewind" : "random";
|
private void updateText(bool rewind = false)
|
||||||
|
{
|
||||||
|
randomSpriteText.Alpha = rewind ? 0 : 1;
|
||||||
|
rewindSpriteText.Alpha = rewind ? 1 : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user