1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 21:07:33 +08:00
osu-lazer/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs

94 lines
3.0 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
using System;
2018-11-20 15:51:59 +08:00
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
2018-04-13 17:19:50 +08:00
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Shapes;
namespace osu.Game.Screens.Select
{
public class BeatmapDetailAreaTabControl : Container
{
public static readonly float HEIGHT = 24;
private readonly OsuTabControlCheckbox modsCheckbox;
private readonly OsuTabControl<BeatmapDetailTab> tabs;
public Action<BeatmapDetailTab, bool> OnFilter; //passed the selected tab and if mods is checked
private Bindable<BeatmapDetailTab> selectedTab;
public BeatmapDetailAreaTabControl()
{
Height = HEIGHT;
Children = new Drawable[]
{
new Box
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.X,
Height = 1,
Colour = Color4.White.Opacity(0.2f),
},
2019-10-08 07:11:40 +08:00
new Container
2018-04-13 17:19:50 +08:00
{
RelativeSizeAxes = Axes.Both,
2019-10-08 07:11:40 +08:00
Padding = new MarginPadding { Right = 100 },
2019-10-07 01:22:55 +08:00
Child = tabs = new OsuTabControl<BeatmapDetailTab>
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.Both,
},
2018-04-13 17:19:50 +08:00
},
modsCheckbox = new OsuTabControlCheckbox
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
2019-09-20 03:47:32 +08:00
Text = @"Selected Mods",
2019-07-26 14:51:51 +08:00
Alpha = 0,
2018-04-13 17:19:50 +08:00
},
};
tabs.Current.ValueChanged += _ => invokeOnFilter();
modsCheckbox.Current.ValueChanged += _ => invokeOnFilter();
2018-04-13 17:19:50 +08:00
}
2019-07-26 14:49:21 +08:00
[BackgroundDependencyLoader]
private void load(OsuColour colour, OsuConfigManager config)
{
modsCheckbox.AccentColour = tabs.AccentColour = colour.YellowLight;
selectedTab = config.GetBindable<BeatmapDetailTab>(OsuSetting.BeatmapDetailTab);
tabs.Current.BindTo(selectedTab);
tabs.Current.TriggerChange();
}
private void invokeOnFilter()
{
OnFilter?.Invoke(tabs.Current.Value, modsCheckbox.Current.Value);
modsCheckbox.FadeTo(tabs.Current.Value == BeatmapDetailTab.Details ? 0 : 1, 200, Easing.OutQuint);
}
2018-04-13 17:19:50 +08:00
}
public enum BeatmapDetailTab
{
Details,
Local,
Country,
Global,
Friends
}
}