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;
|
2017-04-24 18:25:27 +08:00
|
|
|
|
using osu.Framework.Configuration;
|
2017-03-23 11:22:31 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-04-24 18:25:27 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2017-03-23 11:22:31 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2017-06-20 13:54:23 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2017-03-23 11:22:31 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select
|
|
|
|
|
{
|
|
|
|
|
public class BeatmapDetailAreaTabControl : Container
|
|
|
|
|
{
|
|
|
|
|
public static readonly float HEIGHT = 24;
|
2017-03-31 16:38:33 +08:00
|
|
|
|
private readonly OsuTabControlCheckbox modsCheckbox;
|
2017-03-23 13:47:27 +08:00
|
|
|
|
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
|
|
|
|
|
|
2017-04-24 18:25:27 +08:00
|
|
|
|
private Bindable<BeatmapDetailTab> selectedTab;
|
|
|
|
|
|
2017-03-23 12:19:29 +08:00
|
|
|
|
private void invokeOnFilter()
|
|
|
|
|
{
|
2017-04-10 13:31:08 +08:00
|
|
|
|
OnFilter?.Invoke(tabs.Current, modsCheckbox.Current);
|
2017-03-23 12:19:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 11:22:31 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-04-24 18:25:27 +08:00
|
|
|
|
private void load(OsuColour colour, OsuConfigManager config)
|
2017-03-23 11:22:31 +08:00
|
|
|
|
{
|
|
|
|
|
modsCheckbox.AccentColour = tabs.AccentColour = colour.YellowLight;
|
2017-04-24 18:25:27 +08:00
|
|
|
|
|
2017-05-15 09:56:27 +08:00
|
|
|
|
selectedTab = config.GetBindable<BeatmapDetailTab>(OsuSetting.BeatmapDetailTab);
|
2017-04-24 18:25:27 +08:00
|
|
|
|
|
|
|
|
|
tabs.Current.BindTo(selectedTab);
|
|
|
|
|
tabs.Current.TriggerChange();
|
2017-03-23 11:22:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
},
|
2017-03-31 16:38:33 +08:00
|
|
|
|
modsCheckbox = new OsuTabControlCheckbox
|
2017-03-23 11:22:31 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
Text = @"Mods",
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2017-04-10 13:31:08 +08:00
|
|
|
|
tabs.Current.ValueChanged += item => invokeOnFilter();
|
|
|
|
|
modsCheckbox.Current.ValueChanged += item => invokeOnFilter();
|
2017-03-23 11:22:31 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum BeatmapDetailTab
|
|
|
|
|
{
|
|
|
|
|
Details,
|
|
|
|
|
Local,
|
|
|
|
|
Country,
|
|
|
|
|
Global,
|
|
|
|
|
Friends
|
|
|
|
|
}
|
|
|
|
|
}
|