Initial implementation of a beatmap carousell and various minor improvements to song select.

No big optimizations yet, but groundwork is laid out.
This commit is contained in:
Thomas Müller
2016-11-20 20:34:16 +01:00
parent 40805ad32c
commit c6d688898f
13 changed files with 268 additions and 162 deletions

View File

@ -17,7 +17,7 @@ using osu.Framework.Allocation;
namespace osu.Game.Beatmaps.Drawable
{
class BeatmapGroup : Container, IStateful<BeatmapGroupState>
class BeatmapGroup : IStateful<BeatmapGroupState>
{
public BeatmapPanel SelectedPanel;
@ -27,8 +27,7 @@ namespace osu.Game.Beatmaps.Drawable
public Action<BeatmapGroup, BeatmapInfo> SelectionChanged;
private BeatmapSetInfo beatmapSet;
private BeatmapSetHeader header;
private FlowContainer difficulties;
public BeatmapSetHeader Header;
private BeatmapGroupState state;
@ -43,24 +42,24 @@ namespace osu.Game.Beatmaps.Drawable
switch (state)
{
case BeatmapGroupState.Expanded:
FadeTo(1, 250);
//if (!difficulties.Children.All(d => IsLoaded))
// Task.WhenAll(difficulties.Children.Select(d => d.Preload(Game))).ContinueWith(t => difficulties.Show());
//else
difficulties.Show();
foreach (BeatmapPanel panel in BeatmapPanels)
panel.Show();
header.State = PanelSelectedState.Selected;
Header.State = PanelSelectedState.Selected;
if (SelectedPanel != null)
SelectedPanel.State = PanelSelectedState.Selected;
break;
case BeatmapGroupState.Collapsed:
FadeTo(0.8f, 250);
header.State = PanelSelectedState.NotSelected;
Header.State = PanelSelectedState.NotSelected;
if (SelectedPanel != null)
SelectedPanel.State = PanelSelectedState.NotSelected;
difficulties.Hide();
foreach (BeatmapPanel panel in BeatmapPanels)
panel.Hide();
break;
}
}
@ -70,54 +69,21 @@ namespace osu.Game.Beatmaps.Drawable
{
this.beatmapSet = beatmapSet;
Alpha = 0;
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
Children = new[]
Header = new BeatmapSetHeader(beatmapSet, working)
{
new FlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FlowDirection.VerticalOnly,
Children = new Framework.Graphics.Drawable[]
{
header = new BeatmapSetHeader(beatmapSet, working)
{
GainedSelection = headerGainedSelection,
RelativeSizeAxes = Axes.X,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
},
difficulties = new FlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Top = 5 },
Padding = new MarginPadding { Left = 75 },
Spacing = new Vector2(0, 5),
Direction = FlowDirection.VerticalOnly,
}
}
}
GainedSelection = headerGainedSelection,
RelativeSizeAxes = Axes.X,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
};
}
[BackgroundDependencyLoader]
private void load(BaseGame game)
{
BeatmapPanels = beatmapSet.Beatmaps.Select(b => new BeatmapPanel(b)
{
GainedSelection = panelGainedSelection,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.X,
}).ToList();
//for the time being, let's completely load the difficulty panels in the background.
//this likely won't scale so well, but allows us to completely async the loading flow.
Task.WhenAll(BeatmapPanels.Select(panel => panel.Preload(game, p => difficulties.Add(panel)))).Wait();
}).ToList();
}
private void headerGainedSelection(BeatmapSetHeader panel)

View File

