2016-10-14 03:10:00 +08:00
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.GameModes.Backgrounds;
|
|
|
|
using osu.Framework;
|
|
|
|
using osu.Game.Database;
|
|
|
|
using osu.Framework.Graphics.Primitives;
|
|
|
|
using OpenTK;
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Graphics.Drawables;
|
2016-10-14 04:25:41 +08:00
|
|
|
using osu.Framework.Graphics.Transformations;
|
|
|
|
using osu.Framework.Input;
|
|
|
|
using OpenTK.Graphics;
|
2016-10-14 03:10:00 +08:00
|
|
|
|
|
|
|
namespace osu.Game.GameModes.Play
|
|
|
|
{
|
|
|
|
class BeatmapGroup : FlowContainer
|
|
|
|
{
|
2016-10-14 04:25:41 +08:00
|
|
|
public event Action<BeatmapSet> SetSelected;
|
|
|
|
public event Action<BeatmapSet, Beatmap> BeatmapSelected;
|
|
|
|
public BeatmapSet BeatmapSet;
|
|
|
|
private FlowContainer difficulties;
|
2016-10-14 03:10:00 +08:00
|
|
|
private bool collapsed;
|
|
|
|
public bool Collapsed
|
|
|
|
{
|
|
|
|
get { return collapsed; }
|
|
|
|
set
|
|
|
|
{
|
2016-10-14 04:25:41 +08:00
|
|
|
if (collapsed == value)
|
|
|
|
return;
|
2016-10-14 03:10:00 +08:00
|
|
|
collapsed = value;
|
2016-10-14 04:25:41 +08:00
|
|
|
this.ClearTransformations();
|
|
|
|
const float collapsedAlpha = 0.75f;
|
|
|
|
const float uncollapsedAlpha = 1;
|
|
|
|
Transforms.Add(new TransformAlpha(Clock)
|
|
|
|
{
|
|
|
|
StartValue = collapsed ? uncollapsedAlpha : collapsedAlpha,
|
|
|
|
EndValue = collapsed ? collapsedAlpha : uncollapsedAlpha,
|
|
|
|
StartTime = Time,
|
|
|
|
EndTime = Time + 250,
|
|
|
|
});
|
2016-10-14 03:10:00 +08:00
|
|
|
if (collapsed)
|
2016-10-14 04:25:41 +08:00
|
|
|
Remove(difficulties);
|
2016-10-14 03:10:00 +08:00
|
|
|
else
|
2016-10-14 04:25:41 +08:00
|
|
|
Add(difficulties);
|
2016-10-14 03:10:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public BeatmapGroup(BeatmapSet beatmapSet)
|
|
|
|
{
|
2016-10-14 04:25:41 +08:00
|
|
|
BeatmapSet = beatmapSet;
|
2016-10-14 03:10:00 +08:00
|
|
|
Direction = FlowDirection.VerticalOnly;
|
2016-10-14 04:25:41 +08:00
|
|
|
Children = new Drawable[]
|
2016-10-14 03:10:00 +08:00
|
|
|
{
|
2016-10-14 04:25:41 +08:00
|
|
|
new SpriteText { Text = this.BeatmapSet.Metadata.Title, TextSize = 25 },
|
2016-10-14 03:10:00 +08:00
|
|
|
};
|
2016-10-14 04:25:41 +08:00
|
|
|
difficulties = new FlowContainer // Deliberately not added to children
|
|
|
|
{
|
|
|
|
Spacing = new Vector2(0, 10),
|
|
|
|
Padding = new MarginPadding { Left = 50 },
|
|
|
|
Direction = FlowDirection.VerticalOnly,
|
|
|
|
Children = this.BeatmapSet.Beatmaps.Select(b => new BeatmapButton(this.BeatmapSet, b))
|
|
|
|
};
|
|
|
|
collapsed = true;
|
2016-10-14 03:10:00 +08:00
|
|
|
}
|
2016-10-14 04:25:41 +08:00
|
|
|
|
|
|
|
protected override bool OnClick(InputState state)
|
2016-10-14 03:10:00 +08:00
|
|
|
{
|
2016-10-14 04:25:41 +08:00
|
|
|
SetSelected?.Invoke(BeatmapSet);
|
|
|
|
return true;
|
2016-10-14 03:10:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|