2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-24 02:22:38 +00:00
|
|
|
|
|
2016-10-24 05:00:06 +00:00
|
|
|
|
using System;
|
2017-03-09 06:52:40 +00:00
|
|
|
|
using System.Diagnostics;
|
2017-05-02 07:40:29 +00:00
|
|
|
|
using System.Linq;
|
2016-11-05 16:46:09 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2016-10-24 05:00:06 +00:00
|
|
|
|
using OpenTK;
|
2016-10-24 02:50:49 +00:00
|
|
|
|
using OpenTK.Graphics;
|
2016-11-10 22:40:42 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2016-10-28 11:39:02 +00:00
|
|
|
|
using osu.Framework.Configuration;
|
2017-04-26 12:04:32 +00:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-10-24 02:50:49 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-10-24 02:22:38 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-08-01 15:28:18 +00:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2016-10-24 02:50:49 +00:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-10-24 05:13:49 +00:00
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2016-11-07 12:07:45 +00:00
|
|
|
|
using osu.Framework.Input;
|
2017-04-26 12:04:32 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
2017-06-19 12:32:53 +00:00
|
|
|
|
using osu.Framework.Threading;
|
2016-10-28 11:39:02 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2016-10-24 05:00:06 +00:00
|
|
|
|
using osu.Game.Graphics;
|
2017-01-31 09:53:52 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-05-01 04:01:08 +00:00
|
|
|
|
using osu.Game.Overlays.Music;
|
2017-05-17 07:36:24 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2017-06-28 17:18:12 +00:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2016-10-24 02:22:38 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2017-06-28 17:18:12 +00:00
|
|
|
|
public class MusicController : OsuFocusedOverlayContainer
|
2016-10-24 02:22:38 +00:00
|
|
|
|
{
|
2017-04-09 07:26:21 +00:00
|
|
|
|
private const float player_height = 130;
|
2017-05-01 04:01:08 +00:00
|
|
|
|
|
2017-05-01 04:25:32 +00:00
|
|
|
|
private const float transition_length = 800;
|
|
|
|
|
|
|
|
|
|
private const float progress_height = 10;
|
|
|
|
|
|
|
|
|
|
private const float bottom_black_area_height = 55;
|
|
|
|
|
|
2017-03-28 05:35:18 +00:00
|
|
|
|
private Drawable currentBackground;
|
2017-06-22 15:32:50 +00:00
|
|
|
|
private ProgressBar progressBar;
|
2017-05-01 04:41:22 +00:00
|
|
|
|
|
2017-06-20 22:51:32 +00:00
|
|
|
|
private IconButton prevButton;
|
2017-05-30 09:23:53 +00:00
|
|
|
|
private IconButton playButton;
|
2017-06-20 22:51:32 +00:00
|
|
|
|
private IconButton nextButton;
|
2017-05-30 09:23:53 +00:00
|
|
|
|
private IconButton playlistButton;
|
2017-05-01 04:41:22 +00:00
|
|
|
|
|
2016-10-24 05:00:06 +00:00
|
|
|
|
private SpriteText title, artist;
|
2017-05-01 04:41:22 +00:00
|
|
|
|
|
2017-05-01 06:03:11 +00:00
|
|
|
|
private PlaylistOverlay playlist;
|
2016-10-27 10:15:43 +00:00
|
|
|
|
|
2017-04-26 11:41:37 +00:00
|
|
|
|
private LocalisationEngine localisation;
|
2016-10-27 08:58:40 +00:00
|
|
|
|
|
2017-05-01 04:41:22 +00:00
|
|
|
|
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
|
|
|
|
|
2017-01-30 13:00:23 +00:00
|
|
|
|
private Container dragContainer;
|
2017-04-09 07:26:21 +00:00
|
|
|
|
private Container playerContainer;
|
2017-01-30 13:00:23 +00:00
|
|
|
|
|
2016-11-12 10:44:16 +00:00
|
|
|
|
public MusicController()
|
2016-10-27 08:58:40 +00:00
|
|
|
|
{
|
2016-10-28 13:21:47 +00:00
|
|
|
|
Width = 400;
|
2016-11-14 16:22:20 +00:00
|
|
|
|
Margin = new MarginPadding(10);
|
2017-07-11 08:53:36 +00:00
|
|
|
|
|
|
|
|
|
// required to let MusicController handle beatmap cycling.
|
|
|
|
|
AlwaysPresent = true;
|
2017-01-13 04:49:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnDragStart(InputState state) => true;
|
|
|
|
|
|
|
|
|
|
protected override bool OnDrag(InputState state)
|
|
|
|
|
{
|
2017-03-09 06:52:40 +00:00
|
|
|
|
Trace.Assert(state.Mouse.PositionMouseDown != null, "state.Mouse.PositionMouseDown != null");
|
|
|
|
|
|
2017-03-07 01:59:19 +00:00
|
|
|
|
Vector2 change = state.Mouse.Position - state.Mouse.PositionMouseDown.Value;
|
2017-01-13 04:49:05 +00:00
|
|
|
|
|
|
|
|
|
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
|
2017-03-18 11:46:12 +00:00
|
|
|
|
change *= change.Length <= 0 ? 0 : (float)Math.Pow(change.Length, 0.7f) / change.Length;
|
2016-11-14 16:22:20 +00:00
|
|
|
|
|
2017-01-30 13:00:23 +00:00
|
|
|
|
dragContainer.MoveTo(change);
|
2017-01-13 04:49:05 +00:00
|
|
|
|
return base.OnDrag(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnDragEnd(InputState state)
|
|
|
|
|
{
|
2017-07-22 18:50:25 +00:00
|
|
|
|
dragContainer.MoveTo(Vector2.Zero, 800, Easing.OutElastic);
|
2017-01-13 04:49:05 +00:00
|
|
|
|
return base.OnDragEnd(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2017-06-19 12:52:36 +00:00
|
|
|
|
private void load(OsuGameBase game, OsuColour colours, LocalisationEngine localisation)
|
2017-01-13 04:49:05 +00:00
|
|
|
|
{
|
2017-05-01 04:41:22 +00:00
|
|
|
|
this.localisation = localisation;
|
2017-04-09 07:26:21 +00:00
|
|
|
|
|
2016-10-24 02:50:49 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-01-30 13:00:23 +00:00
|
|
|
|
dragContainer = new Container
|
2016-10-24 05:00:06 +00:00
|
|
|
|
{
|
2017-02-09 03:51:56 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-05-01 04:01:08 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2016-10-24 09:19:48 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-05-01 06:03:11 +00:00
|
|
|
|
playlist = new PlaylistOverlay
|
2016-10-24 09:19:48 +00:00
|
|
|
|
{
|
2017-05-01 04:01:08 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Y = player_height + 10,
|
2017-01-30 13:00:23 +00:00
|
|
|
|
},
|
2017-04-09 07:26:21 +00:00
|
|
|
|
playerContainer = new Container
|
2017-01-30 13:00:23 +00:00
|
|
|
|
{
|
2017-03-24 08:59:26 +00:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-04-09 07:26:21 +00:00
|
|
|
|
Height = player_height,
|
|
|
|
|
Masking = true,
|
|
|
|
|
CornerRadius = 5,
|
2017-06-12 03:48:47 +00:00
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
2017-04-09 07:26:21 +00:00
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(40),
|
|
|
|
|
Radius = 5,
|
|
|
|
|
},
|
2017-05-01 04:41:22 +00:00
|
|
|
|
Children = new[]
|
2017-01-30 13:00:23 +00:00
|
|
|
|
{
|
2017-05-01 04:41:22 +00:00
|
|
|
|
currentBackground = new Background(),
|
2017-04-09 07:26:21 +00:00
|
|
|
|
title = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Position = new Vector2(0, 40),
|
|
|
|
|
TextSize = 25,
|
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
Text = @"Nothing to play",
|
|
|
|
|
Font = @"Exo2.0-MediumItalic"
|
|
|
|
|
},
|
|
|
|
|
artist = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Position = new Vector2(0, 45),
|
|
|
|
|
TextSize = 15,
|
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
Text = @"Nothing to play",
|
|
|
|
|
Font = @"Exo2.0-BoldItalic"
|
|
|
|
|
},
|
|
|
|
|
new Container
|
2017-01-30 13:00:23 +00:00
|
|
|
|
{
|
2017-04-09 07:26:21 +00:00
|
|
|
|
Padding = new MarginPadding { Bottom = progress_height },
|
|
|
|
|
Height = bottom_black_area_height,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Children = new Drawable[]
|
2017-03-24 08:59:26 +00:00
|
|
|
|
{
|
2017-05-30 09:23:53 +00:00
|
|
|
|
new FillFlowContainer<IconButton>
|
2017-03-24 08:59:26 +00:00
|
|
|
|
{
|
2017-04-09 07:26:21 +00:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Children = new[]
|
2017-04-07 06:28:18 +00:00
|
|
|
|
{
|
2017-06-20 22:51:32 +00:00
|
|
|
|
prevButton = new IconButton
|
2017-04-09 07:26:21 +00:00
|
|
|
|
{
|
2017-10-10 07:00:11 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-04-09 07:26:21 +00:00
|
|
|
|
Action = prev,
|
|
|
|
|
Icon = FontAwesome.fa_step_backward,
|
|
|
|
|
},
|
2017-05-30 09:23:53 +00:00
|
|
|
|
playButton = new IconButton
|
2017-04-09 07:26:21 +00:00
|
|
|
|
{
|
2017-10-10 07:00:11 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-04-09 07:26:21 +00:00
|
|
|
|
Scale = new Vector2(1.4f),
|
|
|
|
|
IconScale = new Vector2(1.4f),
|
2017-05-01 10:32:31 +00:00
|
|
|
|
Action = play,
|
2017-04-09 07:26:21 +00:00
|
|
|
|
Icon = FontAwesome.fa_play_circle_o,
|
|
|
|
|
},
|
2017-06-20 22:51:32 +00:00
|
|
|
|
nextButton = new IconButton
|
2017-04-09 07:26:21 +00:00
|
|
|
|
{
|
2017-10-10 07:00:11 +00:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-04-09 07:26:21 +00:00
|
|
|
|
Action = next,
|
|
|
|
|
Icon = FontAwesome.fa_step_forward,
|
|
|
|
|
},
|
|
|
|
|
}
|
2017-04-07 06:28:18 +00:00
|
|
|
|
},
|
2017-05-30 09:23:53 +00:00
|
|
|
|
playlistButton = new IconButton
|
2017-04-07 06:28:18 +00:00
|
|
|
|
{
|
2017-04-09 07:26:21 +00:00
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Position = new Vector2(-bottom_black_area_height / 2, 0),
|
|
|
|
|
Icon = FontAwesome.fa_bars,
|
|
|
|
|
Action = () => playlist.ToggleVisibility(),
|
2017-04-07 06:28:18 +00:00
|
|
|
|
},
|
2017-03-24 08:59:26 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2017-06-22 15:32:50 +00:00
|
|
|
|
progressBar = new ProgressBar
|
2017-03-24 08:59:26 +00:00
|
|
|
|
{
|
2017-04-09 07:26:21 +00:00
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Height = progress_height,
|
2017-06-22 15:32:50 +00:00
|
|
|
|
FillColour = colours.Yellow,
|
|
|
|
|
OnSeek = progress => current?.Track.Seek(progress)
|
2017-04-09 07:26:21 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
2017-01-30 13:00:23 +00:00
|
|
|
|
},
|
2016-10-24 09:19:48 +00:00
|
|
|
|
}
|
2016-10-24 02:50:49 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2017-03-13 20:59:44 +00:00
|
|
|
|
|
2017-05-01 04:25:32 +00:00
|
|
|
|
beatmapBacking.BindTo(game.Beatmap);
|
2016-11-05 16:24:03 +00:00
|
|
|
|
|
2017-09-04 00:10:04 +00:00
|
|
|
|
playlist.StateChanged += s => playlistButton.FadeColour(s == Visibility.Visible ? colours.Yellow : Color4.White, 200, Easing.OutQuint);
|
2016-11-05 16:24:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-05 16:46:09 +00:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
2017-05-01 04:25:32 +00:00
|
|
|
|
beatmapBacking.ValueChanged += beatmapChanged;
|
2017-06-21 10:17:59 +00:00
|
|
|
|
beatmapBacking.DisabledChanged += beatmapDisabledChanged;
|
2017-06-21 14:46:30 +00:00
|
|
|
|
beatmapBacking.TriggerChange();
|
2017-06-21 10:17:59 +00:00
|
|
|
|
|
2016-11-05 16:46:09 +00:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-25 18:56:22 +00:00
|
|
|
|
private void beatmapDisabledChanged(bool disabled)
|
2017-06-21 10:17:59 +00:00
|
|
|
|
{
|
2017-07-14 10:45:24 +00:00
|
|
|
|
if (disabled)
|
|
|
|
|
playlist.Hide();
|
|
|
|
|
|
2017-06-25 18:56:22 +00:00
|
|
|
|
prevButton.Enabled.Value = !disabled;
|
|
|
|
|
nextButton.Enabled.Value = !disabled;
|
|
|
|
|
playlistButton.Enabled.Value = !disabled;
|
2017-06-21 10:17:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-01 04:01:08 +00:00
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
Height = dragContainer.Height;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-24 09:23:30 +00:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2016-10-28 12:44:59 +00:00
|
|
|
|
|
2016-11-22 11:47:28 +00:00
|
|
|
|
if (current?.TrackLoaded ?? false)
|
|
|
|
|
{
|
2017-05-01 04:25:32 +00:00
|
|
|
|
var track = current.Track;
|
2016-10-28 12:44:59 +00:00
|
|
|
|
|
2017-07-18 06:36:05 +00:00
|
|
|
|
progressBar.EndTime = track.Length;
|
2017-06-22 16:42:29 +00:00
|
|
|
|
progressBar.CurrentTime = track.CurrentTime;
|
2017-07-18 06:36:05 +00:00
|
|
|
|
|
2017-05-01 04:25:32 +00:00
|
|
|
|
playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
|
|
|
|
|
2017-07-14 10:09:55 +00:00
|
|
|
|
if (track.HasCompleted && !track.Looping && !beatmapBacking.Disabled)
|
|
|
|
|
next();
|
2016-11-22 11:47:28 +00:00
|
|
|
|
}
|
2017-03-13 20:59:44 +00:00
|
|
|
|
else
|
|
|
|
|
playButton.Icon = FontAwesome.fa_play_circle_o;
|
2016-10-24 09:23:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-01 04:41:22 +00:00
|
|
|
|
private void play()
|
2016-11-11 02:35:58 +00:00
|
|
|
|
{
|
2017-05-01 04:41:22 +00:00
|
|
|
|
var track = current?.Track;
|
2017-05-01 04:25:32 +00:00
|
|
|
|
|
2017-05-01 04:41:22 +00:00
|
|
|
|
if (track == null)
|
|
|
|
|
{
|
2017-06-21 14:33:26 +00:00
|
|
|
|
if (!beatmapBacking.Disabled)
|
2017-06-21 10:17:59 +00:00
|
|
|
|
playlist.PlayNext();
|
2017-05-01 06:03:11 +00:00
|
|
|
|
return;
|
2017-05-01 04:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (track.IsRunning)
|
|
|
|
|
track.Stop();
|
|
|
|
|
else
|
|
|
|
|
track.Start();
|
2016-10-28 12:44:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-09 09:11:53 +00:00
|
|
|
|
private void prev()
|
2016-10-28 12:08:27 +00:00
|
|
|
|
{
|
2017-05-01 06:03:11 +00:00
|
|
|
|
queuedDirection = TransformDirection.Prev;
|
|
|
|
|
playlist.PlayPrevious();
|
2016-10-24 07:34:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void next()
|
|
|
|
|
{
|
2017-05-01 06:03:11 +00:00
|
|
|
|
queuedDirection = TransformDirection.Next;
|
|
|
|
|
playlist.PlayNext();
|
2016-10-24 07:34:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-01 04:41:22 +00:00
|
|
|
|
private WorkingBeatmap current;
|
2017-05-02 07:40:29 +00:00
|
|
|
|
private TransformDirection? queuedDirection;
|
2017-05-01 04:41:22 +00:00
|
|
|
|
|
|
|
|
|
private void beatmapChanged(WorkingBeatmap beatmap)
|
|
|
|
|
{
|
2017-05-25 15:49:47 +00:00
|
|
|
|
TransformDirection direction = TransformDirection.None;
|
2017-05-02 07:40:29 +00:00
|
|
|
|
|
2017-05-25 12:16:51 +00:00
|
|
|
|
if (current != null)
|
2017-05-02 07:40:29 +00:00
|
|
|
|
{
|
2017-07-18 06:24:45 +00:00
|
|
|
|
bool audioEquals = beatmap?.BeatmapInfo?.AudioEquals(current.BeatmapInfo) ?? false;
|
2017-05-02 07:40:29 +00:00
|
|
|
|
|
2017-05-25 12:16:51 +00:00
|
|
|
|
if (audioEquals)
|
|
|
|
|
direction = TransformDirection.None;
|
|
|
|
|
else if (queuedDirection.HasValue)
|
|
|
|
|
{
|
|
|
|
|
direction = queuedDirection.Value;
|
|
|
|
|
queuedDirection = null;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//figure out the best direction based on order in playlist.
|
2017-09-11 02:18:53 +00:00
|
|
|
|
var last = playlist.BeatmapSets.TakeWhile(b => b.ID != current.BeatmapSetInfo?.ID).Count();
|
|
|
|
|
var next = beatmap == null ? -1 : playlist.BeatmapSets.TakeWhile(b => b.ID != beatmap.BeatmapSetInfo?.ID).Count();
|
2017-05-25 12:16:51 +00:00
|
|
|
|
|
|
|
|
|
direction = last > next ? TransformDirection.Prev : TransformDirection.Next;
|
|
|
|
|
}
|
2017-05-02 07:40:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-18 06:24:45 +00:00
|
|
|
|
current = beatmap;
|
2017-05-01 04:41:22 +00:00
|
|
|
|
|
2017-07-18 06:36:05 +00:00
|
|
|
|
progressBar.CurrentTime = 0;
|
2017-07-18 06:24:45 +00:00
|
|
|
|
|
2017-07-18 06:36:05 +00:00
|
|
|
|
updateDisplay(current, direction);
|
2017-05-01 04:41:22 +00:00
|
|
|
|
|
2017-05-02 07:40:29 +00:00
|
|
|
|
queuedDirection = null;
|
2017-05-01 04:41:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ScheduledDelegate pendingBeatmapSwitch;
|
2017-02-09 02:28:13 +00:00
|
|
|
|
|
2016-11-22 11:47:28 +00:00
|
|
|
|
private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
|
|
|
|
|
{
|
2017-02-09 02:28:13 +00:00
|
|
|
|
//we might be off-screen when this update comes in.
|
|
|
|
|
//rather than Scheduling, manually handle this to avoid possible memory contention.
|
2017-05-01 04:41:22 +00:00
|
|
|
|
pendingBeatmapSwitch?.Cancel();
|
|
|
|
|
|
|
|
|
|
pendingBeatmapSwitch = Schedule(delegate
|
2016-11-22 11:47:28 +00:00
|
|
|
|
{
|
2017-02-09 02:28:13 +00:00
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
2017-04-26 11:41:37 +00:00
|
|
|
|
if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists
|
2017-03-13 20:59:44 +00:00
|
|
|
|
{
|
2017-04-26 11:41:37 +00:00
|
|
|
|
title.Current = null;
|
2017-03-13 20:59:44 +00:00
|
|
|
|
title.Text = @"Nothing to play";
|
2017-04-26 11:41:37 +00:00
|
|
|
|
|
2017-04-26 12:04:32 +00:00
|
|
|
|
artist.Current = null;
|
2017-03-13 20:59:44 +00:00
|
|
|
|
artist.Text = @"Nothing to play";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-05-06 06:03:08 +00:00
|
|
|
|
BeatmapMetadata metadata = beatmap.Metadata;
|
2017-04-26 11:41:37 +00:00
|
|
|
|
title.Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title);
|
|
|
|
|
artist.Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist);
|
2017-03-13 20:59:44 +00:00
|
|
|
|
}
|
2017-02-09 02:28:13 +00:00
|
|
|
|
});
|
2016-10-27 09:04:41 +00:00
|
|
|
|
|
2017-05-01 04:41:22 +00:00
|
|
|
|
playerContainer.Add(new AsyncLoadWrapper(new Background(beatmap)
|
2017-02-09 02:28:13 +00:00
|
|
|
|
{
|
2017-08-25 04:04:32 +00:00
|
|
|
|
OnLoadComplete = newBackground =>
|
2017-02-09 02:28:13 +00:00
|
|
|
|
{
|
2017-03-28 05:35:18 +00:00
|
|
|
|
switch (direction)
|
|
|
|
|
{
|
|
|
|
|
case TransformDirection.Next:
|
2017-08-25 04:04:32 +00:00
|
|
|
|
newBackground.Position = new Vector2(400, 0);
|
|
|
|
|
newBackground.MoveToX(0, 500, Easing.OutCubic);
|
2017-07-22 18:50:25 +00:00
|
|
|
|
currentBackground.MoveToX(-400, 500, Easing.OutCubic);
|
2017-03-28 05:35:18 +00:00
|
|
|
|
break;
|
|
|
|
|
case TransformDirection.Prev:
|
2017-08-25 04:04:32 +00:00
|
|
|
|
newBackground.Position = new Vector2(-400, 0);
|
|
|
|
|
newBackground.MoveToX(0, 500, Easing.OutCubic);
|
2017-07-22 18:50:25 +00:00
|
|
|
|
currentBackground.MoveToX(400, 500, Easing.OutCubic);
|
2017-03-28 05:35:18 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
currentBackground.Expire();
|
2017-08-25 04:04:32 +00:00
|
|
|
|
currentBackground = newBackground;
|
2017-02-09 02:28:13 +00:00
|
|
|
|
}
|
2017-04-02 06:56:12 +00:00
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Depth = float.MaxValue,
|
2017-02-09 02:28:13 +00:00
|
|
|
|
});
|
2017-05-01 04:41:22 +00:00
|
|
|
|
});
|
2016-10-24 02:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-09 03:51:56 +00:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
2017-02-09 04:53:55 +00:00
|
|
|
|
base.PopIn();
|
2016-11-07 12:07:45 +00:00
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
this.FadeIn(transition_length, Easing.OutQuint);
|
|
|
|
|
dragContainer.ScaleTo(1, transition_length, Easing.OutElastic);
|
2017-02-09 03:51:56 +00:00
|
|
|
|
}
|
2016-10-24 02:22:38 +00:00
|
|
|
|
|
2017-02-09 03:51:56 +00:00
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2017-02-09 04:53:55 +00:00
|
|
|
|
base.PopOut();
|
|
|
|
|
|
2017-07-22 18:50:25 +00:00
|
|
|
|
this.FadeOut(transition_length, Easing.OutQuint);
|
|
|
|
|
dragContainer.ScaleTo(0.9f, transition_length, Easing.OutQuint);
|
2017-02-09 03:51:56 +00:00
|
|
|
|
}
|
2016-11-12 07:44:02 +00:00
|
|
|
|
|
2017-05-01 04:41:22 +00:00
|
|
|
|
private enum TransformDirection
|
|
|
|
|
{
|
|
|
|
|
None,
|
|
|
|
|
Next,
|
|
|
|
|
Prev
|
|
|
|
|
}
|
2016-11-13 19:21:07 +00:00
|
|
|
|
|
2017-05-01 04:41:22 +00:00
|
|
|
|
private class Background : BufferedContainer
|
2016-11-12 07:44:02 +00:00
|
|
|
|
{
|
2017-03-23 04:41:50 +00:00
|
|
|
|
private readonly Sprite sprite;
|
|
|
|
|
private readonly WorkingBeatmap beatmap;
|
2016-11-12 07:44:02 +00:00
|
|
|
|
|
2017-05-01 04:41:22 +00:00
|
|
|
|
public Background(WorkingBeatmap beatmap = null)
|
2016-11-12 07:44:02 +00:00
|
|
|
|
{
|
2016-11-22 11:47:28 +00:00
|
|
|
|
this.beatmap = beatmap;
|
2016-11-12 07:44:02 +00:00
|
|
|
|
CacheDrawnFrameBuffer = true;
|
2016-11-29 19:50:12 +00:00
|
|
|
|
Depth = float.MaxValue;
|
2017-03-28 05:35:18 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2016-11-12 07:44:02 +00:00
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
sprite = new Sprite
|
|
|
|
|
{
|
2017-06-28 09:24:23 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-01-12 21:38:27 +00:00
|
|
|
|
Colour = OsuColour.Gray(150),
|
2016-11-23 04:18:22 +00:00
|
|
|
|
FillMode = FillMode.Fill,
|
2016-11-12 07:44:02 +00:00
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-04-07 04:04:57 +00:00
|
|
|
|
Height = bottom_black_area_height,
|
2016-11-12 07:44:02 +00:00
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
2017-01-10 18:44:40 +00:00
|
|
|
|
Colour = Color4.Black.Opacity(0.5f)
|
2016-11-12 07:44:02 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 11:47:28 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(TextureStore textures)
|
|
|
|
|
{
|
|
|
|
|
sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4");
|
|
|
|
|
}
|
2016-11-12 07:44:02 +00:00
|
|
|
|
}
|
2016-10-24 02:22:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|