Add MusicControllerToast used to display current music playback status on OSD

This commit is contained in:
Lucas A 2019-07-20 21:10:17 +02:00
parent 2ab30281fb
commit 2926932a1a
3 changed files with 16 additions and 48 deletions

View File

@ -726,21 +726,21 @@ public bool OnPressed(GlobalAction action)
if (!musicController.IsLoaded) return true;
if (musicController.PlayTrack())
osd.Display(new Overlays.OSD.OsdIconToast(musicController.IsPlaying ? "Play track" : "Pause track", musicController.IsPlaying ? FontAwesome.Solid.PlayCircle : FontAwesome.Solid.PauseCircle));
osd.Display(new Overlays.OSD.MusicControllerToast(musicController.IsPlaying ? "Play track" : "Pause track"));
return true;
case GlobalAction.MusicNext:
if (!musicController.IsLoaded) return true;
if (musicController.NextTrack())
osd.Display(new Overlays.OSD.OsdIconToast("Next track", FontAwesome.Solid.FastForward));
osd.Display(new Overlays.OSD.MusicControllerToast("Next track"));
return true;
case GlobalAction.MusicPrev:
if (!musicController.IsLoaded) return true;
if (musicController.PreviousTrack())
osd.Display(new Overlays.OSD.OsdIconToast("Previous track", FontAwesome.Solid.FastBackward));
osd.Display(new Overlays.OSD.MusicControllerToast("Previous track"));
return true;
}

View File

@ -0,0 +1,13 @@
// 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.
namespace osu.Game.Overlays.OSD
{
public class MusicControllerToast : Toast
{
public MusicControllerToast(string value)
: base("Music Playback", value, "")
{
}
}
}

View File

@ -1,45 +0,0 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Overlays.OSD
{
public class OsdIconToast : OsdToast
{
public OsdIconToast(string message, IconUsage icon)
{
Children = new Drawable[]
{
new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Vertical,
Spacing = new osuTK.Vector2(10),
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
Font = OsuFont.GetFont(size: 24, weight: FontWeight.Light),
Text = message
},
new SpriteIcon
{
Icon = icon,
Size = new osuTK.Vector2(45),
Anchor = Anchor.Centre,
Origin = Anchor.BottomCentre,
}
}
}
};
}
}
}