1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 15:12:57 +08:00

Add background to song select

This commit is contained in:
Drew DeVault 2016-10-13 16:55:15 -04:00
parent 71f58285fc
commit 3d53af155f
2 changed files with 64 additions and 7 deletions

View File

@ -21,11 +21,14 @@ using OpenTK.Graphics;
namespace osu.Game.GameModes.Play namespace osu.Game.GameModes.Play
{ {
class BeatmapGroup : FlowContainer class BeatmapGroup : AutoSizeContainer
{ {
private const float collapsedAlpha = 0.75f;
public event Action<BeatmapSet> SetSelected; public event Action<BeatmapSet> SetSelected;
public event Action<BeatmapSet, Beatmap> BeatmapSelected; public event Action<BeatmapSet, Beatmap> BeatmapSelected;
public BeatmapSet BeatmapSet; public BeatmapSet BeatmapSet;
private FlowContainer topContainer;
private FlowContainer difficulties; private FlowContainer difficulties;
private bool collapsed; private bool collapsed;
public bool Collapsed public bool Collapsed
@ -37,7 +40,6 @@ namespace osu.Game.GameModes.Play
return; return;
collapsed = value; collapsed = value;
this.ClearTransformations(); this.ClearTransformations();
const float collapsedAlpha = 0.75f;
const float uncollapsedAlpha = 1; const float uncollapsedAlpha = 1;
Transforms.Add(new TransformAlpha(Clock) Transforms.Add(new TransformAlpha(Clock)
{ {
@ -47,19 +49,29 @@ namespace osu.Game.GameModes.Play
EndTime = Time + 250, EndTime = Time + 250,
}); });
if (collapsed) if (collapsed)
Remove(difficulties); topContainer.Remove(difficulties);
else else
Add(difficulties); topContainer.Add(difficulties);
} }
} }
public BeatmapGroup(BeatmapSet beatmapSet) public BeatmapGroup(BeatmapSet beatmapSet)
{ {
BeatmapSet = beatmapSet; BeatmapSet = beatmapSet;
Direction = FlowDirection.VerticalOnly; Alpha = collapsedAlpha;
Children = new Drawable[] Children = new Drawable[]
{ {
new SpriteText { Text = this.BeatmapSet.Metadata.Title, TextSize = 25 }, new Box
{
Colour = new Color4(0, 0, 0, 0.75f),
RelativeSizeAxes = Axes.Both,
Size = new Vector2(1),
},
topContainer = new FlowContainer
{
Direction = FlowDirection.VerticalOnly,
Children = new[] { new SpriteText { Text = this.BeatmapSet.Metadata.Title, TextSize = 25 } }
}
}; };
difficulties = new FlowContainer // Deliberately not added to children difficulties = new FlowContainer // Deliberately not added to children
{ {

View File

@ -12,7 +12,10 @@ using osu.Game.GameModes.Backgrounds;
using osu.Framework; using osu.Framework;
using osu.Game.Database; using osu.Game.Database;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.Drawables;
using System.Linq; using System.Linq;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.GameModes.Play namespace osu.Game.GameModes.Play
{ {
@ -50,10 +53,30 @@ namespace osu.Game.GameModes.Play
public PlaySongSelect() public PlaySongSelect()
{ {
Children = new[] const float backgroundWidth = 0.6f;
const float backgroundSlant = 25;
Children = new Drawable[]
{ {
new BackgroundBox(backgroundSlant)
{
RelativeSizeAxes = Axes.Both,
Size = new Vector2(backgroundWidth, 0.5f),
Colour = new Color4(0, 0, 0, 0.5f),
},
new BackgroundBox(-backgroundSlant)
{
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Y,
Size = new Vector2(backgroundWidth, 0.5f),
Position = new Vector2(0, 0.5f),
Colour = new Color4(0, 0, 0, 0.5f),
},
scrollContainer = new ScrollContainer scrollContainer = new ScrollContainer
{ {
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Both,
Size = new Vector2(0.5f, 1),
Position = new Vector2(0.5f, 0),
Children = new[] Children = new[]
{ {
setList = new FlowContainer setList = new FlowContainer
@ -95,5 +118,27 @@ namespace osu.Game.GameModes.Play
private void PlayMode_ValueChanged(object sender, EventArgs e) private void PlayMode_ValueChanged(object sender, EventArgs e)
{ {
} }
class BackgroundBox : Box
{
private float wedgeWidth;
public BackgroundBox(float wedgeWidth)
{
this.wedgeWidth = wedgeWidth;
}
protected override Quad DrawQuad
{
get
{
Quad q = base.DrawQuad;
q.TopRight.X += wedgeWidth;
q.BottomRight.X -= wedgeWidth;
return q;
}
}
}
} }
} }