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;
|
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-10-24 10:22:38 +08:00
|
|
|
|
using osu.Framework;
|
2016-11-11 06:40:42 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Audio;
|
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;
|
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;
|
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-10-24 15:34:44 +08:00
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
2016-11-07 20:07:45 +08:00
|
|
|
|
using osu.Framework.Input;
|
2016-11-07 22:12:58 +08:00
|
|
|
|
using osu.Framework.MathUtils;
|
2016-10-28 19:39:02 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2016-11-11 10:35:58 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2016-10-24 13:47:05 +08:00
|
|
|
|
using osu.Game.Database;
|
2016-10-24 13:00:06 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2016-11-15 00:22:20 +08:00
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
2017-02-09 10:28:13 +08:00
|
|
|
|
using osu.Framework.Threading;
|
2017-01-31 17:53:52 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
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
|
|
|
|
{
|
2016-11-12 15:44:02 +08:00
|
|
|
|
private MusicControllerBackground backgroundSprite;
|
2016-10-27 18:15:43 +08:00
|
|
|
|
private DragBar progress;
|
2016-10-24 17:19:48 +08:00
|
|
|
|
private TextAwesome playButton, listButton;
|
2016-10-24 13:00:06 +08:00
|
|
|
|
private SpriteText title, artist;
|
2016-10-27 18:15:43 +08:00
|
|
|
|
|
2016-10-24 13:47:05 +08:00
|
|
|
|
private List<BeatmapSetInfo> playList;
|
2016-11-07 21:25:37 +08:00
|
|
|
|
private List<BeatmapInfo> playHistory = new List<BeatmapInfo>();
|
2016-11-07 20:57:33 +08:00
|
|
|
|
private int playListIndex;
|
2016-11-07 21:25:37 +08:00
|
|
|
|
private int playHistoryIndex = -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-11-11 10:35:58 +08:00
|
|
|
|
private Bindable<bool> preferUnicode;
|
2016-10-28 20:21:19 +08:00
|
|
|
|
private WorkingBeatmap current;
|
2016-11-12 18:44:16 +08:00
|
|
|
|
private BeatmapDatabase beatmaps;
|
2016-11-22 19:47:28 +08:00
|
|
|
|
private BaseGame game;
|
2016-10-27 16:58:40 +08:00
|
|
|
|
|
2017-01-30 21:00:23 +08:00
|
|
|
|
private Container dragContainer;
|
|
|
|
|
|
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;
|
|
|
|
|
Height = 130;
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnDragStart(InputState state) => true;
|
|
|
|
|
|
|
|
|
|
protected override bool OnDrag(InputState state)
|
|
|
|
|
{
|
|
|
|
|
Vector2 change = (state.Mouse.Position - state.Mouse.PositionMouseDown.Value);
|
|
|
|
|
|
|
|
|
|
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
|
|
|
|
|
change *= (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-01-25 17:39:41 +08:00
|
|
|
|
private void load(OsuGameBase osuGame, OsuConfigManager config, BeatmapDatabase beatmaps, AudioManager audio,
|
2017-01-13 12:49:05 +08:00
|
|
|
|
TextureStore textures, OsuColour colours)
|
|
|
|
|
{
|
2017-01-25 17:39:41 +08:00
|
|
|
|
unicodeString = config.GetUnicodeString;
|
|
|
|
|
|
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
|
|
|
|
Masking = true,
|
|
|
|
|
CornerRadius = 5,
|
|
|
|
|
EdgeEffect = new EdgeEffect
|
2016-10-24 15:34:44 +08:00
|
|
|
|
{
|
2017-01-30 21:00:23 +08:00
|
|
|
|
Type = EdgeEffectType.Shadow,
|
|
|
|
|
Colour = Color4.Black.Opacity(40),
|
|
|
|
|
Radius = 5,
|
2016-10-24 17:19:48 +08:00
|
|
|
|
},
|
2017-01-30 21:00:23 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2016-10-24 17:19:48 +08:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2017-01-31 17:53:52 +08:00
|
|
|
|
title = new OsuSpriteText
|
2016-10-24 17:19:48 +08:00
|
|
|
|
{
|
2017-01-30 21:00:23 +08:00
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Position = new Vector2(0, 40),
|
|
|
|
|
TextSize = 25,
|
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
Text = @"Nothing to play",
|
|
|
|
|
Font = @"Exo2.0-MediumItalic"
|
|
|
|
|
},
|
2017-01-31 17:53:52 +08:00
|
|
|
|
artist = new OsuSpriteText
|
2016-10-24 17:19:48 +08:00
|
|
|
|
{
|
2017-01-30 21:00:23 +08:00
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Position = new Vector2(0, 45),
|
2016-10-24 17:19:48 +08:00
|
|
|
|
TextSize = 15,
|
2017-01-30 21:00:23 +08:00
|
|
|
|
Colour = Color4.White,
|
|
|
|
|
Text = @"Nothing to play",
|
|
|
|
|
Font = @"Exo2.0-BoldItalic"
|
|
|
|
|
},
|
|
|
|
|
new ClickableContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-10-24 17:19:48 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-01-30 21:00:23 +08:00
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Position = new Vector2(0, -30),
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
if (current?.Track == null) return;
|
|
|
|
|
if (current.Track.IsRunning)
|
|
|
|
|
current.Track.Stop();
|
|
|
|
|
else
|
|
|
|
|
current.Track.Start();
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
playButton = new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
TextSize = 30,
|
|
|
|
|
Icon = FontAwesome.fa_play_circle_o,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new ClickableContainer
|
2016-10-24 17:19:48 +08:00
|
|
|
|
{
|
2017-01-30 21:00:23 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-10-24 17:19:48 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-01-30 21:00:23 +08:00
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Position = new Vector2(-30, -30),
|
|
|
|
|
Action = prev,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
TextSize = 15,
|
|
|
|
|
Icon = FontAwesome.fa_step_backward,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new ClickableContainer
|
2016-10-24 17:19:48 +08:00
|
|
|
|
{
|
2017-01-30 21:00:23 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
2016-10-24 17:19:48 +08:00
|
|
|
|
Origin = Anchor.Centre,
|
2017-01-30 21:00:23 +08:00
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Position = new Vector2(30, -30),
|
|
|
|
|
Action = next,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
TextSize = 15,
|
|
|
|
|
Icon = FontAwesome.fa_step_forward,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new ClickableContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Position = new Vector2(20, -30),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
listButton = new TextAwesome
|
|
|
|
|
{
|
|
|
|
|
TextSize = 15,
|
|
|
|
|
Icon = FontAwesome.fa_bars,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
progress = new DragBar
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomCentre,
|
|
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
|
Height = 10,
|
|
|
|
|
Colour = colours.Yellow,
|
|
|
|
|
SeekRequested = seek
|
2016-10-24 17:19:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-24 10:50:49 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2017-01-13 12:49:05 +08:00
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
this.beatmaps = beatmaps;
|
|
|
|
|
trackManager = osuGame.Audio.Track;
|
2017-01-25 17:39:41 +08:00
|
|
|
|
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
|
2016-11-12 18:44:16 +08:00
|
|
|
|
preferUnicode.ValueChanged += preferUnicode_changed;
|
2016-11-06 00:24:03 +08:00
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
beatmapSource = osuGame.Beatmap ?? new Bindable<WorkingBeatmap>();
|
|
|
|
|
playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>();
|
2016-11-06 00:24:03 +08:00
|
|
|
|
|
2016-11-22 19:47:28 +08:00
|
|
|
|
backgroundSprite = new MusicControllerBackground();
|
2017-01-30 21:00:23 +08:00
|
|
|
|
dragContainer.Add(backgroundSprite);
|
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;
|
2016-11-06 00:46:09 +08:00
|
|
|
|
workingChanged();
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
progress.UpdatePosition((float)(current.Track.CurrentTime / current.Track.Length));
|
|
|
|
|
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();
|
|
|
|
|
}
|
2016-10-24 17:23:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-11 10:35:58 +08:00
|
|
|
|
void preferUnicode_changed(object sender, EventArgs e)
|
|
|
|
|
{
|
2017-01-04 02:12:18 +08:00
|
|
|
|
updateDisplay(current, TransformDirection.None);
|
2016-11-11 10:35:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-28 20:44:59 +08:00
|
|
|
|
private void workingChanged(object sender = null, EventArgs e = null)
|
|
|
|
|
{
|
2016-12-01 08:20:24 +08:00
|
|
|
|
progress.IsEnabled = (beatmapSource.Value != null);
|
2016-10-28 20:44:59 +08:00
|
|
|
|
if (beatmapSource.Value == current) return;
|
2016-11-07 21:58:30 +08:00
|
|
|
|
bool audioEquals = current?.BeatmapInfo.AudioEquals(beatmapSource.Value.BeatmapInfo) ?? false;
|
2016-10-28 21:57:23 +08:00
|
|
|
|
current = beatmapSource.Value;
|
2016-11-14 04:59:41 +08:00
|
|
|
|
updateDisplay(current, audioEquals ? TransformDirection.None : TransformDirection.Next);
|
2016-11-07 21:30:25 +08:00
|
|
|
|
appendToHistory(current.BeatmapInfo);
|
2016-10-28 20:44:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 21:25:37 +08:00
|
|
|
|
private void appendToHistory(BeatmapInfo beatmap)
|
2016-10-28 20:08:27 +08:00
|
|
|
|
{
|
2016-11-07 21:25:37 +08:00
|
|
|
|
if (playHistoryIndex >= 0)
|
|
|
|
|
{
|
2016-11-07 21:52:23 +08:00
|
|
|
|
if (beatmap.AudioEquals(playHistory[playHistoryIndex]))
|
2016-11-07 21:25:37 +08:00
|
|
|
|
return;
|
|
|
|
|
if (playHistoryIndex < playHistory.Count - 1)
|
|
|
|
|
playHistory.RemoveRange(playHistoryIndex + 1, playHistory.Count - playHistoryIndex - 1);
|
|
|
|
|
}
|
|
|
|
|
playHistory.Insert(++playHistoryIndex, beatmap);
|
2016-10-28 20:08:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-24 15:34:44 +08:00
|
|
|
|
private void prev()
|
|
|
|
|
{
|
2016-11-07 21:25:37 +08:00
|
|
|
|
if (playHistoryIndex > 0)
|
|
|
|
|
play(playHistory[--playHistoryIndex], false);
|
2016-10-24 15:34:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void next()
|
|
|
|
|
{
|
2016-11-07 21:25:37 +08:00
|
|
|
|
if (playHistoryIndex < playHistory.Count - 1)
|
|
|
|
|
play(playHistory[++playHistoryIndex], true);
|
|
|
|
|
else
|
2016-10-28 21:57:23 +08:00
|
|
|
|
{
|
2016-11-07 23:06:14 +08:00
|
|
|
|
if (playList.Count == 0) return;
|
|
|
|
|
if (current != null && playList.Count == 1) return;
|
2016-11-07 22:12:58 +08:00
|
|
|
|
//shuffle
|
2016-11-07 23:06:14 +08:00
|
|
|
|
BeatmapInfo nextToPlay;
|
|
|
|
|
do
|
2016-11-07 22:12:58 +08:00
|
|
|
|
{
|
2016-11-07 23:06:14 +08:00
|
|
|
|
int j = RNG.Next(playListIndex, playList.Count);
|
|
|
|
|
if (j != playListIndex)
|
|
|
|
|
{
|
|
|
|
|
BeatmapSetInfo temp = playList[playListIndex];
|
|
|
|
|
playList[playListIndex] = playList[j];
|
|
|
|
|
playList[j] = temp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nextToPlay = playList[playListIndex++].Beatmaps[0];
|
|
|
|
|
if (playListIndex == playList.Count) playListIndex = 0;
|
2016-11-07 22:12:58 +08:00
|
|
|
|
}
|
2016-11-07 23:12:49 +08:00
|
|
|
|
while (nextToPlay.AudioEquals(current?.BeatmapInfo));
|
2016-11-07 22:12:58 +08:00
|
|
|
|
|
2016-11-07 21:25:37 +08:00
|
|
|
|
play(nextToPlay, true);
|
|
|
|
|
appendToHistory(nextToPlay);
|
2016-10-28 21:57:23 +08:00
|
|
|
|
}
|
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;
|
|
|
|
|
});
|
2016-11-14 04:59:41 +08:00
|
|
|
|
updateDisplay(current, isNext ? TransformDirection.Next : TransformDirection.Prev);
|
2016-10-24 15:34:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-22 19:47:28 +08:00
|
|
|
|
protected override void PerformLoad(BaseGame game)
|
2016-10-24 15:34:44 +08:00
|
|
|
|
{
|
2016-11-22 19:47:28 +08:00
|
|
|
|
this.game = game;
|
|
|
|
|
base.PerformLoad(game);
|
|
|
|
|
}
|
2016-11-12 18:44:16 +08:00
|
|
|
|
|
2017-02-09 10:28:13 +08:00
|
|
|
|
Action pendingBeatmapSwitch;
|
|
|
|
|
|
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(() =>
|
|
|
|
|
{
|
|
|
|
|
if (beatmap?.Beatmap == null)
|
|
|
|
|
//todo: we may need to display some default text here (currently in the constructor).
|
|
|
|
|
return;
|
2016-10-27 17:04:41 +08:00
|
|
|
|
|
2017-02-09 10:28:13 +08:00
|
|
|
|
BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
|
|
|
|
|
title.Text = unicodeString(metadata.Title, metadata.TitleUnicode);
|
|
|
|
|
artist.Text = unicodeString(metadata.Artist, metadata.ArtistUnicode);
|
|
|
|
|
});
|
2016-10-27 17:04:41 +08:00
|
|
|
|
|
2017-02-09 10:28:13 +08:00
|
|
|
|
MusicControllerBackground newBackground;
|
2016-10-27 17:04:41 +08:00
|
|
|
|
|
2017-02-09 10:28:13 +08:00
|
|
|
|
(newBackground = new MusicControllerBackground(beatmap)).Preload(game, delegate
|
|
|
|
|
{
|
2016-10-27 17:04:41 +08:00
|
|
|
|
|
2017-02-09 10:28:13 +08:00
|
|
|
|
dragContainer.Add(newBackground);
|
2016-11-22 19:47:28 +08:00
|
|
|
|
|
2017-02-09 10:28:13 +08:00
|
|
|
|
switch (direction)
|
|
|
|
|
{
|
|
|
|
|
case TransformDirection.Next:
|
|
|
|
|
newBackground.Position = new Vector2(400, 0);
|
|
|
|
|
newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
|
|
|
|
|
backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic);
|
|
|
|
|
break;
|
|
|
|
|
case TransformDirection.Prev:
|
|
|
|
|
newBackground.Position = new Vector2(-400, 0);
|
|
|
|
|
newBackground.MoveToX(0, 500, EasingTypes.OutCubic);
|
|
|
|
|
backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-11-22 19:47:28 +08:00
|
|
|
|
|
2017-02-09 10:28:13 +08:00
|
|
|
|
backgroundSprite.Expire();
|
|
|
|
|
backgroundSprite = newBackground;
|
|
|
|
|
});
|
|
|
|
|
};
|
2016-10-24 10:22:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-25 17:39:41 +08:00
|
|
|
|
private Func<string, string, string> unicodeString;
|
|
|
|
|
|
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
|
|
|
|
|
2016-11-11 10:35:58 +08:00
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
if (preferUnicode != null)
|
|
|
|
|
preferUnicode.ValueChanged -= preferUnicode_changed;
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
}
|
2016-10-25 09:18:47 +08:00
|
|
|
|
|
2017-02-09 11:51:56 +08:00
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
private Sprite sprite;
|
2016-11-22 19:47:28 +08:00
|
|
|
|
private 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;
|
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
2016-11-30 03:50:12 +08:00
|
|
|
|
Depth = float.MaxValue;
|
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,
|
|
|
|
|
Height = 50,
|
|
|
|
|
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
|
|
|
|
}
|
2016-10-24 10:22:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|