@ -11,12 +11,14 @@ using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Graphics.Colour;
namespace osu.Game.Beatmaps.Drawable
{
class BeatmapPanel : Panel
{
public BeatmapInfo Beatmap;
private Sprite background;
public Action<BeatmapPanel> GainedSelection;
@ -24,6 +26,17 @@ namespace osu.Game.Beatmaps.Drawable
{
base.Selected();
GainedSelection?.Invoke(this);
background.ColourInfo = ColourInfo.GradientVertical(
new Color4(20, 43, 51, 255),
new Color4(40, 86, 102, 255));
}
protected override void Deselected()
{
base.Deselected();
background.Colour = new Color4(20, 43, 51, 255);
}
public BeatmapPanel(BeatmapInfo beatmap)
@ -33,11 +46,9 @@ namespace osu.Game.Beatmaps.Drawable
Children = new Framework.Graphics.Drawable[]
{
new Box
background = new Box
{
Colour = new Color4(40, 86, 102, 255), // TODO: gradient
RelativeSizeAxes = Axes.Both,
Size = Vector2.One,
},
new FlowContainer
{

View File

@ -10,10 +10,10 @@ using osu.Game.Database;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Game.Configuration;
using osu.Framework.Graphics.Colour;
namespace osu.Game.Beatmaps.Drawable
{
@ -28,15 +28,13 @@ namespace osu.Game.Beatmaps.Drawable
protected override void Selected()
{
base.Selected();
Width = 1;
GainedSelection?.Invoke(this);
}
protected override void Deselected()
{
base.Deselected();
Width = 0.8f;
}
[BackgroundDependencyLoader]
@ -66,36 +64,83 @@ namespace osu.Game.Beatmaps.Drawable
{
this.beatmapSet = beatmapSet;
Children = new Framework.Graphics.Drawable[]
{
working.Background == null ? new Box{ RelativeSizeAxes = Axes.Both, Colour = new Color4(20, 20, 20, 255) } : new Sprite
{
Texture = working.Background,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(1366 / working.Background.Width * 0.6f),
{
new BufferedContainer
{
CacheDrawnFrameBuffer = true,
RelativeSizeAxes = Axes.Both,
Children = new Framework.Graphics.Drawable[]
{
working.Background == null ? new Box{ RelativeSizeAxes = Axes.Both, Colour = new Color4(200, 200, 200, 255) } : new Sprite
{
Texture = working.Background,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(1366 / working.Background.Width * 0.6f),
},
new FlowContainer
{
Direction = FlowDirection.HorizontalOnly,
RelativeSizeAxes = Axes.Both,
// This makes the gradient not be perfectly horizontal, but diagonal at a ~40<34> angle
Shear = new Vector2(0.8f, 0),
Alpha = 0.5f,
Children = new[]
{
// The left half with no gradient applied
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
Width = 0.4f,
},
// Piecewise-linear gradient with 3 segments to make it appear smoother
new Box
{
RelativeSizeAxes = Axes.Both,
ColourInfo = ColourInfo.GradientHorizontal(Color4.Black, new Color4(0f, 0f, 0f, 0.9f)),
Width = 0.05f,
},
new Box
{
RelativeSizeAxes = Axes.Both,
ColourInfo = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.9f), new Color4(0f, 0f, 0f, 0.1f)),
Width = 0.2f,
},
new Box
{
RelativeSizeAxes = Axes.Both,
ColourInfo = ColourInfo.GradientHorizontal(new Color4(0f, 0f, 0f, 0.1f), new Color4(0, 0, 0, 0)),
Width = 0.05f,
},
}
},
}
},
new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
Spacing = new Vector2(0, 2),
Direction = FlowDirection.VerticalOnly,
Padding = new MarginPadding { Top = 5, Left = 18, Right = 10, Bottom = 10 },
AutoSizeAxes = Axes.Both,
Children = new[]
{
title = new SpriteText
{
{
Font = @"Exo2.0-BoldItalic",
Text = beatmapSet.Metadata.Title,
Text = beatmapSet.Metadata.Title,
TextSize = 22,
Shadow = true,
},
artist = new SpriteText
{
{
Margin = new MarginPadding { Top = -1 },
Font = @"Exo2.0-SemiBoldItalic",
Text = beatmapSet.Metadata.Artist,
Text = beatmapSet.Metadata.Artist,
TextSize = 17,
Shadow = true,
},
new FlowContainer
{
Margin = new MarginPadding { Top = 5 },
AutoSizeAxes = Axes.Both,
Children = new[]
@ -106,8 +151,6 @@ namespace osu.Game.Beatmaps.Drawable
}
}
}
};
};
}
}

View File

@ -26,8 +26,26 @@ namespace osu.Game.Beatmaps.Drawable
BorderColour = new Color4(221, 255, 255, 255);
RelativeSizeAxes = Axes.X;
}
Deselected();
protected override void LoadComplete()
{
base.LoadComplete();
applyState();
FadeInFromZero(250);
}
private void applyState()
{
switch (state)
{
case PanelSelectedState.NotSelected:
Deselected();
break;
case PanelSelectedState.Selected:
Selected();
break;
}
}
private PanelSelectedState state = PanelSelectedState.NotSelected;
@ -41,15 +59,7 @@ namespace osu.Game.Beatmaps.Drawable
if (state == value) return;
state = value;
switch (state)
{
case PanelSelectedState.NotSelected:
Deselected();
break;
case PanelSelectedState.Selected:
Selected();
break;
}
applyState();
}
}