1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 15:27:26 +08:00
osu-lazer/osu.Game/Screens/Select/BeatmapDetailAreaTabControl.cs

80 lines
2.5 KiB
C#
Raw Normal View History

2017-03-23 11:22:31 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-03-23 12:19:29 +08:00
using System;
2017-03-23 11:22:31 +08:00
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
2017-03-23 12:19:29 +08:00
using osu.Framework.Graphics.UserInterface;
2017-03-23 11:22:31 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Screens.Select
{
public class BeatmapDetailAreaTabControl : Container
{
public static readonly float HEIGHT = 24;
2017-03-23 13:47:27 +08:00
private readonly OsuTabControlCheckBox modsCheckbox;
private readonly OsuTabControl<BeatmapDetailTab> tabs;
2017-03-23 11:22:31 +08:00
2017-03-23 12:19:29 +08:00
public Action<BeatmapDetailTab, bool> OnFilter; //passed the selected tab and if mods is checked
private void invokeOnFilter()
{
OnFilter?.Invoke(tabs.SelectedItem, modsCheckbox.State == CheckBoxState.Checked);
}
2017-03-23 11:22:31 +08:00
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
modsCheckbox.AccentColour = tabs.AccentColour = colour.YellowLight;
}
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),
},
tabs = new OsuTabControl<BeatmapDetailTab>
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
RelativeSizeAxes = Axes.Both,
},
modsCheckbox = new OsuTabControlCheckBox
{
Anchor = Anchor.BottomRight,
Origin = Anchor.BottomRight,
Text = @"Mods",
},
};
2017-03-23 12:19:29 +08:00
tabs.ItemChanged += (sender, e) => invokeOnFilter();
modsCheckbox.Action += (sender, e) => invokeOnFilter();
tabs.SelectedItem = BeatmapDetailTab.Global;
2017-03-23 11:22:31 +08:00
}
}
public enum BeatmapDetailTab
{
Details,
Local,
Country,
Global,
Friends
}
}