mirror of
https://github.com/osukey/osukey.git
synced 2025-05-19 12:37:38 +09:00
Reimplement with MusicController
This commit is contained in:
parent
2d6a2f41aa
commit
7b5f8800bd
@ -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,104 +88,128 @@ 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,
|
||||||
Masking = true,
|
|
||||||
CornerRadius = 5,
|
|
||||||
EdgeEffect = new EdgeEffect
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Shadow,
|
|
||||||
Colour = Color4.Black.Opacity(40),
|
|
||||||
Radius = 5,
|
|
||||||
},
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
title = new OsuSpriteText
|
playlist = new PlaylistController
|
||||||
{
|
{
|
||||||
Origin = Anchor.BottomCentre,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Anchor = Anchor.TopCentre,
|
Padding = new MarginPadding { Top = player_height + 10 },
|
||||||
Position = new Vector2(0, 40),
|
//todo: this is the logic I expect, but maybe not others
|
||||||
TextSize = 25,
|
OnSelect = (set) =>
|
||||||
Colour = Color4.White,
|
{
|
||||||
Text = @"Nothing to play",
|
if (set.ID == (current?.BeatmapSetInfo?.ID ?? -1))
|
||||||
Font = @"Exo2.0-MediumItalic"
|
current?.Track?.Seek(0);
|
||||||
|
|
||||||
|
play(set.Beatmaps[0], true);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
artist = new OsuSpriteText
|
playerContainer = new Container
|
||||||
{
|
{
|
||||||
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
|
|
||||||
{
|
|
||||||
Padding = new MarginPadding { Bottom = progress_height },
|
|
||||||
Height = bottom_black_area_height,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Origin = Anchor.BottomCentre,
|
Height = player_height,
|
||||||
Anchor = Anchor.BottomCentre,
|
Masking = true,
|
||||||
|
CornerRadius = 5,
|
||||||
|
EdgeEffect = new EdgeEffect
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Shadow,
|
||||||
|
Colour = Color4.Black.Opacity(40),
|
||||||
|
Radius = 5,
|
||||||
|
},
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new FillFlowContainer<Button>
|
title = new OsuSpriteText
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
Origin = Anchor.BottomCentre,
|
||||||
Direction = FillDirection.Horizontal,
|
Anchor = Anchor.TopCentre,
|
||||||
Spacing = new Vector2(5),
|
Position = new Vector2(0, 40),
|
||||||
Origin = Anchor.Centre,
|
TextSize = 25,
|
||||||
Anchor = Anchor.Centre,
|
Colour = Color4.White,
|
||||||
Children = new[]
|
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
|
||||||
|
{
|
||||||
|
Padding = new MarginPadding { Bottom = progress_height },
|
||||||
|
Height = bottom_black_area_height,
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
Anchor = Anchor.BottomCentre,
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Button
|
new FillFlowContainer<Button>
|
||||||
{
|
{
|
||||||
Action = prev,
|
AutoSizeAxes = Axes.Both,
|
||||||
Icon = FontAwesome.fa_step_backward,
|
Direction = FillDirection.Horizontal,
|
||||||
},
|
Spacing = new Vector2(5),
|
||||||
playButton = new Button
|
Origin = Anchor.Centre,
|
||||||
{
|
Anchor = Anchor.Centre,
|
||||||
Scale = new Vector2(1.4f),
|
Children = new[]
|
||||||
IconScale = new Vector2(1.4f),
|
|
||||||
Action = () =>
|
|
||||||
{
|
{
|
||||||
if (current?.Track == null) return;
|
new Button
|
||||||
if (current.Track.IsRunning)
|
{
|
||||||
current.Track.Stop();
|
Action = prev,
|
||||||
else
|
Icon = FontAwesome.fa_step_backward,
|
||||||
current.Track.Start();
|
},
|
||||||
},
|
playButton = new Button
|
||||||
Icon = FontAwesome.fa_play_circle_o,
|
{
|
||||||
|
Scale = new Vector2(1.4f),
|
||||||
|
IconScale = new Vector2(1.4f),
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
if (current?.Track == null) return;
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
}
|
||||||
},
|
},
|
||||||
new Button
|
playlistButton = new Button
|
||||||
{
|
{
|
||||||
Action = next,
|
Origin = Anchor.Centre,
|
||||||
Icon = FontAwesome.fa_step_forward,
|
Anchor = Anchor.CentreRight,
|
||||||
|
Position = new Vector2(-bottom_black_area_height / 2, 0),
|
||||||
|
Icon = FontAwesome.fa_bars,
|
||||||
|
Action = () => playlist.ToggleVisibility(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Button
|
progress = new DragBar
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.BottomCentre,
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.BottomCentre,
|
||||||
Position = new Vector2(-bottom_black_area_height / 2, 0),
|
Height = progress_height,
|
||||||
Icon = FontAwesome.fa_bars,
|
Colour = colours.Yellow,
|
||||||
},
|
SeekRequested = seek
|
||||||
}
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
progress = new DragBar
|
|
||||||
{
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Height = progress_height,
|
|
||||||
Colour = colours.Yellow,
|
|
||||||
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 =>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user