1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 15:33:21 +08:00

Implement SongTicker component

This commit is contained in:
Andrei Zavatski 2020-01-11 06:58:35 +03:00
parent f745d74666
commit 6500cc967f
2 changed files with 73 additions and 0 deletions

View File

@ -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

View 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);
}
}
}