2017-02-07 12:59:30 +08: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 10:22:38 +08:00
|
|
|
|
|
2016-10-24 13:00:06 +08:00
|
|
|
|
using System;
|
2016-10-24 13:47:05 +08:00
|
|
|
|
using System.Collections.Generic;
|
2017-03-09 14:52:40 +08:00
|
|
|
|
using System.Diagnostics;
|
2016-11-06 00:46:09 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2016-10-24 13:00:06 +08:00
|
|
|
|
using OpenTK;
|
2016-10-24 10:50:49 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2016-11-11 06:40:42 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2016-10-24 15:34:44 +08:00
|
|
|
|
using osu.Framework.Audio.Track;
|
2016-10-28 19:39:02 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2017-04-26 20:04:32 +08:00
|
|
|
|
using osu.Framework.Extensions;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-10-24 10:50:49 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-10-24 10:22:38 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-04-26 20:04:32 +08:00
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2016-10-24 10:50:49 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-10-24 13:13:49 +08:00
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2016-11-07 20:07:45 +08:00
|
|
|
|
using osu.Framework.Input;
|
2017-04-26 20:04:32 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2016-10-28 19:39:02 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2016-10-24 13:47:05 +08:00
|
|
|
|
using osu.Game.Database;
|
2016-10-24 13:00:06 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2017-01-31 17:53:52 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2017-04-09 17:11:53 +08:00
|
|
|
|
using System.Linq;
|
2016-10-24 10:22:38 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2017-02-09 12:53:55 +08:00
|
|
|
|
public class MusicController : FocusedOverlayContainer
|
2016-10-24 10:22:38 +08:00
|
|
|
|
{
|
2017-04-09 15:26:21 +08:00
|
|
|
|
private const float player_height = 130;
|
2017-04-29 17:10:12 +08:00
|
|
|
|
private const float playlist_height = 510;
|
2017-03-28 13:35:18 +08:00
|
|
|
|
private Drawable currentBackground;
|
2016-10-27 18:15:43 +08:00
|
|
|
|
private DragBar progress;
|
2017-04-07 12:04:57 +08:00
|
|
|
|
private Button playButton;
|
2016-10-24 13:00:06 +08:00
|
|
|
|
private SpriteText title, artist;
|
2017-04-09 15:26:21 +08:00
|
|
|
|
private ClickableContainer playlistButton;
|
|
|
|
|
private PlaylistController playlist;
|
|
|
|
|
private Color4 activeColour;
|
2016-10-27 18:15:43 +08:00
|
|
|
|
|
2016-10-24 13:47:05 +08:00
|
|
|
|
private List<BeatmapSetInfo> playList;
|
2017-04-09 17:11:53 +08:00
|
|
|
|
private int playListIndex = -1;
|
2016-11-07 20:57:33 +08:00
|
|
|
|
|
|
|
|
|
private TrackManager trackManager;
|
2016-10-28 19:39:02 +08:00
|
|
|
|
private Bindable<WorkingBeatmap> beatmapSource;
|
2016-10-28 20:21:19 +08:00
|
|
|
|
private WorkingBeatmap current;
|
2016-11-12 18:44:16 +08:00
|
|
|
|
private BeatmapDatabase beatmaps;
|
2017-04-26 19:41:37 +08:00
|
|
|
|
private LocalisationEngine localisation;
|
2016-10-27 16:58:40 +08:00
|
|
|
|
|
2017-01-30 21:00:23 +08:00
|
|
|
|
private Container dragContainer;
|
2017-04-09 15:26:21 +08:00
|
|
|
|
private Container playerContainer;
|
2017-01-30 21:00:23 +08:00
|
|
|
|
|
2017-04-07 14:28:18 +08:00
|
|
|
|
private const float progress_height = 10;
|
|
|
|
|
|
2017-04-08 18:25:40 +08:00
|
|
|
|
private const float bottom_black_area_height = 55;
|
2017-04-07 12:04:57 +08:00
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
public MusicController()
|
2016-10-27 16:58:40 +08:00
|
|
|
|
{
|
2016-10-28 21:21:47 +08:00
|
|
|
|
Width = 400;
|
2017-04-09 15:26:21 +08:00
|
|
|
|
Height = player_height + playlist_height;
|
2016-11-12 16:09:58 +08:00
|
|
|
|
|
2016-11-15 00:22:20 +08:00
|
|
|
|
Margin = new MarginPadding(10);
|
2017-01-13 12:49:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-09 17:11:53 +08:00
|
|
|
|
protected override bool InternalContains(Vector2 screenSpacePos) => playlist.State == Visibility.Visible ? dragContainer.Contains(screenSpacePos) : playerContainer.Contains(screenSpacePos);
|
|
|
|
|
|
2017-01-13 12:49:05 +08:00
|
|
|
|
protected override bool OnDragStart(InputState state) => true;
|
|
|
|
|
|
|
|
|
|
protected override bool OnDrag(InputState state)
|
|
|
|
|
{
|
2017-03-09 14:52:40 +08:00
|
|
|
|
Trace.Assert(state.Mouse.PositionMouseDown != null, "state.Mouse.PositionMouseDown != null");
|
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
Vector2 change = state.Mouse.Position - state.Mouse.PositionMouseDown.Value;
|
2017-01-13 12:49:05 +08:00
|
|
|
|
|
|
|
|
|
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
|
2017-03-18 19:46:12 +08:00
|
|
|
|
change *= change.Length <= 0 ? 0 : (float)Math.Pow(change.Length, 0.7f) / change.Length;
|
2016-11-15 00:22:20 +08:00
|
|
|
|
|
2017-01-30 21:00:23 +08:00
|
|
|
|
dragContainer.MoveTo(change);
|
2017-01-13 12:49:05 +08:00
|
|
|
|
return base.OnDrag(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnDragEnd(InputState state)
|
|
|
|
|
{
|
2017-01-30 21:00:23 +08:00
|
|
|
|
dragContainer.MoveTo(Vector2.Zero, 800, EasingTypes.OutElastic);
|
2017-01-13 12:49:05 +08:00
|
|
|
|
return base.OnDragEnd(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2017-04-26 19:41:37 +08:00
|
|
|
|
private void load(OsuGameBase game, BeatmapDatabase beatmaps, OsuColour colours, LocalisationEngine localisation)
|
2017-01-13 12:49:05 +08:00
|
|
|
|
{
|
2017-04-09 15:26:21 +08:00
|
|
|
|
activeColour = colours.Yellow;
|
|
|
|
|
|
2016-10-24 10:50:49 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-01-30 21:00:23 +08:00
|
|
|
|
dragContainer = new Container
|
2016-10-24 13:00:06 +08:00
|
|
|
|
{
|
2017-02-09 11:51:56 +08:00
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2017-01-30 21:00:23 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2016-10-24 17:19:48 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-04-09 15:26:21 +08:00
|
|
|
|
playlist = new PlaylistController
|
2016-10-24 17:19:48 +08:00
|
|
|
|
{
|
2017-04-09 15:26:21 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Top = player_height + 10 },
|
|
|
|
|
//todo: this is the logic I expect, but maybe not others
|
2017-04-09 17:11:53 +08:00
|
|
|
|
OnSelect = (set, index) =>
|
2017-04-09 15:26:21 +08:00
|
|
|
|
{
|
|
|
|
|
if (set.ID == (current?.BeatmapSetInfo?.ID ?? -1))
|
2017-04-09 18:04:41 +08:00
|
|
|
|
current?.Track?.Seek(0);
|
2017-04-09 17:11:53 +08:00
|
|
|
|
|
|
|
|
|
playListIndex = index;
|
2017-04-09 18:04:41 +08:00
|
|
|
|
play(set.Beatmaps[0], true);
|
2017-04-09 15:26:21 +08:00
|
|
|
|
},
|
2017-01-30 21:00:23 +08:00
|
|
|
|
},
|
2017-04-09 15:26:21 +08:00
|
|
|
|
playerContainer = new Container
|
2017-01-30 21:00:23 +08:00
|
|
|
|
{
|
2017-03-24 16:59:26 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-04-09 15:26:21 +08:00
|
|
|
|
Height = player_height,
|
|
|
|
|
Masking = true,
|
|
|
|
|
CornerRadius = 5,
|
|
|
|
|
EdgeEffect = new EdgeEffect
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(40),
|
|
|
|
|
Radius = 5,
|
|
|
|
|
},
|
2017-01-30 21:00:23 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-04-09 15:26:21 +08: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 21:00:23 +08:00
|
|
|
|
{
|
2017-04-09 15:26:21 +08: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 16:59:26 +08:00
|
|
|
|
{
|
2017-04-09 15:26:21 +08:00
|
|
|
|
new FillFlowContainer<Button>
|
2017-03-24 16:59:26 +08:00
|
|
|
|
{
|
2017-04-09 15:26:21 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Children = new[]
|
2017-04-07 14:28:18 +08:00
|
|
|
|
{
|
2017-04-09 15:26:21 +08:00
|
|
|
|
new Button
|
|
|
|
|
{
|
|
|
|
|
Action = prev,
|
|
|
|
|
Icon = FontAwesome.fa_step_backward,
|
|
|
|
|
},
|
|
|
|
|
playButton = new Button
|
|
|
|
|
{
|
|
|
|
|
Scale = new Vector2(1.4f),
|
|
|
|
|
IconScale = new Vector2(1.4f),
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2017-04-09 18:04:41 +08:00
|
|
|
|
if (current?.Track == null)
|
|
|
|
|
{
|
|
|
|
|
if (playList.Count > 0)
|
|
|
|
|
play(playList.First().Beatmaps[0], true);
|
|
|
|
|
else
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-04-09 15:26:21 +08:00
|
|
|
|
if (current.Track.IsRunning)
|
|
|
|
|
current.Track.Stop();
|
|
|
|
|
else
|
|
|
|
|
current.Track.Start();
|
|
|
|
|
},
|
|
|
|
|
Icon = FontAwesome.fa_play_circle_o,
|
|
|
|
|
},
|
|
|
|
|
new Button
|
|
|
|
|
{
|
|
|
|
|
Action = next,
|
|
|
|
|
Icon = FontAwesome.fa_step_forward,
|
|
|
|
|
},
|
|
|
|
|
}
|
2017-04-07 14:28:18 +08:00
|
|
|
|
},
|
2017-04-09 15:26:21 +08:00
|
|
|
|
playlistButton = new Button
|
2017-04-07 14:28:18 +08:00
|
|
|
|
{
|
2017-04-09 15:26:21 +08: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 14:28:18 +08:00
|
|
|
|
},
|
2017-03-24 16:59:26 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2017-04-09 15:26:21 +08:00
|
|
|
|
progress = new DragBar
|
2017-03-24 16:59:26 +08:00
|
|
|
|
{
|
2017-04-09 15:26:21 +08:00
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Height = progress_height,
|
|
|
|
|
Colour = colours.Yellow,
|
|
|
|
|
SeekRequested = seek
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-01-30 21:00:23 +08:00
|
|
|
|
},
|
2016-10-24 17:19:48 +08:00
|
|
|
|
}
|
2016-10-24 10:50:49 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2017-03-14 04:59:44 +08:00
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
this.beatmaps = beatmaps;
|
2017-03-28 13:35:18 +08:00
|
|
|
|
trackManager = game.Audio.Track;
|
2017-04-26 19:41:37 +08:00
|
|
|
|
this.localisation = localisation;
|
2016-11-06 00:24:03 +08:00
|
|
|
|
|
2017-03-28 13:35:18 +08:00
|
|
|
|
beatmapSource = game.Beatmap ?? new Bindable<WorkingBeatmap>();
|
2016-11-06 00:24:03 +08:00
|
|
|
|
|
2017-03-28 13:35:18 +08:00
|
|
|
|
currentBackground = new MusicControllerBackground();
|
2017-04-09 15:26:21 +08:00
|
|
|
|
playerContainer.Add(currentBackground);
|
|
|
|
|
playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible? activeColour : Color4.White, transition_length, EasingTypes.OutQuint);
|
2016-11-06 00:24:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-06 00:46:09 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
2016-11-06 16:42:40 +08:00
|
|
|
|
beatmapSource.ValueChanged += workingChanged;
|
2017-04-03 18:34:00 +08:00
|
|
|
|
beatmapSource.TriggerChange();
|
2017-04-09 17:11:53 +08:00
|
|
|
|
playList = playlist.List.ToList();
|
2017-04-03 18:34:00 +08:00
|
|
|
|
|
2016-11-06 00:46:09 +08:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-24 17:23:30 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2016-10-28 20:44:59 +08:00
|
|
|
|
|
2017-02-09 10:28:13 +08:00
|
|
|
|
if (pendingBeatmapSwitch != null)
|
|
|
|
|
{
|
|
|
|
|
pendingBeatmapSwitch();
|
|
|
|
|
pendingBeatmapSwitch = null;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 19:47:28 +08:00
|
|
|
|
if (current?.TrackLoaded ?? false)
|
|
|
|
|
{
|
2017-04-07 10:02:37 +08:00
|
|
|
|
progress.UpdatePosition(current.Track.Length == 0 ? 0 : (float)(current.Track.CurrentTime / current.Track.Length));
|
2016-11-22 19:47:28 +08:00
|
|
|
|
playButton.Icon = current.Track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
2016-10-28 20:44:59 +08:00
|
|
|
|
|
2016-11-22 19:47:28 +08:00
|
|
|
|
if (current.Track.HasCompleted && !current.Track.Looping) next();
|
|
|
|
|
}
|
2017-03-14 04:59:44 +08:00
|
|
|
|
else
|
|
|
|
|
playButton.Icon = FontAwesome.fa_play_circle_o;
|
2016-10-24 17:23:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-03 18:34:00 +08:00
|
|
|
|
private void workingChanged(WorkingBeatmap beatmap)
|
2016-11-11 10:35:58 +08:00
|
|
|
|
{
|
2017-04-03 18:34:00 +08:00
|
|
|
|
progress.IsEnabled = beatmap != null;
|
|
|
|
|
if (beatmap == current) return;
|
|
|
|
|
bool audioEquals = current?.BeatmapInfo?.AudioEquals(beatmap?.BeatmapInfo) ?? false;
|
|
|
|
|
current = beatmap;
|
2016-11-14 04:59:41 +08:00
|
|
|
|
updateDisplay(current, audioEquals ? TransformDirection.None : TransformDirection.Next);
|
2016-10-28 20:44:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-09 17:11:53 +08:00
|
|
|
|
private void prev()
|
2016-10-28 20:08:27 +08:00
|
|
|
|
{
|
2017-04-09 17:11:53 +08:00
|
|
|
|
if (playList.Count == 0) return;
|
|
|
|
|
if (current != null && playList.Count == 1) return;
|
2017-02-24 13:37:54 +08:00
|
|
|
|
|
2017-04-09 17:11:53 +08:00
|
|
|
|
int n = playListIndex - 1;
|
|
|
|
|
if (n < 0)
|
|
|
|
|
n = playList.Count - 1;
|
2016-10-28 20:08:27 +08:00
|
|
|
|
|
2017-04-09 17:11:53 +08:00
|
|
|
|
play(playList[n].Beatmaps[0], false);
|
|
|
|
|
playListIndex = n;
|
2016-10-24 15:34:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void next()
|
|
|
|
|
{
|
2017-04-09 17:11:53 +08:00
|
|
|
|
if (playList.Count == 0) return;
|
|
|
|
|
if (current != null && playList.Count == 1) return;
|
2016-11-07 23:06:14 +08:00
|
|
|
|
|
2017-04-09 17:11:53 +08:00
|
|
|
|
int n = playListIndex + 1;
|
2017-04-09 18:04:41 +08:00
|
|
|
|
if (n >= playList.Count)
|
2017-04-29 17:10:12 +08:00
|
|
|
|
n = 0;
|
2017-04-09 18:04:41 +08:00
|
|
|
|
|
2017-04-09 17:11:53 +08:00
|
|
|
|
play(playList[n].Beatmaps[0], true);
|
|
|
|
|
playListIndex = n;
|
2016-10-28 20:08:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 21:30:25 +08:00
|
|
|
|
private void play(BeatmapInfo info, bool isNext)
|
2016-10-28 20:08:27 +08:00
|
|
|
|
{
|
2016-11-12 18:44:16 +08:00
|
|
|
|
current = beatmaps.GetWorkingBeatmap(info, current);
|
2016-11-06 16:34:47 +08:00
|
|
|
|
Task.Run(() =>
|
2016-11-06 00:46:09 +08:00
|
|
|
|
{
|
|
|
|
|
trackManager.SetExclusive(current.Track);
|
|
|
|
|
current.Track.Start();
|
|
|
|
|
beatmapSource.Value = current;
|
2017-04-24 12:45:18 +08:00
|
|
|
|
}).ContinueWith(task => Schedule(task.ThrowIfFaulted), TaskContinuationOptions.OnlyOnFaulted);
|
2016-11-14 04:59:41 +08:00
|
|
|
|
updateDisplay(current, isNext ? TransformDirection.Next : TransformDirection.Prev);
|
2016-10-24 15:34:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private Action pendingBeatmapSwitch;
|
2017-02-09 10:28:13 +08:00
|
|
|
|
|
2016-11-22 19:47:28 +08:00
|
|
|
|
private void updateDisplay(WorkingBeatmap beatmap, TransformDirection direction)
|
|
|
|
|
{
|
2017-02-09 10:28:13 +08:00
|
|
|
|
//we might be off-screen when this update comes in.
|
|
|
|
|
//rather than Scheduling, manually handle this to avoid possible memory contention.
|
|
|
|
|
pendingBeatmapSwitch = () =>
|
2016-11-22 19:47:28 +08:00
|
|
|
|
{
|
2017-02-09 10:28:13 +08:00
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
2017-04-26 19:41:37 +08:00
|
|
|
|
if (beatmap?.Beatmap == null) //this is not needed if a placeholder exists
|
2017-03-14 04:59:44 +08:00
|
|
|
|
{
|
2017-04-26 19:41:37 +08:00
|
|
|
|
title.Current = null;
|
2017-03-14 04:59:44 +08:00
|
|
|
|
title.Text = @"Nothing to play";
|
2017-04-26 19:41:37 +08:00
|
|
|
|
|
2017-04-26 20:04:32 +08:00
|
|
|
|
artist.Current = null;
|
2017-03-14 04:59:44 +08:00
|
|
|
|
artist.Text = @"Nothing to play";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
|
2017-04-26 19:41:37 +08:00
|
|
|
|
title.Current = localisation.GetUnicodePreference(metadata.TitleUnicode, metadata.Title);
|
|
|
|
|
artist.Current = localisation.GetUnicodePreference(metadata.ArtistUnicode, metadata.Artist);
|
2017-04-09 15:26:21 +08:00
|
|
|
|
playlist.Current = beatmap.BeatmapSetInfo;
|
2017-03-14 04:59:44 +08:00
|
|
|
|
}
|
2017-02-09 10:28:13 +08:00
|
|
|
|
});
|
2016-10-27 17:04:41 +08:00
|
|
|
|
|
2017-04-09 15:26:21 +08:00
|
|
|
|
playerContainer.Add(new AsyncLoadWrapper(new MusicControllerBackground(beatmap)
|
2017-02-09 10:28:13 +08:00
|
|
|
|
{
|
2017-04-02 14:56:12 +08:00
|
|
|
|
OnLoadComplete = d =>
|
2017-02-09 10:28:13 +08:00
|
|
|
|
{
|
2017-03-28 13:35:18 +08:00
|
|
|
|
switch (direction)
|
|
|
|
|
{
|
|
|
|
|
case TransformDirection.Next:
|
|
|
|
|
d.Position = new Vector2(400, 0);
|
|
|
|
|
d.MoveToX(0, 500, EasingTypes.OutCubic);
|
|
|
|
|
currentBackground.MoveToX(-400, 500, EasingTypes.OutCubic);
|
|
|
|
|
break;
|
|
|
|
|
case TransformDirection.Prev:
|
|
|
|
|
d.Position = new Vector2(-400, 0);
|
|
|
|
|
d.MoveToX(0, 500, EasingTypes.OutCubic);
|
|
|
|
|
currentBackground.MoveToX(400, 500, EasingTypes.OutCubic);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
currentBackground.Expire();
|
|
|
|
|
currentBackground = d;
|
2017-02-09 10:28:13 +08:00
|
|
|
|
}
|
2017-04-02 14:56:12 +08:00
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Depth = float.MaxValue,
|
2017-02-09 10:28:13 +08:00
|
|
|
|
});
|
2017-04-09 15:12:30 +08:00
|
|
|
|
};
|
2016-10-24 10:22:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 19:51:38 +08:00
|
|
|
|
private void seek(float position)
|
|
|
|
|
{
|
2016-10-28 20:21:19 +08:00
|
|
|
|
current?.Track?.Seek(current.Track.Length * position);
|
|
|
|
|
current?.Track?.Start();
|
2016-10-27 19:51:38 +08:00
|
|
|
|
}
|
2016-10-25 09:18:47 +08:00
|
|
|
|
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private const float transition_length = 800;
|
2016-11-07 20:07:45 +08:00
|
|
|
|
|
2017-02-09 11:51:56 +08:00
|
|
|
|
protected override void PopIn()
|
|
|
|
|
{
|
2017-02-09 12:53:55 +08:00
|
|
|
|
base.PopIn();
|
2016-11-07 20:07:45 +08:00
|
|
|
|
|
2017-02-09 11:51:56 +08:00
|
|
|
|
FadeIn(transition_length, EasingTypes.OutQuint);
|
|
|
|
|
dragContainer.ScaleTo(1, transition_length, EasingTypes.OutElastic);
|
|
|
|
|
}
|
2016-10-24 10:22:38 +08:00
|
|
|
|
|
2017-02-09 11:51:56 +08:00
|
|
|
|
protected override void PopOut()
|
|
|
|
|
{
|
2017-02-09 12:53:55 +08:00
|
|
|
|
base.PopOut();
|
|
|
|
|
|
2017-02-09 11:51:56 +08:00
|
|
|
|
FadeOut(transition_length, EasingTypes.OutQuint);
|
|
|
|
|
dragContainer.ScaleTo(0.9f, transition_length, EasingTypes.OutQuint);
|
|
|
|
|
}
|
2016-11-12 15:44:02 +08:00
|
|
|
|
|
2016-11-14 04:59:41 +08:00
|
|
|
|
private enum TransformDirection { None, Next, Prev }
|
2016-11-14 03:21:07 +08:00
|
|
|
|
|
2016-11-12 15:44:02 +08:00
|
|
|
|
private class MusicControllerBackground : BufferedContainer
|
|
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly Sprite sprite;
|
|
|
|
|
private readonly WorkingBeatmap beatmap;
|
2016-11-12 15:44:02 +08:00
|
|
|
|
|
2016-11-22 19:47:28 +08:00
|
|
|
|
public MusicControllerBackground(WorkingBeatmap beatmap = null)
|
2016-11-12 15:44:02 +08:00
|
|
|
|
{
|
2016-11-22 19:47:28 +08:00
|
|
|
|
this.beatmap = beatmap;
|
2016-11-12 15:44:02 +08:00
|
|
|
|
CacheDrawnFrameBuffer = true;
|
2016-11-30 03:50:12 +08:00
|
|
|
|
Depth = float.MaxValue;
|
2017-03-28 13:35:18 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2016-11-12 15:44:02 +08:00
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
sprite = new Sprite
|
|
|
|
|
{
|
2017-01-13 05:38:27 +08:00
|
|
|
|
Colour = OsuColour.Gray(150),
|
2016-11-23 12:18:22 +08:00
|
|
|
|
FillMode = FillMode.Fill,
|
2016-11-12 15:44:02 +08:00
|
|
|
|
},
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2017-04-07 12:04:57 +08:00
|
|
|
|
Height = bottom_black_area_height,
|
2016-11-12 15:44:02 +08:00
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
2017-01-11 02:44:40 +08:00
|
|
|
|
Colour = Color4.Black.Opacity(0.5f)
|
2016-11-12 15:44:02 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 19:47:28 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(TextureStore textures)
|
|
|
|
|
{
|
|
|
|
|
sprite.Texture = beatmap?.Background ?? textures.Get(@"Backgrounds/bg4");
|
|
|
|
|
}
|
2016-11-12 15:44:02 +08:00
|
|
|
|
}
|
2017-04-07 12:04:57 +08:00
|
|
|
|
|
|
|
|
|
private class Button : ClickableContainer
|
|
|
|
|
{
|
|
|
|
|
private readonly TextAwesome icon;
|
|
|
|
|
private readonly Box hover;
|
|
|
|
|
private readonly Container content;
|
|
|
|
|
|
|
|
|
|
public FontAwesome Icon
|
|
|
|
|
{
|
|
|
|
|
get { return icon.Icon; }
|
|
|
|
|
set { icon.Icon = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private const float button_size = 30;
|
2017-04-08 18:28:29 +08:00
|
|
|
|
private Color4 flashColour;
|
2017-04-07 12:04:57 +08:00
|
|
|
|
|
2017-04-08 18:25:40 +08:00
|
|
|
|
public Vector2 IconScale
|
|
|
|
|
{
|
|
|
|
|
get { return icon.Scale; }
|
|
|
|
|
set { icon.Scale = value; }
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 12:04:57 +08:00
|
|
|
|
public Button()
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
content = new Container
|
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(button_size),
|
|
|
|
|
CornerRadius = 5,
|
|
|
|
|
Masking = true,
|
|
|
|
|
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
EdgeEffect = new EdgeEffect
|
|
|
|
|
{
|
|
|
|
|
Colour = Color4.Black.Opacity(0.04f),
|
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Radius = 5,
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
hover = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
},
|
|
|
|
|
icon = new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
TextSize = 18,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
hover.Colour = colours.Yellow.Opacity(0.6f);
|
2017-04-08 18:28:29 +08:00
|
|
|
|
flashColour = colours.Yellow;
|
2017-04-07 12:04:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnHover(InputState state)
|
|
|
|
|
{
|
|
|
|
|
hover.FadeIn(500, EasingTypes.OutQuint);
|
|
|
|
|
return base.OnHover(state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(InputState state)
|
|
|
|
|
{
|
|
|
|
|
hover.FadeOut(500, EasingTypes.OutQuint);
|
|
|
|
|
base.OnHoverLost(state);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-08 18:28:29 +08:00
|
|
|
|
protected override bool OnClick(InputState state)
|
|
|
|
|
{
|
|
|
|
|
hover.FlashColour(flashColour, 800, EasingTypes.OutQuint);
|
|
|
|
|
return base.OnClick(state);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-07 12:04:57 +08:00
|
|
|
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
|
|
|
|
{
|
2017-04-08 17:01:56 +08:00
|
|
|
|
content.ScaleTo(0.75f, 2000, EasingTypes.OutQuint);
|
2017-04-07 12:04:57 +08:00
|
|
|
|
return base.OnMouseDown(state, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
content.ScaleTo(1, 1000, EasingTypes.OutElastic);
|
|
|
|
|
return base.OnMouseUp(state, args);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-24 10:22:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|