Reimplement with MusicController

This commit is contained in:
DrabWeb 2017-04-09 04:26:21 -03:00
parent 2d6a2f41aa
commit 7b5f8800bd

View File

@ -28,10 +28,15 @@ namespace osu.Game.Overlays
{ {
public class MusicController : FocusedOverlayContainer public class MusicController : FocusedOverlayContainer
{ {
private const float player_height = 130;
private const float playlist_height = 510;
private Drawable currentBackground; private Drawable currentBackground;
private DragBar progress; private DragBar progress;
private Button playButton; private Button playButton;
private SpriteText title, artist; private SpriteText title, artist;
private ClickableContainer playlistButton;
private PlaylistController playlist;
private Color4 activeColour;
private List<BeatmapSetInfo> playList; private List<BeatmapSetInfo> playList;
private readonly List<BeatmapInfo> playHistory = new List<BeatmapInfo>(); private readonly List<BeatmapInfo> playHistory = new List<BeatmapInfo>();
@ -45,6 +50,7 @@ namespace osu.Game.Overlays
private BeatmapDatabase beatmaps; private BeatmapDatabase beatmaps;
private Container dragContainer; private Container dragContainer;
private Container playerContainer;
private const float progress_height = 10; private const float progress_height = 10;
@ -53,7 +59,7 @@ namespace osu.Game.Overlays
public MusicController() public MusicController()
{ {
Width = 400; Width = 400;
Height = 130; Height = player_height + playlist_height;
Margin = new MarginPadding(10); Margin = new MarginPadding(10);
} }
@ -82,12 +88,34 @@ namespace osu.Game.Overlays
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuGameBase game, OsuConfigManager config, BeatmapDatabase beatmaps, OsuColour colours) private void load(OsuGameBase game, OsuConfigManager config, BeatmapDatabase beatmaps, OsuColour colours)
{ {
activeColour = colours.Yellow;
Children = new Drawable[] Children = new Drawable[]
{ {
dragContainer = new Container dragContainer = new Container
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
playlist = new PlaylistController
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = player_height + 10 },
//todo: this is the logic I expect, but maybe not others
OnSelect = (set) =>
{
if (set.ID == (current?.BeatmapSetInfo?.ID ?? -1))
current?.Track?.Seek(0);
play(set.Beatmaps[0], true);
},
},
playerContainer = new Container
{
RelativeSizeAxes = Axes.X,
Height = player_height,
Masking = true, Masking = true,
CornerRadius = 5, CornerRadius = 5,
EdgeEffect = new EdgeEffect EdgeEffect = new EdgeEffect
@ -96,7 +124,6 @@ namespace osu.Game.Overlays
Colour = Color4.Black.Opacity(40), Colour = Color4.Black.Opacity(40),
Radius = 5, Radius = 5,
}, },
RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
title = new OsuSpriteText title = new OsuSpriteText
@ -163,12 +190,13 @@ namespace osu.Game.Overlays
}, },
} }
}, },
new Button playlistButton = new Button
{ {
Origin = Anchor.Centre, Origin = Anchor.Centre,
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Position = new Vector2(-bottom_black_area_height / 2, 0), Position = new Vector2(-bottom_black_area_height / 2, 0),
Icon = FontAwesome.fa_bars, Icon = FontAwesome.fa_bars,
Action = () => playlist.ToggleVisibility(),
}, },
} }
}, },
@ -180,6 +208,8 @@ namespace osu.Game.Overlays
Colour = colours.Yellow, Colour = colours.Yellow,
SeekRequested = seek SeekRequested = seek
} }
},
},
} }
} }
}; };
@ -193,7 +223,8 @@ namespace osu.Game.Overlays
playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>(); playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>();
currentBackground = new MusicControllerBackground(); currentBackground = new MusicControllerBackground();
dragContainer.Add(currentBackground); playerContainer.Add(currentBackground);
playlist.StateChanged += (c, s) => playlistButton.FadeColour(s == Visibility.Visible? activeColour : Color4.White, transition_length, EasingTypes.OutQuint);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -317,10 +348,11 @@ namespace osu.Game.Overlays
BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata; BeatmapMetadata metadata = beatmap.Beatmap.BeatmapInfo.Metadata;
title.Text = preferUnicode ? metadata.TitleUnicode : metadata.Title; title.Text = preferUnicode ? metadata.TitleUnicode : metadata.Title;
artist.Text = preferUnicode ? metadata.ArtistUnicode : metadata.Artist; artist.Text = preferUnicode ? metadata.ArtistUnicode : metadata.Artist;
playlist.Current = beatmap.BeatmapSetInfo;
} }
}); });
dragContainer.Add(new AsyncLoadWrapper(new MusicControllerBackground(beatmap) playerContainer.Add(new AsyncLoadWrapper(new MusicControllerBackground(beatmap)
{ {
OnLoadComplete = d => OnLoadComplete = d =>
{ {