mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 17:13:06 +08:00
Implement SongTicker component
This commit is contained in:
parent
f745d74666
commit
6500cc967f
@ -75,6 +75,13 @@ namespace osu.Game.Screens.Menu
|
||||
holdDelay = config.GetBindable<float>(OsuSetting.UIHoldActivationDelay);
|
||||
loginDisplayed = statics.GetBindable<bool>(Static.LoginOverlayDisplayed);
|
||||
|
||||
AddInternal(new SongTicker
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Margin = new MarginPadding { Right = 15 }
|
||||
});
|
||||
|
||||
if (host.CanExit)
|
||||
{
|
||||
AddInternal(exitConfirmOverlay = new ExitConfirmOverlay
|
||||
|
66
osu.Game/Screens/Menu/SongTicker.cs
Normal file
66
osu.Game/Screens/Menu/SongTicker.cs
Normal file
@ -0,0 +1,66 @@
|
||||
// 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.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.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Screens.Menu
|
||||
{
|
||||
public class SongTicker : Container
|
||||
{
|
||||
private const int duration = 500;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> workingBeatmap = new Bindable<WorkingBeatmap>();
|
||||
private readonly OsuSpriteText title, artist;
|
||||
|
||||
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();
|
||||
workingBeatmap.BindTo(beatmap);
|
||||
workingBeatmap.BindValueChanged(onBeatmapChanged);
|
||||
}
|
||||
|
||||
private void onBeatmapChanged(ValueChangedEvent<WorkingBeatmap> working)
|
||||
{
|
||||
title.Text = working.NewValue?.Metadata?.Title;
|
||||
artist.Text = working.NewValue?.Metadata?.Artist;
|
||||
|
||||
this.FadeIn(duration, Easing.OutQuint).Delay(4000).Then().FadeOut(duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user