1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-30 22:22:55 +08:00
osu-lazer/osu.Game/Screens/Menu/SongTicker.cs

75 lines
2.2 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2020-01-11 11:58:35 +08:00
// See the LICENCE file in the repository root for full licence text.
2022-06-17 15:37:17 +08:00
#nullable disable
2020-01-11 11:58:35 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osuTK;
using osu.Game.Graphics;
using osu.Framework.Bindables;
using osu.Framework.Localisation;
2020-01-11 11:58:35 +08:00
using osu.Game.Beatmaps;
namespace osu.Game.Screens.Menu
{
2022-11-24 13:32:20 +08:00
public partial class SongTicker : Container
2020-01-11 11:58:35 +08:00
{
2020-01-11 12:17:13 +08:00
private const int fade_duration = 800;
2020-01-11 11:58:35 +08:00
[Resolved]
private Bindable<WorkingBeatmap> beatmap { get; set; }
private readonly OsuSpriteText title, artist;
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
2020-01-11 11:58:35 +08:00
public SongTicker()
{
AutoSizeAxes = Axes.Both;
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 3),
Children = new Drawable[]
{
title = new OsuSpriteText
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light, italics: true)
},
artist = new OsuSpriteText
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Font = OsuFont.GetFont(size: 16)
}
}
};
}
protected override void LoadComplete()
{
base.LoadComplete();
beatmap.BindValueChanged(_ => Scheduler.AddOnce(show), true);
2020-01-11 11:58:35 +08:00
}
private void show()
2020-01-11 11:58:35 +08:00
{
var metadata = beatmap.Value.Metadata;
2020-01-11 23:27:22 +08:00
title.Text = new RomanisableString(metadata.TitleUnicode, metadata.Title);
artist.Text = new RomanisableString(metadata.ArtistUnicode, metadata.Artist);
2020-01-11 11:58:35 +08:00
2020-01-24 15:32:39 +08:00
this.FadeInFromZero(fade_duration / 2f)
.Delay(4000)
.Then().FadeOut(fade_duration);
2020-01-11 11:58:35 +08:00
}
}
}