1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 13:27:25 +08:00
osu-lazer/osu.Game/Overlays/BeatmapSet/BeatmapRulesetSelector.cs

49 lines
1.5 KiB
C#
Raw Normal View History

2019-10-04 22:35:41 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Bindables;
2019-10-04 22:35:41 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osuTK;
using System.Linq;
namespace osu.Game.Overlays.BeatmapSet
{
public class BeatmapRulesetSelector : RulesetSelector
{
private readonly Bindable<BeatmapSetInfo> beatmapSet = new Bindable<BeatmapSetInfo>();
2019-10-04 22:35:41 +08:00
public BeatmapSetInfo BeatmapSet
{
get => beatmapSet.Value;
2019-10-04 22:35:41 +08:00
set
{
// propagate value to tab items first to enable only available rulesets.
beatmapSet.Value = value;
2019-10-04 22:35:41 +08:00
SelectTab(TabContainer.TabItems.FirstOrDefault(t => t.Enabled.Value));
2019-10-04 22:35:41 +08:00
}
}
public BeatmapRulesetSelector()
{
AutoSizeAxes = Axes.Both;
}
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new BeatmapRulesetTabItem(value)
{
BeatmapSet = { BindTarget = beatmapSet }
};
2019-10-04 22:35:41 +08:00
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
AutoSizeAxes = Axes.Both,
2019-10-05 02:18:03 +08:00
Direction = FillDirection.Horizontal,
Spacing = new Vector2(10, 0),
2019-10-04 22:35:41 +08:00
};
}
}