1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-07 06:32:55 +08:00

PlaySongSelect tweaks

Add a back button, dispose the play button when no beatmaps present,
display track as background, change wedge padding so it wont overlap
with toolbars
This commit is contained in:
Maciej 2016-11-06 11:20:08 +01:00
parent b0279c05e6
commit e2999a0a53

View File

@ -21,6 +21,7 @@ using osu.Game.Beatmaps.Drawable;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Game.Beatmaps;
using osu.Framework.GameModes;
using osu.Game.Graphics;
namespace osu.Game.GameModes.Play
{
@ -30,12 +31,12 @@ namespace osu.Game.GameModes.Play
private BeatmapDatabase database;
private BeatmapGroup selectedBeatmapGroup;
private BeatmapInfo selectedBeatmapInfo;
// TODO: use currently selected track as bg
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
private ScrollContainer scrollContainer;
private Button playButton;
private FlowContainer beatmapSetFlow;
private TrackManager trackManager;
private Container wedgeContainer;
private Sprite background;
/// <param name="database">Optionally provide a database to use instead of the OsuGame one.</param>
public PlaySongSelect(BeatmapDatabase database = null)
@ -44,13 +45,22 @@ namespace osu.Game.GameModes.Play
const float scrollWidth = 640;
const float bottomToolHeight = 50;
const float topToolHeight = 50;
Children = new Drawable[]
{
background = new Sprite {
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = Vector2.One,
Alpha = 0.5f,
},
wedgeContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Size = Vector2.One,
Padding = new MarginPadding { Right = scrollWidth - 200 },
Padding = new MarginPadding { Right = scrollWidth - 200, Bottom = bottomToolHeight, Top = topToolHeight },
Children = new[]
{
new Box
@ -81,7 +91,7 @@ namespace osu.Game.GameModes.Play
{
beatmapSetFlow = new FlowContainer
{
Padding = new MarginPadding { Left = 25, Top = 25, Bottom = 25 + bottomToolHeight },
Padding = new MarginPadding { Left = 25, Top = topToolHeight, Bottom = 25 + bottomToolHeight },
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FlowDirection.VerticalOnly,
@ -103,7 +113,7 @@ namespace osu.Game.GameModes.Play
Size = Vector2.One,
Colour = new Color4(0, 0, 0, 0.5f),
},
new Button
playButton = new Button
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
@ -116,6 +126,18 @@ namespace osu.Game.GameModes.Play
PreferredPlayMode = playMode.Value
}),
},
new Button
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
RelativeSizeAxes = Axes.Y,
Width = 100,
Text = "Back",
Colour = new Color4(238, 51, 153, 255),
Action = delegate {
Exit();
}
}
}
}
};
@ -206,6 +228,7 @@ namespace osu.Game.GameModes.Play
if (!beatmap.Equals(Beatmap?.BeatmapInfo))
{
Beatmap = database.GetWorkingBeatmap(beatmap, Beatmap);
background.Texture = Beatmap.Background;
}
ensurePlayingSelected();
@ -276,8 +299,10 @@ namespace osu.Game.GameModes.Play
private void addBeatmapSets()
{
foreach (var beatmapSet in database.Query<BeatmapSetInfo>())
addBeatmapSet(beatmapSet);
if (database.Query<BeatmapSetInfo>().Count() > 0)
foreach (var beatmapSet in database.Query<BeatmapSetInfo>())
addBeatmapSet(beatmapSet);
else playButton.Dispose(); // not sure about this
}
}
}